EAC_set_cvc_default_dir:
   64|    572|{
   65|    572|    if (default_dir) {
  ------------------
  |  Branch (65:9): [True: 572, False: 0]
  ------------------
   66|    572|        strncpy(cvc_default_dir, default_dir, (sizeof cvc_default_dir) - 1);
   67|    572|        cvc_default_dir[(sizeof cvc_default_dir) - 1] = '\0';
   68|    572|    }
   69|    572|}

EAC_init:
   71|    286|{
   72|       |    OpenSSL_add_all_algorithms();
   73|    286|    EAC_add_all_objects();
   74|    286|    EAC_set_x509_default_dir(X509DIR);
   75|    286|    EAC_set_cvc_default_dir(CVCDIR);
   76|    286|}
EAC_CTX_clear_free:
  277|     11|{
  278|     11|    if (ctx) {
  ------------------
  |  Branch (278:9): [True: 0, False: 11]
  ------------------
  279|      0|        if (ctx->bn_ctx)
  ------------------
  |  Branch (279:13): [True: 0, False: 0]
  ------------------
  280|      0|            BN_CTX_free(ctx->bn_ctx);
  281|      0|        if (ctx->md_ctx)
  ------------------
  |  Branch (281:13): [True: 0, False: 0]
  ------------------
  282|      0|            EVP_MD_CTX_destroy(ctx->md_ctx);
  283|      0|        if (ctx->cipher_ctx)
  ------------------
  |  Branch (283:13): [True: 0, False: 0]
  ------------------
  284|      0|            EVP_CIPHER_CTX_free(ctx->cipher_ctx);
  285|      0|        sk_pop_free((_STACK *) ctx->pace_ctxs, wrap_pace_ctx_clear_free);
  286|      0|        sk_pop_free((_STACK *) ctx->ca_ctxs, wrap_ca_ctx_clear_free);
  287|      0|        sk_pop_free((_STACK *) ctx->ri_ctxs, wrap_ri_ctx_clear_free);
  288|      0|        TA_CTX_clear_free(ctx->ta_ctx);
  289|      0|        KA_CTX_clear_free(ctx->key_ctx);
  290|      0|        if (ctx->ssc)
  ------------------
  |  Branch (290:13): [True: 0, False: 0]
  ------------------
  291|      0|            BN_clear_free(ctx->ssc);
  292|       |        OPENSSL_free(ctx);
  293|      0|    }
  294|     11|}

EAC_add_all_objects:
  174|    286|{
  175|    286|    int obj;
  176|       |
  177|    286|    if (objects_initialized)
  ------------------
  |  Branch (177:9): [True: 285, False: 1]
  ------------------
  178|    285|        return;
  179|       |
  180|       |    /* derived from a patched obj_mac.h with the power of regex */
  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  182|       |
  183|      1|#define ASC_standardizedDomainParameters		ASC_bsi_de".1.2"
  184|      1|    obj = OBJ_txt2nid(ASC_standardizedDomainParameters);
  ------------------
  |  |  183|      1|#define ASC_standardizedDomainParameters		ASC_bsi_de".1.2"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
  185|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (185:9): [True: 1, False: 0]
  ------------------
  186|      1|        obj = OBJ_create(ASC_standardizedDomainParameters	, SN_standardizedDomainParameters	, SN_standardizedDomainParameters	);
  ------------------
  |  |  183|      1|#define ASC_standardizedDomainParameters		ASC_bsi_de".1.2"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_standardizedDomainParameters	, SN_standardizedDomainParameters	, SN_standardizedDomainParameters	);
  ------------------
  |  |   81|      1|#define SN_standardizedDomainParameters		"standardizedDomainParameters"
  ------------------
                      obj = OBJ_create(ASC_standardizedDomainParameters	, SN_standardizedDomainParameters	, SN_standardizedDomainParameters	);
  ------------------
  |  |   81|      1|#define SN_standardizedDomainParameters		"standardizedDomainParameters"
  ------------------
  187|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (187:9): [True: 1, False: 0]
  ------------------
  188|      1|        NID_standardizedDomainParameters = obj;
  189|       |
  190|      1|#define ASC_id_PK		ASC_bsi_de".2.2.1"
  191|       |
  192|      1|#define ASC_id_PK_DH		ASC_id_PK".1"
  193|      1|    obj = OBJ_txt2nid(ASC_id_PK_DH);
  ------------------
  |  |  192|      1|#define ASC_id_PK_DH		ASC_id_PK".1"
  |  |  ------------------
  |  |  |  |  190|      1|#define ASC_id_PK		ASC_bsi_de".2.2.1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  194|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (194:9): [True: 1, False: 0]
  ------------------
  195|      1|        obj = OBJ_create(ASC_id_PK_DH	, SN_id_PK_DH	, SN_id_PK_DH	);
  ------------------
  |  |  192|      1|#define ASC_id_PK_DH		ASC_id_PK".1"
  |  |  ------------------
  |  |  |  |  190|      1|#define ASC_id_PK		ASC_bsi_de".2.2.1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PK_DH	, SN_id_PK_DH	, SN_id_PK_DH	);
  ------------------
  |  |   87|      1|#define SN_id_PK_DH		"id-PK-DH"
  ------------------
                      obj = OBJ_create(ASC_id_PK_DH	, SN_id_PK_DH	, SN_id_PK_DH	);
  ------------------
  |  |   87|      1|#define SN_id_PK_DH		"id-PK-DH"
  ------------------
  196|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (196:9): [True: 1, False: 0]
  ------------------
  197|      1|        NID_id_PK_DH = obj;
  198|       |
  199|      1|#define ASC_id_PK_ECDH		ASC_id_PK".2"
  200|      1|    obj = OBJ_txt2nid(ASC_id_PK_ECDH);
  ------------------
  |  |  199|      1|#define ASC_id_PK_ECDH		ASC_id_PK".2"
  |  |  ------------------
  |  |  |  |  190|      1|#define ASC_id_PK		ASC_bsi_de".2.2.1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (201:9): [True: 1, False: 0]
  ------------------
  202|      1|        obj = OBJ_create(ASC_id_PK_ECDH	, SN_id_PK_ECDH	, SN_id_PK_ECDH	);
  ------------------
  |  |  199|      1|#define ASC_id_PK_ECDH		ASC_id_PK".2"
  |  |  ------------------
  |  |  |  |  190|      1|#define ASC_id_PK		ASC_bsi_de".2.2.1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PK_ECDH	, SN_id_PK_ECDH	, SN_id_PK_ECDH	);
  ------------------
  |  |   91|      1|#define SN_id_PK_ECDH		"id-PK-ECDH"
  ------------------
                      obj = OBJ_create(ASC_id_PK_ECDH	, SN_id_PK_ECDH	, SN_id_PK_ECDH	);
  ------------------
  |  |   91|      1|#define SN_id_PK_ECDH		"id-PK-ECDH"
  ------------------
  203|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (203:9): [True: 1, False: 0]
  ------------------
  204|      1|        NID_id_PK_ECDH = obj;
  205|       |
  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  207|      1|    obj = OBJ_txt2nid(ASC_id_TA);
  ------------------
  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
  208|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (208:9): [True: 1, False: 0]
  ------------------
  209|      1|        obj = OBJ_create(ASC_id_TA	, SN_id_TA	, SN_id_TA	);
  ------------------
  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA	, SN_id_TA	, SN_id_TA	);
  ------------------
  |  |   95|      1|#define SN_id_TA		"id-TA"
  ------------------
                      obj = OBJ_create(ASC_id_TA	, SN_id_TA	, SN_id_TA	);
  ------------------
  |  |   95|      1|#define SN_id_TA		"id-TA"
  ------------------
  210|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (210:9): [True: 1, False: 0]
  ------------------
  211|      1|        NID_id_TA = obj;
  212|       |
  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  214|      1|    obj = OBJ_txt2nid(ASC_id_TA_RSA);
  ------------------
  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  ------------------
  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (215:9): [True: 1, False: 0]
  ------------------
  216|      1|        obj = OBJ_create(ASC_id_TA_RSA	, SN_id_TA_RSA	, SN_id_TA_RSA	);
  ------------------
  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  ------------------
  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA	, SN_id_TA_RSA	, SN_id_TA_RSA	);
  ------------------
  |  |   99|      1|#define SN_id_TA_RSA		"id-TA-RSA"
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA	, SN_id_TA_RSA	, SN_id_TA_RSA	);
  ------------------
  |  |   99|      1|#define SN_id_TA_RSA		"id-TA-RSA"
  ------------------
  217|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (217:9): [True: 1, False: 0]
  ------------------
  218|      1|        NID_id_TA_RSA = obj;
  219|       |
  220|      1|#define ASC_id_TA_RSA_v1_5_SHA_1		ASC_id_TA_RSA".1"
  221|      1|    obj = OBJ_txt2nid(ASC_id_TA_RSA_v1_5_SHA_1);
  ------------------
  |  |  220|      1|#define ASC_id_TA_RSA_v1_5_SHA_1		ASC_id_TA_RSA".1"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (222:9): [True: 1, False: 0]
  ------------------
  223|      1|        obj = OBJ_create(ASC_id_TA_RSA_v1_5_SHA_1	, SN_id_TA_RSA_v1_5_SHA_1	, SN_id_TA_RSA_v1_5_SHA_1	);
  ------------------
  |  |  220|      1|#define ASC_id_TA_RSA_v1_5_SHA_1		ASC_id_TA_RSA".1"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_v1_5_SHA_1	, SN_id_TA_RSA_v1_5_SHA_1	, SN_id_TA_RSA_v1_5_SHA_1	);
  ------------------
  |  |  103|      1|#define SN_id_TA_RSA_v1_5_SHA_1		"id-TA-RSA-v1-5-SHA-1"
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_v1_5_SHA_1	, SN_id_TA_RSA_v1_5_SHA_1	, SN_id_TA_RSA_v1_5_SHA_1	);
  ------------------
  |  |  103|      1|#define SN_id_TA_RSA_v1_5_SHA_1		"id-TA-RSA-v1-5-SHA-1"
  ------------------
  224|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (224:9): [True: 1, False: 0]
  ------------------
  225|      1|        NID_id_TA_RSA_v1_5_SHA_1 = obj;
  226|       |
  227|      1|#define ASC_id_TA_RSA_v1_5_SHA_256		ASC_id_TA_RSA".2"
  228|      1|    obj = OBJ_txt2nid(ASC_id_TA_RSA_v1_5_SHA_256);
  ------------------
  |  |  227|      1|#define ASC_id_TA_RSA_v1_5_SHA_256		ASC_id_TA_RSA".2"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  229|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (229:9): [True: 1, False: 0]
  ------------------
  230|      1|        obj = OBJ_create(ASC_id_TA_RSA_v1_5_SHA_256	, SN_id_TA_RSA_v1_5_SHA_256	, SN_id_TA_RSA_v1_5_SHA_256	);
  ------------------
  |  |  227|      1|#define ASC_id_TA_RSA_v1_5_SHA_256		ASC_id_TA_RSA".2"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_v1_5_SHA_256	, SN_id_TA_RSA_v1_5_SHA_256	, SN_id_TA_RSA_v1_5_SHA_256	);
  ------------------
  |  |  107|      1|#define SN_id_TA_RSA_v1_5_SHA_256		"id-TA-RSA-v1-5-SHA-256"
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_v1_5_SHA_256	, SN_id_TA_RSA_v1_5_SHA_256	, SN_id_TA_RSA_v1_5_SHA_256	);
  ------------------
  |  |  107|      1|#define SN_id_TA_RSA_v1_5_SHA_256		"id-TA-RSA-v1-5-SHA-256"
  ------------------
  231|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (231:9): [True: 1, False: 0]
  ------------------
  232|      1|        NID_id_TA_RSA_v1_5_SHA_256 = obj;
  233|       |
  234|      1|#define ASC_id_TA_RSA_PSS_SHA_1		ASC_id_TA_RSA".3"
  235|      1|    obj = OBJ_txt2nid(ASC_id_TA_RSA_PSS_SHA_1);
  ------------------
  |  |  234|      1|#define ASC_id_TA_RSA_PSS_SHA_1		ASC_id_TA_RSA".3"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (236:9): [True: 1, False: 0]
  ------------------
  237|      1|        obj = OBJ_create(ASC_id_TA_RSA_PSS_SHA_1	, SN_id_TA_RSA_PSS_SHA_1	, SN_id_TA_RSA_PSS_SHA_1	);
  ------------------
  |  |  234|      1|#define ASC_id_TA_RSA_PSS_SHA_1		ASC_id_TA_RSA".3"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_PSS_SHA_1	, SN_id_TA_RSA_PSS_SHA_1	, SN_id_TA_RSA_PSS_SHA_1	);
  ------------------
  |  |  111|      1|#define SN_id_TA_RSA_PSS_SHA_1		"id-TA-RSA-PSS-SHA-1"
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_PSS_SHA_1	, SN_id_TA_RSA_PSS_SHA_1	, SN_id_TA_RSA_PSS_SHA_1	);
  ------------------
  |  |  111|      1|#define SN_id_TA_RSA_PSS_SHA_1		"id-TA-RSA-PSS-SHA-1"
  ------------------
  238|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (238:9): [True: 1, False: 0]
  ------------------
  239|      1|        NID_id_TA_RSA_PSS_SHA_1 = obj;
  240|       |
  241|      1|#define ASC_id_TA_RSA_PSS_SHA_256		ASC_id_TA_RSA".4"
  242|      1|    obj = OBJ_txt2nid(ASC_id_TA_RSA_PSS_SHA_256);
  ------------------
  |  |  241|      1|#define ASC_id_TA_RSA_PSS_SHA_256		ASC_id_TA_RSA".4"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (243:9): [True: 1, False: 0]
  ------------------
  244|      1|        obj = OBJ_create(ASC_id_TA_RSA_PSS_SHA_256	, SN_id_TA_RSA_PSS_SHA_256	, SN_id_TA_RSA_PSS_SHA_256	);
  ------------------
  |  |  241|      1|#define ASC_id_TA_RSA_PSS_SHA_256		ASC_id_TA_RSA".4"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_PSS_SHA_256	, SN_id_TA_RSA_PSS_SHA_256	, SN_id_TA_RSA_PSS_SHA_256	);
  ------------------
  |  |  115|      1|#define SN_id_TA_RSA_PSS_SHA_256		"id-TA-RSA-PSS-SHA-256"
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_PSS_SHA_256	, SN_id_TA_RSA_PSS_SHA_256	, SN_id_TA_RSA_PSS_SHA_256	);
  ------------------
  |  |  115|      1|#define SN_id_TA_RSA_PSS_SHA_256		"id-TA-RSA-PSS-SHA-256"
  ------------------
  245|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (245:9): [True: 1, False: 0]
  ------------------
  246|      1|        NID_id_TA_RSA_PSS_SHA_256 = obj;
  247|       |
  248|      1|#define ASC_id_TA_RSA_v1_5_SHA_512		ASC_id_TA_RSA".5"
  249|      1|    obj = OBJ_txt2nid(ASC_id_TA_RSA_v1_5_SHA_512);
  ------------------
  |  |  248|      1|#define ASC_id_TA_RSA_v1_5_SHA_512		ASC_id_TA_RSA".5"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  250|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (250:9): [True: 1, False: 0]
  ------------------
  251|      1|        obj = OBJ_create(ASC_id_TA_RSA_v1_5_SHA_512	, SN_id_TA_RSA_v1_5_SHA_512	, SN_id_TA_RSA_v1_5_SHA_512	);
  ------------------
  |  |  248|      1|#define ASC_id_TA_RSA_v1_5_SHA_512		ASC_id_TA_RSA".5"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_v1_5_SHA_512	, SN_id_TA_RSA_v1_5_SHA_512	, SN_id_TA_RSA_v1_5_SHA_512	);
  ------------------
  |  |  119|      1|#define SN_id_TA_RSA_v1_5_SHA_512		"id-TA-RSA-v1-5-SHA-512"
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_v1_5_SHA_512	, SN_id_TA_RSA_v1_5_SHA_512	, SN_id_TA_RSA_v1_5_SHA_512	);
  ------------------
  |  |  119|      1|#define SN_id_TA_RSA_v1_5_SHA_512		"id-TA-RSA-v1-5-SHA-512"
  ------------------
  252|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (252:9): [True: 1, False: 0]
  ------------------
  253|      1|        NID_id_TA_RSA_v1_5_SHA_512 = obj;
  254|       |
  255|      1|#define ASC_id_TA_RSA_PSS_SHA_512		ASC_id_TA_RSA".6"
  256|      1|    obj = OBJ_txt2nid(ASC_id_TA_RSA_PSS_SHA_512);
  ------------------
  |  |  255|      1|#define ASC_id_TA_RSA_PSS_SHA_512		ASC_id_TA_RSA".6"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (257:9): [True: 1, False: 0]
  ------------------
  258|      1|        obj = OBJ_create(ASC_id_TA_RSA_PSS_SHA_512	, SN_id_TA_RSA_PSS_SHA_512	, SN_id_TA_RSA_PSS_SHA_512	);
  ------------------
  |  |  255|      1|#define ASC_id_TA_RSA_PSS_SHA_512		ASC_id_TA_RSA".6"
  |  |  ------------------
  |  |  |  |  213|      1|#define ASC_id_TA_RSA		ASC_id_TA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_PSS_SHA_512	, SN_id_TA_RSA_PSS_SHA_512	, SN_id_TA_RSA_PSS_SHA_512	);
  ------------------
  |  |  123|      1|#define SN_id_TA_RSA_PSS_SHA_512		"id-TA-RSA-PSS-SHA-512"
  ------------------
                      obj = OBJ_create(ASC_id_TA_RSA_PSS_SHA_512	, SN_id_TA_RSA_PSS_SHA_512	, SN_id_TA_RSA_PSS_SHA_512	);
  ------------------
  |  |  123|      1|#define SN_id_TA_RSA_PSS_SHA_512		"id-TA-RSA-PSS-SHA-512"
  ------------------
  259|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (259:9): [True: 1, False: 0]
  ------------------
  260|      1|        NID_id_TA_RSA_PSS_SHA_512 = obj;
  261|       |
  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  263|      1|    obj = OBJ_txt2nid(ASC_id_TA_ECDSA);
  ------------------
  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  ------------------
  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  264|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (264:9): [True: 1, False: 0]
  ------------------
  265|      1|        obj = OBJ_create(ASC_id_TA_ECDSA	, SN_id_TA_ECDSA	, SN_id_TA_ECDSA	);
  ------------------
  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  ------------------
  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA	, SN_id_TA_ECDSA	, SN_id_TA_ECDSA	);
  ------------------
  |  |  127|      1|#define SN_id_TA_ECDSA		"id-TA-ECDSA"
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA	, SN_id_TA_ECDSA	, SN_id_TA_ECDSA	);
  ------------------
  |  |  127|      1|#define SN_id_TA_ECDSA		"id-TA-ECDSA"
  ------------------
  266|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (266:9): [True: 1, False: 0]
  ------------------
  267|      1|        NID_id_TA_ECDSA = obj;
  268|       |
  269|      1|#define ASC_id_TA_ECDSA_SHA_1		ASC_id_TA_ECDSA".1"
  270|      1|    obj = OBJ_txt2nid(ASC_id_TA_ECDSA_SHA_1);
  ------------------
  |  |  269|      1|#define ASC_id_TA_ECDSA_SHA_1		ASC_id_TA_ECDSA".1"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (271:9): [True: 1, False: 0]
  ------------------
  272|      1|        obj = OBJ_create(ASC_id_TA_ECDSA_SHA_1	, SN_id_TA_ECDSA_SHA_1	, SN_id_TA_ECDSA_SHA_1	);
  ------------------
  |  |  269|      1|#define ASC_id_TA_ECDSA_SHA_1		ASC_id_TA_ECDSA".1"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_1	, SN_id_TA_ECDSA_SHA_1	, SN_id_TA_ECDSA_SHA_1	);
  ------------------
  |  |  131|      1|#define SN_id_TA_ECDSA_SHA_1		"id-TA-ECDSA-SHA-1"
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_1	, SN_id_TA_ECDSA_SHA_1	, SN_id_TA_ECDSA_SHA_1	);
  ------------------
  |  |  131|      1|#define SN_id_TA_ECDSA_SHA_1		"id-TA-ECDSA-SHA-1"
  ------------------
  273|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (273:9): [True: 1, False: 0]
  ------------------
  274|      1|        NID_id_TA_ECDSA_SHA_1 = obj;
  275|       |
  276|      1|#define ASC_id_TA_ECDSA_SHA_224		ASC_id_TA_ECDSA".2"
  277|      1|    obj = OBJ_txt2nid(ASC_id_TA_ECDSA_SHA_224);
  ------------------
  |  |  276|      1|#define ASC_id_TA_ECDSA_SHA_224		ASC_id_TA_ECDSA".2"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  278|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (278:9): [True: 1, False: 0]
  ------------------
  279|      1|        obj = OBJ_create(ASC_id_TA_ECDSA_SHA_224	, SN_id_TA_ECDSA_SHA_224	, SN_id_TA_ECDSA_SHA_224	);
  ------------------
  |  |  276|      1|#define ASC_id_TA_ECDSA_SHA_224		ASC_id_TA_ECDSA".2"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_224	, SN_id_TA_ECDSA_SHA_224	, SN_id_TA_ECDSA_SHA_224	);
  ------------------
  |  |  135|      1|#define SN_id_TA_ECDSA_SHA_224		"id-TA-ECDSA-SHA-224"
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_224	, SN_id_TA_ECDSA_SHA_224	, SN_id_TA_ECDSA_SHA_224	);
  ------------------
  |  |  135|      1|#define SN_id_TA_ECDSA_SHA_224		"id-TA-ECDSA-SHA-224"
  ------------------
  280|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (280:9): [True: 1, False: 0]
  ------------------
  281|      1|        NID_id_TA_ECDSA_SHA_224 = obj;
  282|       |
  283|      1|#define ASC_id_TA_ECDSA_SHA_256		ASC_id_TA_ECDSA".3"
  284|      1|    obj = OBJ_txt2nid(ASC_id_TA_ECDSA_SHA_256);
  ------------------
  |  |  283|      1|#define ASC_id_TA_ECDSA_SHA_256		ASC_id_TA_ECDSA".3"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  285|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (285:9): [True: 1, False: 0]
  ------------------
  286|      1|        obj = OBJ_create(ASC_id_TA_ECDSA_SHA_256	, SN_id_TA_ECDSA_SHA_256	, SN_id_TA_ECDSA_SHA_256	);
  ------------------
  |  |  283|      1|#define ASC_id_TA_ECDSA_SHA_256		ASC_id_TA_ECDSA".3"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_256	, SN_id_TA_ECDSA_SHA_256	, SN_id_TA_ECDSA_SHA_256	);
  ------------------
  |  |  139|      1|#define SN_id_TA_ECDSA_SHA_256		"id-TA-ECDSA-SHA-256"
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_256	, SN_id_TA_ECDSA_SHA_256	, SN_id_TA_ECDSA_SHA_256	);
  ------------------
  |  |  139|      1|#define SN_id_TA_ECDSA_SHA_256		"id-TA-ECDSA-SHA-256"
  ------------------
  287|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (287:9): [True: 1, False: 0]
  ------------------
  288|      1|        NID_id_TA_ECDSA_SHA_256 = obj;
  289|       |
  290|      1|#define ASC_id_TA_ECDSA_SHA_384		ASC_id_TA_ECDSA".4"
  291|      1|    obj = OBJ_txt2nid(ASC_id_TA_ECDSA_SHA_384);
  ------------------
  |  |  290|      1|#define ASC_id_TA_ECDSA_SHA_384		ASC_id_TA_ECDSA".4"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (292:9): [True: 1, False: 0]
  ------------------
  293|      1|        obj = OBJ_create(ASC_id_TA_ECDSA_SHA_384	, SN_id_TA_ECDSA_SHA_384	, SN_id_TA_ECDSA_SHA_384	);
  ------------------
  |  |  290|      1|#define ASC_id_TA_ECDSA_SHA_384		ASC_id_TA_ECDSA".4"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_384	, SN_id_TA_ECDSA_SHA_384	, SN_id_TA_ECDSA_SHA_384	);
  ------------------
  |  |  143|      1|#define SN_id_TA_ECDSA_SHA_384		"id-TA-ECDSA-SHA-384"
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_384	, SN_id_TA_ECDSA_SHA_384	, SN_id_TA_ECDSA_SHA_384	);
  ------------------
  |  |  143|      1|#define SN_id_TA_ECDSA_SHA_384		"id-TA-ECDSA-SHA-384"
  ------------------
  294|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (294:9): [True: 1, False: 0]
  ------------------
  295|      1|        NID_id_TA_ECDSA_SHA_384 = obj;
  296|       |
  297|      1|#define ASC_id_TA_ECDSA_SHA_512		ASC_id_TA_ECDSA".5"
  298|      1|    obj = OBJ_txt2nid(ASC_id_TA_ECDSA_SHA_512);
  ------------------
  |  |  297|      1|#define ASC_id_TA_ECDSA_SHA_512		ASC_id_TA_ECDSA".5"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  299|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (299:9): [True: 1, False: 0]
  ------------------
  300|      1|        obj = OBJ_create(ASC_id_TA_ECDSA_SHA_512	, SN_id_TA_ECDSA_SHA_512	, SN_id_TA_ECDSA_SHA_512	);
  ------------------
  |  |  297|      1|#define ASC_id_TA_ECDSA_SHA_512		ASC_id_TA_ECDSA".5"
  |  |  ------------------
  |  |  |  |  262|      1|#define ASC_id_TA_ECDSA		ASC_id_TA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  206|      1|#define ASC_id_TA		ASC_bsi_de".2.2.2"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_512	, SN_id_TA_ECDSA_SHA_512	, SN_id_TA_ECDSA_SHA_512	);
  ------------------
  |  |  147|      1|#define SN_id_TA_ECDSA_SHA_512		"id-TA-ECDSA-SHA-512"
  ------------------
                      obj = OBJ_create(ASC_id_TA_ECDSA_SHA_512	, SN_id_TA_ECDSA_SHA_512	, SN_id_TA_ECDSA_SHA_512	);
  ------------------
  |  |  147|      1|#define SN_id_TA_ECDSA_SHA_512		"id-TA-ECDSA-SHA-512"
  ------------------
  301|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (301:9): [True: 1, False: 0]
  ------------------
  302|      1|        NID_id_TA_ECDSA_SHA_512 = obj;
  303|       |
  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  305|       |
  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  307|      1|    obj = OBJ_txt2nid(ASC_id_CA_DH);
  ------------------
  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  ------------------
  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  308|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (308:9): [True: 1, False: 0]
  ------------------
  309|      1|        obj = OBJ_create(ASC_id_CA_DH	, SN_id_CA_DH	, SN_id_CA_DH	);
  ------------------
  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  ------------------
  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH	, SN_id_CA_DH	, SN_id_CA_DH	);
  ------------------
  |  |  153|      1|#define SN_id_CA_DH		"id-CA-DH"
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH	, SN_id_CA_DH	, SN_id_CA_DH	);
  ------------------
  |  |  153|      1|#define SN_id_CA_DH		"id-CA-DH"
  ------------------
  310|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (310:9): [True: 1, False: 0]
  ------------------
  311|      1|        NID_id_CA_DH = obj;
  312|       |
  313|      1|#define ASC_id_CA_DH_3DES_CBC_CBC		ASC_id_CA_DH".1"
  314|      1|    obj = OBJ_txt2nid(ASC_id_CA_DH_3DES_CBC_CBC);
  ------------------
  |  |  313|      1|#define ASC_id_CA_DH_3DES_CBC_CBC		ASC_id_CA_DH".1"
  |  |  ------------------
  |  |  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (315:9): [True: 1, False: 0]
  ------------------
  316|      1|        obj = OBJ_create(ASC_id_CA_DH_3DES_CBC_CBC	, SN_id_CA_DH_3DES_CBC_CBC	, SN_id_CA_DH_3DES_CBC_CBC	);
  ------------------
  |  |  313|      1|#define ASC_id_CA_DH_3DES_CBC_CBC		ASC_id_CA_DH".1"
  |  |  ------------------
  |  |  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH_3DES_CBC_CBC	, SN_id_CA_DH_3DES_CBC_CBC	, SN_id_CA_DH_3DES_CBC_CBC	);
  ------------------
  |  |  157|      1|#define SN_id_CA_DH_3DES_CBC_CBC		"id-CA-DH-3DES-CBC-CBC"
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH_3DES_CBC_CBC	, SN_id_CA_DH_3DES_CBC_CBC	, SN_id_CA_DH_3DES_CBC_CBC	);
  ------------------
  |  |  157|      1|#define SN_id_CA_DH_3DES_CBC_CBC		"id-CA-DH-3DES-CBC-CBC"
  ------------------
  317|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (317:9): [True: 1, False: 0]
  ------------------
  318|      1|        NID_id_CA_DH_3DES_CBC_CBC = obj;
  319|       |
  320|      1|#define ASC_id_CA_DH_AES_CBC_CMAC_128		ASC_id_CA_DH".2"
  321|      1|    obj = OBJ_txt2nid(ASC_id_CA_DH_AES_CBC_CMAC_128);
  ------------------
  |  |  320|      1|#define ASC_id_CA_DH_AES_CBC_CMAC_128		ASC_id_CA_DH".2"
  |  |  ------------------
  |  |  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  322|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (322:9): [True: 1, False: 0]
  ------------------
  323|      1|        obj = OBJ_create(ASC_id_CA_DH_AES_CBC_CMAC_128	, SN_id_CA_DH_AES_CBC_CMAC_128	, SN_id_CA_DH_AES_CBC_CMAC_128	);
  ------------------
  |  |  320|      1|#define ASC_id_CA_DH_AES_CBC_CMAC_128		ASC_id_CA_DH".2"
  |  |  ------------------
  |  |  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH_AES_CBC_CMAC_128	, SN_id_CA_DH_AES_CBC_CMAC_128	, SN_id_CA_DH_AES_CBC_CMAC_128	);
  ------------------
  |  |  161|      1|#define SN_id_CA_DH_AES_CBC_CMAC_128		"id-CA-DH-AES-CBC-CMAC-128"
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH_AES_CBC_CMAC_128	, SN_id_CA_DH_AES_CBC_CMAC_128	, SN_id_CA_DH_AES_CBC_CMAC_128	);
  ------------------
  |  |  161|      1|#define SN_id_CA_DH_AES_CBC_CMAC_128		"id-CA-DH-AES-CBC-CMAC-128"
  ------------------
  324|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (324:9): [True: 1, False: 0]
  ------------------
  325|      1|        NID_id_CA_DH_AES_CBC_CMAC_128 = obj;
  326|       |
  327|      1|#define ASC_id_CA_DH_AES_CBC_CMAC_192		ASC_id_CA_DH".3"
  328|      1|    obj = OBJ_txt2nid(ASC_id_CA_DH_AES_CBC_CMAC_192);
  ------------------
  |  |  327|      1|#define ASC_id_CA_DH_AES_CBC_CMAC_192		ASC_id_CA_DH".3"
  |  |  ------------------
  |  |  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  329|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (329:9): [True: 1, False: 0]
  ------------------
  330|      1|        obj = OBJ_create(ASC_id_CA_DH_AES_CBC_CMAC_192	, SN_id_CA_DH_AES_CBC_CMAC_192	, SN_id_CA_DH_AES_CBC_CMAC_192	);
  ------------------
  |  |  327|      1|#define ASC_id_CA_DH_AES_CBC_CMAC_192		ASC_id_CA_DH".3"
  |  |  ------------------
  |  |  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH_AES_CBC_CMAC_192	, SN_id_CA_DH_AES_CBC_CMAC_192	, SN_id_CA_DH_AES_CBC_CMAC_192	);
  ------------------
  |  |  165|      1|#define SN_id_CA_DH_AES_CBC_CMAC_192		"id-CA-DH-AES-CBC-CMAC-192"
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH_AES_CBC_CMAC_192	, SN_id_CA_DH_AES_CBC_CMAC_192	, SN_id_CA_DH_AES_CBC_CMAC_192	);
  ------------------
  |  |  165|      1|#define SN_id_CA_DH_AES_CBC_CMAC_192		"id-CA-DH-AES-CBC-CMAC-192"
  ------------------
  331|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (331:9): [True: 1, False: 0]
  ------------------
  332|      1|        NID_id_CA_DH_AES_CBC_CMAC_192 = obj;
  333|       |
  334|      1|#define ASC_id_CA_DH_AES_CBC_CMAC_256		ASC_id_CA_DH".4"
  335|      1|    obj = OBJ_txt2nid(ASC_id_CA_DH_AES_CBC_CMAC_256);
  ------------------
  |  |  334|      1|#define ASC_id_CA_DH_AES_CBC_CMAC_256		ASC_id_CA_DH".4"
  |  |  ------------------
  |  |  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  336|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (336:9): [True: 1, False: 0]
  ------------------
  337|      1|        obj = OBJ_create(ASC_id_CA_DH_AES_CBC_CMAC_256	, SN_id_CA_DH_AES_CBC_CMAC_256	, SN_id_CA_DH_AES_CBC_CMAC_256	);
  ------------------
  |  |  334|      1|#define ASC_id_CA_DH_AES_CBC_CMAC_256		ASC_id_CA_DH".4"
  |  |  ------------------
  |  |  |  |  306|      1|#define ASC_id_CA_DH		ASC_id_CA".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH_AES_CBC_CMAC_256	, SN_id_CA_DH_AES_CBC_CMAC_256	, SN_id_CA_DH_AES_CBC_CMAC_256	);
  ------------------
  |  |  169|      1|#define SN_id_CA_DH_AES_CBC_CMAC_256		"id-CA-DH-AES-CBC-CMAC-256"
  ------------------
                      obj = OBJ_create(ASC_id_CA_DH_AES_CBC_CMAC_256	, SN_id_CA_DH_AES_CBC_CMAC_256	, SN_id_CA_DH_AES_CBC_CMAC_256	);
  ------------------
  |  |  169|      1|#define SN_id_CA_DH_AES_CBC_CMAC_256		"id-CA-DH-AES-CBC-CMAC-256"
  ------------------
  338|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (338:9): [True: 1, False: 0]
  ------------------
  339|      1|        NID_id_CA_DH_AES_CBC_CMAC_256 = obj;
  340|       |
  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  342|      1|    obj = OBJ_txt2nid(ASC_id_CA_ECDH);
  ------------------
  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  ------------------
  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  343|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (343:9): [True: 1, False: 0]
  ------------------
  344|      1|        obj = OBJ_create(ASC_id_CA_ECDH	, SN_id_CA_ECDH	, SN_id_CA_ECDH	);
  ------------------
  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  ------------------
  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH	, SN_id_CA_ECDH	, SN_id_CA_ECDH	);
  ------------------
  |  |  173|      1|#define SN_id_CA_ECDH		"id-CA-ECDH"
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH	, SN_id_CA_ECDH	, SN_id_CA_ECDH	);
  ------------------
  |  |  173|      1|#define SN_id_CA_ECDH		"id-CA-ECDH"
  ------------------
  345|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (345:9): [True: 1, False: 0]
  ------------------
  346|      1|        NID_id_CA_ECDH = obj;
  347|       |
  348|      1|#define ASC_id_CA_ECDH_3DES_CBC_CBC		ASC_id_CA_ECDH".1"
  349|      1|    obj = OBJ_txt2nid(ASC_id_CA_ECDH_3DES_CBC_CBC);
  ------------------
  |  |  348|      1|#define ASC_id_CA_ECDH_3DES_CBC_CBC		ASC_id_CA_ECDH".1"
  |  |  ------------------
  |  |  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (350:9): [True: 1, False: 0]
  ------------------
  351|      1|        obj = OBJ_create(ASC_id_CA_ECDH_3DES_CBC_CBC	, SN_id_CA_ECDH_3DES_CBC_CBC	, SN_id_CA_ECDH_3DES_CBC_CBC	);
  ------------------
  |  |  348|      1|#define ASC_id_CA_ECDH_3DES_CBC_CBC		ASC_id_CA_ECDH".1"
  |  |  ------------------
  |  |  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH_3DES_CBC_CBC	, SN_id_CA_ECDH_3DES_CBC_CBC	, SN_id_CA_ECDH_3DES_CBC_CBC	);
  ------------------
  |  |  177|      1|#define SN_id_CA_ECDH_3DES_CBC_CBC		"id-CA-ECDH-3DES-CBC-CBC"
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH_3DES_CBC_CBC	, SN_id_CA_ECDH_3DES_CBC_CBC	, SN_id_CA_ECDH_3DES_CBC_CBC	);
  ------------------
  |  |  177|      1|#define SN_id_CA_ECDH_3DES_CBC_CBC		"id-CA-ECDH-3DES-CBC-CBC"
  ------------------
  352|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (352:9): [True: 1, False: 0]
  ------------------
  353|      1|        NID_id_CA_ECDH_3DES_CBC_CBC = obj;
  354|       |
  355|      1|#define ASC_id_CA_ECDH_AES_CBC_CMAC_128		ASC_id_CA_ECDH".2"
  356|      1|    obj = OBJ_txt2nid(ASC_id_CA_ECDH_AES_CBC_CMAC_128);
  ------------------
  |  |  355|      1|#define ASC_id_CA_ECDH_AES_CBC_CMAC_128		ASC_id_CA_ECDH".2"
  |  |  ------------------
  |  |  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  357|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (357:9): [True: 1, False: 0]
  ------------------
  358|      1|        obj = OBJ_create(ASC_id_CA_ECDH_AES_CBC_CMAC_128	, SN_id_CA_ECDH_AES_CBC_CMAC_128	, SN_id_CA_ECDH_AES_CBC_CMAC_128	);
  ------------------
  |  |  355|      1|#define ASC_id_CA_ECDH_AES_CBC_CMAC_128		ASC_id_CA_ECDH".2"
  |  |  ------------------
  |  |  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH_AES_CBC_CMAC_128	, SN_id_CA_ECDH_AES_CBC_CMAC_128	, SN_id_CA_ECDH_AES_CBC_CMAC_128	);
  ------------------
  |  |  181|      1|#define SN_id_CA_ECDH_AES_CBC_CMAC_128		"id-CA-ECDH-AES-CBC-CMAC-128"
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH_AES_CBC_CMAC_128	, SN_id_CA_ECDH_AES_CBC_CMAC_128	, SN_id_CA_ECDH_AES_CBC_CMAC_128	);
  ------------------
  |  |  181|      1|#define SN_id_CA_ECDH_AES_CBC_CMAC_128		"id-CA-ECDH-AES-CBC-CMAC-128"
  ------------------
  359|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (359:9): [True: 1, False: 0]
  ------------------
  360|      1|        NID_id_CA_ECDH_AES_CBC_CMAC_128 = obj;
  361|       |
  362|      1|#define ASC_id_CA_ECDH_AES_CBC_CMAC_192		ASC_id_CA_ECDH".3"
  363|      1|    obj = OBJ_txt2nid(ASC_id_CA_ECDH_AES_CBC_CMAC_192);
  ------------------
  |  |  362|      1|#define ASC_id_CA_ECDH_AES_CBC_CMAC_192		ASC_id_CA_ECDH".3"
  |  |  ------------------
  |  |  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  364|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (364:9): [True: 1, False: 0]
  ------------------
  365|      1|        obj = OBJ_create(ASC_id_CA_ECDH_AES_CBC_CMAC_192	, SN_id_CA_ECDH_AES_CBC_CMAC_192	, SN_id_CA_ECDH_AES_CBC_CMAC_192	);
  ------------------
  |  |  362|      1|#define ASC_id_CA_ECDH_AES_CBC_CMAC_192		ASC_id_CA_ECDH".3"
  |  |  ------------------
  |  |  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH_AES_CBC_CMAC_192	, SN_id_CA_ECDH_AES_CBC_CMAC_192	, SN_id_CA_ECDH_AES_CBC_CMAC_192	);
  ------------------
  |  |  185|      1|#define SN_id_CA_ECDH_AES_CBC_CMAC_192		"id-CA-ECDH-AES-CBC-CMAC-192"
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH_AES_CBC_CMAC_192	, SN_id_CA_ECDH_AES_CBC_CMAC_192	, SN_id_CA_ECDH_AES_CBC_CMAC_192	);
  ------------------
  |  |  185|      1|#define SN_id_CA_ECDH_AES_CBC_CMAC_192		"id-CA-ECDH-AES-CBC-CMAC-192"
  ------------------
  366|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (366:9): [True: 1, False: 0]
  ------------------
  367|      1|        NID_id_CA_ECDH_AES_CBC_CMAC_192 = obj;
  368|       |
  369|      1|#define ASC_id_CA_ECDH_AES_CBC_CMAC_256		ASC_id_CA_ECDH".4"
  370|      1|    obj = OBJ_txt2nid(ASC_id_CA_ECDH_AES_CBC_CMAC_256);
  ------------------
  |  |  369|      1|#define ASC_id_CA_ECDH_AES_CBC_CMAC_256		ASC_id_CA_ECDH".4"
  |  |  ------------------
  |  |  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (371:9): [True: 1, False: 0]
  ------------------
  372|      1|        obj = OBJ_create(ASC_id_CA_ECDH_AES_CBC_CMAC_256	, SN_id_CA_ECDH_AES_CBC_CMAC_256	, SN_id_CA_ECDH_AES_CBC_CMAC_256	);
  ------------------
  |  |  369|      1|#define ASC_id_CA_ECDH_AES_CBC_CMAC_256		ASC_id_CA_ECDH".4"
  |  |  ------------------
  |  |  |  |  341|      1|#define ASC_id_CA_ECDH		ASC_id_CA".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  304|      1|#define ASC_id_CA		ASC_bsi_de".2.2.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH_AES_CBC_CMAC_256	, SN_id_CA_ECDH_AES_CBC_CMAC_256	, SN_id_CA_ECDH_AES_CBC_CMAC_256	);
  ------------------
  |  |  189|      1|#define SN_id_CA_ECDH_AES_CBC_CMAC_256		"id-CA-ECDH-AES-CBC-CMAC-256"
  ------------------
                      obj = OBJ_create(ASC_id_CA_ECDH_AES_CBC_CMAC_256	, SN_id_CA_ECDH_AES_CBC_CMAC_256	, SN_id_CA_ECDH_AES_CBC_CMAC_256	);
  ------------------
  |  |  189|      1|#define SN_id_CA_ECDH_AES_CBC_CMAC_256		"id-CA-ECDH-AES-CBC-CMAC-256"
  ------------------
  373|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (373:9): [True: 1, False: 0]
  ------------------
  374|      1|        NID_id_CA_ECDH_AES_CBC_CMAC_256 = obj;
  375|       |
  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  377|       |
  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  379|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_GM);
  ------------------
  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  ------------------
  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  380|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (380:9): [True: 1, False: 0]
  ------------------
  381|      1|        obj = OBJ_create(ASC_id_PACE_DH_GM	, SN_id_PACE_DH_GM	, SN_id_PACE_DH_GM	);
  ------------------
  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  ------------------
  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM	, SN_id_PACE_DH_GM	, SN_id_PACE_DH_GM	);
  ------------------
  |  |  195|      1|#define SN_id_PACE_DH_GM		"id-PACE-DH-GM"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM	, SN_id_PACE_DH_GM	, SN_id_PACE_DH_GM	);
  ------------------
  |  |  195|      1|#define SN_id_PACE_DH_GM		"id-PACE-DH-GM"
  ------------------
  382|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (382:9): [True: 1, False: 0]
  ------------------
  383|      1|        NID_id_PACE_DH_GM = obj;
  384|       |
  385|      1|#define ASC_id_PACE_DH_GM_3DES_CBC_CBC		ASC_id_PACE_DH_GM".1"
  386|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_GM_3DES_CBC_CBC);
  ------------------
  |  |  385|      1|#define ASC_id_PACE_DH_GM_3DES_CBC_CBC		ASC_id_PACE_DH_GM".1"
  |  |  ------------------
  |  |  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  387|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (387:9): [True: 1, False: 0]
  ------------------
  388|      1|        obj = OBJ_create(ASC_id_PACE_DH_GM_3DES_CBC_CBC	, SN_id_PACE_DH_GM_3DES_CBC_CBC	, SN_id_PACE_DH_GM_3DES_CBC_CBC	);
  ------------------
  |  |  385|      1|#define ASC_id_PACE_DH_GM_3DES_CBC_CBC		ASC_id_PACE_DH_GM".1"
  |  |  ------------------
  |  |  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM_3DES_CBC_CBC	, SN_id_PACE_DH_GM_3DES_CBC_CBC	, SN_id_PACE_DH_GM_3DES_CBC_CBC	);
  ------------------
  |  |  199|      1|#define SN_id_PACE_DH_GM_3DES_CBC_CBC		"id-PACE-DH-GM-3DES-CBC-CBC"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM_3DES_CBC_CBC	, SN_id_PACE_DH_GM_3DES_CBC_CBC	, SN_id_PACE_DH_GM_3DES_CBC_CBC	);
  ------------------
  |  |  199|      1|#define SN_id_PACE_DH_GM_3DES_CBC_CBC		"id-PACE-DH-GM-3DES-CBC-CBC"
  ------------------
  389|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (389:9): [True: 1, False: 0]
  ------------------
  390|      1|        NID_id_PACE_DH_GM_3DES_CBC_CBC = obj;
  391|       |
  392|      1|#define ASC_id_PACE_DH_GM_AES_CBC_CMAC_128		ASC_id_PACE_DH_GM".2"
  393|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_GM_AES_CBC_CMAC_128);
  ------------------
  |  |  392|      1|#define ASC_id_PACE_DH_GM_AES_CBC_CMAC_128		ASC_id_PACE_DH_GM".2"
  |  |  ------------------
  |  |  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  394|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (394:9): [True: 1, False: 0]
  ------------------
  395|      1|        obj = OBJ_create(ASC_id_PACE_DH_GM_AES_CBC_CMAC_128	, SN_id_PACE_DH_GM_AES_CBC_CMAC_128	, SN_id_PACE_DH_GM_AES_CBC_CMAC_128	);
  ------------------
  |  |  392|      1|#define ASC_id_PACE_DH_GM_AES_CBC_CMAC_128		ASC_id_PACE_DH_GM".2"
  |  |  ------------------
  |  |  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM_AES_CBC_CMAC_128	, SN_id_PACE_DH_GM_AES_CBC_CMAC_128	, SN_id_PACE_DH_GM_AES_CBC_CMAC_128	);
  ------------------
  |  |  203|      1|#define SN_id_PACE_DH_GM_AES_CBC_CMAC_128		"id-PACE-DH-GM-AES-CBC-CMAC-128"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM_AES_CBC_CMAC_128	, SN_id_PACE_DH_GM_AES_CBC_CMAC_128	, SN_id_PACE_DH_GM_AES_CBC_CMAC_128	);
  ------------------
  |  |  203|      1|#define SN_id_PACE_DH_GM_AES_CBC_CMAC_128		"id-PACE-DH-GM-AES-CBC-CMAC-128"
  ------------------
  396|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (396:9): [True: 1, False: 0]
  ------------------
  397|      1|        NID_id_PACE_DH_GM_AES_CBC_CMAC_128 = obj;
  398|       |
  399|      1|#define ASC_id_PACE_DH_GM_AES_CBC_CMAC_192		ASC_id_PACE_DH_GM".3"
  400|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_GM_AES_CBC_CMAC_192);
  ------------------
  |  |  399|      1|#define ASC_id_PACE_DH_GM_AES_CBC_CMAC_192		ASC_id_PACE_DH_GM".3"
  |  |  ------------------
  |  |  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  401|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (401:9): [True: 1, False: 0]
  ------------------
  402|      1|        obj = OBJ_create(ASC_id_PACE_DH_GM_AES_CBC_CMAC_192	, SN_id_PACE_DH_GM_AES_CBC_CMAC_192	, SN_id_PACE_DH_GM_AES_CBC_CMAC_192	);
  ------------------
  |  |  399|      1|#define ASC_id_PACE_DH_GM_AES_CBC_CMAC_192		ASC_id_PACE_DH_GM".3"
  |  |  ------------------
  |  |  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM_AES_CBC_CMAC_192	, SN_id_PACE_DH_GM_AES_CBC_CMAC_192	, SN_id_PACE_DH_GM_AES_CBC_CMAC_192	);
  ------------------
  |  |  207|      1|#define SN_id_PACE_DH_GM_AES_CBC_CMAC_192		"id-PACE-DH-GM-AES-CBC-CMAC-192"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM_AES_CBC_CMAC_192	, SN_id_PACE_DH_GM_AES_CBC_CMAC_192	, SN_id_PACE_DH_GM_AES_CBC_CMAC_192	);
  ------------------
  |  |  207|      1|#define SN_id_PACE_DH_GM_AES_CBC_CMAC_192		"id-PACE-DH-GM-AES-CBC-CMAC-192"
  ------------------
  403|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (403:9): [True: 1, False: 0]
  ------------------
  404|      1|        NID_id_PACE_DH_GM_AES_CBC_CMAC_192 = obj;
  405|       |
  406|      1|#define ASC_id_PACE_DH_GM_AES_CBC_CMAC_256		ASC_id_PACE_DH_GM".4"
  407|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_GM_AES_CBC_CMAC_256);
  ------------------
  |  |  406|      1|#define ASC_id_PACE_DH_GM_AES_CBC_CMAC_256		ASC_id_PACE_DH_GM".4"
  |  |  ------------------
  |  |  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  408|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (408:9): [True: 1, False: 0]
  ------------------
  409|      1|        obj = OBJ_create(ASC_id_PACE_DH_GM_AES_CBC_CMAC_256	, SN_id_PACE_DH_GM_AES_CBC_CMAC_256	, SN_id_PACE_DH_GM_AES_CBC_CMAC_256	);
  ------------------
  |  |  406|      1|#define ASC_id_PACE_DH_GM_AES_CBC_CMAC_256		ASC_id_PACE_DH_GM".4"
  |  |  ------------------
  |  |  |  |  378|      1|#define ASC_id_PACE_DH_GM		ASC_id_PACE".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM_AES_CBC_CMAC_256	, SN_id_PACE_DH_GM_AES_CBC_CMAC_256	, SN_id_PACE_DH_GM_AES_CBC_CMAC_256	);
  ------------------
  |  |  211|      1|#define SN_id_PACE_DH_GM_AES_CBC_CMAC_256		"id-PACE-DH-GM-AES-CBC-CMAC-256"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_GM_AES_CBC_CMAC_256	, SN_id_PACE_DH_GM_AES_CBC_CMAC_256	, SN_id_PACE_DH_GM_AES_CBC_CMAC_256	);
  ------------------
  |  |  211|      1|#define SN_id_PACE_DH_GM_AES_CBC_CMAC_256		"id-PACE-DH-GM-AES-CBC-CMAC-256"
  ------------------
  410|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (410:9): [True: 1, False: 0]
  ------------------
  411|      1|        NID_id_PACE_DH_GM_AES_CBC_CMAC_256 = obj;
  412|       |
  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  414|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_GM);
  ------------------
  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  ------------------
  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  415|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (415:9): [True: 1, False: 0]
  ------------------
  416|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_GM	, SN_id_PACE_ECDH_GM	, SN_id_PACE_ECDH_GM	);
  ------------------
  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  ------------------
  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM	, SN_id_PACE_ECDH_GM	, SN_id_PACE_ECDH_GM	);
  ------------------
  |  |  215|      1|#define SN_id_PACE_ECDH_GM		"id-PACE-ECDH-GM"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM	, SN_id_PACE_ECDH_GM	, SN_id_PACE_ECDH_GM	);
  ------------------
  |  |  215|      1|#define SN_id_PACE_ECDH_GM		"id-PACE-ECDH-GM"
  ------------------
  417|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (417:9): [True: 1, False: 0]
  ------------------
  418|      1|        NID_id_PACE_ECDH_GM = obj;
  419|       |
  420|      1|#define ASC_id_PACE_ECDH_GM_3DES_CBC_CBC		ASC_id_PACE_ECDH_GM".1"
  421|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_GM_3DES_CBC_CBC);
  ------------------
  |  |  420|      1|#define ASC_id_PACE_ECDH_GM_3DES_CBC_CBC		ASC_id_PACE_ECDH_GM".1"
  |  |  ------------------
  |  |  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (422:9): [True: 1, False: 0]
  ------------------
  423|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_GM_3DES_CBC_CBC	, SN_id_PACE_ECDH_GM_3DES_CBC_CBC	, SN_id_PACE_ECDH_GM_3DES_CBC_CBC	);
  ------------------
  |  |  420|      1|#define ASC_id_PACE_ECDH_GM_3DES_CBC_CBC		ASC_id_PACE_ECDH_GM".1"
  |  |  ------------------
  |  |  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM_3DES_CBC_CBC	, SN_id_PACE_ECDH_GM_3DES_CBC_CBC	, SN_id_PACE_ECDH_GM_3DES_CBC_CBC	);
  ------------------
  |  |  219|      1|#define SN_id_PACE_ECDH_GM_3DES_CBC_CBC		"id-PACE-ECDH-GM-3DES-CBC-CBC"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM_3DES_CBC_CBC	, SN_id_PACE_ECDH_GM_3DES_CBC_CBC	, SN_id_PACE_ECDH_GM_3DES_CBC_CBC	);
  ------------------
  |  |  219|      1|#define SN_id_PACE_ECDH_GM_3DES_CBC_CBC		"id-PACE-ECDH-GM-3DES-CBC-CBC"
  ------------------
  424|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (424:9): [True: 1, False: 0]
  ------------------
  425|      1|        NID_id_PACE_ECDH_GM_3DES_CBC_CBC = obj;
  426|       |
  427|      1|#define ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_128		ASC_id_PACE_ECDH_GM".2"
  428|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_128);
  ------------------
  |  |  427|      1|#define ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_128		ASC_id_PACE_ECDH_GM".2"
  |  |  ------------------
  |  |  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  429|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (429:9): [True: 1, False: 0]
  ------------------
  430|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_128	);
  ------------------
  |  |  427|      1|#define ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_128		ASC_id_PACE_ECDH_GM".2"
  |  |  ------------------
  |  |  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_128	);
  ------------------
  |  |  223|      1|#define SN_id_PACE_ECDH_GM_AES_CBC_CMAC_128		"id-PACE-ECDH-GM-AES-CBC-CMAC-128"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_128	);
  ------------------
  |  |  223|      1|#define SN_id_PACE_ECDH_GM_AES_CBC_CMAC_128		"id-PACE-ECDH-GM-AES-CBC-CMAC-128"
  ------------------
  431|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (431:9): [True: 1, False: 0]
  ------------------
  432|      1|        NID_id_PACE_ECDH_GM_AES_CBC_CMAC_128 = obj;
  433|       |
  434|      1|#define ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_192		ASC_id_PACE_ECDH_GM".3"
  435|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_192);
  ------------------
  |  |  434|      1|#define ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_192		ASC_id_PACE_ECDH_GM".3"
  |  |  ------------------
  |  |  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (436:9): [True: 1, False: 0]
  ------------------
  437|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_192	);
  ------------------
  |  |  434|      1|#define ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_192		ASC_id_PACE_ECDH_GM".3"
  |  |  ------------------
  |  |  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_192	);
  ------------------
  |  |  227|      1|#define SN_id_PACE_ECDH_GM_AES_CBC_CMAC_192		"id-PACE-ECDH-GM-AES-CBC-CMAC-192"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_192	);
  ------------------
  |  |  227|      1|#define SN_id_PACE_ECDH_GM_AES_CBC_CMAC_192		"id-PACE-ECDH-GM-AES-CBC-CMAC-192"
  ------------------
  438|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (438:9): [True: 1, False: 0]
  ------------------
  439|      1|        NID_id_PACE_ECDH_GM_AES_CBC_CMAC_192 = obj;
  440|       |
  441|      1|#define ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_256		ASC_id_PACE_ECDH_GM".4"
  442|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_256);
  ------------------
  |  |  441|      1|#define ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_256		ASC_id_PACE_ECDH_GM".4"
  |  |  ------------------
  |  |  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  443|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (443:9): [True: 1, False: 0]
  ------------------
  444|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_256	);
  ------------------
  |  |  441|      1|#define ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_256		ASC_id_PACE_ECDH_GM".4"
  |  |  ------------------
  |  |  |  |  413|      1|#define ASC_id_PACE_ECDH_GM		ASC_id_PACE".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_256	);
  ------------------
  |  |  231|      1|#define SN_id_PACE_ECDH_GM_AES_CBC_CMAC_256		"id-PACE-ECDH-GM-AES-CBC-CMAC-256"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_GM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_GM_AES_CBC_CMAC_256	);
  ------------------
  |  |  231|      1|#define SN_id_PACE_ECDH_GM_AES_CBC_CMAC_256		"id-PACE-ECDH-GM-AES-CBC-CMAC-256"
  ------------------
  445|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (445:9): [True: 1, False: 0]
  ------------------
  446|      1|        NID_id_PACE_ECDH_GM_AES_CBC_CMAC_256 = obj;
  447|       |
  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  449|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_IM);
  ------------------
  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  ------------------
  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  450|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (450:9): [True: 1, False: 0]
  ------------------
  451|      1|        obj = OBJ_create(ASC_id_PACE_DH_IM	, SN_id_PACE_DH_IM	, SN_id_PACE_DH_IM	);
  ------------------
  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  ------------------
  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM	, SN_id_PACE_DH_IM	, SN_id_PACE_DH_IM	);
  ------------------
  |  |  235|      1|#define SN_id_PACE_DH_IM		"id-PACE-DH-IM"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM	, SN_id_PACE_DH_IM	, SN_id_PACE_DH_IM	);
  ------------------
  |  |  235|      1|#define SN_id_PACE_DH_IM		"id-PACE-DH-IM"
  ------------------
  452|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (452:9): [True: 1, False: 0]
  ------------------
  453|      1|        NID_id_PACE_DH_IM = obj;
  454|       |
  455|      1|#define ASC_id_PACE_DH_IM_3DES_CBC_CBC		ASC_id_PACE_DH_IM".1"
  456|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_IM_3DES_CBC_CBC);
  ------------------
  |  |  455|      1|#define ASC_id_PACE_DH_IM_3DES_CBC_CBC		ASC_id_PACE_DH_IM".1"
  |  |  ------------------
  |  |  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  457|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (457:9): [True: 1, False: 0]
  ------------------
  458|      1|        obj = OBJ_create(ASC_id_PACE_DH_IM_3DES_CBC_CBC	, SN_id_PACE_DH_IM_3DES_CBC_CBC	, SN_id_PACE_DH_IM_3DES_CBC_CBC	);
  ------------------
  |  |  455|      1|#define ASC_id_PACE_DH_IM_3DES_CBC_CBC		ASC_id_PACE_DH_IM".1"
  |  |  ------------------
  |  |  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM_3DES_CBC_CBC	, SN_id_PACE_DH_IM_3DES_CBC_CBC	, SN_id_PACE_DH_IM_3DES_CBC_CBC	);
  ------------------
  |  |  239|      1|#define SN_id_PACE_DH_IM_3DES_CBC_CBC		"id-PACE-DH-IM-3DES-CBC-CBC"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM_3DES_CBC_CBC	, SN_id_PACE_DH_IM_3DES_CBC_CBC	, SN_id_PACE_DH_IM_3DES_CBC_CBC	);
  ------------------
  |  |  239|      1|#define SN_id_PACE_DH_IM_3DES_CBC_CBC		"id-PACE-DH-IM-3DES-CBC-CBC"
  ------------------
  459|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (459:9): [True: 1, False: 0]
  ------------------
  460|      1|        NID_id_PACE_DH_IM_3DES_CBC_CBC = obj;
  461|       |
  462|      1|#define ASC_id_PACE_DH_IM_AES_CBC_CMAC_128		ASC_id_PACE_DH_IM".2"
  463|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_IM_AES_CBC_CMAC_128);
  ------------------
  |  |  462|      1|#define ASC_id_PACE_DH_IM_AES_CBC_CMAC_128		ASC_id_PACE_DH_IM".2"
  |  |  ------------------
  |  |  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (464:9): [True: 1, False: 0]
  ------------------
  465|      1|        obj = OBJ_create(ASC_id_PACE_DH_IM_AES_CBC_CMAC_128	, SN_id_PACE_DH_IM_AES_CBC_CMAC_128	, SN_id_PACE_DH_IM_AES_CBC_CMAC_128	);
  ------------------
  |  |  462|      1|#define ASC_id_PACE_DH_IM_AES_CBC_CMAC_128		ASC_id_PACE_DH_IM".2"
  |  |  ------------------
  |  |  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM_AES_CBC_CMAC_128	, SN_id_PACE_DH_IM_AES_CBC_CMAC_128	, SN_id_PACE_DH_IM_AES_CBC_CMAC_128	);
  ------------------
  |  |  243|      1|#define SN_id_PACE_DH_IM_AES_CBC_CMAC_128		"id-PACE-DH-IM-AES-CBC-CMAC-128"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM_AES_CBC_CMAC_128	, SN_id_PACE_DH_IM_AES_CBC_CMAC_128	, SN_id_PACE_DH_IM_AES_CBC_CMAC_128	);
  ------------------
  |  |  243|      1|#define SN_id_PACE_DH_IM_AES_CBC_CMAC_128		"id-PACE-DH-IM-AES-CBC-CMAC-128"
  ------------------
  466|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (466:9): [True: 1, False: 0]
  ------------------
  467|      1|        NID_id_PACE_DH_IM_AES_CBC_CMAC_128 = obj;
  468|       |
  469|      1|#define ASC_id_PACE_DH_IM_AES_CBC_CMAC_192		ASC_id_PACE_DH_IM".3"
  470|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_IM_AES_CBC_CMAC_192);
  ------------------
  |  |  469|      1|#define ASC_id_PACE_DH_IM_AES_CBC_CMAC_192		ASC_id_PACE_DH_IM".3"
  |  |  ------------------
  |  |  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  471|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (471:9): [True: 1, False: 0]
  ------------------
  472|      1|        obj = OBJ_create(ASC_id_PACE_DH_IM_AES_CBC_CMAC_192	, SN_id_PACE_DH_IM_AES_CBC_CMAC_192	, SN_id_PACE_DH_IM_AES_CBC_CMAC_192	);
  ------------------
  |  |  469|      1|#define ASC_id_PACE_DH_IM_AES_CBC_CMAC_192		ASC_id_PACE_DH_IM".3"
  |  |  ------------------
  |  |  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM_AES_CBC_CMAC_192	, SN_id_PACE_DH_IM_AES_CBC_CMAC_192	, SN_id_PACE_DH_IM_AES_CBC_CMAC_192	);
  ------------------
  |  |  247|      1|#define SN_id_PACE_DH_IM_AES_CBC_CMAC_192		"id-PACE-DH-IM-AES-CBC-CMAC-192"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM_AES_CBC_CMAC_192	, SN_id_PACE_DH_IM_AES_CBC_CMAC_192	, SN_id_PACE_DH_IM_AES_CBC_CMAC_192	);
  ------------------
  |  |  247|      1|#define SN_id_PACE_DH_IM_AES_CBC_CMAC_192		"id-PACE-DH-IM-AES-CBC-CMAC-192"
  ------------------
  473|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (473:9): [True: 1, False: 0]
  ------------------
  474|      1|        NID_id_PACE_DH_IM_AES_CBC_CMAC_192 = obj;
  475|       |
  476|      1|#define ASC_id_PACE_DH_IM_AES_CBC_CMAC_256		ASC_id_PACE_DH_IM".4"
  477|      1|    obj = OBJ_txt2nid(ASC_id_PACE_DH_IM_AES_CBC_CMAC_256);
  ------------------
  |  |  476|      1|#define ASC_id_PACE_DH_IM_AES_CBC_CMAC_256		ASC_id_PACE_DH_IM".4"
  |  |  ------------------
  |  |  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  478|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (478:9): [True: 1, False: 0]
  ------------------
  479|      1|        obj = OBJ_create(ASC_id_PACE_DH_IM_AES_CBC_CMAC_256	, SN_id_PACE_DH_IM_AES_CBC_CMAC_256	, SN_id_PACE_DH_IM_AES_CBC_CMAC_256	);
  ------------------
  |  |  476|      1|#define ASC_id_PACE_DH_IM_AES_CBC_CMAC_256		ASC_id_PACE_DH_IM".4"
  |  |  ------------------
  |  |  |  |  448|      1|#define ASC_id_PACE_DH_IM		ASC_id_PACE".3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM_AES_CBC_CMAC_256	, SN_id_PACE_DH_IM_AES_CBC_CMAC_256	, SN_id_PACE_DH_IM_AES_CBC_CMAC_256	);
  ------------------
  |  |  251|      1|#define SN_id_PACE_DH_IM_AES_CBC_CMAC_256		"id-PACE-DH-IM-AES-CBC-CMAC-256"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_DH_IM_AES_CBC_CMAC_256	, SN_id_PACE_DH_IM_AES_CBC_CMAC_256	, SN_id_PACE_DH_IM_AES_CBC_CMAC_256	);
  ------------------
  |  |  251|      1|#define SN_id_PACE_DH_IM_AES_CBC_CMAC_256		"id-PACE-DH-IM-AES-CBC-CMAC-256"
  ------------------
  480|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (480:9): [True: 1, False: 0]
  ------------------
  481|      1|        NID_id_PACE_DH_IM_AES_CBC_CMAC_256 = obj;
  482|       |
  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  484|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_IM);
  ------------------
  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  ------------------
  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  485|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (485:9): [True: 1, False: 0]
  ------------------
  486|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_IM	, SN_id_PACE_ECDH_IM	, SN_id_PACE_ECDH_IM	);
  ------------------
  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  ------------------
  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM	, SN_id_PACE_ECDH_IM	, SN_id_PACE_ECDH_IM	);
  ------------------
  |  |  255|      1|#define SN_id_PACE_ECDH_IM		"id-PACE-ECDH-IM"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM	, SN_id_PACE_ECDH_IM	, SN_id_PACE_ECDH_IM	);
  ------------------
  |  |  255|      1|#define SN_id_PACE_ECDH_IM		"id-PACE-ECDH-IM"
  ------------------
  487|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (487:9): [True: 1, False: 0]
  ------------------
  488|      1|        NID_id_PACE_ECDH_IM = obj;
  489|       |
  490|      1|#define ASC_id_PACE_ECDH_IM_3DES_CBC_CBC		ASC_id_PACE_ECDH_IM".1"
  491|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_IM_3DES_CBC_CBC);
  ------------------
  |  |  490|      1|#define ASC_id_PACE_ECDH_IM_3DES_CBC_CBC		ASC_id_PACE_ECDH_IM".1"
  |  |  ------------------
  |  |  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  492|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (492:9): [True: 1, False: 0]
  ------------------
  493|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_IM_3DES_CBC_CBC	, SN_id_PACE_ECDH_IM_3DES_CBC_CBC	, SN_id_PACE_ECDH_IM_3DES_CBC_CBC	);
  ------------------
  |  |  490|      1|#define ASC_id_PACE_ECDH_IM_3DES_CBC_CBC		ASC_id_PACE_ECDH_IM".1"
  |  |  ------------------
  |  |  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM_3DES_CBC_CBC	, SN_id_PACE_ECDH_IM_3DES_CBC_CBC	, SN_id_PACE_ECDH_IM_3DES_CBC_CBC	);
  ------------------
  |  |  259|      1|#define SN_id_PACE_ECDH_IM_3DES_CBC_CBC		"id-PACE-ECDH-IM-3DES-CBC-CBC"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM_3DES_CBC_CBC	, SN_id_PACE_ECDH_IM_3DES_CBC_CBC	, SN_id_PACE_ECDH_IM_3DES_CBC_CBC	);
  ------------------
  |  |  259|      1|#define SN_id_PACE_ECDH_IM_3DES_CBC_CBC		"id-PACE-ECDH-IM-3DES-CBC-CBC"
  ------------------
  494|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (494:9): [True: 1, False: 0]
  ------------------
  495|      1|        NID_id_PACE_ECDH_IM_3DES_CBC_CBC = obj;
  496|       |
  497|      1|#define ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_128		ASC_id_PACE_ECDH_IM".2"
  498|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_128);
  ------------------
  |  |  497|      1|#define ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_128		ASC_id_PACE_ECDH_IM".2"
  |  |  ------------------
  |  |  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  499|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (499:9): [True: 1, False: 0]
  ------------------
  500|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_128	);
  ------------------
  |  |  497|      1|#define ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_128		ASC_id_PACE_ECDH_IM".2"
  |  |  ------------------
  |  |  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_128	);
  ------------------
  |  |  263|      1|#define SN_id_PACE_ECDH_IM_AES_CBC_CMAC_128		"id-PACE-ECDH-IM-AES-CBC-CMAC-128"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_128	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_128	);
  ------------------
  |  |  263|      1|#define SN_id_PACE_ECDH_IM_AES_CBC_CMAC_128		"id-PACE-ECDH-IM-AES-CBC-CMAC-128"
  ------------------
  501|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (501:9): [True: 1, False: 0]
  ------------------
  502|      1|        NID_id_PACE_ECDH_IM_AES_CBC_CMAC_128 = obj;
  503|       |
  504|      1|#define ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_192		ASC_id_PACE_ECDH_IM".3"
  505|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_192);
  ------------------
  |  |  504|      1|#define ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_192		ASC_id_PACE_ECDH_IM".3"
  |  |  ------------------
  |  |  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (506:9): [True: 1, False: 0]
  ------------------
  507|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_192	);
  ------------------
  |  |  504|      1|#define ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_192		ASC_id_PACE_ECDH_IM".3"
  |  |  ------------------
  |  |  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_192	);
  ------------------
  |  |  267|      1|#define SN_id_PACE_ECDH_IM_AES_CBC_CMAC_192		"id-PACE-ECDH-IM-AES-CBC-CMAC-192"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_192	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_192	);
  ------------------
  |  |  267|      1|#define SN_id_PACE_ECDH_IM_AES_CBC_CMAC_192		"id-PACE-ECDH-IM-AES-CBC-CMAC-192"
  ------------------
  508|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (508:9): [True: 1, False: 0]
  ------------------
  509|      1|        NID_id_PACE_ECDH_IM_AES_CBC_CMAC_192 = obj;
  510|       |
  511|      1|#define ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_256		ASC_id_PACE_ECDH_IM".4"
  512|      1|    obj = OBJ_txt2nid(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_256);
  ------------------
  |  |  511|      1|#define ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_256		ASC_id_PACE_ECDH_IM".4"
  |  |  ------------------
  |  |  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  513|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (513:9): [True: 1, False: 0]
  ------------------
  514|      1|        obj = OBJ_create(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_256	);
  ------------------
  |  |  511|      1|#define ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_256		ASC_id_PACE_ECDH_IM".4"
  |  |  ------------------
  |  |  |  |  483|      1|#define ASC_id_PACE_ECDH_IM		ASC_id_PACE".4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  376|      1|#define ASC_id_PACE		ASC_bsi_de".2.2.4"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_256	);
  ------------------
  |  |  271|      1|#define SN_id_PACE_ECDH_IM_AES_CBC_CMAC_256		"id-PACE-ECDH-IM-AES-CBC-CMAC-256"
  ------------------
                      obj = OBJ_create(ASC_id_PACE_ECDH_IM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_256	, SN_id_PACE_ECDH_IM_AES_CBC_CMAC_256	);
  ------------------
  |  |  271|      1|#define SN_id_PACE_ECDH_IM_AES_CBC_CMAC_256		"id-PACE-ECDH-IM-AES-CBC-CMAC-256"
  ------------------
  515|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (515:9): [True: 1, False: 0]
  ------------------
  516|      1|        NID_id_PACE_ECDH_IM_AES_CBC_CMAC_256 = obj;
  517|       |
  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  519|       |
  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  521|      1|    obj = OBJ_txt2nid(ASC_id_RI_DH);
  ------------------
  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  ------------------
  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  522|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (522:9): [True: 1, False: 0]
  ------------------
  523|      1|        obj = OBJ_create(ASC_id_RI_DH	, SN_id_RI_DH	, SN_id_RI_DH	);
  ------------------
  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  ------------------
  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH	, SN_id_RI_DH	, SN_id_RI_DH	);
  ------------------
  |  |  277|      1|#define SN_id_RI_DH		"id-RI-DH"
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH	, SN_id_RI_DH	, SN_id_RI_DH	);
  ------------------
  |  |  277|      1|#define SN_id_RI_DH		"id-RI-DH"
  ------------------
  524|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (524:9): [True: 1, False: 0]
  ------------------
  525|      1|        NID_id_RI_DH = obj;
  526|       |
  527|      1|#define ASC_id_RI_DH_SHA_1		ASC_id_RI_DH".1"
  528|      1|    obj = OBJ_txt2nid(ASC_id_RI_DH_SHA_1);
  ------------------
  |  |  527|      1|#define ASC_id_RI_DH_SHA_1		ASC_id_RI_DH".1"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  529|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (529:9): [True: 1, False: 0]
  ------------------
  530|      1|        obj = OBJ_create(ASC_id_RI_DH_SHA_1	, SN_id_RI_DH_SHA_1	, SN_id_RI_DH_SHA_1	);
  ------------------
  |  |  527|      1|#define ASC_id_RI_DH_SHA_1		ASC_id_RI_DH".1"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_1	, SN_id_RI_DH_SHA_1	, SN_id_RI_DH_SHA_1	);
  ------------------
  |  |  281|      1|#define SN_id_RI_DH_SHA_1		"id-RI-DH-SHA-1"
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_1	, SN_id_RI_DH_SHA_1	, SN_id_RI_DH_SHA_1	);
  ------------------
  |  |  281|      1|#define SN_id_RI_DH_SHA_1		"id-RI-DH-SHA-1"
  ------------------
  531|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (531:9): [True: 1, False: 0]
  ------------------
  532|      1|        NID_id_RI_DH_SHA_1 = obj;
  533|       |
  534|      1|#define ASC_id_RI_DH_SHA_224		ASC_id_RI_DH".2"
  535|      1|    obj = OBJ_txt2nid(ASC_id_RI_DH_SHA_224);
  ------------------
  |  |  534|      1|#define ASC_id_RI_DH_SHA_224		ASC_id_RI_DH".2"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  536|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (536:9): [True: 1, False: 0]
  ------------------
  537|      1|        obj = OBJ_create(ASC_id_RI_DH_SHA_224	, SN_id_RI_DH_SHA_224	, SN_id_RI_DH_SHA_224	);
  ------------------
  |  |  534|      1|#define ASC_id_RI_DH_SHA_224		ASC_id_RI_DH".2"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_224	, SN_id_RI_DH_SHA_224	, SN_id_RI_DH_SHA_224	);
  ------------------
  |  |  285|      1|#define SN_id_RI_DH_SHA_224		"id-RI-DH-SHA-224"
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_224	, SN_id_RI_DH_SHA_224	, SN_id_RI_DH_SHA_224	);
  ------------------
  |  |  285|      1|#define SN_id_RI_DH_SHA_224		"id-RI-DH-SHA-224"
  ------------------
  538|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (538:9): [True: 1, False: 0]
  ------------------
  539|      1|        NID_id_RI_DH_SHA_224 = obj;
  540|       |
  541|      1|#define ASC_id_RI_DH_SHA_256		ASC_id_RI_DH".3"
  542|      1|    obj = OBJ_txt2nid(ASC_id_RI_DH_SHA_256);
  ------------------
  |  |  541|      1|#define ASC_id_RI_DH_SHA_256		ASC_id_RI_DH".3"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  543|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (543:9): [True: 1, False: 0]
  ------------------
  544|      1|        obj = OBJ_create(ASC_id_RI_DH_SHA_256	, SN_id_RI_DH_SHA_256	, SN_id_RI_DH_SHA_256	);
  ------------------
  |  |  541|      1|#define ASC_id_RI_DH_SHA_256		ASC_id_RI_DH".3"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_256	, SN_id_RI_DH_SHA_256	, SN_id_RI_DH_SHA_256	);
  ------------------
  |  |  289|      1|#define SN_id_RI_DH_SHA_256		"id-RI-DH-SHA-256"
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_256	, SN_id_RI_DH_SHA_256	, SN_id_RI_DH_SHA_256	);
  ------------------
  |  |  289|      1|#define SN_id_RI_DH_SHA_256		"id-RI-DH-SHA-256"
  ------------------
  545|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (545:9): [True: 1, False: 0]
  ------------------
  546|      1|        NID_id_RI_DH_SHA_256 = obj;
  547|       |
  548|      1|#define ASC_id_RI_DH_SHA_384		ASC_id_RI_DH".4"
  549|      1|    obj = OBJ_txt2nid(ASC_id_RI_DH_SHA_384);
  ------------------
  |  |  548|      1|#define ASC_id_RI_DH_SHA_384		ASC_id_RI_DH".4"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  550|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (550:9): [True: 1, False: 0]
  ------------------
  551|      1|        obj = OBJ_create(ASC_id_RI_DH_SHA_384	, SN_id_RI_DH_SHA_384	, SN_id_RI_DH_SHA_384	);
  ------------------
  |  |  548|      1|#define ASC_id_RI_DH_SHA_384		ASC_id_RI_DH".4"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_384	, SN_id_RI_DH_SHA_384	, SN_id_RI_DH_SHA_384	);
  ------------------
  |  |  293|      1|#define SN_id_RI_DH_SHA_384		"id-RI-DH-SHA-384"
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_384	, SN_id_RI_DH_SHA_384	, SN_id_RI_DH_SHA_384	);
  ------------------
  |  |  293|      1|#define SN_id_RI_DH_SHA_384		"id-RI-DH-SHA-384"
  ------------------
  552|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (552:9): [True: 1, False: 0]
  ------------------
  553|      1|        NID_id_RI_DH_SHA_384 = obj;
  554|       |
  555|      1|#define ASC_id_RI_DH_SHA_512		ASC_id_RI_DH".5"
  556|      1|    obj = OBJ_txt2nid(ASC_id_RI_DH_SHA_512);
  ------------------
  |  |  555|      1|#define ASC_id_RI_DH_SHA_512		ASC_id_RI_DH".5"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  557|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (557:9): [True: 1, False: 0]
  ------------------
  558|      1|        obj = OBJ_create(ASC_id_RI_DH_SHA_512	, SN_id_RI_DH_SHA_512	, SN_id_RI_DH_SHA_512	);
  ------------------
  |  |  555|      1|#define ASC_id_RI_DH_SHA_512		ASC_id_RI_DH".5"
  |  |  ------------------
  |  |  |  |  520|      1|#define ASC_id_RI_DH		ASC_id_RI".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_512	, SN_id_RI_DH_SHA_512	, SN_id_RI_DH_SHA_512	);
  ------------------
  |  |  297|      1|#define SN_id_RI_DH_SHA_512		"id-RI-DH-SHA-512"
  ------------------
                      obj = OBJ_create(ASC_id_RI_DH_SHA_512	, SN_id_RI_DH_SHA_512	, SN_id_RI_DH_SHA_512	);
  ------------------
  |  |  297|      1|#define SN_id_RI_DH_SHA_512		"id-RI-DH-SHA-512"
  ------------------
  559|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (559:9): [True: 1, False: 0]
  ------------------
  560|      1|        NID_id_RI_DH_SHA_512 = obj;
  561|       |
  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  563|      1|    obj = OBJ_txt2nid(ASC_id_RI_ECDH);
  ------------------
  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  ------------------
  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (564:9): [True: 1, False: 0]
  ------------------
  565|      1|        obj = OBJ_create(ASC_id_RI_ECDH	, SN_id_RI_ECDH	, SN_id_RI_ECDH	);
  ------------------
  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  ------------------
  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH	, SN_id_RI_ECDH	, SN_id_RI_ECDH	);
  ------------------
  |  |  301|      1|#define SN_id_RI_ECDH		"id-RI-ECDH"
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH	, SN_id_RI_ECDH	, SN_id_RI_ECDH	);
  ------------------
  |  |  301|      1|#define SN_id_RI_ECDH		"id-RI-ECDH"
  ------------------
  566|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (566:9): [True: 1, False: 0]
  ------------------
  567|      1|        NID_id_RI_ECDH = obj;
  568|       |
  569|      1|#define ASC_id_RI_ECDH_SHA_1		ASC_id_RI_ECDH".1"
  570|      1|    obj = OBJ_txt2nid(ASC_id_RI_ECDH_SHA_1);
  ------------------
  |  |  569|      1|#define ASC_id_RI_ECDH_SHA_1		ASC_id_RI_ECDH".1"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  571|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (571:9): [True: 1, False: 0]
  ------------------
  572|      1|        obj = OBJ_create(ASC_id_RI_ECDH_SHA_1	, SN_id_RI_ECDH_SHA_1	, SN_id_RI_ECDH_SHA_1	);
  ------------------
  |  |  569|      1|#define ASC_id_RI_ECDH_SHA_1		ASC_id_RI_ECDH".1"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_1	, SN_id_RI_ECDH_SHA_1	, SN_id_RI_ECDH_SHA_1	);
  ------------------
  |  |  305|      1|#define SN_id_RI_ECDH_SHA_1		"id-RI-ECDH-SHA-1"
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_1	, SN_id_RI_ECDH_SHA_1	, SN_id_RI_ECDH_SHA_1	);
  ------------------
  |  |  305|      1|#define SN_id_RI_ECDH_SHA_1		"id-RI-ECDH-SHA-1"
  ------------------
  573|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (573:9): [True: 1, False: 0]
  ------------------
  574|      1|        NID_id_RI_ECDH_SHA_1 = obj;
  575|       |
  576|      1|#define ASC_id_RI_ECDH_SHA_224		ASC_id_RI_ECDH".2"
  577|      1|    obj = OBJ_txt2nid(ASC_id_RI_ECDH_SHA_224);
  ------------------
  |  |  576|      1|#define ASC_id_RI_ECDH_SHA_224		ASC_id_RI_ECDH".2"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  578|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (578:9): [True: 1, False: 0]
  ------------------
  579|      1|        obj = OBJ_create(ASC_id_RI_ECDH_SHA_224	, SN_id_RI_ECDH_SHA_224	, SN_id_RI_ECDH_SHA_224	);
  ------------------
  |  |  576|      1|#define ASC_id_RI_ECDH_SHA_224		ASC_id_RI_ECDH".2"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_224	, SN_id_RI_ECDH_SHA_224	, SN_id_RI_ECDH_SHA_224	);
  ------------------
  |  |  309|      1|#define SN_id_RI_ECDH_SHA_224		"id-RI-ECDH-SHA-224"
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_224	, SN_id_RI_ECDH_SHA_224	, SN_id_RI_ECDH_SHA_224	);
  ------------------
  |  |  309|      1|#define SN_id_RI_ECDH_SHA_224		"id-RI-ECDH-SHA-224"
  ------------------
  580|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (580:9): [True: 1, False: 0]
  ------------------
  581|      1|        NID_id_RI_ECDH_SHA_224 = obj;
  582|       |
  583|      1|#define ASC_id_RI_ECDH_SHA_256		ASC_id_RI_ECDH".3"
  584|      1|    obj = OBJ_txt2nid(ASC_id_RI_ECDH_SHA_256);
  ------------------
  |  |  583|      1|#define ASC_id_RI_ECDH_SHA_256		ASC_id_RI_ECDH".3"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (585:9): [True: 1, False: 0]
  ------------------
  586|      1|        obj = OBJ_create(ASC_id_RI_ECDH_SHA_256	, SN_id_RI_ECDH_SHA_256	, SN_id_RI_ECDH_SHA_256	);
  ------------------
  |  |  583|      1|#define ASC_id_RI_ECDH_SHA_256		ASC_id_RI_ECDH".3"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_256	, SN_id_RI_ECDH_SHA_256	, SN_id_RI_ECDH_SHA_256	);
  ------------------
  |  |  313|      1|#define SN_id_RI_ECDH_SHA_256		"id-RI-ECDH-SHA-256"
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_256	, SN_id_RI_ECDH_SHA_256	, SN_id_RI_ECDH_SHA_256	);
  ------------------
  |  |  313|      1|#define SN_id_RI_ECDH_SHA_256		"id-RI-ECDH-SHA-256"
  ------------------
  587|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (587:9): [True: 1, False: 0]
  ------------------
  588|      1|        NID_id_RI_ECDH_SHA_256 = obj;
  589|       |
  590|      1|#define ASC_id_RI_ECDH_SHA_384		ASC_id_RI_ECDH".4"
  591|      1|    obj = OBJ_txt2nid(ASC_id_RI_ECDH_SHA_384);
  ------------------
  |  |  590|      1|#define ASC_id_RI_ECDH_SHA_384		ASC_id_RI_ECDH".4"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  592|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (592:9): [True: 1, False: 0]
  ------------------
  593|      1|        obj = OBJ_create(ASC_id_RI_ECDH_SHA_384	, SN_id_RI_ECDH_SHA_384	, SN_id_RI_ECDH_SHA_384	);
  ------------------
  |  |  590|      1|#define ASC_id_RI_ECDH_SHA_384		ASC_id_RI_ECDH".4"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_384	, SN_id_RI_ECDH_SHA_384	, SN_id_RI_ECDH_SHA_384	);
  ------------------
  |  |  317|      1|#define SN_id_RI_ECDH_SHA_384		"id-RI-ECDH-SHA-384"
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_384	, SN_id_RI_ECDH_SHA_384	, SN_id_RI_ECDH_SHA_384	);
  ------------------
  |  |  317|      1|#define SN_id_RI_ECDH_SHA_384		"id-RI-ECDH-SHA-384"
  ------------------
  594|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (594:9): [True: 1, False: 0]
  ------------------
  595|      1|        NID_id_RI_ECDH_SHA_384 = obj;
  596|       |
  597|      1|#define ASC_id_RI_ECDH_SHA_512		ASC_id_RI_ECDH".5"
  598|      1|    obj = OBJ_txt2nid(ASC_id_RI_ECDH_SHA_512);
  ------------------
  |  |  597|      1|#define ASC_id_RI_ECDH_SHA_512		ASC_id_RI_ECDH".5"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  599|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (599:9): [True: 1, False: 0]
  ------------------
  600|      1|        obj = OBJ_create(ASC_id_RI_ECDH_SHA_512	, SN_id_RI_ECDH_SHA_512	, SN_id_RI_ECDH_SHA_512	);
  ------------------
  |  |  597|      1|#define ASC_id_RI_ECDH_SHA_512		ASC_id_RI_ECDH".5"
  |  |  ------------------
  |  |  |  |  562|      1|#define ASC_id_RI_ECDH		ASC_id_RI".2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  518|      1|#define ASC_id_RI		ASC_bsi_de".2.2.5"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_512	, SN_id_RI_ECDH_SHA_512	, SN_id_RI_ECDH_SHA_512	);
  ------------------
  |  |  321|      1|#define SN_id_RI_ECDH_SHA_512		"id-RI-ECDH-SHA-512"
  ------------------
                      obj = OBJ_create(ASC_id_RI_ECDH_SHA_512	, SN_id_RI_ECDH_SHA_512	, SN_id_RI_ECDH_SHA_512	);
  ------------------
  |  |  321|      1|#define SN_id_RI_ECDH_SHA_512		"id-RI-ECDH-SHA-512"
  ------------------
  601|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (601:9): [True: 1, False: 0]
  ------------------
  602|      1|        NID_id_RI_ECDH_SHA_512 = obj;
  603|       |
  604|      1|#define ASC_id_CI		ASC_bsi_de".2.2.6"
  605|      1|    obj = OBJ_txt2nid(ASC_id_CI);
  ------------------
  |  |  604|      1|#define ASC_id_CI		ASC_bsi_de".2.2.6"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
  606|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (606:9): [True: 1, False: 0]
  ------------------
  607|      1|        obj = OBJ_create(ASC_id_CI	, SN_id_CI	, SN_id_CI	);
  ------------------
  |  |  604|      1|#define ASC_id_CI		ASC_bsi_de".2.2.6"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CI	, SN_id_CI	, SN_id_CI	);
  ------------------
  |  |  325|      1|#define SN_id_CI		"id-CI"
  ------------------
                      obj = OBJ_create(ASC_id_CI	, SN_id_CI	, SN_id_CI	);
  ------------------
  |  |  325|      1|#define SN_id_CI		"id-CI"
  ------------------
  608|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (608:9): [True: 1, False: 0]
  ------------------
  609|      1|        NID_id_CI = obj;
  610|       |
  611|      1|#define ASC_id_eIDSecurity		ASC_bsi_de".2.2.7"
  612|      1|    obj = OBJ_txt2nid(ASC_id_eIDSecurity);
  ------------------
  |  |  611|      1|#define ASC_id_eIDSecurity		ASC_bsi_de".2.2.7"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
  613|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (613:9): [True: 1, False: 0]
  ------------------
  614|      1|        obj = OBJ_create(ASC_id_eIDSecurity	, SN_id_eIDSecurity	, SN_id_eIDSecurity	);
  ------------------
  |  |  611|      1|#define ASC_id_eIDSecurity		ASC_bsi_de".2.2.7"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_eIDSecurity	, SN_id_eIDSecurity	, SN_id_eIDSecurity	);
  ------------------
  |  |  329|      1|#define SN_id_eIDSecurity		"id-eIDSecurity"
  ------------------
                      obj = OBJ_create(ASC_id_eIDSecurity	, SN_id_eIDSecurity	, SN_id_eIDSecurity	);
  ------------------
  |  |  329|      1|#define SN_id_eIDSecurity		"id-eIDSecurity"
  ------------------
  615|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (615:9): [True: 1, False: 0]
  ------------------
  616|      1|        NID_id_eIDSecurity = obj;
  617|       |
  618|      1|#define ASC_id_PT		ASC_bsi_de".2.2.8"
  619|      1|    obj = OBJ_txt2nid(ASC_id_PT);
  ------------------
  |  |  618|      1|#define ASC_id_PT		ASC_bsi_de".2.2.8"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
  620|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (620:9): [True: 1, False: 0]
  ------------------
  621|      1|        obj = OBJ_create(ASC_id_PT	, SN_id_PT	, SN_id_PT	);
  ------------------
  |  |  618|      1|#define ASC_id_PT		ASC_bsi_de".2.2.8"
  |  |  ------------------
  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_PT	, SN_id_PT	, SN_id_PT	);
  ------------------
  |  |  333|      1|#define SN_id_PT		"id-PT"
  ------------------
                      obj = OBJ_create(ASC_id_PT	, SN_id_PT	, SN_id_PT	);
  ------------------
  |  |  333|      1|#define SN_id_PT		"id-PT"
  ------------------
  622|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (622:9): [True: 1, False: 0]
  ------------------
  623|      1|        NID_id_PT = obj;
  624|       |
  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  626|       |
  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  628|       |
  629|      1|#define ASC_ecka_dh_SessionKDF		ASC_ecka_dh".2"
  630|      1|    obj = OBJ_txt2nid(ASC_ecka_dh_SessionKDF);
  ------------------
  |  |  629|      1|#define ASC_ecka_dh_SessionKDF		ASC_ecka_dh".2"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (631:9): [True: 1, False: 0]
  ------------------
  632|      1|        obj = OBJ_create(ASC_ecka_dh_SessionKDF	, SN_ecka_dh_SessionKDF	, SN_ecka_dh_SessionKDF	);
  ------------------
  |  |  629|      1|#define ASC_ecka_dh_SessionKDF		ASC_ecka_dh".2"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF	, SN_ecka_dh_SessionKDF	, SN_ecka_dh_SessionKDF	);
  ------------------
  |  |  341|      1|#define SN_ecka_dh_SessionKDF		"ecka-dh-SessionKDF"
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF	, SN_ecka_dh_SessionKDF	, SN_ecka_dh_SessionKDF	);
  ------------------
  |  |  341|      1|#define SN_ecka_dh_SessionKDF		"ecka-dh-SessionKDF"
  ------------------
  633|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (633:9): [True: 1, False: 0]
  ------------------
  634|      1|        NID_ecka_dh_SessionKDF = obj;
  635|       |
  636|      1|#define ASC_ecka_dh_SessionKDF_DES3		ASC_ecka_dh".2.1"
  637|      1|    obj = OBJ_txt2nid(ASC_ecka_dh_SessionKDF_DES3);
  ------------------
  |  |  636|      1|#define ASC_ecka_dh_SessionKDF_DES3		ASC_ecka_dh".2.1"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (638:9): [True: 1, False: 0]
  ------------------
  639|      1|        obj = OBJ_create(ASC_ecka_dh_SessionKDF_DES3	, SN_ecka_dh_SessionKDF_DES3	, SN_ecka_dh_SessionKDF_DES3	);
  ------------------
  |  |  636|      1|#define ASC_ecka_dh_SessionKDF_DES3		ASC_ecka_dh".2.1"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF_DES3	, SN_ecka_dh_SessionKDF_DES3	, SN_ecka_dh_SessionKDF_DES3	);
  ------------------
  |  |  345|      1|#define SN_ecka_dh_SessionKDF_DES3		"ecka-dh-SessionKDF-DES3"
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF_DES3	, SN_ecka_dh_SessionKDF_DES3	, SN_ecka_dh_SessionKDF_DES3	);
  ------------------
  |  |  345|      1|#define SN_ecka_dh_SessionKDF_DES3		"ecka-dh-SessionKDF-DES3"
  ------------------
  640|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (640:9): [True: 1, False: 0]
  ------------------
  641|      1|        NID_ecka_dh_SessionKDF_DES3 = obj;
  642|       |
  643|      1|#define ASC_ecka_dh_SessionKDF_AES128		ASC_ecka_dh".2.2"
  644|      1|    obj = OBJ_txt2nid(ASC_ecka_dh_SessionKDF_AES128);
  ------------------
  |  |  643|      1|#define ASC_ecka_dh_SessionKDF_AES128		ASC_ecka_dh".2.2"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  645|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (645:9): [True: 1, False: 0]
  ------------------
  646|      1|        obj = OBJ_create(ASC_ecka_dh_SessionKDF_AES128	, SN_ecka_dh_SessionKDF_AES128	, SN_ecka_dh_SessionKDF_AES128	);
  ------------------
  |  |  643|      1|#define ASC_ecka_dh_SessionKDF_AES128		ASC_ecka_dh".2.2"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF_AES128	, SN_ecka_dh_SessionKDF_AES128	, SN_ecka_dh_SessionKDF_AES128	);
  ------------------
  |  |  349|      1|#define SN_ecka_dh_SessionKDF_AES128		"ecka-dh-SessionKDF-AES128"
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF_AES128	, SN_ecka_dh_SessionKDF_AES128	, SN_ecka_dh_SessionKDF_AES128	);
  ------------------
  |  |  349|      1|#define SN_ecka_dh_SessionKDF_AES128		"ecka-dh-SessionKDF-AES128"
  ------------------
  647|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (647:9): [True: 1, False: 0]
  ------------------
  648|      1|        NID_ecka_dh_SessionKDF_AES128 = obj;
  649|       |
  650|      1|#define ASC_ecka_dh_SessionKDF_AES192		ASC_ecka_dh".2.3"
  651|      1|    obj = OBJ_txt2nid(ASC_ecka_dh_SessionKDF_AES192);
  ------------------
  |  |  650|      1|#define ASC_ecka_dh_SessionKDF_AES192		ASC_ecka_dh".2.3"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (652:9): [True: 1, False: 0]
  ------------------
  653|      1|        obj = OBJ_create(ASC_ecka_dh_SessionKDF_AES192	, SN_ecka_dh_SessionKDF_AES192	, SN_ecka_dh_SessionKDF_AES192	);
  ------------------
  |  |  650|      1|#define ASC_ecka_dh_SessionKDF_AES192		ASC_ecka_dh".2.3"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF_AES192	, SN_ecka_dh_SessionKDF_AES192	, SN_ecka_dh_SessionKDF_AES192	);
  ------------------
  |  |  353|      1|#define SN_ecka_dh_SessionKDF_AES192		"ecka-dh-SessionKDF-AES192"
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF_AES192	, SN_ecka_dh_SessionKDF_AES192	, SN_ecka_dh_SessionKDF_AES192	);
  ------------------
  |  |  353|      1|#define SN_ecka_dh_SessionKDF_AES192		"ecka-dh-SessionKDF-AES192"
  ------------------
  654|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (654:9): [True: 1, False: 0]
  ------------------
  655|      1|        NID_ecka_dh_SessionKDF_AES192 = obj;
  656|       |
  657|      1|#define ASC_ecka_dh_SessionKDF_AES256		ASC_ecka_dh".2.4"
  658|      1|    obj = OBJ_txt2nid(ASC_ecka_dh_SessionKDF_AES256);
  ------------------
  |  |  657|      1|#define ASC_ecka_dh_SessionKDF_AES256		ASC_ecka_dh".2.4"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  659|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (659:9): [True: 1, False: 0]
  ------------------
  660|      1|        obj = OBJ_create(ASC_ecka_dh_SessionKDF_AES256	, SN_ecka_dh_SessionKDF_AES256	, SN_ecka_dh_SessionKDF_AES256	);
  ------------------
  |  |  657|      1|#define ASC_ecka_dh_SessionKDF_AES256		ASC_ecka_dh".2.4"
  |  |  ------------------
  |  |  |  |  627|      1|#define ASC_ecka_dh		ASC_id_ecc".5.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  625|      1|#define ASC_id_ecc		ASC_bsi_de".1.1"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF_AES256	, SN_ecka_dh_SessionKDF_AES256	, SN_ecka_dh_SessionKDF_AES256	);
  ------------------
  |  |  357|      1|#define SN_ecka_dh_SessionKDF_AES256		"ecka-dh-SessionKDF-AES256"
  ------------------
                      obj = OBJ_create(ASC_ecka_dh_SessionKDF_AES256	, SN_ecka_dh_SessionKDF_AES256	, SN_ecka_dh_SessionKDF_AES256	);
  ------------------
  |  |  357|      1|#define SN_ecka_dh_SessionKDF_AES256		"ecka-dh-SessionKDF-AES256"
  ------------------
  661|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (661:9): [True: 1, False: 0]
  ------------------
  662|      1|        NID_ecka_dh_SessionKDF_AES256 = obj;
  663|       |
  664|      1|#define ASC_id_roles		ASC_bsi_de".3.1.2"
  665|       |
  666|      1|#define ASC_id_IS		ASC_id_roles".1"
  667|      1|    obj = OBJ_txt2nid(ASC_id_IS);
  ------------------
  |  |  666|      1|#define ASC_id_IS		ASC_id_roles".1"
  |  |  ------------------
  |  |  |  |  664|      1|#define ASC_id_roles		ASC_bsi_de".3.1.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  668|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (668:9): [True: 1, False: 0]
  ------------------
  669|      1|        obj = OBJ_create(ASC_id_IS	, SN_id_IS	, SN_id_IS	);
  ------------------
  |  |  666|      1|#define ASC_id_IS		ASC_id_roles".1"
  |  |  ------------------
  |  |  |  |  664|      1|#define ASC_id_roles		ASC_bsi_de".3.1.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_IS	, SN_id_IS	, SN_id_IS	);
  ------------------
  |  |  363|      1|#define SN_id_IS		"id-IS"
  ------------------
                      obj = OBJ_create(ASC_id_IS	, SN_id_IS	, SN_id_IS	);
  ------------------
  |  |  363|      1|#define SN_id_IS		"id-IS"
  ------------------
  670|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (670:9): [True: 1, False: 0]
  ------------------
  671|      1|        NID_id_IS = obj;
  672|       |
  673|      1|#define ASC_id_AT		ASC_id_roles".2"
  674|      1|    obj = OBJ_txt2nid(ASC_id_AT);
  ------------------
  |  |  673|      1|#define ASC_id_AT		ASC_id_roles".2"
  |  |  ------------------
  |  |  |  |  664|      1|#define ASC_id_roles		ASC_bsi_de".3.1.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  675|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (675:9): [True: 1, False: 0]
  ------------------
  676|      1|        obj = OBJ_create(ASC_id_AT	, SN_id_AT	, SN_id_AT	);
  ------------------
  |  |  673|      1|#define ASC_id_AT		ASC_id_roles".2"
  |  |  ------------------
  |  |  |  |  664|      1|#define ASC_id_roles		ASC_bsi_de".3.1.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_AT	, SN_id_AT	, SN_id_AT	);
  ------------------
  |  |  367|      1|#define SN_id_AT		"id-AT"
  ------------------
                      obj = OBJ_create(ASC_id_AT	, SN_id_AT	, SN_id_AT	);
  ------------------
  |  |  367|      1|#define SN_id_AT		"id-AT"
  ------------------
  677|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (677:9): [True: 1, False: 0]
  ------------------
  678|      1|        NID_id_AT = obj;
  679|       |
  680|      1|#define ASC_id_ST		ASC_id_roles".3"
  681|      1|    obj = OBJ_txt2nid(ASC_id_ST);
  ------------------
  |  |  680|      1|#define ASC_id_ST		ASC_id_roles".3"
  |  |  ------------------
  |  |  |  |  664|      1|#define ASC_id_roles		ASC_bsi_de".3.1.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  682|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (682:9): [True: 1, False: 0]
  ------------------
  683|      1|        obj = OBJ_create(ASC_id_ST	, SN_id_ST	, SN_id_ST	);
  ------------------
  |  |  680|      1|#define ASC_id_ST		ASC_id_roles".3"
  |  |  ------------------
  |  |  |  |  664|      1|#define ASC_id_roles		ASC_bsi_de".3.1.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_ST	, SN_id_ST	, SN_id_ST	);
  ------------------
  |  |  371|      1|#define SN_id_ST		"id-ST"
  ------------------
                      obj = OBJ_create(ASC_id_ST	, SN_id_ST	, SN_id_ST	);
  ------------------
  |  |  371|      1|#define SN_id_ST		"id-ST"
  ------------------
  684|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (684:9): [True: 1, False: 0]
  ------------------
  685|      1|        NID_id_ST = obj;
  686|       |
  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  688|       |
  689|      1|#define ASC_id_description		ASC_id_extensions".1"
  690|      1|    obj = OBJ_txt2nid(ASC_id_description);
  ------------------
  |  |  689|      1|#define ASC_id_description		ASC_id_extensions".1"
  |  |  ------------------
  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  691|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (691:9): [True: 1, False: 0]
  ------------------
  692|      1|        obj = OBJ_create(ASC_id_description	, SN_id_description	, SN_id_description	);
  ------------------
  |  |  689|      1|#define ASC_id_description		ASC_id_extensions".1"
  |  |  ------------------
  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_description	, SN_id_description	, SN_id_description	);
  ------------------
  |  |  377|      1|#define SN_id_description		"id-description"
  ------------------
                      obj = OBJ_create(ASC_id_description	, SN_id_description	, SN_id_description	);
  ------------------
  |  |  377|      1|#define SN_id_description		"id-description"
  ------------------
  693|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (693:9): [True: 1, False: 0]
  ------------------
  694|      1|        NID_id_description = obj;
  695|       |
  696|      1|#define ASC_id_plainFormat		ASC_id_description".1"
  697|      1|    obj = OBJ_txt2nid(ASC_id_plainFormat);
  ------------------
  |  |  696|      1|#define ASC_id_plainFormat		ASC_id_description".1"
  |  |  ------------------
  |  |  |  |  689|      1|#define ASC_id_description		ASC_id_extensions".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  698|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (698:9): [True: 1, False: 0]
  ------------------
  699|      1|        obj = OBJ_create(ASC_id_plainFormat	, SN_id_plainFormat	, SN_id_plainFormat	);
  ------------------
  |  |  696|      1|#define ASC_id_plainFormat		ASC_id_description".1"
  |  |  ------------------
  |  |  |  |  689|      1|#define ASC_id_description		ASC_id_extensions".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_plainFormat	, SN_id_plainFormat	, SN_id_plainFormat	);
  ------------------
  |  |  381|      1|#define SN_id_plainFormat		"id-plainFormat"
  ------------------
                      obj = OBJ_create(ASC_id_plainFormat	, SN_id_plainFormat	, SN_id_plainFormat	);
  ------------------
  |  |  381|      1|#define SN_id_plainFormat		"id-plainFormat"
  ------------------
  700|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (700:9): [True: 1, False: 0]
  ------------------
  701|      1|        NID_id_plainFormat = obj;
  702|       |
  703|      1|#define ASC_id_htmlFormat		ASC_id_description".2"
  704|      1|    obj = OBJ_txt2nid(ASC_id_htmlFormat);
  ------------------
  |  |  703|      1|#define ASC_id_htmlFormat		ASC_id_description".2"
  |  |  ------------------
  |  |  |  |  689|      1|#define ASC_id_description		ASC_id_extensions".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  705|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (705:9): [True: 1, False: 0]
  ------------------
  706|      1|        obj = OBJ_create(ASC_id_htmlFormat	, SN_id_htmlFormat	, SN_id_htmlFormat	);
  ------------------
  |  |  703|      1|#define ASC_id_htmlFormat		ASC_id_description".2"
  |  |  ------------------
  |  |  |  |  689|      1|#define ASC_id_description		ASC_id_extensions".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_htmlFormat	, SN_id_htmlFormat	, SN_id_htmlFormat	);
  ------------------
  |  |  385|      1|#define SN_id_htmlFormat		"id-htmlFormat"
  ------------------
                      obj = OBJ_create(ASC_id_htmlFormat	, SN_id_htmlFormat	, SN_id_htmlFormat	);
  ------------------
  |  |  385|      1|#define SN_id_htmlFormat		"id-htmlFormat"
  ------------------
  707|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (707:9): [True: 1, False: 0]
  ------------------
  708|      1|        NID_id_htmlFormat = obj;
  709|       |
  710|      1|#define ASC_id_pdfFormat		ASC_id_description".3"
  711|      1|    obj = OBJ_txt2nid(ASC_id_pdfFormat);
  ------------------
  |  |  710|      1|#define ASC_id_pdfFormat		ASC_id_description".3"
  |  |  ------------------
  |  |  |  |  689|      1|#define ASC_id_description		ASC_id_extensions".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  712|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (712:9): [True: 1, False: 0]
  ------------------
  713|      1|        obj = OBJ_create(ASC_id_pdfFormat	, SN_id_pdfFormat	, SN_id_pdfFormat	);
  ------------------
  |  |  710|      1|#define ASC_id_pdfFormat		ASC_id_description".3"
  |  |  ------------------
  |  |  |  |  689|      1|#define ASC_id_description		ASC_id_extensions".1"
  |  |  |  |  ------------------
  |  |  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_pdfFormat	, SN_id_pdfFormat	, SN_id_pdfFormat	);
  ------------------
  |  |  389|      1|#define SN_id_pdfFormat		"id-pdfFormat"
  ------------------
                      obj = OBJ_create(ASC_id_pdfFormat	, SN_id_pdfFormat	, SN_id_pdfFormat	);
  ------------------
  |  |  389|      1|#define SN_id_pdfFormat		"id-pdfFormat"
  ------------------
  714|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (714:9): [True: 1, False: 0]
  ------------------
  715|      1|        NID_id_pdfFormat = obj;
  716|       |
  717|      1|#define ASC_id_sector		ASC_id_extensions".2"
  718|      1|    obj = OBJ_txt2nid(ASC_id_sector);
  ------------------
  |  |  717|      1|#define ASC_id_sector		ASC_id_extensions".2"
  |  |  ------------------
  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  719|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (719:9): [True: 1, False: 0]
  ------------------
  720|      1|        obj = OBJ_create(ASC_id_sector	, SN_id_sector	, SN_id_sector	);
  ------------------
  |  |  717|      1|#define ASC_id_sector		ASC_id_extensions".2"
  |  |  ------------------
  |  |  |  |  687|      1|#define ASC_id_extensions		ASC_bsi_de".3.1.3"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_sector	, SN_id_sector	, SN_id_sector	);
  ------------------
  |  |  393|      1|#define SN_id_sector		"id-sector"
  ------------------
                      obj = OBJ_create(ASC_id_sector	, SN_id_sector	, SN_id_sector	);
  ------------------
  |  |  393|      1|#define SN_id_sector		"id-sector"
  ------------------
  721|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (721:9): [True: 1, False: 0]
  ------------------
  722|      1|        NID_id_sector = obj;
  723|       |
  724|      1|#define ASC_id_eID		ASC_bsi_de".3.2"
  725|       |
  726|      1|#define ASC_id_SecurityObject		ASC_id_eID".1"
  727|      1|    obj = OBJ_txt2nid(ASC_id_SecurityObject);
  ------------------
  |  |  726|      1|#define ASC_id_SecurityObject		ASC_id_eID".1"
  |  |  ------------------
  |  |  |  |  724|      1|#define ASC_id_eID		ASC_bsi_de".3.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  728|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (728:9): [True: 1, False: 0]
  ------------------
  729|      1|        obj = OBJ_create(ASC_id_SecurityObject	, SN_id_SecurityObject	, SN_id_SecurityObject	);
  ------------------
  |  |  726|      1|#define ASC_id_SecurityObject		ASC_id_eID".1"
  |  |  ------------------
  |  |  |  |  724|      1|#define ASC_id_eID		ASC_bsi_de".3.2"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_SecurityObject	, SN_id_SecurityObject	, SN_id_SecurityObject	);
  ------------------
  |  |  399|      1|#define SN_id_SecurityObject		"id-SecurityObject"
  ------------------
                      obj = OBJ_create(ASC_id_SecurityObject	, SN_id_SecurityObject	, SN_id_SecurityObject	);
  ------------------
  |  |  399|      1|#define SN_id_SecurityObject		"id-SecurityObject"
  ------------------
  730|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (730:9): [True: 1, False: 0]
  ------------------
  731|      1|        NID_id_SecurityObject = obj;
  732|       |
  733|      1|#define ASC_id_AuxiliaryData		ASC_bsi_de".3.1.4"
  734|       |
  735|      1|#define ASC_id_DateOfBirth		ASC_id_AuxiliaryData".1"
  736|      1|    obj = OBJ_txt2nid(ASC_id_DateOfBirth);
  ------------------
  |  |  735|      1|#define ASC_id_DateOfBirth		ASC_id_AuxiliaryData".1"
  |  |  ------------------
  |  |  |  |  733|      1|#define ASC_id_AuxiliaryData		ASC_bsi_de".3.1.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  737|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (737:9): [True: 1, False: 0]
  ------------------
  738|      1|        obj = OBJ_create(ASC_id_DateOfBirth	, SN_id_DateOfBirth	, SN_id_DateOfBirth	);
  ------------------
  |  |  735|      1|#define ASC_id_DateOfBirth		ASC_id_AuxiliaryData".1"
  |  |  ------------------
  |  |  |  |  733|      1|#define ASC_id_AuxiliaryData		ASC_bsi_de".3.1.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_DateOfBirth	, SN_id_DateOfBirth	, SN_id_DateOfBirth	);
  ------------------
  |  |  405|      1|#define SN_id_DateOfBirth		"id-DateOfBirth"
  ------------------
                      obj = OBJ_create(ASC_id_DateOfBirth	, SN_id_DateOfBirth	, SN_id_DateOfBirth	);
  ------------------
  |  |  405|      1|#define SN_id_DateOfBirth		"id-DateOfBirth"
  ------------------
  739|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (739:9): [True: 1, False: 0]
  ------------------
  740|      1|        NID_id_DateOfBirth = obj;
  741|       |
  742|      1|#define ASC_id_DateOfExpiry		ASC_id_AuxiliaryData".2"
  743|      1|    obj = OBJ_txt2nid(ASC_id_DateOfExpiry);
  ------------------
  |  |  742|      1|#define ASC_id_DateOfExpiry		ASC_id_AuxiliaryData".2"
  |  |  ------------------
  |  |  |  |  733|      1|#define ASC_id_AuxiliaryData		ASC_bsi_de".3.1.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  744|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (744:9): [True: 1, False: 0]
  ------------------
  745|      1|        obj = OBJ_create(ASC_id_DateOfExpiry	, SN_id_DateOfExpiry	, SN_id_DateOfExpiry	);
  ------------------
  |  |  742|      1|#define ASC_id_DateOfExpiry		ASC_id_AuxiliaryData".2"
  |  |  ------------------
  |  |  |  |  733|      1|#define ASC_id_AuxiliaryData		ASC_bsi_de".3.1.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_DateOfExpiry	, SN_id_DateOfExpiry	, SN_id_DateOfExpiry	);
  ------------------
  |  |  409|      1|#define SN_id_DateOfExpiry		"id-DateOfExpiry"
  ------------------
                      obj = OBJ_create(ASC_id_DateOfExpiry	, SN_id_DateOfExpiry	, SN_id_DateOfExpiry	);
  ------------------
  |  |  409|      1|#define SN_id_DateOfExpiry		"id-DateOfExpiry"
  ------------------
  746|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (746:9): [True: 1, False: 0]
  ------------------
  747|      1|        NID_id_DateOfExpiry = obj;
  748|       |
  749|      1|#define ASC_id_CommunityID		ASC_id_AuxiliaryData".3"
  750|      1|    obj = OBJ_txt2nid(ASC_id_CommunityID);
  ------------------
  |  |  749|      1|#define ASC_id_CommunityID		ASC_id_AuxiliaryData".3"
  |  |  ------------------
  |  |  |  |  733|      1|#define ASC_id_AuxiliaryData		ASC_bsi_de".3.1.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  751|      1|    if (obj == NID_undef)
  ------------------
  |  Branch (751:9): [True: 1, False: 0]
  ------------------
  752|      1|        obj = OBJ_create(ASC_id_CommunityID	, SN_id_CommunityID	, SN_id_CommunityID	);
  ------------------
  |  |  749|      1|#define ASC_id_CommunityID		ASC_id_AuxiliaryData".3"
  |  |  ------------------
  |  |  |  |  733|      1|#define ASC_id_AuxiliaryData		ASC_bsi_de".3.1.4"
  |  |  |  |  ------------------
  |  |  |  |  |  |  181|      1|#define ASC_bsi_de		"0.4.0.127.0.7"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
                      obj = OBJ_create(ASC_id_CommunityID	, SN_id_CommunityID	, SN_id_CommunityID	);
  ------------------
  |  |  413|      1|#define SN_id_CommunityID		"id-CommunityID"
  ------------------
                      obj = OBJ_create(ASC_id_CommunityID	, SN_id_CommunityID	, SN_id_CommunityID	);
  ------------------
  |  |  413|      1|#define SN_id_CommunityID		"id-CommunityID"
  ------------------
  753|      1|    if (obj != NID_undef)
  ------------------
  |  Branch (753:9): [True: 1, False: 0]
  ------------------
  754|      1|        NID_id_CommunityID = obj;
  755|       |
  756|      1|    if (NID_undef == NID_standardizedDomainParameters
  ------------------
  |  Branch (756:9): [True: 0, False: 1]
  ------------------
  757|      1|            || NID_undef == NID_id_PK_DH
  ------------------
  |  Branch (757:16): [True: 0, False: 1]
  ------------------
  758|      1|            || NID_undef == NID_id_PK_ECDH
  ------------------
  |  Branch (758:16): [True: 0, False: 1]
  ------------------
  759|      1|            || NID_undef == NID_id_TA
  ------------------
  |  Branch (759:16): [True: 0, False: 1]
  ------------------
  760|      1|            || NID_undef == NID_id_TA_RSA
  ------------------
  |  Branch (760:16): [True: 0, False: 1]
  ------------------
  761|      1|            || NID_undef == NID_id_TA_RSA_v1_5_SHA_1
  ------------------
  |  Branch (761:16): [True: 0, False: 1]
  ------------------
  762|      1|            || NID_undef == NID_id_TA_RSA_v1_5_SHA_256
  ------------------
  |  Branch (762:16): [True: 0, False: 1]
  ------------------
  763|      1|            || NID_undef == NID_id_TA_RSA_PSS_SHA_1
  ------------------
  |  Branch (763:16): [True: 0, False: 1]
  ------------------
  764|      1|            || NID_undef == NID_id_TA_RSA_PSS_SHA_256
  ------------------
  |  Branch (764:16): [True: 0, False: 1]
  ------------------
  765|      1|            || NID_undef == NID_id_TA_RSA_v1_5_SHA_512
  ------------------
  |  Branch (765:16): [True: 0, False: 1]
  ------------------
  766|      1|            || NID_undef == NID_id_TA_RSA_PSS_SHA_512
  ------------------
  |  Branch (766:16): [True: 0, False: 1]
  ------------------
  767|      1|            || NID_undef == NID_id_TA_ECDSA
  ------------------
  |  Branch (767:16): [True: 0, False: 1]
  ------------------
  768|      1|            || NID_undef == NID_id_TA_ECDSA_SHA_1
  ------------------
  |  Branch (768:16): [True: 0, False: 1]
  ------------------
  769|      1|            || NID_undef == NID_id_TA_ECDSA_SHA_224
  ------------------
  |  Branch (769:16): [True: 0, False: 1]
  ------------------
  770|      1|            || NID_undef == NID_id_TA_ECDSA_SHA_256
  ------------------
  |  Branch (770:16): [True: 0, False: 1]
  ------------------
  771|      1|            || NID_undef == NID_id_TA_ECDSA_SHA_384
  ------------------
  |  Branch (771:16): [True: 0, False: 1]
  ------------------
  772|      1|            || NID_undef == NID_id_TA_ECDSA_SHA_512
  ------------------
  |  Branch (772:16): [True: 0, False: 1]
  ------------------
  773|      1|            || NID_undef == NID_id_CA_DH
  ------------------
  |  Branch (773:16): [True: 0, False: 1]
  ------------------
  774|      1|            || NID_undef == NID_id_CA_DH_3DES_CBC_CBC
  ------------------
  |  Branch (774:16): [True: 0, False: 1]
  ------------------
  775|      1|            || NID_undef == NID_id_CA_DH_AES_CBC_CMAC_128
  ------------------
  |  Branch (775:16): [True: 0, False: 1]
  ------------------
  776|      1|            || NID_undef == NID_id_CA_DH_AES_CBC_CMAC_192
  ------------------
  |  Branch (776:16): [True: 0, False: 1]
  ------------------
  777|      1|            || NID_undef == NID_id_CA_DH_AES_CBC_CMAC_256
  ------------------
  |  Branch (777:16): [True: 0, False: 1]
  ------------------
  778|      1|            || NID_undef == NID_id_CA_ECDH
  ------------------
  |  Branch (778:16): [True: 0, False: 1]
  ------------------
  779|      1|            || NID_undef == NID_id_CA_ECDH_3DES_CBC_CBC
  ------------------
  |  Branch (779:16): [True: 0, False: 1]
  ------------------
  780|      1|            || NID_undef == NID_id_CA_ECDH_AES_CBC_CMAC_128
  ------------------
  |  Branch (780:16): [True: 0, False: 1]
  ------------------
  781|      1|            || NID_undef == NID_id_CA_ECDH_AES_CBC_CMAC_192
  ------------------
  |  Branch (781:16): [True: 0, False: 1]
  ------------------
  782|      1|            || NID_undef == NID_id_CA_ECDH_AES_CBC_CMAC_256
  ------------------
  |  Branch (782:16): [True: 0, False: 1]
  ------------------
  783|      1|            || NID_undef == NID_id_PACE_DH_GM
  ------------------
  |  Branch (783:16): [True: 0, False: 1]
  ------------------
  784|      1|            || NID_undef == NID_id_PACE_DH_GM_3DES_CBC_CBC
  ------------------
  |  Branch (784:16): [True: 0, False: 1]
  ------------------
  785|      1|            || NID_undef == NID_id_PACE_DH_GM_AES_CBC_CMAC_128
  ------------------
  |  Branch (785:16): [True: 0, False: 1]
  ------------------
  786|      1|            || NID_undef == NID_id_PACE_DH_GM_AES_CBC_CMAC_192
  ------------------
  |  Branch (786:16): [True: 0, False: 1]
  ------------------
  787|      1|            || NID_undef == NID_id_PACE_DH_GM_AES_CBC_CMAC_256
  ------------------
  |  Branch (787:16): [True: 0, False: 1]
  ------------------
  788|      1|            || NID_undef == NID_id_PACE_ECDH_GM
  ------------------
  |  Branch (788:16): [True: 0, False: 1]
  ------------------
  789|      1|            || NID_undef == NID_id_PACE_ECDH_GM_3DES_CBC_CBC
  ------------------
  |  Branch (789:16): [True: 0, False: 1]
  ------------------
  790|      1|            || NID_undef == NID_id_PACE_ECDH_GM_AES_CBC_CMAC_128
  ------------------
  |  Branch (790:16): [True: 0, False: 1]
  ------------------
  791|      1|            || NID_undef == NID_id_PACE_ECDH_GM_AES_CBC_CMAC_192
  ------------------
  |  Branch (791:16): [True: 0, False: 1]
  ------------------
  792|      1|            || NID_undef == NID_id_PACE_ECDH_GM_AES_CBC_CMAC_256
  ------------------
  |  Branch (792:16): [True: 0, False: 1]
  ------------------
  793|      1|            || NID_undef == NID_id_PACE_DH_IM
  ------------------
  |  Branch (793:16): [True: 0, False: 1]
  ------------------
  794|      1|            || NID_undef == NID_id_PACE_DH_IM_3DES_CBC_CBC
  ------------------
  |  Branch (794:16): [True: 0, False: 1]
  ------------------
  795|      1|            || NID_undef == NID_id_PACE_DH_IM_AES_CBC_CMAC_128
  ------------------
  |  Branch (795:16): [True: 0, False: 1]
  ------------------
  796|      1|            || NID_undef == NID_id_PACE_DH_IM_AES_CBC_CMAC_192
  ------------------
  |  Branch (796:16): [True: 0, False: 1]
  ------------------
  797|      1|            || NID_undef == NID_id_PACE_DH_IM_AES_CBC_CMAC_256
  ------------------
  |  Branch (797:16): [True: 0, False: 1]
  ------------------
  798|      1|            || NID_undef == NID_id_PACE_ECDH_IM
  ------------------
  |  Branch (798:16): [True: 0, False: 1]
  ------------------
  799|      1|            || NID_undef == NID_id_PACE_ECDH_IM_3DES_CBC_CBC
  ------------------
  |  Branch (799:16): [True: 0, False: 1]
  ------------------
  800|      1|            || NID_undef == NID_id_PACE_ECDH_IM_AES_CBC_CMAC_128
  ------------------
  |  Branch (800:16): [True: 0, False: 1]
  ------------------
  801|      1|            || NID_undef == NID_id_PACE_ECDH_IM_AES_CBC_CMAC_192
  ------------------
  |  Branch (801:16): [True: 0, False: 1]
  ------------------
  802|      1|            || NID_undef == NID_id_PACE_ECDH_IM_AES_CBC_CMAC_256
  ------------------
  |  Branch (802:16): [True: 0, False: 1]
  ------------------
  803|      1|            || NID_undef == NID_id_RI_DH
  ------------------
  |  Branch (803:16): [True: 0, False: 1]
  ------------------
  804|      1|            || NID_undef == NID_id_RI_DH_SHA_1
  ------------------
  |  Branch (804:16): [True: 0, False: 1]
  ------------------
  805|      1|            || NID_undef == NID_id_RI_DH_SHA_224
  ------------------
  |  Branch (805:16): [True: 0, False: 1]
  ------------------
  806|      1|            || NID_undef == NID_id_RI_DH_SHA_256
  ------------------
  |  Branch (806:16): [True: 0, False: 1]
  ------------------
  807|      1|            || NID_undef == NID_id_RI_DH_SHA_384
  ------------------
  |  Branch (807:16): [True: 0, False: 1]
  ------------------
  808|      1|            || NID_undef == NID_id_RI_DH_SHA_512
  ------------------
  |  Branch (808:16): [True: 0, False: 1]
  ------------------
  809|      1|            || NID_undef == NID_id_RI_ECDH
  ------------------
  |  Branch (809:16): [True: 0, False: 1]
  ------------------
  810|      1|            || NID_undef == NID_id_RI_ECDH_SHA_1
  ------------------
  |  Branch (810:16): [True: 0, False: 1]
  ------------------
  811|      1|            || NID_undef == NID_id_RI_ECDH_SHA_224
  ------------------
  |  Branch (811:16): [True: 0, False: 1]
  ------------------
  812|      1|            || NID_undef == NID_id_RI_ECDH_SHA_256
  ------------------
  |  Branch (812:16): [True: 0, False: 1]
  ------------------
  813|      1|            || NID_undef == NID_id_RI_ECDH_SHA_384
  ------------------
  |  Branch (813:16): [True: 0, False: 1]
  ------------------
  814|      1|            || NID_undef == NID_id_RI_ECDH_SHA_512
  ------------------
  |  Branch (814:16): [True: 0, False: 1]
  ------------------
  815|      1|            || NID_undef == NID_id_CI
  ------------------
  |  Branch (815:16): [True: 0, False: 1]
  ------------------
  816|      1|            || NID_undef == NID_id_eIDSecurity
  ------------------
  |  Branch (816:16): [True: 0, False: 1]
  ------------------
  817|      1|            || NID_undef == NID_id_PT
  ------------------
  |  Branch (817:16): [True: 0, False: 1]
  ------------------
  818|      1|            || NID_undef == NID_ecka_dh_SessionKDF
  ------------------
  |  Branch (818:16): [True: 0, False: 1]
  ------------------
  819|      1|            || NID_undef == NID_ecka_dh_SessionKDF_DES3
  ------------------
  |  Branch (819:16): [True: 0, False: 1]
  ------------------
  820|      1|            || NID_undef == NID_ecka_dh_SessionKDF_AES128
  ------------------
  |  Branch (820:16): [True: 0, False: 1]
  ------------------
  821|      1|            || NID_undef == NID_ecka_dh_SessionKDF_AES192
  ------------------
  |  Branch (821:16): [True: 0, False: 1]
  ------------------
  822|      1|            || NID_undef == NID_ecka_dh_SessionKDF_AES256
  ------------------
  |  Branch (822:16): [True: 0, False: 1]
  ------------------
  823|      1|            || NID_undef == NID_id_IS
  ------------------
  |  Branch (823:16): [True: 0, False: 1]
  ------------------
  824|      1|            || NID_undef == NID_id_AT
  ------------------
  |  Branch (824:16): [True: 0, False: 1]
  ------------------
  825|      1|            || NID_undef == NID_id_ST
  ------------------
  |  Branch (825:16): [True: 0, False: 1]
  ------------------
  826|      1|            || NID_undef == NID_id_description
  ------------------
  |  Branch (826:16): [True: 0, False: 1]
  ------------------
  827|      1|            || NID_undef == NID_id_plainFormat
  ------------------
  |  Branch (827:16): [True: 0, False: 1]
  ------------------
  828|      1|            || NID_undef == NID_id_htmlFormat
  ------------------
  |  Branch (828:16): [True: 0, False: 1]
  ------------------
  829|      1|            || NID_undef == NID_id_pdfFormat
  ------------------
  |  Branch (829:16): [True: 0, False: 1]
  ------------------
  830|      1|            || NID_undef == NID_id_sector
  ------------------
  |  Branch (830:16): [True: 0, False: 1]
  ------------------
  831|      1|            || NID_undef == NID_id_SecurityObject
  ------------------
  |  Branch (831:16): [True: 0, False: 1]
  ------------------
  832|      1|            || NID_undef == NID_id_DateOfBirth
  ------------------
  |  Branch (832:16): [True: 0, False: 1]
  ------------------
  833|      1|            || NID_undef == NID_id_DateOfExpiry
  ------------------
  |  Branch (833:16): [True: 0, False: 1]
  ------------------
  834|      1|            || NID_undef == NID_id_CommunityID) {
  ------------------
  |  Branch (834:16): [True: 0, False: 1]
  ------------------
  835|      0|        log_err("Error adding objects");
  ------------------
  |  |   61|      0|#define log_err(M, ...) {fprintf(stderr, "[ERROR] (%s:%d ) " M "\n", __FILE__, __LINE__, ##__VA_ARGS__); ossl_errors();}
  |  |  ------------------
  |  |  |  |   60|      0|#define ossl_errors() ERR_print_errors_fp(stderr)
  |  |  ------------------
  ------------------
  836|      0|    }
  837|       |
  838|      1|    objects_initialized = 1;
  839|      1|}

EAC_set_x509_default_dir:
   63|    286|{
   64|    286|    if (default_dir) {
  ------------------
  |  Branch (64:9): [True: 286, False: 0]
  ------------------
   65|    286|        strncpy(x509_default_dir, default_dir, (sizeof x509_default_dir) - 1);
   66|    286|        x509_default_dir[(sizeof x509_default_dir) - 1] = '\0';
   67|    286|    }
   68|    286|}

strlcat:
   49|  1.95M|{
   50|  1.95M|	char *d = dst;
   51|  1.95M|	const char *s = src;
   52|  1.95M|	size_t n = siz;
   53|  1.95M|	size_t dlen;
   54|       |
   55|       |	/* Find the end of dst and adjust bytes left but don't go past end */
   56|  1.96M|	while (n-- != 0 && *d != '\0')
  ------------------
  |  Branch (56:9): [True: 1.96M, False: 0]
  |  Branch (56:21): [True: 8.51k, False: 1.95M]
  ------------------
   57|  8.51k|		d++;
   58|  1.95M|	dlen = d - dst;
   59|  1.95M|	n = siz - dlen;
   60|       |
   61|  1.95M|	if (n == 0)
  ------------------
  |  Branch (61:6): [True: 0, False: 1.95M]
  ------------------
   62|      0|		return(dlen + strlen(s));
   63|  7.81M|	while (*s != '\0') {
  ------------------
  |  Branch (63:9): [True: 5.86M, False: 1.95M]
  ------------------
   64|  5.86M|		if (n != 1) {
  ------------------
  |  Branch (64:7): [True: 5.86M, False: 0]
  ------------------
   65|  5.86M|			*d++ = *s;
   66|  5.86M|			n--;
   67|  5.86M|		}
   68|  5.86M|		s++;
   69|  5.86M|	}
   70|  1.95M|	*d = '\0';
   71|       |
   72|  1.95M|	return(dlen + (s - src));	/* count does not include NUL */
   73|  1.95M|}

_strlcpy:
   36|  18.4k|{
   37|  18.4k|	char *d = dst;
   38|  18.4k|	const char *s = src;
   39|  18.4k|	size_t n = siz;
   40|       |
   41|       |	/* Copy as many bytes as will fit */
   42|  18.4k|	if (n != 0) {
  ------------------
  |  Branch (42:6): [True: 18.4k, False: 0]
  ------------------
   43|   261k|		while (--n != 0) {
  ------------------
  |  Branch (43:10): [True: 261k, False: 0]
  ------------------
   44|   261k|			if ((*d++ = *s++) == '\0')
  ------------------
  |  Branch (44:8): [True: 18.4k, False: 243k]
  ------------------
   45|  18.4k|				break;
   46|   261k|		}
   47|  18.4k|	}
   48|       |
   49|       |	/* Not enough room in dst, add NUL and traverse rest of src */
   50|  18.4k|	if (n == 0) {
  ------------------
  |  Branch (50:6): [True: 0, False: 18.4k]
  ------------------
   51|      0|		if (siz != 0)
  ------------------
  |  Branch (51:7): [True: 0, False: 0]
  ------------------
   52|      0|			*d = '\0';		/* NUL-terminate dst */
   53|      0|		while (*s++)
  ------------------
  |  Branch (53:10): [True: 0, False: 0]
  ------------------
   54|      0|			;
   55|      0|	}
   56|       |
   57|  18.4k|	return(s - src - 1);	/* count does not include NUL */
   58|  18.4k|}

misc.c:constant_time_eq_s:
  124|  3.44k|{
  125|  3.44k|	return constant_time_is_zero_s(a ^ b);
  126|  3.44k|}
misc.c:constant_time_is_zero_s:
   91|  3.44k|{
   92|  3.44k|	return constant_time_msb_s(~a & (a - 1));
   93|  3.44k|}
misc.c:constant_time_msb_s:
   53|  3.44k|{
   54|  3.44k|	return 0 - (a >> (sizeof(a) * 8 - 1));
   55|  3.44k|}
mechanism.c:constant_time_eq_s:
  124|    204|{
  125|    204|	return constant_time_is_zero_s(a ^ b);
  126|    204|}
mechanism.c:constant_time_is_zero_s:
   91|    204|{
   92|    204|	return constant_time_msb_s(~a & (a - 1));
   93|    204|}
mechanism.c:constant_time_msb_s:
   53|    204|{
   54|    204|	return 0 - (a >> (sizeof(a) * 8 - 1));
   55|    204|}
framework-pkcs15.c:constant_time_eq_s:
  124|    203|{
  125|    203|	return constant_time_is_zero_s(a ^ b);
  126|    203|}
framework-pkcs15.c:constant_time_is_zero_s:
   91|    203|{
   92|    203|	return constant_time_msb_s(~a & (a - 1));
   93|    203|}
framework-pkcs15.c:constant_time_msb_s:
   53|   137k|{
   54|   137k|	return 0 - (a >> (sizeof(a) * 8 - 1));
   55|   137k|}
framework-pkcs15.c:constant_time_lt_s:
   98|   137k|{
   99|   137k|	return constant_time_msb_s(a ^ ((a ^ b) | ((a - b) ^ b)));
  100|   137k|}
framework-pkcs15.c:constant_time_eq_i:
  130|     67|{
  131|     67|	return constant_time_eq((unsigned int)a, (unsigned int)b);
  132|     67|}
framework-pkcs15.c:constant_time_eq:
  118|     67|{
  119|     67|	return constant_time_is_zero(a ^ b);
  120|     67|}
framework-pkcs15.c:constant_time_is_zero:
   85|     67|{
   86|     67|	return constant_time_msb(~a & (a - 1));
   87|     67|}
framework-pkcs15.c:constant_time_msb:
   59|     67|{
   60|     67|	return 0 - (a >> (sizeof(a) * 8 - 1));
   61|     67|}
framework-pkcs15.c:constant_time_select_s:
   78|   137k|{
   79|   137k|	return (value_barrier_s(mask) & a) | (value_barrier_s(~mask) & b);
   80|   137k|}
framework-pkcs15.c:value_barrier_s:
   45|   274k|{
   46|   274k|	volatile size_t r = a;
   47|   274k|	return r;
   48|   274k|}
framework-pkcs15.c:constant_time_select_8:
   72|  68.6k|{
   73|  68.6k|	return (unsigned char)constant_time_select(mask, a, b);
   74|  68.6k|}
framework-pkcs15.c:constant_time_select:
   66|  68.6k|{
   67|  68.6k|	return (value_barrier(mask) & a) | (value_barrier(~mask) & b);
   68|  68.6k|}
framework-pkcs15.c:value_barrier:
   38|   137k|{
   39|   137k|	volatile unsigned int r = a;
   40|   137k|	return r;
   41|   137k|}
padding.c:constant_time_is_zero:
   85|  27.2k|{
   86|  27.2k|	return constant_time_msb(~a & (a - 1));
   87|  27.2k|}
padding.c:constant_time_msb:
   59|  31.5k|{
   60|  31.5k|	return 0 - (a >> (sizeof(a) * 8 - 1));
   61|  31.5k|}
padding.c:constant_time_eq:
  118|    427|{
  119|    427|	return constant_time_is_zero(a ^ b);
  120|    427|}
padding.c:constant_time_select:
   66|   114k|{
   67|   114k|	return (value_barrier(mask) & a) | (value_barrier(~mask) & b);
   68|   114k|}
padding.c:value_barrier:
   38|   229k|{
   39|   229k|	volatile unsigned int r = a;
   40|   229k|	return r;
   41|   229k|}
padding.c:constant_time_ge:
  110|     92|{
  111|     92|	return ~constant_time_lt(a, b);
  112|     92|}
padding.c:constant_time_lt:
  104|  4.25k|{
  105|  4.25k|	return constant_time_msb(a ^ ((a ^ b) | ((a - b) ^ b)));
  106|  4.25k|}
padding.c:constant_time_select_8:
   72|  97.3k|{
   73|  97.3k|	return (unsigned char)constant_time_select(mask, a, b);
   74|  97.3k|}

list_init:
  240|  90.3k|int list_init(list_t *simclist_restrict l) {
  241|  90.3k|    if (l == NULL) {
  ------------------
  |  Branch (241:9): [True: 0, False: 90.3k]
  ------------------
  242|      0|        return -1;
  243|      0|    }
  244|       |
  245|  90.3k|    memset(l, 0, sizeof *l);
  246|       |
  247|  90.3k|    seed_random();
  248|       |
  249|  90.3k|    l->numels = 0;
  250|       |
  251|       |    /* head/tail sentinels and mid pointer */
  252|  90.3k|    l->head_sentinel = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  253|  90.3k|    l->tail_sentinel = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  254|  90.3k|    if (l->tail_sentinel == NULL || l->head_sentinel == NULL) {
  ------------------
  |  Branch (254:9): [True: 0, False: 90.3k]
  |  Branch (254:37): [True: 0, False: 90.3k]
  ------------------
  255|      0|        return -1;
  256|      0|    }
  257|  90.3k|    l->head_sentinel->next = l->tail_sentinel;
  258|  90.3k|    l->tail_sentinel->prev = l->head_sentinel;
  259|  90.3k|    l->head_sentinel->prev = l->tail_sentinel->next = l->mid = NULL;
  260|  90.3k|    l->head_sentinel->data = l->tail_sentinel->data = NULL;
  261|       |
  262|       |    /* iteration attributes */
  263|  90.3k|    l->iter_active = 0;
  264|  90.3k|    l->iter_pos = 0;
  265|  90.3k|    l->iter_curentry = NULL;
  266|       |
  267|       |    /* free-list attributes */
  268|  90.3k|    l->spareelsnum = 0;
  269|  90.3k|    l->spareels = (struct list_entry_s **)malloc(SIMCLIST_MAX_SPARE_ELEMS * sizeof(struct list_entry_s *));
  ------------------
  |  |  115|  90.3k|#define SIMCLIST_MAX_SPARE_ELEMS        5
  ------------------
  270|  90.3k|    if (l->spareels == NULL) {
  ------------------
  |  Branch (270:9): [True: 0, False: 90.3k]
  ------------------
  271|      0|        return -1;
  272|      0|    }
  273|       |
  274|       |#ifdef SIMCLIST_WITH_THREADS
  275|       |    l->threadcount = 0;
  276|       |#endif
  277|       |
  278|  90.3k|    if (0 != list_attributes_setdefaults(l)) {
  ------------------
  |  Branch (278:9): [True: 0, False: 90.3k]
  ------------------
  279|      0|        return -1;
  280|      0|    }
  281|       |
  282|  90.3k|    assert(list_repOk(l));
  283|  90.3k|    assert(list_attrOk(l));
  284|       |
  285|  90.3k|    return 0;
  286|  90.3k|}
list_destroy:
  288|  90.3k|void list_destroy(list_t *simclist_restrict l) {
  289|  90.3k|    unsigned int i;
  290|       |
  291|  90.3k|    list_clear(l);
  292|   153k|    for (i = 0; i < l->spareelsnum; i++) {
  ------------------
  |  Branch (292:17): [True: 63.6k, False: 90.3k]
  ------------------
  293|  63.6k|        free(l->spareels[i]);
  294|  63.6k|    }
  295|  90.3k|    free(l->spareels);
  296|  90.3k|    free(l->head_sentinel);
  297|  90.3k|    free(l->tail_sentinel);
  298|  90.3k|}
list_attributes_comparator:
  320|  3.61k|int list_attributes_comparator(list_t *simclist_restrict l, element_comparator comparator_fun) {
  321|  3.61k|    if (l == NULL) return -1;
  ------------------
  |  Branch (321:9): [True: 0, False: 3.61k]
  ------------------
  322|       |
  323|  3.61k|    l->attrs.comparator = comparator_fun;
  324|       |
  325|  3.61k|    assert(list_attrOk(l));
  326|       |
  327|  3.61k|    return 0;
  328|  3.61k|}
list_attributes_seeker:
  330|  69.1k|int list_attributes_seeker(list_t *simclist_restrict l, element_seeker seeker_fun) {
  331|  69.1k|    if (l == NULL) return -1;
  ------------------
  |  Branch (331:9): [True: 0, False: 69.1k]
  ------------------
  332|       |
  333|  69.1k|    l->attrs.seeker = seeker_fun;
  334|  69.1k|    assert(list_attrOk(l));
  335|       |
  336|  69.1k|    return 0;
  337|  69.1k|}
list_attributes_copy:
  339|  5.19k|int list_attributes_copy(list_t *simclist_restrict l, element_meter metric_fun, int copy_data) {
  340|  5.19k|    if (l == NULL || (metric_fun == NULL && copy_data != 0)) return -1;
  ------------------
  |  Branch (340:9): [True: 0, False: 5.19k]
  |  Branch (340:23): [True: 0, False: 5.19k]
  |  Branch (340:45): [True: 0, False: 0]
  ------------------
  341|       |
  342|  5.19k|    l->attrs.meter = metric_fun;
  343|  5.19k|    l->attrs.copy_data = copy_data;
  344|       |
  345|  5.19k|    assert(list_attrOk(l));
  346|       |
  347|  5.19k|    return 0;
  348|  5.19k|}
list_append:
  374|  96.9k|int list_append(list_t *simclist_restrict l, const void *data) {
  375|  96.9k|    return list_insert_at(l, data, l->numels);
  376|  96.9k|}
list_fetch:
  382|  98.9k|void *list_fetch(list_t *simclist_restrict l) {
  383|  98.9k|    return list_extract_at(l, 0);
  384|  98.9k|}
list_get_at:
  386|   140k|void *list_get_at(const list_t *simclist_restrict l, unsigned int pos) {
  387|   140k|    struct list_entry_s *tmp;
  388|       |
  389|   140k|    tmp = list_findpos(l, pos);
  390|       |
  391|   140k|    return (tmp != NULL ? tmp->data : NULL);
  ------------------
  |  Branch (391:13): [True: 140k, False: 0]
  ------------------
  392|   140k|}
list_extract_at:
  449|  98.9k|void *list_extract_at(list_t *simclist_restrict l, unsigned int pos) {
  450|  98.9k|    struct list_entry_s *tmp;
  451|  98.9k|    void *data;
  452|       |
  453|  98.9k|    if (l->iter_active || pos >= l->numels) return NULL;
  ------------------
  |  Branch (453:9): [True: 0, False: 98.9k]
  |  Branch (453:27): [True: 51.0k, False: 47.9k]
  ------------------
  454|       |
  455|  47.9k|    tmp = list_findpos(l, pos);
  456|  47.9k|    if (tmp == NULL) {
  ------------------
  |  Branch (456:9): [True: 0, False: 47.9k]
  ------------------
  457|      0|        return NULL;
  458|      0|    }
  459|  47.9k|    data = tmp->data;
  460|       |
  461|  47.9k|    tmp->data = NULL;   /* save data from list_drop_elem() free() */
  462|  47.9k|    list_drop_elem(l, tmp, pos);
  463|  47.9k|    l->numels--;
  464|       |
  465|  47.9k|    assert(list_repOk(l));
  466|       |
  467|  47.9k|    return data;
  468|  47.9k|}
list_insert_at:
  470|  96.9k|int list_insert_at(list_t *simclist_restrict l, const void *data, unsigned int pos) {
  471|  96.9k|    struct list_entry_s *lent, *succ, *prec;
  472|       |
  473|  96.9k|    if (l->iter_active || pos > l->numels) return -1;
  ------------------
  |  Branch (473:9): [True: 0, False: 96.9k]
  |  Branch (473:27): [True: 0, False: 96.9k]
  ------------------
  474|       |
  475|       |    /* this code optimizes malloc() with a free-list */
  476|  96.9k|    if (l->spareelsnum > 0) {
  ------------------
  |  Branch (476:9): [True: 0, False: 96.9k]
  ------------------
  477|      0|        lent = l->spareels[l->spareelsnum-1];
  478|      0|        l->spareelsnum--;
  479|  96.9k|    } else {
  480|  96.9k|        lent = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  481|  96.9k|        if (lent == NULL) {
  ------------------
  |  Branch (481:13): [True: 0, False: 96.9k]
  ------------------
  482|      0|            return -1;
  483|      0|        }
  484|  96.9k|    }
  485|       |
  486|  96.9k|    if (l->attrs.copy_data) {
  ------------------
  |  Branch (486:9): [True: 20.7k, False: 76.2k]
  ------------------
  487|       |        /* make room for user' data (has to be copied) */
  488|  20.7k|        size_t datalen = l->attrs.meter(data);
  489|  20.7k|        lent->data = (struct list_entry_s *)malloc(datalen);
  490|  20.7k|        if (lent->data == NULL) {
  ------------------
  |  Branch (490:13): [True: 0, False: 20.7k]
  ------------------
  491|      0|            if (!(l->spareelsnum > 0)) {
  ------------------
  |  Branch (491:17): [True: 0, False: 0]
  ------------------
  492|      0|                free(lent);
  493|      0|            }
  494|      0|            return -1;
  495|      0|        }
  496|  20.7k|        memcpy(lent->data, data, datalen);
  497|  76.2k|    } else {
  498|  76.2k|        lent->data = (void*)data;
  499|  76.2k|    }
  500|       |
  501|       |    /* actually append element */
  502|  96.9k|    prec = list_findpos(l, pos-1);
  503|  96.9k|    if (prec == NULL) {
  ------------------
  |  Branch (503:9): [True: 0, False: 96.9k]
  ------------------
  504|      0|        if (l->attrs.copy_data) {
  ------------------
  |  Branch (504:13): [True: 0, False: 0]
  ------------------
  505|      0|            free(lent->data);
  506|      0|        }
  507|      0|        if (!(l->spareelsnum > 0)) {
  ------------------
  |  Branch (507:13): [True: 0, False: 0]
  ------------------
  508|      0|            free(lent);
  509|      0|        }
  510|      0|        return -1;
  511|      0|    }
  512|  96.9k|    succ = prec->next;
  513|       |
  514|  96.9k|    prec->next = lent;
  515|  96.9k|    lent->prev = prec;
  516|  96.9k|    lent->next = succ;
  517|  96.9k|    succ->prev = lent;
  518|       |
  519|  96.9k|    l->numels++;
  520|       |
  521|       |    /* fix mid pointer */
  522|  96.9k|    if (l->numels == 1) { /* first element, set pointer */
  ------------------
  |  Branch (522:9): [True: 52.9k, False: 44.0k]
  ------------------
  523|  52.9k|        l->mid = lent;
  524|  52.9k|    } else if (l->numels % 2) {    /* now odd */
  ------------------
  |  Branch (524:16): [True: 20.8k, False: 23.2k]
  ------------------
  525|  20.8k|        if (pos >= (l->numels-1)/2) l->mid = l->mid->next;
  ------------------
  |  Branch (525:13): [True: 20.8k, False: 0]
  ------------------
  526|  23.2k|    } else {                /* now even */
  527|  23.2k|        if (pos <= (l->numels-1)/2) l->mid = l->mid->prev;
  ------------------
  |  Branch (527:13): [True: 0, False: 23.2k]
  ------------------
  528|  23.2k|    }
  529|       |
  530|  96.9k|    assert(list_repOk(l));
  531|       |
  532|  96.9k|    return 1;
  533|  96.9k|}
list_delete:
  535|  28.3k|int list_delete(list_t *simclist_restrict l, const void *data) {
  536|  28.3k|	int pos, r;
  537|       |
  538|  28.3k|	pos = list_locate(l, data);
  539|  28.3k|	if (pos < 0)
  ------------------
  |  Branch (539:6): [True: 0, False: 28.3k]
  ------------------
  540|      0|		return -1;
  541|       |
  542|  28.3k|	r = list_delete_at(l, pos);
  543|  28.3k|	if (r < 0)
  ------------------
  |  Branch (543:6): [True: 0, False: 28.3k]
  ------------------
  544|      0|		return -1;
  545|       |
  546|  28.3k|    assert(list_repOk(l));
  547|       |
  548|  28.3k|	return 0;
  549|  28.3k|}
list_delete_at:
  551|  28.3k|int list_delete_at(list_t *simclist_restrict l, unsigned int pos) {
  552|  28.3k|    struct list_entry_s *delendo;
  553|       |
  554|       |
  555|  28.3k|    if (l->iter_active || pos >= l->numels) return -1;
  ------------------
  |  Branch (555:9): [True: 0, False: 28.3k]
  |  Branch (555:27): [True: 0, False: 28.3k]
  ------------------
  556|       |
  557|  28.3k|    delendo = list_findpos(l, pos);
  558|       |
  559|  28.3k|    list_drop_elem(l, delendo, pos);
  560|       |
  561|  28.3k|    l->numels--;
  562|       |
  563|       |
  564|  28.3k|    assert(list_repOk(l));
  565|       |
  566|  28.3k|    return  0;
  567|  28.3k|}
list_clear:
  634|   107k|int list_clear(list_t *simclist_restrict l) {
  635|   107k|    struct list_entry_s *s;
  636|       |
  637|   107k|    if (l->iter_active) return -1;
  ------------------
  |  Branch (637:9): [True: 0, False: 107k]
  ------------------
  638|       |
  639|   107k|    if (l->head_sentinel && l->tail_sentinel) {
  ------------------
  |  Branch (639:9): [True: 107k, False: 0]
  |  Branch (639:29): [True: 107k, False: 0]
  ------------------
  640|   107k|        if (l->attrs.copy_data) {        /* also free user data */
  ------------------
  |  Branch (640:13): [True: 5.19k, False: 102k]
  ------------------
  641|       |            /* spare a loop conditional with two loops: spareing elems and freeing elems */
  642|  10.0k|            for (s = l->head_sentinel->next; l->spareelsnum < SIMCLIST_MAX_SPARE_ELEMS && s != l->tail_sentinel; s = s->next) {
  ------------------
  |  |  115|  20.1k|#define SIMCLIST_MAX_SPARE_ELEMS        5
  ------------------
  |  Branch (642:46): [True: 9.46k, False: 594]
  |  Branch (642:91): [True: 4.85k, False: 4.60k]
  ------------------
  643|       |                /* move elements as spares as long as there is room */
  644|  4.85k|                if (s->data != NULL) free(s->data);
  ------------------
  |  Branch (644:21): [True: 4.85k, False: 0]
  ------------------
  645|  4.85k|                l->spareels[l->spareelsnum++] = s;
  646|  4.85k|            }
  647|  21.0k|            while (s != l->tail_sentinel) {
  ------------------
  |  Branch (647:20): [True: 15.8k, False: 5.19k]
  ------------------
  648|       |                /* free the remaining elems */
  649|  15.8k|                if (s->data != NULL) free(s->data);
  ------------------
  |  Branch (649:21): [True: 15.8k, False: 0]
  ------------------
  650|  15.8k|                s = s->next;
  651|  15.8k|                free(s->prev);
  652|  15.8k|            }
  653|  5.19k|            l->head_sentinel->next = l->tail_sentinel;
  654|  5.19k|            l->tail_sentinel->prev = l->head_sentinel;
  655|   102k|        } else { /* only free element containers */
  656|       |            /* spare a loop conditional with two loops: spareing elems and freeing elems */
  657|   102k|            for (s = l->head_sentinel->next; l->spareelsnum < SIMCLIST_MAX_SPARE_ELEMS && s != l->tail_sentinel; s = s->next) {
  ------------------
  |  |  115|   204k|#define SIMCLIST_MAX_SPARE_ELEMS        5
  ------------------
  |  Branch (657:46): [True: 100k, False: 1.53k]
  |  Branch (657:91): [True: 0, False: 100k]
  ------------------
  658|       |                /* move elements as spares as long as there is room */
  659|      0|                l->spareels[l->spareelsnum++] = s;
  660|      0|            }
  661|   102k|            while (s != l->tail_sentinel) {
  ------------------
  |  Branch (661:20): [True: 0, False: 102k]
  ------------------
  662|       |                /* free the remaining elems */
  663|      0|                s = s->next;
  664|      0|                free(s->prev);
  665|      0|            }
  666|   102k|            l->head_sentinel->next = l->tail_sentinel;
  667|   102k|            l->tail_sentinel->prev = l->head_sentinel;
  668|   102k|        }
  669|   107k|    }
  670|   107k|    l->numels = 0;
  671|   107k|    l->mid = NULL;
  672|       |
  673|   107k|    assert(list_repOk(l));
  674|       |
  675|   107k|    return 0;
  676|   107k|}
list_size:
  678|   286k|unsigned int list_size(const list_t *simclist_restrict l) {
  679|   286k|    return l->numels;
  680|   286k|}
list_locate:
  686|  99.3k|int list_locate(const list_t *simclist_restrict l, const void *data) {
  687|  99.3k|    struct list_entry_s *el;
  688|  99.3k|    int pos = 0;
  689|       |
  690|  99.3k|    if (l->head_sentinel == NULL || l->tail_sentinel == NULL) return -1;
  ------------------
  |  Branch (690:9): [True: 0, False: 99.3k]
  |  Branch (690:37): [True: 0, False: 99.3k]
  ------------------
  691|       |
  692|  99.3k|    if (l->attrs.comparator != NULL) {
  ------------------
  |  Branch (692:9): [True: 21.8k, False: 77.5k]
  ------------------
  693|       |        /* use comparator */
  694|   170k|        for (el = l->head_sentinel->next; el != l->tail_sentinel; el = el->next, pos++) {
  ------------------
  |  Branch (694:43): [True: 157k, False: 12.8k]
  ------------------
  695|   157k|            if (l->attrs.comparator(data, el->data) == 0) break;
  ------------------
  |  Branch (695:17): [True: 8.99k, False: 148k]
  ------------------
  696|   157k|        }
  697|  77.5k|    } else {
  698|       |        /* compare references */
  699|   427k|        for (el = l->head_sentinel->next; el != l->tail_sentinel; el = el->next, pos++) {
  ------------------
  |  Branch (699:43): [True: 396k, False: 30.8k]
  ------------------
  700|   396k|            if (el->data == data) break;
  ------------------
  |  Branch (700:17): [True: 46.6k, False: 350k]
  ------------------
  701|   396k|        }
  702|  77.5k|    }
  703|  99.3k|    if (el == l->tail_sentinel) return -1;
  ------------------
  |  Branch (703:9): [True: 43.6k, False: 55.6k]
  ------------------
  704|       |
  705|  55.6k|    return pos;
  706|  99.3k|}
list_seek:
  708|  73.8k|void *list_seek(list_t *simclist_restrict l, const void *indicator) {
  709|  73.8k|    const struct list_entry_s *iter;
  710|       |
  711|  73.8k|    if (l->attrs.seeker == NULL) return NULL;
  ------------------
  |  Branch (711:9): [True: 0, False: 73.8k]
  ------------------
  712|       |
  713|  73.8k|    if (l->head_sentinel == NULL || l->tail_sentinel == NULL) return NULL;
  ------------------
  |  Branch (713:9): [True: 0, False: 73.8k]
  |  Branch (713:37): [True: 0, False: 73.8k]
  ------------------
  714|       |
  715|  75.2k|    for (iter = l->head_sentinel->next; iter != l->tail_sentinel; iter = iter->next) {
  ------------------
  |  Branch (715:41): [True: 63.1k, False: 12.1k]
  ------------------
  716|  63.1k|        if (l->attrs.seeker(iter->data, indicator) != 0) return iter->data;
  ------------------
  |  Branch (716:13): [True: 61.7k, False: 1.37k]
  ------------------
  717|  63.1k|    }
  718|       |
  719|  12.1k|    return NULL;
  720|  73.8k|}
list_contains:
  722|  40.4k|int list_contains(const list_t *simclist_restrict l, const void *data) {
  723|  40.4k|    return (list_locate(l, data) >= 0);
  724|  40.4k|}
list_iterator_start:
  967|  7.85k|int list_iterator_start(list_t *simclist_restrict l) {
  968|  7.85k|    if (l->iter_active) return 0;
  ------------------
  |  Branch (968:9): [True: 0, False: 7.85k]
  ------------------
  969|  7.85k|    if (l->head_sentinel == NULL) return -1;
  ------------------
  |  Branch (969:9): [True: 0, False: 7.85k]
  ------------------
  970|  7.85k|    l->iter_pos = 0;
  971|  7.85k|    l->iter_active = 1;
  972|  7.85k|    l->iter_curentry = l->head_sentinel->next;
  973|  7.85k|    return 1;
  974|  7.85k|}
list_iterator_next:
  976|  67.4k|void *list_iterator_next(list_t *simclist_restrict l) {
  977|  67.4k|    void *toret;
  978|       |
  979|  67.4k|    if (! l->iter_active) return NULL;
  ------------------
  |  Branch (979:9): [True: 0, False: 67.4k]
  ------------------
  980|       |
  981|  67.4k|    toret = l->iter_curentry->data;
  982|  67.4k|    l->iter_curentry = l->iter_curentry->next;
  983|  67.4k|    l->iter_pos++;
  984|       |
  985|  67.4k|    return toret;
  986|  67.4k|}
list_iterator_hasnext:
  988|  65.7k|int list_iterator_hasnext(const list_t *simclist_restrict l) {
  989|  65.7k|    if (! l->iter_active) return 0;
  ------------------
  |  Branch (989:9): [True: 0, False: 65.7k]
  ------------------
  990|  65.7k|    return (l->iter_pos < l->numels);
  991|  65.7k|}
list_iterator_stop:
  993|  7.85k|int list_iterator_stop(list_t *simclist_restrict l) {
  994|  7.85k|    if (! l->iter_active) return 0;
  ------------------
  |  Branch (994:9): [True: 0, False: 7.85k]
  ------------------
  995|  7.85k|    l->iter_pos = 0;
  996|  7.85k|    l->iter_active = 0;
  997|  7.85k|    return 1;
  998|  7.85k|}
simclist.c:seed_random:
  217|  90.3k|static simclist_inline void seed_random() {
  218|  90.3k|    if (random_seed == 0) {
  ------------------
  |  Branch (218:9): [True: 1, False: 90.3k]
  ------------------
  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|  90.3k|}
simclist.c:list_attributes_setdefaults:
  300|  90.3k|int list_attributes_setdefaults(list_t *simclist_restrict l) {
  301|  90.3k|    l->attrs.comparator = NULL;
  302|  90.3k|    l->attrs.seeker = NULL;
  303|       |
  304|       |    /* also free() element data when removing and element from the list */
  305|  90.3k|    l->attrs.meter = NULL;
  306|  90.3k|    l->attrs.copy_data = 0;
  307|       |
  308|  90.3k|    l->attrs.hasher = NULL;
  309|       |
  310|       |    /* serializer/unserializer */
  311|  90.3k|    l->attrs.serializer = NULL;
  312|  90.3k|    l->attrs.unserializer = NULL;
  313|       |
  314|  90.3k|    assert(list_attrOk(l));
  315|       |
  316|  90.3k|    return 0;
  317|  90.3k|}
simclist.c:list_findpos:
  421|   313k|static simclist_inline struct list_entry_s *list_findpos(const list_t *simclist_restrict l, int posstart) {
  422|   313k|    struct list_entry_s *ptr;
  423|   313k|    float x;
  424|   313k|    int i;
  425|       |
  426|   313k|    if (l->head_sentinel == NULL || l->tail_sentinel == NULL) return NULL;
  ------------------
  |  Branch (426:9): [True: 0, False: 313k]
  |  Branch (426:37): [True: 0, False: 313k]
  ------------------
  427|       |
  428|       |    /* accept 1 slot overflow for fetching head and tail sentinels */
  429|   313k|    if (posstart < -1 || posstart > (int)l->numels) return NULL;
  ------------------
  |  Branch (429:9): [True: 0, False: 313k]
  |  Branch (429:26): [True: 0, False: 313k]
  ------------------
  430|       |
  431|   313k|    x = l->numels ? (float)(posstart+1) / l->numels : 0;
  ------------------
  |  Branch (431:9): [True: 260k, False: 52.9k]
  ------------------
  432|   313k|    if (x <= 0.25) {
  ------------------
  |  Branch (432:9): [True: 78.8k, False: 235k]
  ------------------
  433|       |        /* first quarter: get to posstart from head */
  434|   129k|        for (i = -1, ptr = l->head_sentinel; i < posstart; ptr = ptr->next, i++);
  ------------------
  |  Branch (434:46): [True: 50.3k, False: 78.8k]
  ------------------
  435|   235k|    } else if (x < 0.5) {
  ------------------
  |  Branch (435:16): [True: 7.52k, False: 227k]
  ------------------
  436|       |        /* second quarter: get to posstart from mid */
  437|  39.6k|        for (i = (l->numels-1)/2, ptr = l->mid; i > posstart; ptr = ptr->prev, i--);
  ------------------
  |  Branch (437:49): [True: 32.1k, False: 7.52k]
  ------------------
  438|   227k|    } else if (x <= 0.75) {
  ------------------
  |  Branch (438:16): [True: 9.93k, False: 217k]
  ------------------
  439|       |        /* third quarter: get to posstart from mid */
  440|  37.5k|        for (i = (l->numels-1)/2, ptr = l->mid; i < posstart; ptr = ptr->next, i++);
  ------------------
  |  Branch (440:49): [True: 27.6k, False: 9.93k]
  ------------------
  441|   217k|    } else {
  442|       |        /* fourth quarter: get to posstart from tail */
  443|   462k|        for (i = l->numels, ptr = l->tail_sentinel; i > posstart; ptr = ptr->prev, i--);
  ------------------
  |  Branch (443:53): [True: 245k, False: 217k]
  ------------------
  444|   217k|    }
  445|       |
  446|   313k|    return ptr;
  447|   313k|}
simclist.c:list_drop_elem:
 1432|  76.2k|static int list_drop_elem(list_t *simclist_restrict l, struct list_entry_s *tmp, unsigned int pos) {
 1433|  76.2k|    if (tmp == NULL) return -1;
  ------------------
  |  Branch (1433:9): [True: 0, False: 76.2k]
  ------------------
 1434|       |
 1435|       |    /* fix mid pointer. This is wrt the PRE situation */
 1436|  76.2k|    if (l->numels % 2) {    /* now odd */
  ------------------
  |  Branch (1436:9): [True: 62.9k, False: 13.3k]
  ------------------
 1437|       |        /* sort out the base case by hand */
 1438|  62.9k|        if (l->numels == 1) l->mid = NULL;
  ------------------
  |  Branch (1438:13): [True: 51.3k, False: 11.5k]
  ------------------
 1439|  11.5k|        else if (pos >= l->numels/2) l->mid = l->mid->prev;
  ------------------
  |  Branch (1439:18): [True: 0, False: 11.5k]
  ------------------
 1440|  62.9k|    } else {                /* now even */
 1441|  13.3k|        if (pos < l->numels/2) l->mid = l->mid->next;
  ------------------
  |  Branch (1441:13): [True: 13.3k, False: 0]
  ------------------
 1442|  13.3k|    }
 1443|       |
 1444|  76.2k|    tmp->prev->next = tmp->next;
 1445|  76.2k|    tmp->next->prev = tmp->prev;
 1446|       |
 1447|       |    /* free what's to be freed */
 1448|  76.2k|    if (l->attrs.copy_data && tmp->data != NULL)
  ------------------
  |  Branch (1448:9): [True: 0, False: 76.2k]
  |  Branch (1448:31): [True: 0, False: 0]
  ------------------
 1449|      0|        free(tmp->data);
 1450|       |
 1451|  76.2k|    if (l->spareels != NULL && l->spareelsnum < SIMCLIST_MAX_SPARE_ELEMS) {
  ------------------
  |  |  115|  76.2k|#define SIMCLIST_MAX_SPARE_ELEMS        5
  ------------------
  |  Branch (1451:9): [True: 76.2k, False: 0]
  |  Branch (1451:32): [True: 58.7k, False: 17.5k]
  ------------------
 1452|  58.7k|        l->spareels[l->spareelsnum++] = tmp;
 1453|  58.7k|    } else {
 1454|  17.5k|        free(tmp);
 1455|  17.5k|    }
 1456|       |
 1457|  76.2k|    return 0;
 1458|  76.2k|}

sc_apdu_get_length:
   42|  8.94k|{
   43|  8.94k|	size_t ret = 4;
   44|       |
   45|  8.94k|	switch (apdu->cse) {
   46|      0|	case SC_APDU_CASE_1:
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  |  Branch (46:2): [True: 0, False: 8.94k]
  ------------------
   47|      0|		if (proto == SC_PROTO_T0)
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (47:7): [True: 0, False: 0]
  ------------------
   48|      0|			ret++;
   49|      0|		break;
   50|  8.94k|	case SC_APDU_CASE_2_SHORT:
  ------------------
  |  |  292|  8.94k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  |  Branch (50:2): [True: 8.94k, False: 0]
  ------------------
   51|  8.94k|		ret++;
   52|  8.94k|		break;
   53|      0|	case SC_APDU_CASE_2_EXT:
  ------------------
  |  |  297|      0|#define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  |  |  ------------------
  |  |               #define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  |  Branch (53:2): [True: 0, False: 8.94k]
  ------------------
   54|      0|		ret += (proto == SC_PROTO_T0 ? 1 : 3);
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (54:11): [True: 0, False: 0]
  ------------------
   55|      0|		break;
   56|      0|	case SC_APDU_CASE_3_SHORT:
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (56:2): [True: 0, False: 8.94k]
  ------------------
   57|      0|		ret += 1 + apdu->lc;
   58|      0|		break;
   59|      0|	case SC_APDU_CASE_3_EXT:
  ------------------
  |  |  298|      0|#define SC_APDU_CASE_3_EXT		SC_APDU_CASE_3_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  |  |  ------------------
  |  |               #define SC_APDU_CASE_3_EXT		SC_APDU_CASE_3_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  |  Branch (59:2): [True: 0, False: 8.94k]
  ------------------
   60|      0|		ret += apdu->lc + (proto == SC_PROTO_T0 ? 1 : 3);
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (60:22): [True: 0, False: 0]
  ------------------
   61|      0|		break;
   62|      0|	case SC_APDU_CASE_4_SHORT:
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (62:2): [True: 0, False: 8.94k]
  ------------------
   63|      0|		ret += apdu->lc + (proto != SC_PROTO_T0 ? 2 : 1);
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (63:22): [True: 0, False: 0]
  ------------------
   64|      0|		break;
   65|      0|	case SC_APDU_CASE_4_EXT:
  ------------------
  |  |  299|      0|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  |  Branch (65:2): [True: 0, False: 8.94k]
  ------------------
   66|      0|		ret += apdu->lc + (proto == SC_PROTO_T0 ? 1 : 5);
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (66:22): [True: 0, False: 0]
  ------------------
   67|      0|		break;
   68|      0|	default:
  ------------------
  |  Branch (68:2): [True: 0, False: 8.94k]
  ------------------
   69|      0|		return 0;
   70|  8.94k|	}
   71|  8.94k|	return ret;
   72|  8.94k|}
sc_apdu2bytes:
   84|  4.47k|{
   85|  4.47k|	u8     *p = out;
   86|       |
   87|  4.47k|	size_t len = sc_apdu_get_length(apdu, proto);
   88|       |
   89|  4.47k|	if (out == NULL || outlen < len)
  ------------------
  |  Branch (89:6): [True: 0, False: 4.47k]
  |  Branch (89:21): [True: 0, False: 4.47k]
  ------------------
   90|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   91|       |	/* CLA, INS, P1 and P2 */
   92|  4.47k|	*p++ = apdu->cla;
   93|  4.47k|	*p++ = apdu->ins;
   94|  4.47k|	*p++ = apdu->p1;
   95|  4.47k|	*p++ = apdu->p2;
   96|       |	/* case depend part */
   97|  4.47k|	switch (apdu->cse) {
  ------------------
  |  Branch (97:10): [True: 4.47k, False: 0]
  ------------------
   98|      0|	case SC_APDU_CASE_1:
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  |  Branch (98:2): [True: 0, False: 4.47k]
  ------------------
   99|       |		/* T0 needs an additional 0x00 byte */
  100|      0|		if (proto == SC_PROTO_T0)
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (100:7): [True: 0, False: 0]
  ------------------
  101|      0|			*p = (u8)0x00;
  102|      0|		break;
  103|  4.47k|	case SC_APDU_CASE_2_SHORT:
  ------------------
  |  |  292|  4.47k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  |  Branch (103:2): [True: 4.47k, False: 0]
  ------------------
  104|  4.47k|		*p = (u8)apdu->le;
  105|  4.47k|		break;
  106|      0|	case SC_APDU_CASE_2_EXT:
  ------------------
  |  |  297|      0|#define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  |  |  ------------------
  |  |               #define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  |  Branch (106:2): [True: 0, False: 4.47k]
  ------------------
  107|      0|		if (proto == SC_PROTO_T0)
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (107:7): [True: 0, False: 0]
  ------------------
  108|       |			/* T0 extended APDUs look just like short APDUs */
  109|      0|			*p = (u8)apdu->le;
  110|      0|		else {
  111|       |			/* in case of T1 always use 3 bytes for length */
  112|      0|			*p++ = (u8)0x00;
  113|      0|			*p++ = (u8)(apdu->le >> 8);
  114|      0|			*p = (u8)apdu->le;
  115|      0|		}
  116|      0|		break;
  117|      0|	case SC_APDU_CASE_3_SHORT:
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (117:2): [True: 0, False: 4.47k]
  ------------------
  118|      0|		*p++ = (u8)apdu->lc;
  119|      0|		memcpy(p, apdu->data, apdu->lc);
  120|      0|		break;
  121|      0|	case SC_APDU_CASE_3_EXT:
  ------------------
  |  |  298|      0|#define SC_APDU_CASE_3_EXT		SC_APDU_CASE_3_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  |  |  ------------------
  |  |               #define SC_APDU_CASE_3_EXT		SC_APDU_CASE_3_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  |  Branch (121:2): [True: 0, False: 4.47k]
  ------------------
  122|      0|		if (proto == SC_PROTO_T0) {
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (122:7): [True: 0, False: 0]
  ------------------
  123|       |			/* in case of T0 the command is transmitted in chunks
  124|       |			 * < 255 using the ENVELOPE command ... */
  125|      0|			if (apdu->lc > 255) {
  ------------------
  |  Branch (125:8): [True: 0, False: 0]
  ------------------
  126|       |				/* ... so if Lc is greater than 255 bytes
  127|       |				 * an error has occurred on a higher level */
  128|      0|				sc_log(ctx, "invalid Lc length for CASE 3 extended APDU (need ENVELOPE)");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  129|      0|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  130|      0|			}
  131|      0|		}
  132|      0|		else {
  133|       |			/* in case of T1 always use 3 bytes for length */
  134|      0|			*p++ = (u8)0x00;
  135|      0|			*p++ = (u8)(apdu->lc >> 8);
  136|      0|			*p++ = (u8)apdu->lc;
  137|      0|		}
  138|      0|		memcpy(p, apdu->data, apdu->lc);
  139|      0|		break;
  140|      0|	case SC_APDU_CASE_4_SHORT:
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (140:2): [True: 0, False: 4.47k]
  ------------------
  141|      0|		*p++ = (u8)apdu->lc;
  142|      0|		memcpy(p, apdu->data, apdu->lc);
  143|      0|		p += apdu->lc;
  144|       |		/* in case of T0 no Le byte is added */
  145|      0|		if (proto != SC_PROTO_T0)
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (145:7): [True: 0, False: 0]
  ------------------
  146|      0|			*p = (u8)apdu->le;
  147|      0|		break;
  148|      0|	case SC_APDU_CASE_4_EXT:
  ------------------
  |  |  299|      0|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  |  Branch (148:2): [True: 0, False: 4.47k]
  ------------------
  149|      0|		if (proto == SC_PROTO_T0) {
  ------------------
  |  |  352|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (149:7): [True: 0, False: 0]
  ------------------
  150|       |			/* again a T0 extended case 4 APDU looks just
  151|       |			 * like a short APDU, the additional data is
  152|       |			 * transferred using ENVELOPE and GET RESPONSE */
  153|      0|			*p++ = (u8)apdu->lc;
  154|      0|			memcpy(p, apdu->data, apdu->lc);
  155|      0|		}
  156|      0|		else {
  157|      0|			*p++ = (u8)0x00;
  158|      0|			*p++ = (u8)(apdu->lc >> 8);
  159|      0|			*p++ = (u8)apdu->lc;
  160|      0|			memcpy(p, apdu->data, apdu->lc);
  161|      0|			p += apdu->lc;
  162|       |			/* only 2 bytes are use to specify the length of the
  163|       |			 * expected data */
  164|      0|			*p++ = (u8)(apdu->le >> 8);
  165|      0|			*p = (u8)apdu->le;
  166|      0|		}
  167|      0|		break;
  168|  4.47k|	}
  169|       |
  170|  4.47k|	return SC_SUCCESS;
  ------------------
  |  |   28|  4.47k|#define SC_SUCCESS				0
  ------------------
  171|  4.47k|}
sc_apdu_get_octets:
  175|  4.47k|{
  176|  4.47k|	size_t	nlen;
  177|  4.47k|	u8	*nbuf;
  178|       |
  179|  4.47k|	if (apdu == NULL || buf == NULL || len == NULL)
  ------------------
  |  Branch (179:6): [True: 0, False: 4.47k]
  |  Branch (179:22): [True: 0, False: 4.47k]
  |  Branch (179:37): [True: 0, False: 4.47k]
  ------------------
  180|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  181|       |
  182|       |	/* get the estimated length of encoded APDU */
  183|  4.47k|	nlen = sc_apdu_get_length(apdu, proto);
  184|  4.47k|	if (nlen == 0)
  ------------------
  |  Branch (184:6): [True: 0, False: 4.47k]
  ------------------
  185|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  186|  4.47k|	nbuf = malloc(nlen);
  187|  4.47k|	if (nbuf == NULL)
  ------------------
  |  Branch (187:6): [True: 0, False: 4.47k]
  ------------------
  188|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  189|       |	/* encode the APDU in the buffer */
  190|  4.47k|	if (sc_apdu2bytes(ctx, apdu, proto, nbuf, nlen) != SC_SUCCESS) {
  ------------------
  |  |   28|  4.47k|#define SC_SUCCESS				0
  ------------------
  |  Branch (190:6): [True: 0, False: 4.47k]
  ------------------
  191|      0|		free(nbuf);
  192|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  193|      0|	}
  194|  4.47k|	*buf = nbuf;
  195|  4.47k|	*len = nlen;
  196|       |
  197|  4.47k|	return SC_SUCCESS;
  ------------------
  |  |   28|  4.47k|#define SC_SUCCESS				0
  ------------------
  198|  4.47k|}
sc_check_apdu:
  256|   612k|{
  257|   612k|	if ((apdu->cse & ~SC_APDU_SHORT_MASK) == 0) {
  ------------------
  |  |  295|   612k|#define SC_APDU_SHORT_MASK		0x0f
  ------------------
  |  Branch (257:6): [True: 610k, False: 1.51k]
  ------------------
  258|       |		/* length check for short APDU */
  259|   610k|		if (apdu->le > 256 || (apdu->lc > 255 && (apdu->flags & SC_APDU_FLAGS_CHAINING) == 0))   {
  ------------------
  |  |  306|     26|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  |  Branch (259:7): [True: 22, False: 610k]
  |  Branch (259:26): [True: 26, False: 610k]
  |  Branch (259:44): [True: 0, False: 26]
  ------------------
  260|     22|			sc_log(card->ctx, "failed length check for short APDU");
  ------------------
  |  |   71|     22|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  261|     22|			goto error;
  262|     22|		}
  263|   610k|	}
  264|  1.51k|	else if ((apdu->cse & SC_APDU_EXT) != 0) {
  ------------------
  |  |  296|  1.51k|#define SC_APDU_EXT			0x10
  ------------------
  |  Branch (264:11): [True: 1.51k, False: 0]
  ------------------
  265|       |		/* check if the card supports extended APDUs */
  266|  1.51k|		if ((card->caps & SC_CARD_CAP_APDU_EXT) == 0) {
  ------------------
  |  |  547|  1.51k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (266:7): [True: 1, False: 1.51k]
  ------------------
  267|      1|			sc_log(card->ctx, "card doesn't support extended APDUs");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  268|      1|			goto error;
  269|      1|		}
  270|       |		/* length check for extended APDU */
  271|  1.51k|		if (apdu->le > 65536 || apdu->lc > 65535)   {
  ------------------
  |  Branch (271:7): [True: 0, False: 1.51k]
  |  Branch (271:27): [True: 0, False: 1.51k]
  ------------------
  272|      0|			sc_log(card->ctx, "failed length check for extended APDU");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  273|      0|			goto error;
  274|      0|		}
  275|  1.51k|	}
  276|      0|	else   {
  277|      0|		goto error;
  278|      0|	}
  279|       |
  280|   612k|	switch (apdu->cse & SC_APDU_SHORT_MASK) {
  ------------------
  |  |  295|   612k|#define SC_APDU_SHORT_MASK		0x0f
  ------------------
  281|  3.92k|	case SC_APDU_CASE_1:
  ------------------
  |  |  291|  3.92k|#define SC_APDU_CASE_1			0x01
  ------------------
  |  Branch (281:2): [True: 3.92k, False: 608k]
  ------------------
  282|       |		/* no data is sent or received */
  283|  3.92k|		if (apdu->datalen != 0 || apdu->lc != 0 || apdu->le != 0)
  ------------------
  |  Branch (283:7): [True: 0, False: 3.92k]
  |  Branch (283:29): [True: 0, False: 3.92k]
  |  Branch (283:46): [True: 0, False: 3.92k]
  ------------------
  284|      0|			goto error;
  285|  3.92k|		break;
  286|   251k|	case SC_APDU_CASE_2_SHORT:
  ------------------
  |  |  292|   251k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  |  Branch (286:2): [True: 251k, False: 360k]
  ------------------
  287|       |		/* no data is sent */
  288|   251k|		if (apdu->datalen != 0 || apdu->lc != 0)
  ------------------
  |  Branch (288:7): [True: 0, False: 251k]
  |  Branch (288:29): [True: 0, False: 251k]
  ------------------
  289|      0|			goto error;
  290|       |		/* data is expected       */
  291|   251k|		if (apdu->resplen == 0 || apdu->resp == NULL)
  ------------------
  |  Branch (291:7): [True: 1, False: 251k]
  |  Branch (291:29): [True: 0, False: 251k]
  ------------------
  292|      1|			goto error;
  293|   251k|		break;
  294|   251k|	case SC_APDU_CASE_3_SHORT:
  ------------------
  |  |  293|  73.7k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (294:2): [True: 73.7k, False: 538k]
  ------------------
  295|       |		/* data is sent */
  296|  73.7k|		if (apdu->datalen == 0 || apdu->data == NULL || apdu->lc == 0)
  ------------------
  |  Branch (296:7): [True: 6, False: 73.7k]
  |  Branch (296:29): [True: 0, False: 73.7k]
  |  Branch (296:51): [True: 0, False: 73.7k]
  ------------------
  297|      6|			goto error;
  298|       |		/* no data is expected    */
  299|  73.7k|		if (apdu->le != 0)
  ------------------
  |  Branch (299:7): [True: 0, False: 73.7k]
  ------------------
  300|      0|			goto error;
  301|       |		/* inconsistent datalen   */
  302|  73.7k|		if (apdu->datalen != apdu->lc)
  ------------------
  |  Branch (302:7): [True: 0, False: 73.7k]
  ------------------
  303|      0|			goto error;
  304|  73.7k|		break;
  305|   283k|	case SC_APDU_CASE_4_SHORT:
  ------------------
  |  |  294|   283k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (305:2): [True: 283k, False: 329k]
  ------------------
  306|       |		/* data is sent */
  307|   283k|		if (apdu->datalen == 0 || apdu->data == NULL || apdu->lc == 0)
  ------------------
  |  Branch (307:7): [True: 631, False: 282k]
  |  Branch (307:29): [True: 0, False: 282k]
  |  Branch (307:51): [True: 0, False: 282k]
  ------------------
  308|    631|			goto error;
  309|       |		/* data is expected       */
  310|   282k|		if (apdu->resplen == 0 || apdu->resp == NULL)
  ------------------
  |  Branch (310:7): [True: 0, False: 282k]
  |  Branch (310:29): [True: 0, False: 282k]
  ------------------
  311|      0|			goto error;
  312|       |		/* inconsistent datalen   */
  313|   282k|		if (apdu->datalen != apdu->lc)
  ------------------
  |  Branch (313:7): [True: 0, False: 282k]
  ------------------
  314|      0|			goto error;
  315|   282k|		break;
  316|   282k|	default:
  ------------------
  |  Branch (316:2): [True: 0, False: 612k]
  ------------------
  317|      0|		sc_log(card->ctx, "Invalid APDU case %d", apdu->cse);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  318|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  319|   612k|	}
  320|   611k|	return SC_SUCCESS;
  ------------------
  |  |   28|   611k|#define SC_SUCCESS				0
  ------------------
  321|    661|error:
  322|    661|	sc_log(card->ctx, "Invalid Case %d %s APDU:\n"
  ------------------
  |  |   71|    661|#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)
  |  |  ------------------
  |  |  |  |  325|  1.32k|		apdu->cse & SC_APDU_SHORT_MASK,
  |  |  |  |  ------------------
  |  |  |  |  |  |  295|    661|#define SC_APDU_SHORT_MASK		0x0f
  |  |  |  |  ------------------
  |  |  |  |  326|  1.32k|		(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
  |  |  |  |  ------------------
  |  |  |  |  |  |  296|    661|#define SC_APDU_EXT			0x10
  |  |  |  |  ------------------
  |  |  |  |  327|  1.32k|		apdu->cse, apdu->cla, apdu->ins, apdu->p1, apdu->p2,
  |  |  |  |  328|  1.32k|		(unsigned long) apdu->lc, (unsigned long) apdu->le,
  |  |  |  |  329|  1.32k|		apdu->resp, (unsigned long) apdu->resplen,
  |  |  |  |  330|  1.32k|		apdu->data, (unsigned long) apdu->datalen, apdu->flags);
  |  |  ------------------
  ------------------
  323|    661|		"cse=%02x cla=%02x ins=%02x p1=%02x p2=%02x lc=%lu le=%lu\n"
  324|    661|		"resp=%p resplen=%lu data=%p datalen=%lu flags=0x%8.8lx",
  325|    661|		apdu->cse & SC_APDU_SHORT_MASK,
  326|    661|		(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
  327|    661|		apdu->cse, apdu->cla, apdu->ins, apdu->p1, apdu->p2,
  328|    661|		(unsigned long) apdu->lc, (unsigned long) apdu->le,
  329|    661|		apdu->resp, (unsigned long) apdu->resplen,
  330|    661|		apdu->data, (unsigned long) apdu->datalen, apdu->flags);
  331|    661|	return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    661|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  332|   612k|}
sc_transmit_apdu:
  541|   605k|{
  542|   605k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|   605k|#define SC_SUCCESS				0
  ------------------
  543|       |
  544|   605k|	if (card == NULL || apdu == NULL)
  ------------------
  |  Branch (544:6): [True: 0, False: 605k]
  |  Branch (544:22): [True: 0, False: 605k]
  ------------------
  545|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  546|       |
  547|   605k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|   605k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   605k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   605k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   605k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 605k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  548|       |
  549|       |	/* determine the APDU type if necessary, i.e. to use
  550|       |	 * short or extended APDUs  */
  551|   605k|	sc_detect_apdu_cse(card, apdu);
  552|       |	/* basic APDU consistency check */
  553|   605k|	r = sc_check_apdu(card, apdu);
  554|   605k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|   605k|#define SC_SUCCESS				0
  ------------------
  |  Branch (554:6): [True: 661, False: 604k]
  ------------------
  555|    661|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    661|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  556|       |
  557|   604k|	r = sc_lock(card);	/* acquire card lock*/
  558|   604k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|   604k|#define SC_SUCCESS				0
  ------------------
  |  Branch (558:6): [True: 0, False: 604k]
  ------------------
  559|      0|		sc_log(card->ctx, "unable to acquire lock");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  560|      0|		return r;
  561|      0|	}
  562|       |
  563|   604k|#if ENABLE_SM
  564|   604k|	if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT
  ------------------
  |  |   47|  1.20M|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (564:6): [True: 7.69k, False: 596k]
  ------------------
  565|  7.69k|			&& (apdu->flags & SC_APDU_FLAGS_CHAINING) != 0
  ------------------
  |  |  306|  7.69k|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  |  Branch (565:7): [True: 0, False: 7.69k]
  ------------------
  566|      0|			&& (apdu->flags & SC_APDU_FLAGS_SM_CHAINING) != 0) {
  ------------------
  |  |  316|      0|#define SC_APDU_FLAGS_SM_CHAINING	0x00000010UL
  ------------------
  |  Branch (566:7): [True: 0, False: 0]
  ------------------
  567|      0|		sc_log(card->ctx,"Let SM do the chaining");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  568|      0|		r = sc_transmit(card, apdu);
  569|      0|	} else
  570|   604k|#endif
  571|   604k|	if ((apdu->flags & SC_APDU_FLAGS_CHAINING) != 0) {
  ------------------
  |  |  306|   604k|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  |  Branch (571:6): [True: 1.08k, False: 603k]
  ------------------
  572|       |		/* divide et impera: transmit APDU in chunks with Lc <= max_send_size
  573|       |		 * bytes using command chaining */
  574|  1.08k|		size_t    len  = apdu->datalen;
  575|  1.08k|		const u8  *buf = apdu->data;
  576|  1.08k|		size_t    max_send_size = sc_get_max_send_size(card);
  577|       |
  578|  3.95k|		while (len != 0) {
  ------------------
  |  Branch (578:10): [True: 3.23k, False: 720]
  ------------------
  579|  3.23k|			size_t    plen;
  580|  3.23k|			sc_apdu_t tapdu;
  581|  3.23k|			int       last = 0;
  582|       |
  583|  3.23k|			tapdu = *apdu;
  584|       |			/* clear chaining flag */
  585|  3.23k|			tapdu.flags &= ~SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|  3.23k|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  586|  3.23k|			if (len > max_send_size) {
  ------------------
  |  Branch (586:8): [True: 2.49k, False: 743]
  ------------------
  587|       |				/* adjust APDU case: in case of CASE 4 APDU
  588|       |				 * the intermediate APDU are of CASE 3 */
  589|  2.49k|				if ((tapdu.cse & SC_APDU_SHORT_MASK) == SC_APDU_CASE_4_SHORT)
  ------------------
  |  |  295|  2.49k|#define SC_APDU_SHORT_MASK		0x0f
  ------------------
              				if ((tapdu.cse & SC_APDU_SHORT_MASK) == SC_APDU_CASE_4_SHORT)
  ------------------
  |  |  294|  2.49k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (589:9): [True: 2.49k, False: 0]
  ------------------
  590|  2.49k|					tapdu.cse--;
  591|       |				/* XXX: the chunk size must be adjusted when
  592|       |				 *      secure messaging is used */
  593|  2.49k|				plen          = max_send_size;
  594|  2.49k|				tapdu.cla    |= 0x10;
  595|       |				/* the intermediate APDU don't expect response data */
  596|  2.49k|				tapdu.le      = 0;
  597|  2.49k|				tapdu.resplen = 0;
  598|  2.49k|				tapdu.resp    = NULL;
  599|  2.49k|			} else {
  600|    743|				plen = len;
  601|    743|				last = 1;
  602|    743|			}
  603|  3.23k|			tapdu.data    = buf;
  604|  3.23k|			tapdu.datalen = tapdu.lc = plen;
  605|       |
  606|  3.23k|			r = sc_check_apdu(card, &tapdu);
  607|  3.23k|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  3.23k|#define SC_SUCCESS				0
  ------------------
  |  Branch (607:8): [True: 0, False: 3.23k]
  ------------------
  608|      0|				sc_log(card->ctx, "inconsistent APDU while chaining");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  609|      0|				break;
  610|      0|			}
  611|       |
  612|  3.23k|			r = sc_transmit(card, &tapdu);
  613|  3.23k|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|  3.23k|#define SC_SUCCESS				0
  ------------------
  |  Branch (613:8): [True: 24, False: 3.20k]
  ------------------
  614|     24|				break;
  615|  3.20k|			if (last != 0) {
  ------------------
  |  Branch (615:8): [True: 720, False: 2.48k]
  ------------------
  616|       |				/* in case of the last APDU set the SW1
  617|       |				 * and SW2 bytes in the original APDU */
  618|    720|				apdu->sw1 = tapdu.sw1;
  619|    720|				apdu->sw2 = tapdu.sw2;
  620|    720|				apdu->resplen = tapdu.resplen;
  621|  2.48k|			} else {
  622|       |				/* otherwise check the status bytes */
  623|  2.48k|				r = sc_check_sw(card, tapdu.sw1, tapdu.sw2);
  624|  2.48k|				if (r != SC_SUCCESS)
  ------------------
  |  |   28|  2.48k|#define SC_SUCCESS				0
  ------------------
  |  Branch (624:9): [True: 344, False: 2.14k]
  ------------------
  625|    344|					break;
  626|  2.48k|			}
  627|  2.86k|			len -= plen;
  628|  2.86k|			buf += plen;
  629|  2.86k|		}
  630|   603k|	} else {
  631|       |		/* transmit single APDU */
  632|   603k|		r = sc_transmit(card, apdu);
  633|   603k|	}
  634|       |
  635|   604k|	if (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   37|  1.20M|#define SC_ERROR_CARD_RESET			-1106
  ------------------
              	if (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   46|   604k|#define SC_ERROR_READER_REATTACHED		-1115
  ------------------
  |  Branch (635:6): [True: 0, False: 604k]
  |  Branch (635:34): [True: 0, False: 604k]
  ------------------
  636|       |		/* give card driver a chance to react on resets */
  637|      0|		if (card->ops->card_reader_lock_obtained)
  ------------------
  |  Branch (637:7): [True: 0, False: 0]
  ------------------
  638|      0|			card->ops->card_reader_lock_obtained(card, 1);
  639|      0|	}
  640|       |
  641|       |	/* all done => release lock */
  642|   604k|	if (sc_unlock(card) != SC_SUCCESS)
  ------------------
  |  |   28|   604k|#define SC_SUCCESS				0
  ------------------
  |  Branch (642:6): [True: 0, False: 604k]
  ------------------
  643|      0|		sc_log(card->ctx, "sc_unlock failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  644|       |
  645|   604k|	return r;
  646|   604k|}
sc_bytes2apdu:
  651|    105|{
  652|    105|	const unsigned char *p;
  653|    105|	size_t len0;
  654|       |
  655|    105|	if (!buf || !apdu)
  ------------------
  |  Branch (655:6): [True: 0, False: 105]
  |  Branch (655:14): [True: 0, False: 105]
  ------------------
  656|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  657|       |
  658|    105|	len0 = len;
  659|    105|	if (len < 4) {
  ------------------
  |  Branch (659:6): [True: 0, False: 105]
  ------------------
  660|      0|		sc_log(ctx, "APDU too short (must be at least 4 bytes)");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  661|      0|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  662|      0|	}
  663|       |
  664|    105|	memset(apdu, 0, sizeof *apdu);
  665|    105|	p = buf;
  666|    105|	apdu->cla = *p++;
  667|    105|	apdu->ins = *p++;
  668|    105|	apdu->p1 = *p++;
  669|    105|	apdu->p2 = *p++;
  670|    105|	len -= 4;
  671|       |
  672|    105|	if (!len) {
  ------------------
  |  Branch (672:6): [True: 0, False: 105]
  ------------------
  673|      0|		apdu->cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  674|      0|		sc_log(ctx, "CASE_1 APDU: %zu bytes:\tins=%02x p1=%02x p2=%02x lc=%04zx le=%04zx",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  675|      0|				len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le);
  676|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  677|      0|	}
  678|       |
  679|    105|	if (*p == 0 && len >= 3) {
  ------------------
  |  Branch (679:6): [True: 0, False: 105]
  |  Branch (679:17): [True: 0, False: 0]
  ------------------
  680|       |		/* ...must be an extended APDU */
  681|      0|		p++;
  682|      0|		if (len == 3) {
  ------------------
  |  Branch (682:7): [True: 0, False: 0]
  ------------------
  683|      0|			apdu->le = (*p++)<<8;
  684|      0|			apdu->le += *p++;
  685|      0|			if (apdu->le == 0)
  ------------------
  |  Branch (685:8): [True: 0, False: 0]
  ------------------
  686|      0|				apdu->le = 0xffff+1;
  687|      0|			len -= 3;
  688|      0|			apdu->cse = SC_APDU_CASE_2_EXT;
  ------------------
  |  |  297|      0|#define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  |  |  ------------------
  |  |               #define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  689|      0|		}
  690|      0|		else {
  691|       |			/* len > 3 */
  692|      0|			apdu->lc = (*p++)<<8;
  693|      0|			apdu->lc += *p++;
  694|      0|			len -= 3;
  695|      0|			if (len < apdu->lc) {
  ------------------
  |  Branch (695:8): [True: 0, False: 0]
  ------------------
  696|      0|				sc_log(ctx, "APDU too short (need %zu more bytes)", apdu->lc - len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  697|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  698|      0|			}
  699|      0|			apdu->data = p;
  700|      0|			apdu->datalen = apdu->lc;
  701|      0|			len -= apdu->lc;
  702|      0|			p += apdu->lc;
  703|      0|			if (!len) {
  ------------------
  |  Branch (703:8): [True: 0, False: 0]
  ------------------
  704|      0|				apdu->cse = SC_APDU_CASE_3_EXT;
  ------------------
  |  |  298|      0|#define SC_APDU_CASE_3_EXT		SC_APDU_CASE_3_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  |  |  ------------------
  |  |               #define SC_APDU_CASE_3_EXT		SC_APDU_CASE_3_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  705|      0|			}
  706|      0|			else {
  707|       |				/* at this point the apdu has a Lc, so Le is on 2 bytes */
  708|      0|				if (len < 2) {
  ------------------
  |  Branch (708:9): [True: 0, False: 0]
  ------------------
  709|      0|					sc_debug(ctx, SC_LOG_DEBUG_VERBOSE, "APDU too short (need 2 more bytes)\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__
  |  |  ------------------
  ------------------
  710|      0|					return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  711|      0|				}
  712|      0|				apdu->le = (*p++)<<8;
  713|      0|				apdu->le += *p++;
  714|      0|				if (apdu->le == 0)
  ------------------
  |  Branch (714:9): [True: 0, False: 0]
  ------------------
  715|      0|					apdu->le = 0xffff+1;
  716|      0|				len -= 2;
  717|      0|				apdu->cse = SC_APDU_CASE_4_EXT;
  ------------------
  |  |  299|      0|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  718|      0|			}
  719|      0|		}
  720|      0|	}
  721|    105|	else {
  722|       |		/* ...must be a short APDU */
  723|    105|		if (len == 1) {
  ------------------
  |  Branch (723:7): [True: 105, False: 0]
  ------------------
  724|    105|			apdu->le = *p++;
  725|    105|			if (apdu->le == 0)
  ------------------
  |  Branch (725:8): [True: 0, False: 105]
  ------------------
  726|      0|				apdu->le = 0xff+1;
  727|    105|			len--;
  728|    105|			apdu->cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|    105|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  729|    105|		}
  730|      0|		else {
  731|      0|			apdu->lc = *p++;
  732|      0|			len--;
  733|      0|			if (len < apdu->lc) {
  ------------------
  |  Branch (733:8): [True: 0, False: 0]
  ------------------
  734|      0|				sc_log(ctx, "APDU too short (need %zu more bytes)", apdu->lc - len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  735|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  736|      0|			}
  737|      0|			apdu->data = p;
  738|      0|			apdu->datalen = apdu->lc;
  739|      0|			len -= apdu->lc;
  740|      0|			p += apdu->lc;
  741|      0|			if (!len) {
  ------------------
  |  Branch (741:8): [True: 0, False: 0]
  ------------------
  742|      0|				apdu->cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  743|      0|			}
  744|      0|			else {
  745|      0|				apdu->le = *p++;
  746|      0|				if (apdu->le == 0)
  ------------------
  |  Branch (746:9): [True: 0, False: 0]
  ------------------
  747|      0|					apdu->le = 0xff+1;
  748|      0|				len--;
  749|      0|				apdu->cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  750|      0|			}
  751|      0|		}
  752|    105|	}
  753|    105|	if (len) {
  ------------------
  |  Branch (753:6): [True: 0, False: 105]
  ------------------
  754|      0|		sc_log(ctx, "APDU too long (%lu bytes extra)",(unsigned long) len);
  ------------------
  |  |   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|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  756|      0|	}
  757|       |
  758|    105|	sc_log(ctx, "Case %d %s APDU, %zu bytes:\tins=%02x p1=%02x p2=%02x lc=%04zx le=%04zx",
  ------------------
  |  |   71|    105|#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)
  |  |  ------------------
  |  |  |  |  759|    210|			apdu->cse & SC_APDU_SHORT_MASK, (apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
  |  |  |  |  ------------------
  |  |  |  |  |  |  295|    105|#define SC_APDU_SHORT_MASK		0x0f
  |  |  |  |  ------------------
  |  |  |  |               			apdu->cse & SC_APDU_SHORT_MASK, (apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
  |  |  |  |  ------------------
  |  |  |  |  |  |  296|    105|#define SC_APDU_EXT			0x10
  |  |  |  |  ------------------
  |  |  |  |  760|    210|			len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le);
  |  |  ------------------
  ------------------
  759|    105|			apdu->cse & SC_APDU_SHORT_MASK, (apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
  760|    105|			len0, apdu->ins, apdu->p1, apdu->p2, apdu->lc, apdu->le);
  761|       |
  762|    105|	return SC_SUCCESS;
  ------------------
  |  |   28|    105|#define SC_SUCCESS				0
  ------------------
  763|    105|}
apdu.c:sc_detect_apdu_cse:
  340|   605k|{
  341|   605k|	if (apdu->cse == SC_APDU_CASE_2 || apdu->cse == SC_APDU_CASE_3 ||
  ------------------
  |  |  301|  1.21M|#define SC_APDU_CASE_2			0x22
  ------------------
              	if (apdu->cse == SC_APDU_CASE_2 || apdu->cse == SC_APDU_CASE_3 ||
  ------------------
  |  |  302|  1.02M|#define SC_APDU_CASE_3			0x23
  ------------------
  |  Branch (341:6): [True: 190k, False: 414k]
  |  Branch (341:37): [True: 9, False: 414k]
  ------------------
  342|   414k|	    apdu->cse == SC_APDU_CASE_4) {
  ------------------
  |  |  303|   414k|#define SC_APDU_CASE_4			0x24
  ------------------
  |  Branch (342:6): [True: 8.59k, False: 406k]
  ------------------
  343|   199k|		int btype = apdu->cse & SC_APDU_SHORT_MASK;
  ------------------
  |  |  295|   199k|#define SC_APDU_SHORT_MASK		0x0f
  ------------------
  344|       |		/* if either Lc or Le is bigger than the maximum for
  345|       |		 * short APDUs and the card supports extended APDUs
  346|       |		 * use extended APDUs (unless Lc is greater than
  347|       |		 * 255 and command chaining is activated) */
  348|   199k|		if ((apdu->le > 256 || (apdu->lc > 255 && (apdu->flags & SC_APDU_FLAGS_CHAINING) == 0)) &&
  ------------------
  |  |  306|     20|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  |  Branch (348:8): [True: 1.42k, False: 197k]
  |  Branch (348:27): [True: 20, False: 197k]
  |  Branch (348:45): [True: 0, False: 20]
  ------------------
  349|  1.42k|		    (card->caps & SC_CARD_CAP_APDU_EXT) != 0)
  ------------------
  |  |  547|  1.42k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (349:7): [True: 1.39k, False: 22]
  ------------------
  350|  1.39k|			btype |= SC_APDU_EXT;
  ------------------
  |  |  296|  1.39k|#define SC_APDU_EXT			0x10
  ------------------
  351|   199k|		apdu->cse = btype;
  352|   199k|	}
  353|   605k|}
apdu.c:sc_transmit:
  507|   606k|{
  508|   606k|	struct sc_context *ctx  = card->ctx;
  509|   606k|	size_t       olen  = apdu->resplen;
  510|   606k|	int          r;
  511|       |
  512|   606k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|   606k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   606k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   606k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   606k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 606k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  513|       |
  514|   606k|	r = sc_single_transmit(card, apdu);
  515|   606k|	LOG_TEST_RET(ctx, r, "transmit APDU failed");
  ------------------
  |  |  174|   606k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   606k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   606k|	int _ret = (r); \
  |  |  |  |  168|   606k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 601, False: 606k]
  |  |  |  |  ------------------
  |  |  |  |  169|    601|		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|    601|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    601|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    601|		return _ret; \
  |  |  |  |  172|    601|	} \
  |  |  |  |  173|   606k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 606k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  516|       |
  517|       |	/* ok, the APDU was successfully transmitted. Now we have two special cases:
  518|       |	 * 1. the card returned 0x6Cxx: in this case APDU will be re-transmitted with Le set to SW2
  519|       |	 * (possible only if response buffer size is larger than new Le = SW2)
  520|       |	 */
  521|   606k|	if (apdu->sw1 == 0x6C && (apdu->flags & SC_APDU_FLAGS_NO_RETRY_WL) == 0) {
  ------------------
  |  |  312|  1.86k|#define SC_APDU_FLAGS_NO_RETRY_WL	0x00000004UL
  ------------------
  |  Branch (521:6): [True: 1.86k, False: 604k]
  |  Branch (521:27): [True: 1.72k, False: 144]
  ------------------
  522|  1.72k|		r = sc_set_le_and_transmit(card, apdu, olen);
  523|  1.72k|		LOG_TEST_RET(ctx, r, "cannot re-transmit APDU ");
  ------------------
  |  |  174|  1.72k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.72k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.72k|	int _ret = (r); \
  |  |  |  |  168|  1.72k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.20k, False: 519]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.20k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.20k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.20k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.20k|		return _ret; \
  |  |  |  |  172|  1.20k|	} \
  |  |  |  |  173|  1.72k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 519]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  524|  1.72k|	}
  525|       |
  526|       |	/* 2. the card returned 0x61xx: more data can be read from the card
  527|       |	 *    using the GET RESPONSE command (mostly used in the T0 protocol).
  528|       |	 *    Unless the SC_APDU_FLAGS_NO_GET_RESP is set we try to read as
  529|       |	 *    much data as possible using GET RESPONSE.
  530|       |	 */
  531|   605k|	if (apdu->sw1 == 0x61 && (apdu->flags & SC_APDU_FLAGS_NO_GET_RESP) == 0) {
  ------------------
  |  |  308|   125k|#define SC_APDU_FLAGS_NO_GET_RESP	0x00000002UL
  ------------------
  |  Branch (531:6): [True: 125k, False: 479k]
  |  Branch (531:27): [True: 61.0k, False: 64.8k]
  ------------------
  532|  61.0k|		r = sc_get_response(card, apdu, olen);
  533|  61.0k|		LOG_TEST_RET(ctx, r, "cannot get all data with 'GET RESPONSE'");
  ------------------
  |  |  174|  61.0k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  61.0k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  61.0k|	int _ret = (r); \
  |  |  |  |  168|  61.0k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7.07k, False: 53.9k]
  |  |  |  |  ------------------
  |  |  |  |  169|  7.07k|		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|  7.07k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  7.07k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  7.07k|		return _ret; \
  |  |  |  |  172|  7.07k|	} \
  |  |  |  |  173|  61.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 53.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  534|  61.0k|	}
  535|       |
  536|   597k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|   597k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   597k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   597k|	int _ret = r; \
  |  |  |  |  155|   597k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 597k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   597k|		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: 597k]
  |  |  |  |  ------------------
  |  |  |  |  157|   597k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   597k|	} 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|   597k|	return _ret; \
  |  |  |  |  163|   597k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  537|   597k|}
apdu.c:sc_single_transmit:
  358|   607k|{
  359|   607k|	struct sc_context *ctx  = card->ctx;
  360|   607k|	int rv;
  361|       |
  362|   607k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|   607k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   607k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   607k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   607k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 607k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|   607k|	if (card->reader->ops->transmit == NULL)
  ------------------
  |  Branch (363:6): [True: 0, False: 607k]
  ------------------
  364|   607k|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "cannot transmit APDU");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  365|       |
  366|   607k|	sc_log(ctx, "CLA:%X, INS:%X, P1:%X, P2:%X, data(%zu) %p",
  ------------------
  |  |   71|   607k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  367|   607k|			apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen, apdu->data);
  368|   607k|#ifdef ENABLE_SM
  369|   607k|	if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT
  ------------------
  |  |   47|  1.21M|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (369:6): [True: 7.71k, False: 599k]
  ------------------
  370|  7.71k|		   	&& (apdu->flags & SC_APDU_FLAGS_NO_SM) == 0) {
  ------------------
  |  |  314|  7.71k|#define SC_APDU_FLAGS_NO_SM		0x00000008UL
  ------------------
  |  Branch (370:10): [True: 3.85k, False: 3.85k]
  ------------------
  371|  3.85k|		LOG_FUNC_RETURN(ctx, sc_sm_single_transmit(card, apdu));
  ------------------
  |  |  164|  3.85k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.85k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.85k|	int _ret = r; \
  |  |  |  |  155|  3.85k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.85k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.85k|		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|    604|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 604, False: 3.25k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.85k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.85k|	} 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|  3.85k|	return _ret; \
  |  |  |  |  163|  3.85k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  372|  3.85k|	}
  373|   603k|#endif
  374|       |
  375|       |	/* send APDU to the reader driver */
  376|   603k|	rv = card->reader->ops->transmit(card->reader, apdu);
  377|   603k|	LOG_TEST_RET(ctx, rv, "unable to transmit APDU");
  ------------------
  |  |  174|   603k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   603k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   603k|	int _ret = (r); \
  |  |  |  |  168|   603k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 603k]
  |  |  |  |  ------------------
  |  |  |  |  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|   603k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 603k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  378|       |
  379|   603k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|   603k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   603k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   603k|	int _ret = r; \
  |  |  |  |  155|   603k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 603k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   603k|		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: 603k]
  |  |  |  |  ------------------
  |  |  |  |  157|   603k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   603k|	} 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|   603k|	return _ret; \
  |  |  |  |  163|   603k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  380|   603k|}
apdu.c:sc_set_le_and_transmit:
  385|  1.72k|{
  386|  1.72k|	struct sc_context *ctx  = card->ctx;
  387|  1.72k|	size_t nlen = apdu->sw2 ? (size_t)apdu->sw2 : 256;
  ------------------
  |  Branch (387:16): [True: 1.01k, False: 715]
  ------------------
  388|  1.72k|	int rv;
  389|       |
  390|  1.72k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.72k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.72k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.72k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.72k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.72k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  391|       |	/* we cannot re-transmit the APDU with the demanded Le value
  392|       |	 * as the buffer is too small => error */
  393|  1.72k|	if (olen < nlen)
  ------------------
  |  Branch (393:6): [True: 1.20k, False: 522]
  ------------------
  394|  1.72k|		LOG_TEST_RET(ctx, SC_ERROR_WRONG_LENGTH, "wrong length: required length exceeds resplen");
  ------------------
  |  |  174|  1.20k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.20k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.20k|	int _ret = (r); \
  |  |  |  |  168|  1.20k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.20k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.20k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.20k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.20k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.20k|		return _ret; \
  |  |  |  |  172|  1.20k|	} \
  |  |  |  |  173|  1.20k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  395|       |
  396|       |	/* don't try again if it doesn't work this time */
  397|    522|	apdu->flags  |= SC_APDU_FLAGS_NO_RETRY_WL;
  ------------------
  |  |  312|    522|#define SC_APDU_FLAGS_NO_RETRY_WL	0x00000004UL
  ------------------
  398|       |	/* set the new expected length */
  399|    522|	apdu->resplen = olen;
  400|    522|	apdu->le      = nlen;
  401|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  402|       |	/* Belpic V1 applets have a problem: if the card sends a 6C XX (only XX bytes available),
  403|       |	 * and we resend the command too soon (i.e. the reader is too fast), the card doesn't respond.
  404|       |	 * So we build in a delay. */
  405|       |	if (card->type == SC_CARD_TYPE_BELPIC_EID)
  406|       |		msleep(40);
  407|       |#endif
  408|       |
  409|       |	/* re-transmit the APDU with new Le length */
  410|    522|	rv = sc_single_transmit(card, apdu);
  411|    522|	LOG_TEST_RET(ctx, rv, "cannot re-transmit APDU");
  ------------------
  |  |  174|    522|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    522|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    522|	int _ret = (r); \
  |  |  |  |  168|    522|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 519]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|    522|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 519]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|       |
  413|    519|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    519|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    519|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    519|	int _ret = r; \
  |  |  |  |  155|    519|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 519, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    519|		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: 519]
  |  |  |  |  ------------------
  |  |  |  |  157|    519|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    519|	} 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|    519|	return _ret; \
  |  |  |  |  163|    519|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  414|    519|}
apdu.c:sc_get_response:
  419|  61.0k|{
  420|  61.0k|	struct sc_context *ctx  = card->ctx;
  421|  61.0k|	size_t le, minlen, buflen;
  422|  61.0k|	unsigned char *buf;
  423|  61.0k|	int rv;
  424|       |
  425|  61.0k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  61.0k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  61.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  61.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  61.0k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 61.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|  61.0k|	if (apdu->le == 0) {
  ------------------
  |  Branch (426:6): [True: 11.8k, False: 49.2k]
  ------------------
  427|       |		/* no data is requested => change return value to 0x9000 and ignore the remaining data */
  428|  11.8k|		apdu->sw1 = 0x90;
  429|  11.8k|		apdu->sw2 = 0x00;
  430|  11.8k|		return SC_SUCCESS;
  ------------------
  |  |   28|  11.8k|#define SC_SUCCESS				0
  ------------------
  431|  11.8k|	}
  432|       |
  433|       |	/* this should _never_ happen */
  434|  49.2k|	if (!card->ops->get_response)
  ------------------
  |  Branch (434:6): [True: 118, False: 49.1k]
  ------------------
  435|  49.2k|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "no GET RESPONSE command");
  ------------------
  |  |  174|    118|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    118|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    118|	int _ret = (r); \
  |  |  |  |  168|    118|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 118, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    118|		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|    118|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    118|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    118|		return _ret; \
  |  |  |  |  172|    118|	} \
  |  |  |  |  173|    118|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|       |
  437|       |	/* call GET RESPONSE until we have read all data requested or until the card returns 0x9000,
  438|       |	 * whatever happens first. */
  439|       |
  440|       |	/* if there are already data in response append a new data to the end of the buffer */
  441|  49.1k|	buf = apdu->resp + apdu->resplen;
  442|       |
  443|       |	/* read as much data as fits in apdu->resp (i.e. min(apdu->resplen, amount of data available)). */
  444|  49.1k|	buflen = olen - apdu->resplen;
  445|       |
  446|       |	/* 0x6100 means at least 256 more bytes to read */
  447|  49.1k|	le = apdu->sw2 != 0 ? (size_t)apdu->sw2 : 256;
  ------------------
  |  Branch (447:7): [True: 43.5k, False: 5.59k]
  ------------------
  448|       |	/* we try to read at least as much as bytes as promised in the response bytes */
  449|  49.1k|	minlen = le;
  450|       |
  451|   113k|	do {
  452|   113k|		unsigned char resp[256];
  453|   113k|		size_t resp_len = le;
  454|       |
  455|       |		/* we have all the data the caller requested even if the card has more data */
  456|   113k|		if (buflen == 0)
  ------------------
  |  Branch (456:7): [True: 12.6k, False: 100k]
  ------------------
  457|  12.6k|			break;
  458|       |
  459|       |		/* call GET RESPONSE to get more date from the card;
  460|       |		 * note: GET RESPONSE returns the left amount of data (== SW2) */
  461|   100k|		memset(resp, 0, sizeof(resp));
  462|   100k|		rv = card->ops->get_response(card, &resp_len, resp);
  463|   100k|		if (rv < 0)   {
  ------------------
  |  Branch (463:7): [True: 6.96k, False: 93.8k]
  ------------------
  464|  6.96k|#ifdef ENABLE_SM
  465|  6.96k|			if (resp_len)   {
  ------------------
  |  Branch (465:8): [True: 3.99k, False: 2.96k]
  ------------------
  466|  3.99k|				sc_log_hex(ctx, "SM response data", resp, resp_len);
  ------------------
  |  |  129|  3.99k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  3.99k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|  3.99k|				sc_sm_update_apdu_response(card, resp, resp_len, rv, apdu);
  468|  3.99k|			}
  469|  6.96k|#endif
  470|  6.96k|			LOG_TEST_RET(ctx, rv, "GET RESPONSE error");
  ------------------
  |  |  174|  6.96k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  6.96k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  6.96k|	int _ret = (r); \
  |  |  |  |  168|  6.96k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6.96k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|  6.96k|		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|  6.96k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  6.96k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  6.96k|		return _ret; \
  |  |  |  |  172|  6.96k|	} \
  |  |  |  |  173|  6.96k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  471|  6.96k|		}
  472|       |
  473|  93.8k|		le = resp_len;
  474|       |		/* copy as much as will fit in requested buffer */
  475|  93.8k|		if (buflen < le)
  ------------------
  |  Branch (475:7): [True: 16.5k, False: 77.3k]
  ------------------
  476|  16.5k|			le = buflen;
  477|       |
  478|  93.8k|		memcpy(buf, resp, le);
  479|  93.8k|		buf    += le;
  480|  93.8k|		buflen -= le;
  481|       |
  482|  93.8k|		minlen -= le;
  483|  93.8k|		if (rv != 0)
  ------------------
  |  Branch (483:7): [True: 64.3k, False: 29.5k]
  ------------------
  484|  64.3k|			le = minlen = (size_t)rv;
  485|  29.5k|		else
  486|       |			/* if the card has returned 0x9000 but we still expect data ask for more
  487|       |			 * until we have read enough bytes */
  488|  29.5k|			le = minlen;
  489|  93.8k|	} while (rv != 0 && minlen != 0);
  ------------------
  |  Branch (489:11): [True: 64.3k, False: 29.5k]
  |  Branch (489:22): [True: 64.3k, False: 0]
  ------------------
  490|       |
  491|       |	/* we've read all data, let's return 0x9000 */
  492|  42.1k|	apdu->resplen = buf - apdu->resp;
  493|  42.1k|	apdu->sw1 = 0x90;
  494|  42.1k|	apdu->sw2 = 0x00;
  495|       |
  496|  42.1k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  42.1k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  42.1k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  42.1k|	int _ret = r; \
  |  |  |  |  155|  42.1k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 42.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  42.1k|		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: 42.1k]
  |  |  |  |  ------------------
  |  |  |  |  157|  42.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  42.1k|	} 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|  42.1k|	return _ret; \
  |  |  |  |  163|  42.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  497|  42.1k|}

sc_asn1_read_tag:
   63|   317k|{
   64|   317k|	const u8 *p = *buf;
   65|   317k|	size_t left = buflen, len;
   66|   317k|	unsigned int cla, tag, i;
   67|       |
   68|   317k|	*buf = NULL;
   69|       |
   70|   317k|	if (left == 0 || !p || buflen == 0)
  ------------------
  |  Branch (70:6): [True: 11.1k, False: 306k]
  |  Branch (70:19): [True: 0, False: 306k]
  |  Branch (70:25): [True: 0, False: 306k]
  ------------------
   71|  11.1k|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  11.1k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   72|   306k|	if (*p == 0xff || *p == 0) {
  ------------------
  |  Branch (72:6): [True: 1.65k, False: 305k]
  |  Branch (72:20): [True: 18.8k, False: 286k]
  ------------------
   73|       |		/* end of data reached */
   74|  20.4k|		*taglen = 0;
   75|  20.4k|		*tag_out = SC_ASN1_TAG_EOC;
  ------------------
  |  |  194|  20.4k|#define SC_ASN1_TAG_EOC			0
  ------------------
   76|  20.4k|		return SC_SUCCESS;
  ------------------
  |  |   28|  20.4k|#define SC_SUCCESS				0
  ------------------
   77|  20.4k|	}
   78|       |
   79|       |	/* parse tag byte(s)
   80|       |	 * Resulted tag is presented by integer that has not to be
   81|       |	 * confused with the 'tag number' part of ASN.1 tag.
   82|       |	 */
   83|   286k|	cla = (*p & SC_ASN1_TAG_CLASS) | (*p & SC_ASN1_TAG_CONSTRUCTED);
  ------------------
  |  |  184|   286k|#define SC_ASN1_TAG_CLASS		0xC0
  ------------------
              	cla = (*p & SC_ASN1_TAG_CLASS) | (*p & SC_ASN1_TAG_CONSTRUCTED);
  ------------------
  |  |  190|   286k|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
   84|   286k|	tag = *p & SC_ASN1_TAG_PRIMITIVE;
  ------------------
  |  |  191|   286k|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
   85|   286k|	p++;
   86|   286k|	left--;
   87|   286k|	if (tag == SC_ASN1_TAG_PRIMITIVE) {
  ------------------
  |  |  191|   286k|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
  |  Branch (87:6): [True: 3.14k, False: 283k]
  ------------------
   88|       |		/* high tag number */
   89|  3.14k|		size_t n = SC_ASN1_TAGNUM_SIZE - 1;
  ------------------
  |  |  145|  3.14k|#define SC_ASN1_TAGNUM_SIZE		3
  ------------------
   90|       |		/* search the last tag octet */
   91|  4.68k|		do {
   92|  4.68k|			if (left == 0 || n == 0)
  ------------------
  |  Branch (92:8): [True: 205, False: 4.48k]
  |  Branch (92:21): [True: 176, False: 4.30k]
  ------------------
   93|       |				/* either an invalid tag or it doesn't fit in
   94|       |				 * unsigned int */
   95|    381|				return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    381|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   96|  4.30k|			tag <<= 8;
   97|  4.30k|			tag |= *p;
   98|  4.30k|			p++;
   99|  4.30k|			left--;
  100|  4.30k|			n--;
  101|  4.30k|		} while (tag & 0x80);
  ------------------
  |  Branch (101:12): [True: 1.53k, False: 2.76k]
  ------------------
  102|  3.14k|	}
  103|       |
  104|       |	/* parse length byte(s) */
  105|   285k|	if (left == 0)
  ------------------
  |  Branch (105:6): [True: 1.75k, False: 284k]
  ------------------
  106|  1.75k|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  1.75k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  107|   284k|	len = *p;
  108|   284k|	p++;
  109|   284k|	left--;
  110|   284k|	if (len & 0x80) {
  ------------------
  |  Branch (110:6): [True: 44.9k, False: 239k]
  ------------------
  111|  44.9k|		len &= 0x7f;
  112|  44.9k|		unsigned int a = 0;
  113|  44.9k|		if (len > sizeof a || len > left)
  ------------------
  |  Branch (113:7): [True: 9.17k, False: 35.7k]
  |  Branch (113:25): [True: 247, False: 35.5k]
  ------------------
  114|  9.42k|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  9.42k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  115|  69.0k|		for (i = 0; i < len; i++) {
  ------------------
  |  Branch (115:15): [True: 33.5k, False: 35.5k]
  ------------------
  116|  33.5k|			a <<= 8;
  117|  33.5k|			a |= *p;
  118|  33.5k|			p++;
  119|  33.5k|			left--;
  120|  33.5k|		}
  121|  35.5k|		len = a;
  122|  35.5k|	}
  123|       |
  124|   274k|	*cla_out = cla;
  125|   274k|	*tag_out = tag;
  126|   274k|	*taglen = len;
  127|   274k|	*buf = p;
  128|       |
  129|   274k|	if (len > left)
  ------------------
  |  Branch (129:6): [True: 14.8k, False: 259k]
  ------------------
  130|  14.8k|		return SC_ERROR_ASN1_END_OF_CONTENTS;
  ------------------
  |  |   84|  14.8k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  131|       |
  132|   259k|	return SC_SUCCESS;
  ------------------
  |  |   28|   259k|#define SC_SUCCESS				0
  ------------------
  133|   274k|}
sc_format_asn1_entry:
  137|   236k|{
  138|   236k|	entry->parm = parm;
  139|   236k|	entry->arg  = arg;
  140|   236k|	if (set_present)
  ------------------
  |  Branch (140:6): [True: 35.4k, False: 201k]
  ------------------
  141|  35.4k|		entry->flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|  35.4k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  142|   236k|}
sc_copy_asn1_entry:
  146|  86.5k|{
  147|   337k|	while (src->name != NULL) {
  ------------------
  |  Branch (147:9): [True: 250k, False: 86.5k]
  ------------------
  148|   250k|		*dest = *src;
  149|   250k|		dest++;
  150|   250k|		src++;
  151|   250k|	}
  152|       |	dest->name = NULL;
  153|  86.5k|}
sc_asn1_find_tag:
  481|  54.8k|{
  482|  54.8k|	size_t left = buflen, taglen;
  483|  54.8k|	const u8 *p = buf;
  484|       |
  485|  54.8k|	*taglen_in = 0;
  486|   124k|	while (left >= 2) {
  ------------------
  |  Branch (486:9): [True: 115k, False: 9.05k]
  ------------------
  487|   115k|		unsigned int cla = 0, tag, mask = 0xff00;
  488|       |
  489|   115k|		buf = p;
  490|       |		/* read a tag */
  491|   115k|		if (sc_asn1_read_tag(&p, left, &cla, &tag, &taglen) != SC_SUCCESS
  ------------------
  |  |   28|   230k|#define SC_SUCCESS				0
  ------------------
  |  Branch (491:7): [True: 11.6k, False: 103k]
  ------------------
  492|   103k|				|| p == NULL)
  ------------------
  |  Branch (492:8): [True: 8.60k, False: 94.9k]
  ------------------
  493|  20.2k|			return NULL;
  494|       |
  495|  94.9k|		left -= (p - buf);
  496|       |		/* we need to shift the class byte to the leftmost
  497|       |		 * byte of the tag */
  498|  96.4k|		while ((tag & mask) != 0) {
  ------------------
  |  Branch (498:10): [True: 1.50k, False: 94.9k]
  ------------------
  499|  1.50k|			cla  <<= 8;
  500|  1.50k|			mask <<= 8;
  501|  1.50k|		}
  502|       |		/* compare the read tag with the given tag */
  503|  94.9k|		if ((tag | cla) == tag_in) {
  ------------------
  |  Branch (503:7): [True: 25.5k, False: 69.3k]
  ------------------
  504|       |			/* we have a match => return length and value part */
  505|  25.5k|			if (taglen > left)
  ------------------
  |  Branch (505:8): [True: 0, False: 25.5k]
  ------------------
  506|      0|				return NULL;
  507|  25.5k|			*taglen_in = taglen;
  508|  25.5k|			return p;
  509|  25.5k|		}
  510|       |		/* otherwise continue reading tags */
  511|  69.3k|		left -= taglen;
  512|  69.3k|		p += taglen;
  513|  69.3k|	}
  514|  9.05k|	return NULL;
  515|  54.8k|}
sc_asn1_skip_tag:
  519|   133k|{
  520|   133k|	const u8 *p = *buf;
  521|   133k|	size_t len = *buflen, taglen;
  522|   133k|	unsigned int cla = 0, tag;
  523|       |
  524|   133k|	if (sc_asn1_read_tag((const u8 **) &p, len, &cla, &tag, &taglen) != SC_SUCCESS
  ------------------
  |  |   28|   266k|#define SC_SUCCESS				0
  ------------------
  |  Branch (524:6): [True: 18.7k, False: 114k]
  ------------------
  525|   114k|			|| p == NULL)
  ------------------
  |  Branch (525:7): [True: 8.38k, False: 105k]
  ------------------
  526|  27.1k|		return NULL;
  527|   105k|	switch (cla & 0xC0) {
  ------------------
  |  Branch (527:10): [True: 105k, False: 0]
  ------------------
  528|  69.9k|	case SC_ASN1_TAG_UNIVERSAL:
  ------------------
  |  |  185|  69.9k|#define SC_ASN1_TAG_UNIVERSAL		0x00
  ------------------
  |  Branch (528:2): [True: 69.9k, False: 35.9k]
  ------------------
  529|  69.9k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_UNI)
  ------------------
  |  |  136|  69.9k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_UNI)
  ------------------
  |  |  137|  69.9k|#define SC_ASN1_UNI			0x00000000 /* Universal */
  ------------------
  |  Branch (529:7): [True: 2.19k, False: 67.7k]
  ------------------
  530|  2.19k|			return NULL;
  531|  67.7k|		break;
  532|  67.7k|	case SC_ASN1_TAG_APPLICATION:
  ------------------
  |  |  186|  22.2k|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
  |  Branch (532:2): [True: 22.2k, False: 83.7k]
  ------------------
  533|  22.2k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_APP)
  ------------------
  |  |  136|  22.2k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_APP)
  ------------------
  |  |  138|  22.2k|#define SC_ASN1_APP			0x40000000 /* Application */
  ------------------
  |  Branch (533:7): [True: 4.57k, False: 17.6k]
  ------------------
  534|  4.57k|			return NULL;
  535|  17.6k|		break;
  536|  17.6k|	case SC_ASN1_TAG_CONTEXT:
  ------------------
  |  |  187|  12.7k|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
  |  Branch (536:2): [True: 12.7k, False: 93.2k]
  ------------------
  537|  12.7k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_CTX)
  ------------------
  |  |  136|  12.7k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_CTX)
  ------------------
  |  |  139|  12.7k|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
  |  Branch (537:7): [True: 1.84k, False: 10.8k]
  ------------------
  538|  1.84k|			return NULL;
  539|  10.8k|		break;
  540|  10.8k|	case SC_ASN1_TAG_PRIVATE:
  ------------------
  |  |  188|  1.03k|#define SC_ASN1_TAG_PRIVATE		0xC0
  ------------------
  |  Branch (540:2): [True: 1.03k, False: 104k]
  ------------------
  541|  1.03k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_PRV)
  ------------------
  |  |  136|  1.03k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_PRV)
  ------------------
  |  |  140|  1.03k|#define SC_ASN1_PRV			0xC0000000 /* Private */
  ------------------
  |  Branch (541:7): [True: 1.03k, False: 0]
  ------------------
  542|  1.03k|			return NULL;
  543|      0|		break;
  544|   105k|	}
  545|  96.3k|	if (cla & SC_ASN1_TAG_CONSTRUCTED) {
  ------------------
  |  |  190|  96.3k|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
  |  Branch (545:6): [True: 48.0k, False: 48.2k]
  ------------------
  546|  48.0k|		if ((tag_in & SC_ASN1_CONS) == 0)
  ------------------
  |  |  141|  48.0k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (546:7): [True: 2.75k, False: 45.2k]
  ------------------
  547|  2.75k|			return NULL;
  548|  48.0k|	} else
  549|  48.2k|		if (tag_in & SC_ASN1_CONS)
  ------------------
  |  |  141|  48.2k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (549:7): [True: 4.78k, False: 43.4k]
  ------------------
  550|  4.78k|			return NULL;
  551|  88.7k|	if ((tag_in & SC_ASN1_TAG_MASK) != tag)
  ------------------
  |  |  144|  88.7k|#define SC_ASN1_TAG_MASK		0x00FFFFFF
  ------------------
  |  Branch (551:6): [True: 12.6k, False: 76.1k]
  ------------------
  552|  12.6k|		return NULL;
  553|  76.1k|	len -= (p - *buf);	/* header size */
  554|  76.1k|	if (taglen > len) {
  ------------------
  |  Branch (554:6): [True: 0, False: 76.1k]
  ------------------
  555|      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__
  |  |  ------------------
  ------------------
  556|      0|				taglen, len);
  557|      0|		return NULL;
  558|      0|	}
  559|  76.1k|	*buflen -= (p - *buf) + taglen;
  560|  76.1k|	*buf = p + taglen;	/* point to next tag */
  561|  76.1k|	*taglen_out = taglen;
  562|  76.1k|	return p;
  563|  76.1k|}
sc_asn1_verify_tag:
  567|  3.73k|{
  568|  3.73k|	return sc_asn1_skip_tag(ctx, &buf, &buflen, tag_in, taglen_out);
  569|  3.73k|}
sc_asn1_decode_integer:
  728|  3.13k|{
  729|  3.13k|	int    a = 0, is_negative = 0;
  730|  3.13k|	size_t i = 0;
  731|       |
  732|  3.13k|	if (inlen == 0) {
  ------------------
  |  Branch (732:6): [True: 20, False: 3.11k]
  ------------------
  733|     20|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     20|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  734|     20|	}
  735|  3.11k|	if (inlen > sizeof(int)) {
  ------------------
  |  Branch (735:6): [True: 18, False: 3.09k]
  ------------------
  736|     18|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     18|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  737|     18|	}
  738|  3.09k|	if (inbuf[0] & 0x80) {
  ------------------
  |  Branch (738:6): [True: 204, False: 2.89k]
  ------------------
  739|    204|		if (strict && inlen > 1 && inbuf[0] == 0xff && (inbuf[1] & 0x80)) {
  ------------------
  |  Branch (739:7): [True: 0, False: 204]
  |  Branch (739:17): [True: 0, False: 0]
  |  Branch (739:30): [True: 0, False: 0]
  |  Branch (739:50): [True: 0, False: 0]
  ------------------
  740|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  741|      0|		}
  742|    204|		is_negative = 1;
  743|    204|		a |= 0xff^(*inbuf++);
  744|    204|		i = 1;
  745|  2.89k|	} else {
  746|  2.89k|		if (strict && inlen > 1 && inbuf[0] == 0x00 && (inbuf[1] & 0x80) == 0) {
  ------------------
  |  Branch (746:7): [True: 0, False: 2.89k]
  |  Branch (746:17): [True: 0, False: 0]
  |  Branch (746:30): [True: 0, False: 0]
  |  Branch (746:50): [True: 0, False: 0]
  ------------------
  747|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  748|      0|		}
  749|  2.89k|	}
  750|  6.20k|	for (; i < inlen; i++) {
  ------------------
  |  Branch (750:9): [True: 3.10k, False: 3.09k]
  ------------------
  751|  3.10k|		if (a > (INT_MAX >> 8) || a < (INT_MIN + (1<<8))) {
  ------------------
  |  Branch (751:7): [True: 0, False: 3.10k]
  |  Branch (751:29): [True: 0, False: 3.10k]
  ------------------
  752|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  753|      0|		}
  754|  3.10k|		a <<= 8;
  755|  3.10k|		if (is_negative) {
  ------------------
  |  Branch (755:7): [True: 118, False: 2.99k]
  ------------------
  756|    118|			a |= 0xff^(*inbuf++);
  757|  2.99k|		} else {
  758|  2.99k|			a |= *inbuf++;
  759|  2.99k|		}
  760|  3.10k|	}
  761|  3.09k|	if (is_negative) {
  ------------------
  |  Branch (761:6): [True: 204, False: 2.89k]
  ------------------
  762|       |		/* Calculate Two's complement from previously positive number */
  763|    204|		a = (-1 * a) - 1;
  764|    204|	}
  765|  3.09k|	*out = a;
  766|  3.09k|	return 0;
  767|  3.09k|}
sc_asn1_decode_object_id:
  828|  16.9k|{
  829|  16.9k|	int large_second_octet = 0;
  830|  16.9k|	unsigned int a = 0;
  831|  16.9k|	const u8 *p = inbuf;
  832|  16.9k|	int *octet;
  833|       |
  834|  16.9k|	if (inlen == 0 || inbuf == NULL || id == NULL)
  ------------------
  |  Branch (834:6): [True: 955, False: 16.0k]
  |  Branch (834:20): [True: 3, False: 16.0k]
  |  Branch (834:37): [True: 0, False: 16.0k]
  ------------------
  835|    958|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    958|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  836|       |
  837|  16.0k|	sc_init_oid(id);
  838|  16.0k|	octet = id->value;
  839|       |
  840|       |	/* The first octet can be 0, 1 or 2 and is derived from the first byte */
  841|  16.0k|	a = MIN(*p / 40, 2);
  ------------------
  |  |   69|  16.0k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 13.9k, False: 2.06k]
  |  |  ------------------
  ------------------
  842|  16.0k|	*octet++ = a;
  843|       |
  844|       |	/* The second octet fits here if the previous was 0 or 1 and second one is smaller than 40.
  845|       |	 * for the value 2 we can go up to 47. Otherwise the first bit needs to be set
  846|       |	 * and we continue reading further */
  847|  16.0k|	if ((*p & 0x80) == 0) {
  ------------------
  |  Branch (847:6): [True: 14.1k, False: 1.89k]
  ------------------
  848|  14.1k|		*octet++ = *p - (a * 40);
  849|  14.1k|		inlen--;
  850|  14.1k|	} else {
  851|  1.89k|		large_second_octet = 1;
  852|  1.89k|	}
  853|       |
  854|  78.2k|	while (inlen) {
  ------------------
  |  Branch (854:9): [True: 64.6k, False: 13.6k]
  ------------------
  855|  64.6k|		if (!large_second_octet)
  ------------------
  |  Branch (855:7): [True: 62.7k, False: 1.89k]
  ------------------
  856|  62.7k|			p++;
  857|       |		/* This signalizes empty most significant bits, which means
  858|       |		 * the unsigned integer encoding is not minimal */
  859|  64.6k|		if (*p == 0x80) {
  ------------------
  |  Branch (859:7): [True: 963, False: 63.6k]
  ------------------
  860|    963|			sc_init_oid(id);
  861|    963|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    963|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  862|    963|		}
  863|       |		/* Use unsigned type here so we can process the whole INT range.
  864|       |		 * Values can not be negative */
  865|  63.6k|		a = *p & 0x7F;
  866|  63.6k|		inlen--;
  867|  93.8k|		while (inlen && *p & 0x80) {
  ------------------
  |  Branch (867:10): [True: 81.1k, False: 12.6k]
  |  Branch (867:19): [True: 30.3k, False: 50.7k]
  ------------------
  868|       |			/* Limit the OID values to int size and do not overflow */
  869|  30.3k|			if (a > (UINT_MAX>>7)) {
  ------------------
  |  Branch (869:8): [True: 228, False: 30.1k]
  ------------------
  870|    228|				sc_init_oid(id);
  871|    228|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    228|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  872|    228|			}
  873|  30.1k|			p++;
  874|  30.1k|			a <<= 7;
  875|  30.1k|			a |= *p & 0x7F;
  876|  30.1k|			inlen--;
  877|  30.1k|		}
  878|  63.4k|		if (*p & 0x80) {
  ------------------
  |  Branch (878:7): [True: 744, False: 62.7k]
  ------------------
  879|       |			/* We dropped out from previous cycle on the end of
  880|       |			 * data while still expecting continuation of value */
  881|    744|			sc_init_oid(id);
  882|    744|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    744|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  883|    744|		}
  884|  62.7k|		if (large_second_octet) {
  ------------------
  |  Branch (884:7): [True: 952, False: 61.7k]
  ------------------
  885|    952|			a -= (2 * 40);
  886|    952|		}
  887|  62.7k|		if (a > INT_MAX) {
  ------------------
  |  Branch (887:7): [True: 208, False: 62.5k]
  ------------------
  888|    208|			sc_init_oid(id);
  889|    208|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    208|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  890|    208|		}
  891|  62.5k|		*octet++ = a;
  892|  62.5k|		if (octet - id->value >= SC_MAX_OBJECT_ID_OCTETS)   {
  ------------------
  |  |   46|  62.5k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (892:7): [True: 226, False: 62.2k]
  ------------------
  893|    226|			sc_init_oid(id);
  894|    226|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    226|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  895|    226|		}
  896|  62.2k|		large_second_octet = 0;
  897|  62.2k|	}
  898|       |
  899|  13.6k|	return 0;
  900|  16.0k|}
sc_asn1_encode_object_id:
  904|  6.75k|{
  905|  6.75k|	u8 temp[SC_MAX_OBJECT_ID_OCTETS*5], *p = temp;
  906|  6.75k|	int	i;
  907|       |
  908|  6.75k|	if (!buflen || !id)
  ------------------
  |  Branch (908:6): [True: 0, False: 6.75k]
  |  Branch (908:17): [True: 0, False: 6.75k]
  ------------------
  909|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  910|       |
  911|       |	/* an OID must have at least two components */
  912|  6.75k|	if (id->value[0] == -1 || id->value[1] == -1)
  ------------------
  |  Branch (912:6): [True: 0, False: 6.75k]
  |  Branch (912:28): [True: 0, False: 6.75k]
  ------------------
  913|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  914|       |
  915|  48.5k|	for (i = 0; i < SC_MAX_OBJECT_ID_OCTETS; i++) {
  ------------------
  |  |   46|  48.5k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (915:14): [True: 48.5k, False: 0]
  ------------------
  916|  48.5k|		unsigned int k, shift;
  917|       |
  918|  48.5k|		if (id->value[i] == -1)
  ------------------
  |  Branch (918:7): [True: 6.75k, False: 41.7k]
  ------------------
  919|  6.75k|			break;
  920|       |
  921|  41.7k|		k = id->value[i];
  922|  41.7k|		switch (i) {
  923|  6.75k|		case 0:
  ------------------
  |  Branch (923:3): [True: 6.75k, False: 35.0k]
  ------------------
  924|  6.75k|			if (k > 2)
  ------------------
  |  Branch (924:8): [True: 0, False: 6.75k]
  ------------------
  925|      0|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  926|  6.75k|			*p = k * 40;
  927|  6.75k|			break;
  928|  6.75k|		case 1:
  ------------------
  |  Branch (928:3): [True: 6.75k, False: 35.0k]
  ------------------
  929|  6.75k|			if (k > 39 && id->value[0] < 2) {
  ------------------
  |  Branch (929:8): [True: 0, False: 6.75k]
  |  Branch (929:18): [True: 0, False: 0]
  ------------------
  930|      0|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  931|      0|			}
  932|       |			/* We can encode larger IDs to multiple bytes
  933|       |			 * similarly as the following IDs */
  934|  6.75k|			k += *p;
  935|       |			/* fall through */
  936|  35.0k|		default:
  ------------------
  |  Branch (936:3): [True: 28.2k, False: 13.5k]
  ------------------
  937|  35.0k|			shift = 28;
  938|   163k|			while (shift && (k >> shift) == 0)
  ------------------
  |  Branch (938:11): [True: 139k, False: 23.8k]
  |  Branch (938:20): [True: 128k, False: 11.1k]
  ------------------
  939|   128k|				shift -= 7;
  940|  46.4k|			while (shift) {
  ------------------
  |  Branch (940:11): [True: 11.3k, False: 35.0k]
  ------------------
  941|  11.3k|				*p++ = 0x80 | ((k >> shift) & 0x7f);
  942|  11.3k|				shift -= 7;
  943|  11.3k|			}
  944|  35.0k|			*p++ = k & 0x7F;
  945|  35.0k|			break;
  946|  41.7k|		}
  947|  41.7k|	}
  948|       |
  949|  6.75k|	*buflen = p - temp;
  950|       |
  951|  6.75k|	if (buf)   {
  ------------------
  |  Branch (951:6): [True: 6.75k, False: 0]
  ------------------
  952|  6.75k|		*buf = malloc(*buflen);
  953|  6.75k|		if (!*buf)
  ------------------
  |  Branch (953:7): [True: 0, False: 6.75k]
  ------------------
  954|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  955|  6.75k|		memcpy(*buf, temp, *buflen);
  956|  6.75k|	}
  957|  6.75k|	return 0;
  958|  6.75k|}
sc_asn1_put_tag:
  975|  13.8k|{
  976|  13.8k|	size_t c = 0;
  977|  13.8k|	unsigned int tag_len, ii;
  978|  13.8k|	u8 *p = out;
  979|  13.8k|	u8 tag_char[4] = {0, 0, 0, 0};
  980|       |
  981|       |	/* Check tag */
  982|  13.8k|	if (tag == 0 || tag > 0xFFFFFFFF) {
  ------------------
  |  Branch (982:6): [True: 0, False: 13.8k]
  |  Branch (982:18): [True: 0, False: 13.8k]
  ------------------
  983|       |		/* A tag of 0x00 is not valid and at most 4-byte tag names are supported. */
  984|      0|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  985|      0|	}
  986|  27.6k|	for (tag_len = 0; tag; tag >>= 8) {
  ------------------
  |  Branch (986:20): [True: 13.8k, False: 13.8k]
  ------------------
  987|       |		/* Note: tag char will be reversed order. */
  988|  13.8k|		tag_char[tag_len++] = tag & 0xFF;
  989|  13.8k|	}
  990|       |
  991|  13.8k|	if (tag_len > 1)   {
  ------------------
  |  Branch (991:6): [True: 0, False: 13.8k]
  ------------------
  992|      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 (992:7): [True: 0, False: 0]
  ------------------
  993|       |			/* First byte is not escape marker. */
  994|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  995|      0|		}
  996|      0|		for (ii = 1; ii < tag_len - 1; ii++) {
  ------------------
  |  Branch (996:16): [True: 0, False: 0]
  ------------------
  997|      0|			if ((tag_char[ii] & 0x80) != 0x80) {
  ------------------
  |  Branch (997:8): [True: 0, False: 0]
  ------------------
  998|       |				/* MS bit is not 'one'. */
  999|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1000|      0|			}
 1001|      0|		}
 1002|      0|		if ((tag_char[0] & 0x80) != 0x00) {
  ------------------
  |  Branch (1002:7): [True: 0, False: 0]
  ------------------
 1003|       |			/* MS bit of the last byte is not 'zero'. */
 1004|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1005|      0|		}
 1006|      0|	}
 1007|       |
 1008|       |	/* Calculate the number of additional bytes necessary to encode the length. */
 1009|       |	/* c+1 is the size of the length field. */
 1010|  13.8k|	if (datalen > 127) {
  ------------------
  |  Branch (1010:6): [True: 0, False: 13.8k]
  ------------------
 1011|      0|		c = 1;
 1012|      0|		while (datalen >> (c << 3))
  ------------------
  |  Branch (1012:10): [True: 0, False: 0]
  ------------------
 1013|      0|			c++;
 1014|      0|	}
 1015|  13.8k|	if (outlen == 0 || out == NULL) {
  ------------------
  |  Branch (1015:6): [True: 58, False: 13.7k]
  |  Branch (1015:21): [True: 0, False: 13.7k]
  ------------------
 1016|       |		/* Caller only asks for the length that would be written. */
 1017|     58|		return (int)(tag_len + (c + 1) + datalen);
 1018|     58|	}
 1019|       |	/* We will write the tag, so check the length. */
 1020|  13.7k|	if (outlen < tag_len + (c+1) + datalen)
  ------------------
  |  Branch (1020:6): [True: 0, False: 13.7k]
  ------------------
 1021|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 1022|  27.5k|	for (ii=0;ii<tag_len;ii++)
  ------------------
  |  Branch (1022:12): [True: 13.7k, False: 13.7k]
  ------------------
 1023|  13.7k|		*p++ = tag_char[tag_len - ii - 1];
 1024|       |
 1025|  13.7k|	if (c > 0) {
  ------------------
  |  Branch (1025:6): [True: 0, False: 13.7k]
  ------------------
 1026|      0|		*p++ = 0x80 | c;
 1027|      0|		while (c--)
  ------------------
  |  Branch (1027:10): [True: 0, False: 0]
  ------------------
 1028|      0|			*p++ = (datalen >> (c << 3)) & 0xFF;
 1029|      0|	}
 1030|  13.7k|	else {
 1031|  13.7k|		*p++ = datalen & 0x7F;
 1032|  13.7k|	}
 1033|  13.7k|	if(data && datalen > 0) {
  ------------------
  |  Branch (1033:5): [True: 13.6k, False: 58]
  |  Branch (1033:13): [True: 13.6k, False: 0]
  ------------------
 1034|  13.6k|		memcpy(p, data, datalen);
 1035|  13.6k|		p += datalen;
 1036|  13.6k|	}
 1037|  13.7k|	if (ptr != NULL)
  ------------------
  |  Branch (1037:6): [True: 13.7k, False: 0]
  ------------------
 1038|  13.7k|		*ptr = p;
 1039|  13.7k|	return 0;
 1040|  13.7k|}
sc_asn1_decode:
 1813|  22.3k|{
 1814|  22.3k|	return asn1_decode(ctx, asn1, in, len, newp, len_left, 0, 0);
 1815|  22.3k|}
sc_asn1_decode_choice:
 1819|  7.10k|{
 1820|  7.10k|	return asn1_decode(ctx, asn1, in, len, newp, len_left, 1, 0);
 1821|  7.10k|}
sc_asn1_encode:
 2081|  16.0k|{
 2082|  16.0k|	return asn1_encode(ctx, asn1, ptr, size, 0);
 2083|  16.0k|}
_sc_asn1_encode:
 2087|  6.75k|{
 2088|  6.75k|	return asn1_encode(ctx, asn1, ptr, size, depth);
 2089|  6.75k|}
_sc_asn1_decode:
 2095|  7.31k|{
 2096|  7.31k|	return asn1_decode(ctx, asn1, in, len, newp, left, choice, depth);
 2097|  7.31k|}
sc_der_copy:
 2101|  3.52k|{
 2102|  3.52k|	if (!dst || !src)
  ------------------
  |  Branch (2102:6): [True: 0, False: 3.52k]
  |  Branch (2102:14): [True: 0, False: 3.52k]
  ------------------
 2103|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2104|  3.52k|	memset(dst, 0, sizeof(*dst));
 2105|  3.52k|	if (src->len) {
  ------------------
  |  Branch (2105:6): [True: 3.50k, False: 14]
  ------------------
 2106|  3.50k|		if (!src->value)
  ------------------
  |  Branch (2106:7): [True: 0, False: 3.50k]
  ------------------
 2107|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2108|  3.50k|		dst->value = malloc(src->len);
 2109|  3.50k|		if (!dst->value)
  ------------------
  |  Branch (2109:7): [True: 0, False: 3.50k]
  ------------------
 2110|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2111|  3.50k|		dst->len = src->len;
 2112|  3.50k|		memcpy(dst->value, src->value, src->len);
 2113|  3.50k|	}
 2114|  3.52k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.52k|#define SC_SUCCESS				0
  ------------------
 2115|  3.52k|}
sc_encode_oid:
 2120|  3.41k|{
 2121|  3.41k|	static const struct sc_asn1_entry c_asn1_object_id[2] = {
 2122|  3.41k|		{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  159|  3.41k|#define SC_ASN1_OBJECT                  6
  ------------------
              		{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  200|  3.41k|#define SC_ASN1_TAG_OBJECT		6
  ------------------
              		{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  149|  3.41k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
 2123|  3.41k|		{ NULL, 0, 0, 0, NULL, NULL }
 2124|  3.41k|	};
 2125|  3.41k|	struct sc_asn1_entry asn1_object_id[2];
 2126|  3.41k|	int rv;
 2127|       |
 2128|  3.41k|	sc_copy_asn1_entry(c_asn1_object_id, asn1_object_id);
 2129|  3.41k|	sc_format_asn1_entry(asn1_object_id + 0, id, NULL, 1);
 2130|       |
 2131|  3.41k|	rv = _sc_asn1_encode(ctx, asn1_object_id, out, size, 1);
 2132|  3.41k|	LOG_TEST_RET(ctx, rv, "Cannot encode object ID");
  ------------------
  |  |  174|  3.41k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.41k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.41k|	int _ret = (r); \
  |  |  |  |  168|  3.41k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.41k]
  |  |  |  |  ------------------
  |  |  |  |  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|  3.41k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.41k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2133|       |
 2134|  3.41k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.41k|#define SC_SUCCESS				0
  ------------------
 2135|  3.41k|}
sc_asn1_sig_value_rs_to_sequence:
 2155|     21|{
 2156|     21|	struct sc_asn1_entry asn1_sig_value[C_ASN1_SIG_VALUE_SIZE];
 2157|     21|	struct sc_asn1_entry asn1_sig_value_coefficients[C_ASN1_SIG_VALUE_COEFFICIENTS_SIZE];
 2158|     21|	unsigned char *r = in, *s = in + inlen/2;
 2159|     21|	size_t r_len = inlen/2, s_len = inlen/2;
 2160|     21|	int rv;
 2161|       |
 2162|     21|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     21|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     21|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     21|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     21|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2163|       |
 2164|       |	/* R/S are filled up with zeroes, we do not want that in sequence format */
 2165|    136|	while(r_len > 1 && *r == 0x00) {
  ------------------
  |  Branch (2165:8): [True: 131, False: 5]
  |  Branch (2165:21): [True: 115, False: 16]
  ------------------
 2166|    115|		r++;
 2167|    115|		r_len--;
 2168|    115|	}
 2169|    272|	while(s_len > 1 && *s == 0x00) {
  ------------------
  |  Branch (2169:8): [True: 268, False: 4]
  |  Branch (2169:21): [True: 251, False: 17]
  ------------------
 2170|    251|		s++;
 2171|    251|		s_len--;
 2172|    251|	}
 2173|       |
 2174|     21|	sc_copy_asn1_entry(c_asn1_sig_value, asn1_sig_value);
 2175|     21|	sc_format_asn1_entry(asn1_sig_value + 0, asn1_sig_value_coefficients, NULL, 1);
 2176|       |
 2177|     21|	sc_copy_asn1_entry(c_asn1_sig_value_coefficients, asn1_sig_value_coefficients);
 2178|     21|	sc_format_asn1_entry(asn1_sig_value_coefficients + 0, r, &r_len, 1);
 2179|     21|	sc_format_asn1_entry(asn1_sig_value_coefficients + 1, s, &s_len, 1);
 2180|       |
 2181|     21|	rv = sc_asn1_encode(ctx, asn1_sig_value, buf, buflen);
 2182|     21|	LOG_TEST_RET(ctx, rv, "ASN.1 encoding ECDSA-SIg-Value failed");
  ------------------
  |  |  174|     21|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     21|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     21|	int _ret = (r); \
  |  |  |  |  168|     21|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2183|       |
 2184|     19|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     19|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     19|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     19|	int _ret = r; \
  |  |  |  |  155|     19|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 19, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     19|		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: 19]
  |  |  |  |  ------------------
  |  |  |  |  157|     19|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     19|	} 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|     19|	return _ret; \
  |  |  |  |  163|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2185|     19|}
sc_asn1_decode_ecdsa_signature:
 2234|     12|int sc_asn1_decode_ecdsa_signature(sc_context_t *ctx, const u8 *data, size_t datalen, size_t fieldsize, u8 **out, size_t outlen) {
 2235|     12|	int i, r;
 2236|     12|	const unsigned char *pseq, *pint, *pend;
 2237|     12|	unsigned int cla, tag;
 2238|     12|	size_t seqlen, intlen;
 2239|       |
 2240|     12|	if (!ctx || !data || !out || !(*out)) {
  ------------------
  |  Branch (2240:6): [True: 0, False: 12]
  |  Branch (2240:14): [True: 0, False: 12]
  |  Branch (2240:23): [True: 0, False: 12]
  |  Branch (2240:31): [True: 0, False: 12]
  ------------------
 2241|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2242|      0|	}
 2243|     12|	if (outlen < 2 * fieldsize) {
  ------------------
  |  Branch (2243:6): [True: 0, False: 12]
  ------------------
 2244|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Output too small for EC signature");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2245|      0|	}
 2246|       |
 2247|     12|	memset(*out, 0, outlen);
 2248|       |
 2249|     12|	pseq = data;
 2250|     12|	r = sc_asn1_read_tag(&pseq, datalen, &cla, &tag, &seqlen);
 2251|     12|	if (pseq == NULL || r < 0 || seqlen == 0 || (cla | tag) != 0x30)
  ------------------
  |  Branch (2251:6): [True: 5, False: 7]
  |  Branch (2251:22): [True: 1, False: 6]
  |  Branch (2251:31): [True: 1, False: 5]
  |  Branch (2251:46): [True: 1, False: 4]
  ------------------
 2252|     12|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Can not find 0x30 tag");
  ------------------
  |  |  174|      8|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      8|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      8|	int _ret = (r); \
  |  |  |  |  168|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      8|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      8|		return _ret; \
  |  |  |  |  172|      8|	} \
  |  |  |  |  173|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2253|       |
 2254|      4|	pint = pseq;
 2255|      4|	pend = pseq + seqlen;
 2256|      5|	for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (2256:14): [True: 5, False: 0]
  ------------------
 2257|      5|		r = sc_asn1_read_tag(&pint, (pend - pint), &cla, &tag, &intlen);
 2258|      5|		if (pint == NULL || r < 0 || intlen == 0 || (cla | tag) != 0x02) {
  ------------------
  |  Branch (2258:7): [True: 1, False: 4]
  |  Branch (2258:23): [True: 1, False: 3]
  |  Branch (2258:32): [True: 1, False: 2]
  |  Branch (2258:47): [True: 1, False: 1]
  ------------------
 2259|      4|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      4|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2260|      4|			LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INVALID_DATA, "Can not find 0x02");
  ------------------
  |  |  184|      4|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      4|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      4|	int _ret = (r); \
  |  |  |  |  178|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      4|		goto err; \
  |  |  |  |  182|      4|	} \
  |  |  |  |  183|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2261|      4|		}
 2262|       |
 2263|      1|		if (intlen == fieldsize + 1) { /* drop leading 00 if present */
  ------------------
  |  Branch (2263:7): [True: 0, False: 1]
  ------------------
 2264|      0|			if (*pint != 0x00) {
  ------------------
  |  Branch (2264:8): [True: 0, False: 0]
  ------------------
 2265|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2266|      0|				LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INVALID_DATA, "Signature too long");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2267|      0|			}
 2268|      0|			pint++;
 2269|      0|			intlen--;
 2270|      0|		}
 2271|      1|		if (intlen > fieldsize) {
  ------------------
  |  Branch (2271:7): [True: 0, False: 1]
  ------------------
 2272|      0|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2273|      0|			LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INVALID_DATA, "Signature too long");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2274|      0|		}
 2275|      1|		memcpy(*out + fieldsize * i + fieldsize - intlen , pint, intlen);
 2276|      1|		pint += intlen; /* next integer */
 2277|      1|	}
 2278|      0|	r = (int)(2 * fieldsize);
 2279|      4|err:
 2280|      4|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|      4|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      4|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      4|	int _ret = r; \
  |  |  |  |  155|      4|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      4|	} 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|      4|	return _ret; \
  |  |  |  |  163|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2281|      4|}
asn1.c:decode_bit_string:
  573|  2.70k|{
  574|  2.70k|	const u8 *in = inbuf;
  575|  2.70k|	u8 *out = (u8 *) outbuf;
  576|  2.70k|	int i, count = 0;
  577|  2.70k|	int zero_bits;
  578|  2.70k|	size_t octets_left;
  579|       |
  580|  2.70k|	if (inlen < 1)
  ------------------
  |  Branch (580:6): [True: 6, False: 2.69k]
  ------------------
  581|      6|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      6|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  582|       |
  583|       |	/* The formatting is only enforced by SHALL keyword so we should accept
  584|       |	 * by default also non-strict values. */
  585|  2.69k|	if (strict) {
  ------------------
  |  Branch (585:6): [True: 0, False: 2.69k]
  ------------------
  586|       |		/* 8.6.2.3 If the bitstring is empty, there shall be no
  587|       |		 * subsequent octets,and the initial octet shall be zero. */
  588|      0|		if (inlen == 1 && *in != 0)
  ------------------
  |  Branch (588:7): [True: 0, False: 0]
  |  Branch (588:21): [True: 0, False: 0]
  ------------------
  589|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  590|       |		/* ITU-T Rec. X.690 8.6.2.2: The number shall be in the range zero to seven. */
  591|      0|		if ((*in & ~0x07) != 0)
  ------------------
  |  Branch (591:7): [True: 0, False: 0]
  ------------------
  592|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  593|      0|	}
  594|       |
  595|  2.69k|	memset(outbuf, 0, outlen);
  596|  2.69k|	zero_bits = *in & 0x07;
  597|  2.69k|	in++;
  598|  2.69k|	octets_left = inlen - 1;
  599|  2.69k|	if (outlen < octets_left)
  ------------------
  |  Branch (599:6): [True: 1, False: 2.69k]
  ------------------
  600|      1|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      1|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  601|       |
  602|   174k|	while (octets_left) {
  ------------------
  |  Branch (602:9): [True: 171k, False: 2.68k]
  ------------------
  603|       |		/* 1st octet of input:  ABCDEFGH, where A is the MSB */
  604|       |		/* 1st octet of output: HGFEDCBA, where A is the LSB */
  605|       |		/* first bit in bit string is the LSB in first resulting octet */
  606|   171k|		int bits_to_go;
  607|       |
  608|   171k|		*out = 0;
  609|   171k|		if (octets_left == 1 && zero_bits > 0) {
  ------------------
  |  Branch (609:7): [True: 2.55k, False: 168k]
  |  Branch (609:27): [True: 2.10k, False: 453]
  ------------------
  610|  2.10k|			bits_to_go = 8 - zero_bits;
  611|       |			/* Verify the padding is zero bits */
  612|  2.10k|			if (*in & (1 << (zero_bits-1))) {
  ------------------
  |  Branch (612:8): [True: 14, False: 2.09k]
  ------------------
  613|     14|				return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     14|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  614|     14|			}
  615|  2.10k|		} else
  616|   169k|			bits_to_go = 8;
  617|   171k|		if (invert)
  ------------------
  |  Branch (617:7): [True: 35, False: 171k]
  ------------------
  618|    267|			for (i = 0; i < bits_to_go; i++) {
  ------------------
  |  Branch (618:16): [True: 232, False: 35]
  ------------------
  619|    232|				*out |= ((*in >> (7 - i)) & 1) << i;
  620|    232|			}
  621|   171k|		else {
  622|   171k|			*out = *in;
  623|   171k|		}
  624|   171k|		out++;
  625|   171k|		in++;
  626|   171k|		octets_left--;
  627|   171k|		count++;
  628|   171k|	}
  629|  2.68k|	return (count * 8) - zero_bits;
  630|  2.69k|}
asn1.c:asn1_write_element:
 1050|  25.7k|{
 1051|  25.7k|	unsigned char t;
 1052|  25.7k|	unsigned char *buf, *p;
 1053|  25.7k|	int c = 0;
 1054|  25.7k|	unsigned short_tag;
 1055|  25.7k|	unsigned char tag_char[3] = {0, 0, 0};
 1056|  25.7k|	size_t tag_len, ii;
 1057|       |
 1058|  25.7k|	short_tag = tag & SC_ASN1_TAG_MASK;
  ------------------
  |  |  144|  25.7k|#define SC_ASN1_TAG_MASK		0x00FFFFFF
  ------------------
 1059|  51.5k|	for (tag_len = 0; short_tag >> (8 * tag_len); tag_len++)
  ------------------
  |  Branch (1059:20): [True: 25.7k, False: 25.7k]
  ------------------
 1060|  25.7k|		tag_char[tag_len] = (short_tag >> (8 * tag_len)) & 0xFF;
 1061|  25.7k|	if (!tag_len)
  ------------------
  |  Branch (1061:6): [True: 0, False: 25.7k]
  ------------------
 1062|      0|		tag_len = 1;
 1063|       |
 1064|  25.7k|	if (tag_len > 1)   {
  ------------------
  |  Branch (1064:6): [True: 0, False: 25.7k]
  ------------------
 1065|      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 (1065:7): [True: 0, False: 0]
  ------------------
 1066|      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]
  |  |  ------------------
  ------------------
 1067|       |
 1068|      0|		for (ii = 1; ii < tag_len - 1; ii++)
  ------------------
  |  Branch (1068:16): [True: 0, False: 0]
  ------------------
 1069|      0|			if (!(tag_char[ii] & 0x80))
  ------------------
  |  Branch (1069:8): [True: 0, False: 0]
  ------------------
 1070|      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]
  |  |  ------------------
  ------------------
 1071|       |
 1072|      0|		if (tag_char[0] & 0x80)
  ------------------
  |  Branch (1072:7): [True: 0, False: 0]
  ------------------
 1073|      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]
  |  |  ------------------
  ------------------
 1074|      0|	}
 1075|       |
 1076|  25.7k|	t = tag_char[tag_len - 1] & 0x1F;
 1077|       |
 1078|  25.7k|	switch (tag & SC_ASN1_CLASS_MASK) {
  ------------------
  |  |  136|  25.7k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
  |  Branch (1078:10): [True: 25.7k, False: 0]
  ------------------
 1079|  18.0k|	case SC_ASN1_UNI:
  ------------------
  |  |  137|  18.0k|#define SC_ASN1_UNI			0x00000000 /* Universal */
  ------------------
  |  Branch (1079:2): [True: 18.0k, False: 7.76k]
  ------------------
 1080|  18.0k|		break;
 1081|  7.76k|	case SC_ASN1_APP:
  ------------------
  |  |  138|  7.76k|#define SC_ASN1_APP			0x40000000 /* Application */
  ------------------
  |  Branch (1081:2): [True: 7.76k, False: 18.0k]
  ------------------
 1082|  7.76k|		t |= SC_ASN1_TAG_APPLICATION;
  ------------------
  |  |  186|  7.76k|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
 1083|  7.76k|		break;
 1084|      0|	case SC_ASN1_CTX:
  ------------------
  |  |  139|      0|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
  |  Branch (1084:2): [True: 0, False: 25.7k]
  ------------------
 1085|      0|		t |= SC_ASN1_TAG_CONTEXT;
  ------------------
  |  |  187|      0|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
 1086|      0|		break;
 1087|      0|	case SC_ASN1_PRV:
  ------------------
  |  |  140|      0|#define SC_ASN1_PRV			0xC0000000 /* Private */
  ------------------
  |  Branch (1087:2): [True: 0, False: 25.7k]
  ------------------
 1088|      0|		t |= SC_ASN1_TAG_PRIVATE;
  ------------------
  |  |  188|      0|#define SC_ASN1_TAG_PRIVATE		0xC0
  ------------------
 1089|      0|		break;
 1090|  25.7k|	}
 1091|  25.7k|	if (tag & SC_ASN1_CONS)
  ------------------
  |  |  141|  25.7k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (1091:6): [True: 7.06k, False: 18.7k]
  ------------------
 1092|  7.06k|		t |= SC_ASN1_TAG_CONSTRUCTED;
  ------------------
  |  |  190|  7.06k|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
 1093|  25.7k|	if (datalen > 127) {
  ------------------
  |  Branch (1093:6): [True: 486, False: 25.2k]
  ------------------
 1094|    486|		c = 1;
 1095|    547|		while (datalen >> (c << 3))
  ------------------
  |  Branch (1095:10): [True: 61, False: 486]
  ------------------
 1096|     61|			c++;
 1097|    486|	}
 1098|       |
 1099|  25.7k|	*outlen = tag_len + 1 + c + datalen;
 1100|  25.7k|	buf = malloc(*outlen);
 1101|  25.7k|	if (buf == NULL)
  ------------------
  |  Branch (1101:6): [True: 0, False: 25.7k]
  ------------------
 1102|      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]
  |  |  ------------------
  ------------------
 1103|       |
 1104|  25.7k|	*out = p = buf;
 1105|  25.7k|	*p++ = t;
 1106|  25.7k|	for (ii=1;ii<tag_len;ii++)
  ------------------
  |  Branch (1106:12): [True: 0, False: 25.7k]
  ------------------
 1107|      0|		*p++ = tag_char[tag_len - ii - 1];
 1108|       |
 1109|  25.7k|	if (c) {
  ------------------
  |  Branch (1109:6): [True: 486, False: 25.2k]
  ------------------
 1110|    486|		*p++ = 0x80 | c;
 1111|  1.03k|		while (c--)
  ------------------
  |  Branch (1111:10): [True: 547, False: 486]
  ------------------
 1112|    547|			*p++ = (datalen >> (c << 3)) & 0xFF;
 1113|    486|	}
 1114|  25.2k|	else   {
 1115|  25.2k|		*p++ = datalen & 0x7F;
 1116|  25.2k|	}
 1117|  25.7k|	if (datalen && data) {
  ------------------
  |  Branch (1117:6): [True: 25.4k, False: 286]
  |  Branch (1117:17): [True: 25.4k, False: 0]
  ------------------
 1118|  25.4k|		memcpy(p, data, datalen);
 1119|  25.4k|	}
 1120|       |
 1121|  25.7k|	return SC_SUCCESS;
  ------------------
  |  |   28|  25.7k|#define SC_SUCCESS				0
  ------------------
 1122|  25.7k|}
asn1.c:asn1_decode:
 1722|  53.0k|{
 1723|  53.0k|	int r, idx = 0;
 1724|  53.0k|	const u8 *p = in, *obj;
 1725|  53.0k|	struct sc_asn1_entry *entry = asn1;
 1726|  53.0k|	size_t left = len, objlen;
 1727|       |
 1728|  53.0k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*s""called, left=%zu, depth %d%s",
  ------------------
  |  |   70|   106k|#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: 7.23k, False: 45.8k]
  |  |  ------------------
  ------------------
 1729|  53.0k|			depth, depth, "", left, depth, choice ? ", choice" : "");
 1730|       |
 1731|  53.0k|	if (!p)
  ------------------
  |  Branch (1731:6): [True: 1, False: 53.0k]
  ------------------
 1732|      1|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|      1|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1733|  53.0k|	if (left < 2) {
  ------------------
  |  Branch (1733:6): [True: 2.73k, False: 50.3k]
  ------------------
 1734|  6.21k|		while (asn1->name && (asn1->flags & SC_ASN1_OPTIONAL))
  ------------------
  |  |  148|  4.63k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1734:10): [True: 4.63k, False: 1.58k]
  |  Branch (1734:24): [True: 3.48k, False: 1.15k]
  ------------------
 1735|  3.48k|			asn1++;
 1736|       |		/* If all elements were optional, there's nothing
 1737|       |		 * to complain about */
 1738|  2.73k|		if (asn1->name == NULL)
  ------------------
  |  Branch (1738:7): [True: 1.58k, False: 1.15k]
  ------------------
 1739|  1.58k|			return 0;
 1740|  1.15k|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "End of ASN.1 stream, "
  ------------------
  |  |   70|  1.15k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1741|  1.15k|			      "non-optional field \"%s\" not found\n",
 1742|  1.15k|			      asn1->name);
 1743|  1.15k|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|  1.15k|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1744|  2.73k|	}
 1745|  50.3k|	if (p[0] == 0 || p[0] == 0xFF || len == 0)
  ------------------
  |  Branch (1745:6): [True: 1.25k, False: 49.0k]
  |  Branch (1745:19): [True: 124, False: 48.9k]
  |  Branch (1745:35): [True: 0, False: 48.9k]
  ------------------
 1746|  1.37k|		return SC_ERROR_ASN1_END_OF_CONTENTS;
  ------------------
  |  |   84|  1.37k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
 1747|       |
 1748|   162k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (1748:16): [True: 125k, False: 36.6k]
  ------------------
 1749|   125k|		entry = &asn1[idx];
 1750|       |
 1751|   125k|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "Looking for '%s', tag 0x%x%s%s\n",
  ------------------
  |  |   70|   125k|#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)
  |  |  ------------------
  |  |  |  | 1752|   125k|			entry->name, entry->tag, choice? ", CHOICE" : "",
  |  |  |  | 1753|   125k|			(entry->flags & SC_ASN1_OPTIONAL)? ", OPTIONAL": "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  148|   125k|#define SC_ASN1_OPTIONAL		0x00000002
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1752|   125k|			entry->name, entry->tag, choice? ", CHOICE" : "",
 1753|   125k|			(entry->flags & SC_ASN1_OPTIONAL)? ", OPTIONAL": "");
 1754|       |
 1755|       |		/* Special case CHOICE has no tag */
 1756|   125k|		if (entry->type == SC_ASN1_CHOICE) {
  ------------------
  |  |  170|   125k|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1756:7): [True: 139, False: 125k]
  ------------------
 1757|    139|			r = asn1_decode(ctx,
 1758|    139|				(struct sc_asn1_entry *) entry->parm,
 1759|    139|				p, left, &p, &left, 1, depth + 1);
 1760|       |			/* When the inner call fails it returns before writing
 1761|       |			 * back to *newp and *len_left, so the caller's p/left are
 1762|       |			 * unchanged.  Swallowing the error for an optional
 1763|       |			 * CHOICE is therefore safe: the next field will be
 1764|       |			 * attempted at the same position. */
 1765|    139|			if (r >= 0 || (entry->flags & SC_ASN1_OPTIONAL))
  ------------------
  |  |  148|    138|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1765:8): [True: 1, False: 138]
  |  Branch (1765:18): [True: 0, False: 138]
  ------------------
 1766|      1|				r = 0;
 1767|    139|			goto decode_ok;
 1768|    139|		}
 1769|       |
 1770|   125k|		obj = sc_asn1_skip_tag(ctx, &p, &left, entry->tag, &objlen);
 1771|   125k|		if (obj == NULL) {
  ------------------
  |  Branch (1771:7): [True: 55.0k, False: 70.7k]
  ------------------
 1772|  55.0k|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "'%s' not present\n", entry->name);
  ------------------
  |  |   70|  55.0k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1773|  55.0k|			if (choice)
  ------------------
  |  Branch (1773:8): [True: 8.85k, False: 46.2k]
  ------------------
 1774|  8.85k|				continue;
 1775|  46.2k|			if (entry->flags & SC_ASN1_OPTIONAL)
  ------------------
  |  |  148|  46.2k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1775:8): [True: 42.2k, False: 3.92k]
  ------------------
 1776|  42.2k|				continue;
 1777|  3.92k|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "mandatory ASN.1 object '%s' not found\n", entry->name);
  ------------------
  |  |   70|  3.92k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1778|  3.92k|			if (left) {
  ------------------
  |  Branch (1778:8): [True: 3.82k, False: 108]
  ------------------
 1779|  3.82k|				u8 line[128], *linep = line;
 1780|  3.82k|				size_t i;
 1781|       |
 1782|  3.82k|				line[0] = 0;
 1783|  38.9k|				for (i = 0; i < 10 && i < left; i++) {
  ------------------
  |  Branch (1783:17): [True: 35.7k, False: 3.21k]
  |  Branch (1783:27): [True: 35.0k, False: 610]
  ------------------
 1784|  35.0k|					sprintf((char *) linep, "%02X ", p[i]);
 1785|  35.0k|					linep += 3;
 1786|  35.0k|				}
 1787|  3.82k|				sc_debug(ctx, SC_LOG_DEBUG_ASN1, "next tag: %s\n", line);
  ------------------
  |  |   70|  3.82k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1788|  3.82k|			}
 1789|  3.92k|			sc_free_entry(asn1);
 1790|  3.92k|			SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  153|  3.92k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  3.92k|	int _ret = r; \
  |  |  155|  3.92k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 3.92k, False: 0]
  |  |  ------------------
  |  |  156|  3.92k|		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|  3.92k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 3.92k, False: 0]
  |  |  ------------------
  |  |  157|  3.92k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  3.92k|	} 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|  3.92k|	return _ret; \
  |  |  163|  3.92k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1791|  3.92k|		}
 1792|  70.7k|		r = asn1_decode_entry(ctx, entry, obj, objlen, depth);
 1793|       |
 1794|  70.8k|decode_ok:
 1795|  70.8k|		if (r)
  ------------------
  |  Branch (1795:7): [True: 1.44k, False: 69.4k]
  ------------------
 1796|  1.44k|			return r;
 1797|  69.4k|		if (choice)
  ------------------
  |  Branch (1797:7): [True: 6.93k, False: 62.4k]
  ------------------
 1798|  6.93k|			break;
 1799|  69.4k| 	}
 1800|  43.5k| 	if (choice && asn1[idx].name == NULL) /* No match */
  ------------------
  |  Branch (1800:7): [True: 7.13k, False: 36.4k]
  |  Branch (1800:17): [True: 202, False: 6.93k]
  ------------------
 1801|    202|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  153|    202|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    202|	int _ret = r; \
  |  |  155|    202|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 202, False: 0]
  |  |  ------------------
  |  |  156|    202|		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|    202|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 202, False: 0]
  |  |  ------------------
  |  |  157|    202|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    202|	} 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|    202|	return _ret; \
  |  |  163|    202|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1802|  43.3k| 	if (newp != NULL)
  ------------------
  |  Branch (1802:7): [True: 14.1k, False: 29.2k]
  ------------------
 1803|  14.1k|		*newp = p;
 1804|  43.3k| 	if (len_left != NULL)
  ------------------
  |  Branch (1804:7): [True: 14.1k, False: 29.2k]
  ------------------
 1805|  14.1k|		*len_left = left;
 1806|  43.3k|	if (choice)
  ------------------
  |  Branch (1806:6): [True: 6.93k, False: 36.4k]
  ------------------
 1807|  6.93k|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, idx);
  ------------------
  |  |  153|  6.93k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  6.93k|	int _ret = r; \
  |  |  155|  6.93k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 154, False: 6.78k]
  |  |  ------------------
  |  |  156|    154|		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: 154]
  |  |  ------------------
  |  |  157|    154|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  6.78k|	} else { \
  |  |  159|  6.78k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|  6.78k|			"returning with: %d\n", _ret); \
  |  |  161|  6.78k|	} \
  |  |  162|  6.93k|	return _ret; \
  |  |  163|  6.93k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1808|  36.4k|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, 0);
  ------------------
  |  |  153|  36.4k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  36.4k|	int _ret = r; \
  |  |  155|  36.4k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 36.4k, False: 0]
  |  |  ------------------
  |  |  156|  36.4k|		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: 36.4k]
  |  |  ------------------
  |  |  157|  36.4k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  36.4k|	} 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|  36.4k|	return _ret; \
  |  |  163|  36.4k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1809|  36.4k|}
asn1.c:sc_free_entry:
 1687|  14.4k|static void sc_free_entry(struct sc_asn1_entry *asn1) {
 1688|  14.4k|	int idx = 0;
 1689|  14.4k|	struct sc_asn1_entry *entry = asn1;
 1690|       |
 1691|  14.4k|	if (!asn1)
  ------------------
  |  Branch (1691:6): [True: 600, False: 13.8k]
  ------------------
 1692|    600|		return;
 1693|       |
 1694|  67.1k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (1694:16): [True: 53.2k, False: 13.8k]
  ------------------
 1695|  53.2k|		entry = &asn1[idx];
 1696|  53.2k|		switch (entry->type) {
 1697|  3.76k|		case SC_ASN1_CHOICE:
  ------------------
  |  |  170|  3.76k|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1697:3): [True: 3.76k, False: 49.5k]
  ------------------
 1698|  10.5k|		case SC_ASN1_STRUCT:
  ------------------
  |  |  169|  10.5k|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1698:3): [True: 6.79k, False: 46.5k]
  ------------------
 1699|  10.5k|			sc_free_entry((struct sc_asn1_entry *) entry->parm);
 1700|  10.5k|			break;
 1701|  11.3k|		case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  11.3k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1701:3): [True: 11.3k, False: 41.9k]
  ------------------
 1702|  11.4k|		case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|  11.4k|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1702:3): [True: 78, False: 53.2k]
  ------------------
 1703|  11.5k|		case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|  11.5k|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1703:3): [True: 73, False: 53.2k]
  ------------------
 1704|  11.7k|		case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|  11.7k|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1704:3): [True: 236, False: 53.0k]
  ------------------
 1705|  12.0k|		case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|  12.0k|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1705:3): [True: 353, False: 52.9k]
  ------------------
 1706|  14.0k|		case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|  14.0k|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1706:3): [True: 1.93k, False: 51.3k]
  ------------------
 1707|  14.0k|			if ((entry->flags & SC_ASN1_ALLOC) && (entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  149|  14.0k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
              			if ((entry->flags & SC_ASN1_ALLOC) && (entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|  1.31k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1707:8): [True: 1.31k, False: 12.7k]
  |  Branch (1707:42): [True: 374, False: 937]
  ------------------
 1708|    374|				u8 **buf = (u8 **)entry->parm;
 1709|    374|				free(*buf);
 1710|    374|				*buf = NULL;
 1711|    374|			}
 1712|  14.0k|			break;
 1713|  28.7k|		default:
  ------------------
  |  Branch (1713:3): [True: 28.7k, False: 24.5k]
  ------------------
 1714|  28.7k|			break;
 1715|  53.2k|		}
 1716|  53.2k|	}
 1717|  13.8k|}
asn1.c:asn1_decode_entry:
 1485|  70.7k|{
 1486|  70.7k|	void *parm = entry->parm;
 1487|  70.7k|	int (*callback_func)(sc_context_t *nctx, void *arg, const u8 *nobj,
 1488|  70.7k|			     size_t nobjlen, int ndepth);
 1489|  70.7k|	size_t *len = (size_t *) entry->arg;
 1490|  70.7k|	int r = 0;
 1491|       |
 1492|  70.7k|	callback_func = parm;
 1493|       |
 1494|  70.7k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sdecoding '%s', raw data:%s%s\n",
  ------------------
  |  |   70|   282k|#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: 23.5k, False: 47.1k]
  |  |  |  Branch (70:115): [True: 23.5k, False: 47.1k]
  |  |  ------------------
  ------------------
 1495|  70.7k|		depth, depth, "", entry->name,
 1496|  70.7k|		sc_dump_hex(obj, objlen > 16  ? 16 : objlen),
 1497|  70.7k|		objlen > 16 ? "..." : "");
 1498|       |
 1499|  70.7k|	switch (entry->type) {
 1500|  18.7k|	case SC_ASN1_STRUCT:
  ------------------
  |  |  169|  18.7k|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1500:2): [True: 18.7k, False: 51.9k]
  ------------------
 1501|  18.7k|		if (parm != NULL)
  ------------------
  |  Branch (1501:7): [True: 13.1k, False: 5.63k]
  ------------------
 1502|  13.1k|			r = asn1_decode(ctx, (struct sc_asn1_entry *) parm, obj,
 1503|  13.1k|				       objlen, NULL, NULL, 0, depth + 1);
 1504|  18.7k|		break;
 1505|    593|	case SC_ASN1_NULL:
  ------------------
  |  |  158|    593|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1505:2): [True: 593, False: 70.1k]
  ------------------
 1506|    593|		break;
 1507|      0|	case SC_ASN1_BOOLEAN:
  ------------------
  |  |  153|      0|#define SC_ASN1_BOOLEAN                 1
  ------------------
  |  Branch (1507:2): [True: 0, False: 70.7k]
  ------------------
 1508|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1508:7): [True: 0, False: 0]
  ------------------
 1509|      0|			if (objlen != 1) {
  ------------------
  |  Branch (1509:8): [True: 0, False: 0]
  ------------------
 1510|      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__
  |  |  ------------------
  ------------------
 1511|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1512|      0|			} else
 1513|      0|				*((int *) parm) = obj[0] ? 1 : 0;
  ------------------
  |  Branch (1513:23): [True: 0, False: 0]
  ------------------
 1514|      0|		}
 1515|      0|		break;
 1516|  3.13k|	case SC_ASN1_INTEGER:
  ------------------
  |  |  154|  3.13k|#define SC_ASN1_INTEGER                 2
  ------------------
  |  Branch (1516:2): [True: 3.13k, False: 67.5k]
  ------------------
 1517|  3.13k|	case SC_ASN1_ENUMERATED:
  ------------------
  |  |  160|  3.13k|#define SC_ASN1_ENUMERATED              10
  ------------------
  |  Branch (1517:2): [True: 0, False: 70.7k]
  ------------------
 1518|  3.13k|		if (parm != NULL) {
  ------------------
  |  Branch (1518:7): [True: 3.13k, False: 0]
  ------------------
 1519|  3.13k|			r = sc_asn1_decode_integer(obj, objlen, (int *) entry->parm, 0);
 1520|  3.13k|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  3.13k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1520:8): [True: 3.09k, False: 38]
  ------------------
 1521|  3.09k|				sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sdecoding '%s' returned %d\n",
  ------------------
  |  |   70|  3.09k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1522|  3.09k|						depth, depth, "", entry->name, *((int *)entry->parm));
 1523|  3.09k|			}
 1524|  3.13k|		}
 1525|  3.13k|		break;
 1526|  2.58k|	case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|  2.58k|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1526:2): [True: 2.58k, False: 68.1k]
  ------------------
 1527|  4.94k|	case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|  4.94k|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1527:2): [True: 2.35k, False: 68.3k]
  ------------------
 1528|  4.94k|		if (parm != NULL) {
  ------------------
  |  Branch (1528:7): [True: 2.58k, False: 2.35k]
  ------------------
 1529|  2.58k|			int invert = entry->type == SC_ASN1_BIT_STRING ? 1 : 0;
  ------------------
  |  |  155|  2.58k|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1529:17): [True: 0, False: 2.58k]
  ------------------
 1530|  2.58k|			if (len == NULL)
  ------------------
  |  Branch (1530:8): [True: 0, False: 2.58k]
  ------------------
 1531|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1532|  2.58k|			if (objlen < 1) {
  ------------------
  |  Branch (1532:8): [True: 15, False: 2.56k]
  ------------------
 1533|     15|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     15|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1534|     15|				break;
 1535|     15|			}
 1536|  2.56k|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|  2.56k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1536:8): [True: 2.56k, False: 0]
  ------------------
 1537|  2.56k|				u8 **buf = (u8 **) parm;
 1538|  2.56k|				if (objlen > 1) {
  ------------------
  |  Branch (1538:9): [True: 2.54k, False: 29]
  ------------------
 1539|  2.54k|					*buf = malloc(objlen-1);
 1540|  2.54k|					if (*buf == NULL) {
  ------------------
  |  Branch (1540:10): [True: 0, False: 2.54k]
  ------------------
 1541|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1542|      0|						break;
 1543|      0|					}
 1544|  2.54k|				} else {
 1545|     29|					*buf = NULL;
 1546|     29|				}
 1547|  2.56k|				*len = objlen-1;
 1548|  2.56k|				parm = *buf;
 1549|  2.56k|			}
 1550|  2.56k|			r = decode_bit_string(obj, objlen, (u8 *) parm, *len, invert, 0);
 1551|  2.56k|			if (r >= 0) {
  ------------------
  |  Branch (1551:8): [True: 2.54k, False: 25]
  ------------------
 1552|  2.54k|				*len = r;
 1553|  2.54k|				r = 0;
 1554|  2.54k|			}
 1555|  2.56k|		}
 1556|  4.92k|		break;
 1557|  4.92k|	case SC_ASN1_BIT_FIELD:
  ------------------
  |  |  171|    132|#define SC_ASN1_BIT_FIELD		131	/* bit string as integer */
  ------------------
  |  Branch (1557:2): [True: 132, False: 70.5k]
  ------------------
 1558|    132|		if (parm != NULL)
  ------------------
  |  Branch (1558:7): [True: 132, False: 0]
  ------------------
 1559|    132|			r = decode_bit_field(obj, objlen, (u8 *) parm, *len, 0);
 1560|    132|		break;
 1561|  20.3k|	case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  20.3k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1561:2): [True: 20.3k, False: 50.3k]
  ------------------
 1562|  20.3k|		if (parm != NULL) {
  ------------------
  |  Branch (1562:7): [True: 20.3k, False: 69]
  ------------------
 1563|  20.3k|			size_t c;
 1564|  20.3k|			if (len == NULL)
  ------------------
  |  Branch (1564:8): [True: 0, False: 20.3k]
  ------------------
 1565|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1566|       |
 1567|       |			/* Strip off padding zero */
 1568|  20.3k|			if ((entry->flags & SC_ASN1_UNSIGNED)
  ------------------
  |  |  150|  20.3k|#define SC_ASN1_UNSIGNED		0x00000008
  ------------------
  |  Branch (1568:8): [True: 2.69k, False: 17.6k]
  ------------------
 1569|  2.69k|					&& objlen > 1 && obj[0] == 0x00) {
  ------------------
  |  Branch (1569:9): [True: 2.61k, False: 74]
  |  Branch (1569:23): [True: 1.56k, False: 1.05k]
  ------------------
 1570|  1.56k|				objlen--;
 1571|  1.56k|				obj++;
 1572|  1.56k|			}
 1573|       |
 1574|       |			/* Allocate buffer if needed */
 1575|  20.3k|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|  20.3k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1575:8): [True: 11.1k, False: 9.19k]
  ------------------
 1576|  11.1k|				u8 **buf = (u8 **) parm;
 1577|  11.1k|				if (objlen > 0) {
  ------------------
  |  Branch (1577:9): [True: 10.9k, False: 151]
  ------------------
 1578|  10.9k|					*buf = malloc(objlen);
 1579|  10.9k|					if (*buf == NULL) {
  ------------------
  |  Branch (1579:10): [True: 0, False: 10.9k]
  ------------------
 1580|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1581|      0|						break;
 1582|      0|					}
 1583|  10.9k|				} else {
 1584|    151|					*buf = NULL;
 1585|    151|				}
 1586|  11.1k|				c = *len = objlen;
 1587|  11.1k|				parm = *buf;
 1588|  11.1k|			} else
 1589|  9.19k|				c = objlen > *len ? *len : objlen;
  ------------------
  |  Branch (1589:9): [True: 265, False: 8.92k]
  ------------------
 1590|       |
 1591|  20.3k|			memcpy(parm, obj, c);
 1592|  20.3k|			*len = c;
 1593|  20.3k|		}
 1594|  20.3k|		break;
 1595|  20.3k|	case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|      0|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1595:2): [True: 0, False: 70.7k]
  ------------------
 1596|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1596:7): [True: 0, False: 0]
  ------------------
 1597|      0|			size_t c;
 1598|      0|			if (len == NULL)
  ------------------
  |  Branch (1598:8): [True: 0, False: 0]
  ------------------
 1599|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1600|      0|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|      0|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1600:8): [True: 0, False: 0]
  ------------------
 1601|      0|				u8 **buf = (u8 **) parm;
 1602|      0|				if (objlen > 0) {
  ------------------
  |  Branch (1602:9): [True: 0, False: 0]
  ------------------
 1603|      0|					*buf = malloc(objlen);
 1604|      0|					if (*buf == NULL) {
  ------------------
  |  Branch (1604:10): [True: 0, False: 0]
  ------------------
 1605|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1606|      0|						break;
 1607|      0|					}
 1608|      0|				} else {
 1609|      0|					*buf = NULL;
 1610|      0|				}
 1611|      0|				c = *len = objlen;
 1612|      0|				parm = *buf;
 1613|      0|			} else
 1614|      0|				c = objlen > *len ? *len : objlen;
  ------------------
  |  Branch (1614:9): [True: 0, False: 0]
  ------------------
 1615|       |
 1616|      0|			memcpy(parm, obj, c);
 1617|      0|			*len = c;
 1618|      0|		}
 1619|      0|		break;
 1620|  11.7k|	case SC_ASN1_OBJECT:
  ------------------
  |  |  159|  11.7k|#define SC_ASN1_OBJECT                  6
  ------------------
  |  Branch (1620:2): [True: 11.7k, False: 59.0k]
  ------------------
 1621|  11.7k|		if (parm != NULL)
  ------------------
  |  Branch (1621:7): [True: 11.6k, False: 64]
  ------------------
 1622|  11.6k|			r = sc_asn1_decode_object_id(obj, objlen, (struct sc_object_id *) parm);
 1623|  11.7k|		break;
 1624|      3|	case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|      3|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1624:2): [True: 3, False: 70.7k]
  ------------------
 1625|    107|	case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|    107|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1625:2): [True: 104, False: 70.6k]
  ------------------
 1626|    107|		if (parm != NULL) {
  ------------------
  |  Branch (1626:7): [True: 106, False: 1]
  ------------------
 1627|    106|			if (len == NULL)
  ------------------
  |  Branch (1627:8): [True: 0, False: 106]
  ------------------
 1628|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1629|    106|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|    106|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1629:8): [True: 0, False: 106]
  ------------------
 1630|      0|				u8 **buf = (u8 **) parm;
 1631|      0|				*buf = malloc(objlen+1);
 1632|      0|				if (*buf == NULL) {
  ------------------
  |  Branch (1632:9): [True: 0, False: 0]
  ------------------
 1633|      0|					r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1634|      0|					break;
 1635|      0|				}
 1636|      0|				*len = objlen+1;
 1637|      0|				parm = *buf;
 1638|      0|			}
 1639|    106|			r = sc_asn1_decode_utf8string(obj, objlen, (u8 *) parm, len);
 1640|    106|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|    106|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1640:8): [True: 0, False: 106]
  ------------------
 1641|      0|				*len -= 1;
 1642|      0|			}
 1643|    106|		}
 1644|    107|		break;
 1645|  3.06k|	case SC_ASN1_PATH:
  ------------------
  |  |  174|  3.06k|#define SC_ASN1_PATH			256
  ------------------
  |  Branch (1645:2): [True: 3.06k, False: 67.6k]
  ------------------
 1646|  3.06k|		if (entry->parm != NULL)
  ------------------
  |  Branch (1646:7): [True: 3.06k, False: 0]
  ------------------
 1647|  3.06k|			r = asn1_decode_path(ctx, obj, objlen, (sc_path_t *) parm, depth);
 1648|  3.06k|		break;
 1649|      6|	case SC_ASN1_PKCS15_ID:
  ------------------
  |  |  175|      6|#define SC_ASN1_PKCS15_ID		257
  ------------------
  |  Branch (1649:2): [True: 6, False: 70.7k]
  ------------------
 1650|      6|		if (entry->parm != NULL) {
  ------------------
  |  Branch (1650:7): [True: 6, False: 0]
  ------------------
 1651|      6|			struct sc_pkcs15_id *id = (struct sc_pkcs15_id *) parm;
 1652|      6|			size_t c = objlen > sizeof(id->value) ? sizeof(id->value) : objlen;
  ------------------
  |  Branch (1652:15): [True: 0, False: 6]
  ------------------
 1653|       |
 1654|      6|			memcpy(id->value, obj, c);
 1655|      6|			id->len = c;
 1656|      6|		}
 1657|      6|		break;
 1658|     14|	case SC_ASN1_PKCS15_OBJECT:
  ------------------
  |  |  176|     14|#define SC_ASN1_PKCS15_OBJECT		258
  ------------------
  |  Branch (1658:2): [True: 14, False: 70.6k]
  ------------------
 1659|     14|		if (entry->parm != NULL)
  ------------------
  |  Branch (1659:7): [True: 13, False: 1]
  ------------------
 1660|     13|			r = asn1_decode_p15_object(ctx, obj, objlen, (struct sc_asn1_pkcs15_object *) parm, depth);
 1661|     14|		break;
 1662|  5.10k|	case SC_ASN1_ALGORITHM_ID:
  ------------------
  |  |  177|  5.10k|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
  |  Branch (1662:2): [True: 5.10k, False: 65.6k]
  ------------------
 1663|  5.10k|		if (entry->parm != NULL)
  ------------------
  |  Branch (1663:7): [True: 5.10k, False: 0]
  ------------------
 1664|  5.10k|			r = sc_asn1_decode_algorithm_id(ctx, obj, objlen, (struct sc_algorithm_id *) parm, depth);
 1665|  5.10k|		break;
 1666|      8|	case SC_ASN1_SE_INFO:
  ------------------
  |  |  178|      8|#define SC_ASN1_SE_INFO			260
  ------------------
  |  Branch (1666:2): [True: 8, False: 70.7k]
  ------------------
 1667|      8|		if (entry->parm != NULL)
  ------------------
  |  Branch (1667:7): [True: 8, False: 0]
  ------------------
 1668|      8|			r = asn1_decode_se_info(ctx, obj, objlen, (sc_pkcs15_sec_env_info_t ***)entry->parm, len, depth);
 1669|      8|		break;
 1670|  2.74k|	case SC_ASN1_CALLBACK:
  ------------------
  |  |  181|  2.74k|#define SC_ASN1_CALLBACK		384
  ------------------
  |  Branch (1670:2): [True: 2.74k, False: 67.9k]
  ------------------
 1671|  2.74k|		if (entry->parm != NULL)
  ------------------
  |  Branch (1671:7): [True: 2.74k, False: 0]
  ------------------
 1672|  2.74k|			r = callback_func(ctx, entry->arg, obj, objlen, depth);
 1673|  2.74k|		break;
 1674|      0|	default:
  ------------------
  |  Branch (1674:2): [True: 0, False: 70.7k]
  ------------------
 1675|      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__
  |  |  ------------------
  ------------------
 1676|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1677|  70.7k|	}
 1678|  70.7k|	if (r) {
  ------------------
  |  Branch (1678:6): [True: 1.30k, False: 69.4k]
  ------------------
 1679|  1.30k|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "decoding of ASN.1 object '%s' failed: %s\n", entry->name,
  ------------------
  |  |   70|  1.30k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1680|  1.30k|		      sc_strerror(r));
 1681|  1.30k|		return r;
 1682|  1.30k|	}
 1683|  69.4k|	entry->flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|  69.4k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
 1684|  69.4k|	return 0;
 1685|  70.7k|}
asn1.c:decode_bit_field:
  686|    132|{
  687|    132|	u8		data[sizeof(unsigned int)];
  688|    132|	unsigned int	field = 0;
  689|    132|	int		i, n;
  690|       |
  691|    132|	if (outlen != sizeof(data))
  ------------------
  |  Branch (691:6): [True: 0, False: 132]
  ------------------
  692|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  693|       |
  694|    132|	n = decode_bit_string(inbuf, inlen, data, sizeof(data), 1, strict);
  695|    132|	if (n < 0)
  ------------------
  |  Branch (695:6): [True: 25, False: 107]
  ------------------
  696|     25|		return n;
  697|       |
  698|    137|	for (i = 0; i < n; i += 8) {
  ------------------
  |  Branch (698:14): [True: 30, False: 107]
  ------------------
  699|     30|		field |= ((unsigned int) data[i/8] << i);
  700|     30|	}
  701|    107|	memcpy(outbuf, &field, outlen);
  702|    107|	return 0;
  703|    132|}
asn1.c:sc_asn1_decode_utf8string:
  962|    106|{
  963|    106|	if (inlen+1 > *outlen)
  ------------------
  |  Branch (963:6): [True: 0, False: 106]
  ------------------
  964|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  965|    106|	*outlen = inlen+1;
  966|    106|	memcpy(out, inbuf, inlen);
  967|    106|	out[inlen] = 0;
  968|    106|	return 0;
  969|    106|}
asn1.c:asn1_decode_path:
 1144|  3.06k|{
 1145|  3.06k|	int idx, count, r;
 1146|  3.06k|	struct sc_asn1_entry asn1_path_ext[3], asn1_path[5];
 1147|  3.06k|	unsigned char path_value[SC_MAX_PATH_SIZE], aid_value[SC_MAX_AID_SIZE];
 1148|  3.06k|	size_t path_len = sizeof(path_value), aid_len = sizeof(aid_value);
 1149|       |
 1150|  3.06k|	memset(path, 0, sizeof(struct sc_path));
 1151|       |
 1152|  3.06k|	sc_copy_asn1_entry(c_asn1_path_ext, asn1_path_ext);
 1153|  3.06k|	sc_copy_asn1_entry(c_asn1_path, asn1_path);
 1154|       |
 1155|  3.06k|	sc_format_asn1_entry(asn1_path_ext + 0, aid_value, &aid_len, 0);
 1156|  3.06k|	sc_format_asn1_entry(asn1_path_ext + 1, path_value, &path_len, 0);
 1157|       |
 1158|  3.06k|	sc_format_asn1_entry(asn1_path + 0, path_value, &path_len, 0);
 1159|  3.06k|	sc_format_asn1_entry(asn1_path + 1, &idx, NULL, 0);
 1160|  3.06k|	sc_format_asn1_entry(asn1_path + 2, &count, NULL, 0);
 1161|  3.06k|	sc_format_asn1_entry(asn1_path + 3, asn1_path_ext, NULL, 0);
 1162|       |
 1163|  3.06k|	r = asn1_decode(ctx, asn1_path, in, len, NULL, NULL, 0, depth + 1);
 1164|  3.06k|	if (r)
  ------------------
  |  Branch (1164:6): [True: 39, False: 3.02k]
  ------------------
 1165|     39|		return r;
 1166|       |
 1167|  3.02k|	if (asn1_path[3].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|  3.02k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1167:6): [True: 0, False: 3.02k]
  ------------------
 1168|       |		/* extended path present: set 'path' and 'aid' */
 1169|      0|		memcpy(path->aid.value, aid_value, aid_len);
 1170|      0|		path->aid.len = aid_len;
 1171|       |
 1172|      0|		memcpy(path->value, path_value, path_len);
 1173|      0|		path->len = path_len;
 1174|      0|	}
 1175|  3.02k|	else if (asn1_path[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|  3.02k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1175:11): [True: 2.91k, False: 112]
  ------------------
 1176|       |		/* path present: set 'path' */
 1177|  2.91k|		memcpy(path->value, path_value, path_len);
 1178|  2.91k|		path->len = path_len;
 1179|  2.91k|	}
 1180|    112|	else   {
 1181|       |		/* failed if both 'path' and 'pathExtended' are absent */
 1182|    112|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|    112|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1183|    112|	}
 1184|       |
 1185|  2.91k|	if (path->len == 2)
  ------------------
  |  Branch (1185:6): [True: 1.22k, False: 1.68k]
  ------------------
 1186|  1.22k|		path->type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  1.22k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1187|  1.68k|	else   if (path->aid.len && path->len > 2)
  ------------------
  |  Branch (1187:13): [True: 0, False: 1.68k]
  |  Branch (1187:30): [True: 0, False: 0]
  ------------------
 1188|      0|		path->type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|      0|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
 1189|  1.68k|	else
 1190|  1.68k|		path->type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  1.68k|#define SC_PATH_TYPE_PATH		2
  ------------------
 1191|       |
 1192|  2.91k|	if ((asn1_path[1].flags & SC_ASN1_PRESENT) && (asn1_path[2].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|  2.91k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
              	if ((asn1_path[1].flags & SC_ASN1_PRESENT) && (asn1_path[2].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|     32|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1192:6): [True: 32, False: 2.88k]
  |  Branch (1192:48): [True: 0, False: 32]
  ------------------
 1193|      0|		path->index = idx;
 1194|      0|		path->count = count;
 1195|      0|	}
 1196|  2.91k|	else {
 1197|  2.91k|		path->index = 0;
 1198|  2.91k|		path->count = -1;
 1199|  2.91k|	}
 1200|       |
 1201|  2.91k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.91k|#define SC_SUCCESS				0
  ------------------
 1202|  3.02k|}
asn1.c:asn1_decode_p15_object:
 1390|     13|{
 1391|     13|	struct sc_pkcs15_object *p15_obj = obj->p15_obj;
 1392|     13|	struct sc_asn1_entry asn1_c_attr[6], asn1_p15_obj[5];
 1393|     13|	struct sc_asn1_entry asn1_ac_rules[SC_PKCS15_MAX_ACCESS_RULES + 1], asn1_ac_rule[SC_PKCS15_MAX_ACCESS_RULES][3];
 1394|     13|	size_t flags_len = sizeof(p15_obj->flags);
 1395|     13|	size_t label_len = sizeof(p15_obj->label);
 1396|     13|	size_t access_mode_len = sizeof(p15_obj->access_rules[0].access_mode);
 1397|     13|	int r, ii;
 1398|       |
 1399|    117|	for (ii=0; ii<SC_PKCS15_MAX_ACCESS_RULES; ii++)
  ------------------
  |  |   42|    117|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (1399:13): [True: 104, False: 13]
  ------------------
 1400|    104|		sc_copy_asn1_entry(c_asn1_access_control_rule, asn1_ac_rule[ii]);
 1401|     13|	sc_copy_asn1_entry(c_asn1_access_control_rules, asn1_ac_rules);
 1402|       |
 1403|       |
 1404|     13|	sc_copy_asn1_entry(c_asn1_com_obj_attr, asn1_c_attr);
 1405|     13|	sc_copy_asn1_entry(c_asn1_p15_obj, asn1_p15_obj);
 1406|     13|	sc_format_asn1_entry(asn1_c_attr + 0, p15_obj->label, &label_len, 0);
 1407|     13|	sc_format_asn1_entry(asn1_c_attr + 1, &p15_obj->flags, &flags_len, 0);
 1408|     13|	sc_format_asn1_entry(asn1_c_attr + 2, &p15_obj->auth_id, NULL, 0);
 1409|     13|	sc_format_asn1_entry(asn1_c_attr + 3, &p15_obj->user_consent, NULL, 0);
 1410|       |
 1411|    117|	for (ii=0; ii<SC_PKCS15_MAX_ACCESS_RULES; ii++)   {
  ------------------
  |  |   42|    117|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (1411:13): [True: 104, False: 13]
  ------------------
 1412|    104|		sc_format_asn1_entry(asn1_ac_rule[ii] + 0, &p15_obj->access_rules[ii].access_mode, &access_mode_len, 0);
 1413|    104|		sc_format_asn1_entry(asn1_ac_rule[ii] + 1, &p15_obj->access_rules[ii].auth_id, NULL, 0);
 1414|    104|		sc_format_asn1_entry(asn1_ac_rules + ii, asn1_ac_rule[ii], NULL, 0);
 1415|    104|	}
 1416|     13|	sc_format_asn1_entry(asn1_c_attr + 4, asn1_ac_rules, NULL, 0);
 1417|       |
 1418|     13|	sc_format_asn1_entry(asn1_p15_obj + 0, asn1_c_attr, NULL, 0);
 1419|     13|	sc_format_asn1_entry(asn1_p15_obj + 1, obj->asn1_class_attr, NULL, 0);
 1420|     13|	sc_format_asn1_entry(asn1_p15_obj + 2, obj->asn1_subclass_attr, NULL, 0);
 1421|     13|	sc_format_asn1_entry(asn1_p15_obj + 3, obj->asn1_type_attr, NULL, 0);
 1422|       |
 1423|     13|	r = asn1_decode(ctx, asn1_p15_obj, in, len, NULL, NULL, 0, depth + 1);
 1424|     13|	return r;
 1425|     13|}
asn1.c:asn1_decode_se_info:
 1238|      8|{
 1239|      8|	struct sc_pkcs15_sec_env_info **ses;
 1240|      8|	const unsigned char *ptr = obj;
 1241|      8|	size_t idx, ptrlen = objlen;
 1242|      8|	int ret;
 1243|       |
 1244|      8|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|      8|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      8|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      8|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      8|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1245|       |
 1246|      8|	ses = calloc(SC_MAX_SE_NUM, sizeof(sc_pkcs15_sec_env_info_t *));
  ------------------
  |  |   51|      8|#define SC_MAX_SE_NUM			8
  ------------------
 1247|      8|	if (ses == NULL) {
  ------------------
  |  Branch (1247:6): [True: 0, False: 8]
  ------------------
 1248|      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]
  |  |  ------------------
  ------------------
 1249|      0|	}
 1250|       |
 1251|      8|	for (idx=0; idx < SC_MAX_SE_NUM && ptrlen; )   {
  ------------------
  |  |   51|     16|#define SC_MAX_SE_NUM			8
  ------------------
  |  Branch (1251:14): [True: 8, False: 0]
  |  Branch (1251:37): [True: 1, False: 7]
  ------------------
 1252|      1|		struct sc_asn1_entry asn1_se[2];
 1253|      1|		struct sc_asn1_entry asn1_se_info[4];
 1254|      1|		struct sc_pkcs15_sec_env_info si;
 1255|       |
 1256|      1|		sc_copy_asn1_entry(c_asn1_se, asn1_se);
 1257|      1|		sc_copy_asn1_entry(c_asn1_se_info, asn1_se_info);
 1258|       |
 1259|      1|		si.aid.len = sizeof(si.aid.value);
 1260|      1|		sc_format_asn1_entry(asn1_se_info + 0, &si.se, NULL, 0);
 1261|      1|		sc_format_asn1_entry(asn1_se_info + 1, &si.owner, NULL, 0);
 1262|      1|		sc_format_asn1_entry(asn1_se_info + 2, &si.aid.value, &si.aid.len, 0);
 1263|      1|		sc_format_asn1_entry(asn1_se + 0, asn1_se_info, NULL, 0);
 1264|       |
 1265|      1|		ret = asn1_decode(ctx, asn1_se, ptr, ptrlen, &ptr, &ptrlen, 0, depth+1);
 1266|      1|		if (ret != SC_SUCCESS)
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (1266:7): [True: 1, False: 0]
  ------------------
 1267|      1|			goto err;
 1268|      0|		if (!(asn1_se_info[1].flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1268:7): [True: 0, False: 0]
  ------------------
 1269|      0|			sc_init_oid(&si.owner);
 1270|       |
 1271|      0|		ses[idx] = calloc(1, sizeof(sc_pkcs15_sec_env_info_t));
 1272|      0|		if (ses[idx] == NULL) {
  ------------------
  |  Branch (1272:7): [True: 0, False: 0]
  ------------------
 1273|      0|			ret = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1274|      0|			goto err;
 1275|      0|		}
 1276|       |
 1277|      0|		memcpy(ses[idx], &si, sizeof(struct sc_pkcs15_sec_env_info));
 1278|      0|		idx++;
 1279|      0|	}
 1280|       |
 1281|      7|	*se  = ses;
 1282|      7|	*num = idx;
 1283|      7|	ret = SC_SUCCESS;
  ------------------
  |  |   28|      7|#define SC_SUCCESS				0
  ------------------
 1284|      8|err:
 1285|      8|	if (ret != SC_SUCCESS) {
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  |  Branch (1285:6): [True: 1, False: 7]
  ------------------
 1286|      1|		size_t i;
 1287|      1|		for (i = 0; i < idx; i++)
  ------------------
  |  Branch (1287:15): [True: 0, False: 1]
  ------------------
 1288|      0|			if (ses[i])
  ------------------
  |  Branch (1288:8): [True: 0, False: 0]
  ------------------
 1289|      0|				free(ses[i]);
 1290|      1|		free(ses);
 1291|      1|	}
 1292|       |
 1293|      8|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, ret);
  ------------------
  |  |  153|      8|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      8|	int _ret = r; \
  |  |  155|      8|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 8, False: 0]
  |  |  ------------------
  |  |  156|      8|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1, False: 7]
  |  |  ------------------
  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      8|	} 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|      8|	return _ret; \
  |  |  163|      8|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1294|      8|}
asn1.c:asn1_encode:
 2038|  24.1k|{
 2039|  24.1k|	int r, idx = 0;
 2040|  24.1k|	u8 *obj = NULL, *buf = NULL, *tmp;
 2041|  24.1k|	size_t total = 0, objsize;
 2042|       |
 2043|  24.1k|	if (asn1 == NULL) {
  ------------------
  |  Branch (2043:6): [True: 0, False: 24.1k]
  ------------------
 2044|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2045|      0|	}
 2046|       |
 2047|  60.7k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (2047:16): [True: 36.6k, False: 24.1k]
  ------------------
 2048|  36.6k|		r = asn1_encode_entry(ctx, &asn1[idx], &obj, &objsize, depth);
 2049|  36.6k|		if (r) {
  ------------------
  |  Branch (2049:7): [True: 54, False: 36.5k]
  ------------------
 2050|     54|			if (obj)
  ------------------
  |  Branch (2050:8): [True: 0, False: 54]
  ------------------
 2051|      0|				free(obj);
 2052|     54|			if (buf)
  ------------------
  |  Branch (2052:8): [True: 18, False: 36]
  ------------------
 2053|     18|				free(buf);
 2054|     54|			return r;
 2055|     54|		}
 2056|       |		/* in case of an empty (optional) element continue with
 2057|       |		 * the next asn1 element */
 2058|  36.5k|		if (!objsize)
  ------------------
  |  Branch (2058:7): [True: 10.8k, False: 25.7k]
  ------------------
 2059|  10.8k|			continue;
 2060|  25.7k|		tmp = (u8 *) realloc(buf, total + objsize);
 2061|  25.7k|		if (!tmp) {
  ------------------
  |  Branch (2061:7): [True: 0, False: 25.7k]
  ------------------
 2062|      0|			if (obj)
  ------------------
  |  Branch (2062:8): [True: 0, False: 0]
  ------------------
 2063|      0|				free(obj);
 2064|      0|			if (buf)
  ------------------
  |  Branch (2064:8): [True: 0, False: 0]
  ------------------
 2065|      0|				free(buf);
 2066|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2067|      0|		}
 2068|  25.7k|		buf = tmp;
 2069|  25.7k|		memcpy(buf + total, obj, objsize);
 2070|  25.7k|		free(obj);
 2071|  25.7k|		obj = NULL;
 2072|  25.7k|		total += objsize;
 2073|  25.7k|	}
 2074|  24.1k|	*ptr = buf;
 2075|  24.1k|	*size = total;
 2076|  24.1k|	return 0;
 2077|  24.1k|}
asn1.c:asn1_encode_entry:
 1825|  36.6k|{
 1826|  36.6k|	void *parm = entry->parm;
 1827|  36.6k|	int (*callback_func)(sc_context_t *nctx, void *arg, u8 **nobj,
 1828|  36.6k|			     size_t *nobjlen, int ndepth);
 1829|  36.6k|	const size_t *len = (const size_t *) entry->arg;
 1830|  36.6k|	int r = 0;
 1831|  36.6k|	u8 * buf = NULL;
 1832|  36.6k|	size_t buflen = 0;
 1833|       |
 1834|  36.6k|	callback_func = parm;
 1835|       |
 1836|  36.6k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sencoding '%s'%s\n",
  ------------------
  |  |   70|  36.6k|#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)
  |  |  ------------------
  |  |  |  | 1837|  36.6k|	       	depth, depth, "", entry->name,
  |  |  |  | 1838|  36.6k|		(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|  36.6k|#define SC_ASN1_PRESENT			0x00000001
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1837|  36.6k|	       	depth, depth, "", entry->name,
 1838|  36.6k|		(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
 1839|  36.6k|	if (!(entry->flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|  36.6k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1839:6): [True: 10.8k, False: 25.8k]
  ------------------
 1840|  10.8k|		goto no_object;
 1841|  25.8k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*stype=%d, tag=0x%02x, parm=%p, len=%zu",
  ------------------
  |  |   70|  51.6k|#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: 16.2k, False: 9.53k]
  |  |  ------------------
  ------------------
 1842|  25.8k|			depth, depth, "", entry->type, entry->tag, parm, len ? *len : 0);
 1843|       |
 1844|  25.8k|	if (entry->type == SC_ASN1_CHOICE) {
  ------------------
  |  |  170|  25.8k|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1844:6): [True: 0, False: 25.8k]
  ------------------
 1845|      0|		const struct sc_asn1_entry *list, *choice = NULL;
 1846|       |
 1847|      0|		list = (const struct sc_asn1_entry *) parm;
 1848|      0|		while (list->name != NULL) {
  ------------------
  |  Branch (1848:10): [True: 0, False: 0]
  ------------------
 1849|      0|			if (list->flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1849:8): [True: 0, False: 0]
  ------------------
 1850|      0|				if (choice) {
  ------------------
  |  Branch (1850:9): [True: 0, False: 0]
  ------------------
 1851|      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__
  |  |  ------------------
  ------------------
 1852|      0|						"ASN.1 problem: more than "
 1853|      0|						"one CHOICE when encoding %s: "
 1854|      0|						"%s and %s both present\n",
 1855|      0|						entry->name,
 1856|      0|						choice->name,
 1857|      0|						list->name);
 1858|      0|					return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1859|      0|				}
 1860|      0|				choice = list;
 1861|      0|			}
 1862|      0|			list++;
 1863|      0|		}
 1864|      0|		if (choice == NULL)
  ------------------
  |  Branch (1864:7): [True: 0, False: 0]
  ------------------
 1865|      0|			goto no_object;
 1866|      0|		return asn1_encode_entry(ctx, choice, obj, objlen, depth + 1);
 1867|      0|	}
 1868|       |
 1869|  25.8k|	if (entry->type != SC_ASN1_NULL && parm == NULL) {
  ------------------
  |  |  158|  51.6k|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1869:6): [True: 25.5k, False: 286]
  |  Branch (1869:37): [True: 21, False: 25.5k]
  ------------------
 1870|     21|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "unexpected parm == NULL\n");
  ------------------
  |  |   70|     21|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1871|     21|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     21|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1872|     21|	}
 1873|       |
 1874|  25.8k|	switch (entry->type) {
 1875|  1.36k|	case SC_ASN1_STRUCT:
  ------------------
  |  |  169|  1.36k|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1875:2): [True: 1.36k, False: 24.4k]
  ------------------
 1876|  1.36k|		r = asn1_encode(ctx, (const struct sc_asn1_entry *) parm, &buf,
 1877|  1.36k|				&buflen, depth + 1);
 1878|  1.36k|		break;
 1879|    286|	case SC_ASN1_NULL:
  ------------------
  |  |  158|    286|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1879:2): [True: 286, False: 25.5k]
  ------------------
 1880|    286|		buf = NULL;
 1881|    286|		buflen = 0;
 1882|    286|		break;
 1883|      0|	case SC_ASN1_BOOLEAN:
  ------------------
  |  |  153|      0|#define SC_ASN1_BOOLEAN                 1
  ------------------
  |  Branch (1883:2): [True: 0, False: 25.8k]
  ------------------
 1884|      0|		buf = malloc(1);
 1885|      0|		if (buf == NULL) {
  ------------------
  |  Branch (1885:7): [True: 0, False: 0]
  ------------------
 1886|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1887|      0|			break;
 1888|      0|		}
 1889|      0|		buf[0] = *((int *) parm) ? 0xFF : 0;
  ------------------
  |  Branch (1889:12): [True: 0, False: 0]
  ------------------
 1890|      0|		buflen = 1;
 1891|      0|		break;
 1892|      0|	case SC_ASN1_INTEGER:
  ------------------
  |  |  154|      0|#define SC_ASN1_INTEGER                 2
  ------------------
  |  Branch (1892:2): [True: 0, False: 25.8k]
  ------------------
 1893|      0|	case SC_ASN1_ENUMERATED:
  ------------------
  |  |  160|      0|#define SC_ASN1_ENUMERATED              10
  ------------------
  |  Branch (1893:2): [True: 0, False: 25.8k]
  ------------------
 1894|      0|		r = asn1_encode_integer(*((int *) entry->parm), &buf, &buflen);
 1895|      0|		break;
 1896|  1.13k|	case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|  1.13k|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1896:2): [True: 1.13k, False: 24.6k]
  ------------------
 1897|  1.13k|	case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|  1.13k|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1897:2): [True: 0, False: 25.8k]
  ------------------
 1898|  1.13k|		if (len != NULL) {
  ------------------
  |  Branch (1898:7): [True: 1.13k, False: 0]
  ------------------
 1899|  1.13k|			if (entry->type == SC_ASN1_BIT_STRING)
  ------------------
  |  |  155|  1.13k|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1899:8): [True: 0, False: 1.13k]
  ------------------
 1900|      0|				r = encode_bit_string((const u8 *) parm, *len, &buf, &buflen, 1);
 1901|  1.13k|			else
 1902|  1.13k|				r = encode_bit_string((const u8 *) parm, *len, &buf, &buflen, 0);
 1903|  1.13k|		} else {
 1904|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1905|      0|		}
 1906|  1.13k|		break;
 1907|      0|	case SC_ASN1_BIT_FIELD:
  ------------------
  |  |  171|      0|#define SC_ASN1_BIT_FIELD		131	/* bit string as integer */
  ------------------
  |  Branch (1907:2): [True: 0, False: 25.8k]
  ------------------
 1908|      0|		if (len != NULL) {
  ------------------
  |  Branch (1908:7): [True: 0, False: 0]
  ------------------
 1909|      0|			r = encode_bit_field((const u8 *) parm, *len, &buf, &buflen);
 1910|      0|		} else {
 1911|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1912|      0|		}
 1913|      0|		break;
 1914|      0|	case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|      0|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1914:2): [True: 0, False: 25.8k]
  ------------------
 1915|  15.1k|	case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  15.1k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1915:2): [True: 15.1k, False: 10.6k]
  ------------------
 1916|  15.1k|	case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|  15.1k|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1916:2): [True: 0, False: 25.8k]
  ------------------
 1917|  15.1k|		if (len != NULL) {
  ------------------
  |  Branch (1917:7): [True: 15.1k, False: 0]
  ------------------
 1918|  15.1k|			buf = malloc(*len + 1);
 1919|  15.1k|			if (buf == NULL) {
  ------------------
  |  Branch (1919:8): [True: 0, False: 15.1k]
  ------------------
 1920|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1921|      0|				break;
 1922|      0|			}
 1923|  15.1k|			buflen = 0;
 1924|       |			/* If the integer is supposed to be unsigned, insert
 1925|       |			 * a padding byte if the MSB is one */
 1926|  15.1k|			if ((entry->flags & SC_ASN1_UNSIGNED)
  ------------------
  |  |  150|  15.1k|#define SC_ASN1_UNSIGNED		0x00000008
  ------------------
  |  Branch (1926:8): [True: 434, False: 14.7k]
  ------------------
 1927|    434|					&& (((u8 *) parm)[0] & 0x80)) {
  ------------------
  |  Branch (1927:9): [True: 223, False: 211]
  ------------------
 1928|    223|				buf[buflen++] = 0x00;
 1929|    223|			}
 1930|  15.1k|			memcpy(buf + buflen, parm, *len);
 1931|  15.1k|			buflen += *len;
 1932|  15.1k|		} else {
 1933|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1934|      0|		}
 1935|  15.1k|		break;
 1936|  15.1k|	case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|      0|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1936:2): [True: 0, False: 25.8k]
  ------------------
 1937|      0|		if (len != NULL) {
  ------------------
  |  Branch (1937:7): [True: 0, False: 0]
  ------------------
 1938|      0|			buf = malloc(*len);
 1939|      0|			if (buf == NULL) {
  ------------------
  |  Branch (1939:8): [True: 0, False: 0]
  ------------------
 1940|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1941|      0|				break;
 1942|      0|			}
 1943|      0|			memcpy(buf, parm, *len);
 1944|      0|			buflen = *len;
 1945|      0|		} else {
 1946|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1947|      0|		}
 1948|      0|		break;
 1949|  6.75k|	case SC_ASN1_OBJECT:
  ------------------
  |  |  159|  6.75k|#define SC_ASN1_OBJECT                  6
  ------------------
  |  Branch (1949:2): [True: 6.75k, False: 19.0k]
  ------------------
 1950|  6.75k|		r = sc_asn1_encode_object_id(&buf, &buflen, (struct sc_object_id *) parm);
 1951|  6.75k|		break;
 1952|      0|	case SC_ASN1_PATH:
  ------------------
  |  |  174|      0|#define SC_ASN1_PATH			256
  ------------------
  |  Branch (1952:2): [True: 0, False: 25.8k]
  ------------------
 1953|      0|		r = asn1_encode_path(ctx, (const sc_path_t *) parm, &buf, &buflen, depth, entry->flags);
 1954|      0|		break;
 1955|      0|	case SC_ASN1_PKCS15_ID:
  ------------------
  |  |  175|      0|#define SC_ASN1_PKCS15_ID		257
  ------------------
  |  Branch (1955:2): [True: 0, False: 25.8k]
  ------------------
 1956|      0|		{
 1957|      0|			const struct sc_pkcs15_id *id = (const struct sc_pkcs15_id *) parm;
 1958|       |
 1959|      0|			buf = malloc(id->len);
 1960|      0|			if (buf == NULL) {
  ------------------
  |  Branch (1960:8): [True: 0, False: 0]
  ------------------
 1961|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1962|      0|				break;
 1963|      0|			}
 1964|      0|			memcpy(buf, id->value, id->len);
 1965|      0|			buflen = id->len;
 1966|      0|		}
 1967|      0|		break;
 1968|      0|	case SC_ASN1_PKCS15_OBJECT:
  ------------------
  |  |  176|      0|#define SC_ASN1_PKCS15_OBJECT		258
  ------------------
  |  Branch (1968:2): [True: 0, False: 25.8k]
  ------------------
 1969|      0|		r = asn1_encode_p15_object(ctx, (const struct sc_asn1_pkcs15_object *) parm, &buf, &buflen, depth);
 1970|      0|		break;
 1971|  1.13k|	case SC_ASN1_ALGORITHM_ID:
  ------------------
  |  |  177|  1.13k|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
  |  Branch (1971:2): [True: 1.13k, False: 24.6k]
  ------------------
 1972|  1.13k|		r = sc_asn1_encode_algorithm_id(ctx, &buf, &buflen, (const struct sc_algorithm_id *) parm, depth);
 1973|  1.13k|		break;
 1974|      0|	case SC_ASN1_SE_INFO:
  ------------------
  |  |  178|      0|#define SC_ASN1_SE_INFO			260
  ------------------
  |  Branch (1974:2): [True: 0, False: 25.8k]
  ------------------
 1975|      0|		if (!len)
  ------------------
  |  Branch (1975:7): [True: 0, False: 0]
  ------------------
 1976|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1977|      0|		r = asn1_encode_se_info(ctx, (struct sc_pkcs15_sec_env_info **)parm, *len, &buf, &buflen, depth);
 1978|      0|		break;
 1979|      0|	case SC_ASN1_CALLBACK:
  ------------------
  |  |  181|      0|#define SC_ASN1_CALLBACK		384
  ------------------
  |  Branch (1979:2): [True: 0, False: 25.8k]
  ------------------
 1980|      0|		r = callback_func(ctx, entry->arg, &buf, &buflen, depth);
 1981|      0|		break;
 1982|      0|	default:
  ------------------
  |  Branch (1982:2): [True: 0, False: 25.8k]
  ------------------
 1983|      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__
  |  |  ------------------
  ------------------
 1984|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1985|  25.8k|	}
 1986|  25.8k|	if (r) {
  ------------------
  |  Branch (1986:6): [True: 27, False: 25.7k]
  ------------------
 1987|     27|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "encoding of ASN.1 object '%s' failed: %s\n", entry->name,
  ------------------
  |  |   70|     27|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1988|     27|		      sc_strerror(r));
 1989|     27|		if (buf)
  ------------------
  |  Branch (1989:7): [True: 0, False: 27]
  ------------------
 1990|      0|			free(buf);
 1991|     27|		return r;
 1992|     27|	}
 1993|       |
 1994|       |	/* Treatment of OPTIONAL elements:
 1995|       |	 *  -	if the encoding has 0 length, and the element is OPTIONAL,
 1996|       |	 *	we don't write anything (unless it's an ASN1 NULL and the
 1997|       |	 *      SC_ASN1_PRESENT flag is set).
 1998|       |	 *  -	if the encoding has 0 length, but the element is non-OPTIONAL,
 1999|       |	 *	constructed, we write a empty element (e.g. a SEQUENCE of
 2000|       |	 *      length 0). In case of an ASN1 NULL just write the tag and
 2001|       |	 *      length (i.e. 0x05,0x00).
 2002|       |	 *  -	any other empty objects are considered bogus
 2003|       |	 */
 2004|  36.5k|no_object:
 2005|  36.5k|	if (!buflen && entry->flags & SC_ASN1_OPTIONAL && !(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  148|  47.6k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
              	if (!buflen && entry->flags & SC_ASN1_OPTIONAL && !(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|  11.1k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (2005:6): [True: 11.1k, False: 25.4k]
  |  Branch (2005:17): [True: 11.1k, False: 6]
  |  Branch (2005:52): [True: 10.8k, False: 286]
  ------------------
 2006|       |		/* This happens when we try to encode e.g. the
 2007|       |		 * subClassAttributes, which may be empty */
 2008|  10.8k|		*obj = NULL;
 2009|  10.8k|		*objlen = 0;
 2010|  10.8k|		r = 0;
 2011|  25.7k|	} else if (!buflen && (entry->flags & SC_ASN1_EMPTY_ALLOWED)) {
  ------------------
  |  |  151|    292|#define SC_ASN1_EMPTY_ALLOWED           0x00000010
  ------------------
  |  Branch (2011:13): [True: 292, False: 25.4k]
  |  Branch (2011:24): [True: 0, False: 292]
  ------------------
 2012|      0|		*obj = NULL;
 2013|      0|		*objlen = 0;
 2014|      0|		r = asn1_write_element(ctx, entry->tag, buf, buflen, obj, objlen);
 2015|      0|		if (r)
  ------------------
  |  Branch (2015:7): [True: 0, False: 0]
  ------------------
 2016|      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__
  |  |  ------------------
  ------------------
 2017|  25.7k|	} else if (buflen || entry->type == SC_ASN1_NULL || entry->tag & SC_ASN1_CONS) {
  ------------------
  |  |  158|  26.0k|#define SC_ASN1_NULL                    5
  ------------------
              	} else if (buflen || entry->type == SC_ASN1_NULL || entry->tag & SC_ASN1_CONS) {
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (2017:13): [True: 25.4k, False: 292]
  |  Branch (2017:23): [True: 286, False: 6]
  |  Branch (2017:54): [True: 0, False: 6]
  ------------------
 2018|  25.7k|		r = asn1_write_element(ctx, entry->tag, buf, buflen, obj, objlen);
 2019|  25.7k|		if (r)
  ------------------
  |  Branch (2019:7): [True: 0, False: 25.7k]
  ------------------
 2020|      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__
  |  |  ------------------
  ------------------
 2021|  25.7k|					sc_strerror(r));
 2022|  25.7k|	} else if (!(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|      6|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (2022:13): [True: 0, False: 6]
  ------------------
 2023|      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__
  |  |  ------------------
  ------------------
 2024|      0|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2025|      6|	} else {
 2026|      6|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "cannot encode empty non-optional ASN.1 object\n");
  ------------------
  |  |   70|      6|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2027|      6|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      6|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2028|      6|	}
 2029|  36.5k|	if (buf)
  ------------------
  |  Branch (2029:6): [True: 25.4k, False: 11.1k]
  ------------------
 2030|  25.4k|		free(buf);
 2031|  36.5k|	if (r >= 0)
  ------------------
  |  Branch (2031:6): [True: 36.5k, False: 6]
  ------------------
 2032|  36.5k|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*slength of encoded item=%zu", depth, depth, "", *objlen);
  ------------------
  |  |   70|  36.5k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2033|  36.5k|	return r;
 2034|  25.8k|}
asn1.c:encode_bit_string:
  646|  1.13k|{
  647|  1.13k|	const u8 *in = inbuf;
  648|  1.13k|	u8 *out;
  649|  1.13k|	size_t bytes, skipped = 0;
  650|       |
  651|  1.13k|	bytes = BYTES4BITS(bits_left) + 1;
  ------------------
  |  |  145|  1.13k|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  652|  1.13k|	*outbuf = out = malloc(bytes);
  653|  1.13k|	if (out == NULL)
  ------------------
  |  Branch (653:6): [True: 0, False: 1.13k]
  ------------------
  654|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  655|  1.13k|	*outlen = bytes;
  656|  1.13k|	out += 1;
  657|  77.3k|	while (bits_left) {
  ------------------
  |  Branch (657:9): [True: 76.2k, False: 1.13k]
  ------------------
  658|  76.2k|		size_t i, bits_to_go = 8;
  659|       |
  660|  76.2k|		*out = 0;
  661|  76.2k|		if (bits_left < 8) {
  ------------------
  |  Branch (661:7): [True: 0, False: 76.2k]
  ------------------
  662|      0|			bits_to_go = bits_left;
  663|      0|			skipped = 8 - bits_left;
  664|      0|		}
  665|  76.2k|		if (invert) {
  ------------------
  |  Branch (665:7): [True: 0, False: 76.2k]
  ------------------
  666|      0|			for (i = 0; i < bits_to_go; i++)
  ------------------
  |  Branch (666:16): [True: 0, False: 0]
  ------------------
  667|      0|				*out |= ((*in >> i) & 1) << (7 - i);
  668|  76.2k|		} else {
  669|  76.2k|			*out = *in;
  670|  76.2k|			if (bits_left < 8)
  ------------------
  |  Branch (670:8): [True: 0, False: 76.2k]
  ------------------
  671|      0|				return SC_ERROR_NOT_SUPPORTED; /* FIXME */
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  672|  76.2k|		}
  673|  76.2k|		bits_left -= bits_to_go;
  674|  76.2k|		out++, in++;
  675|  76.2k|	}
  676|  1.13k|	out = *outbuf;
  677|  1.13k|	out[0] = skipped;
  678|  1.13k|	return 0;
  679|  1.13k|}

sc_aux_data_free:
  193|  3.87k|{
  194|  3.87k|	if (data == NULL || *data == NULL)
  ------------------
  |  Branch (194:6): [True: 0, False: 3.87k]
  |  Branch (194:22): [True: 3.87k, False: 0]
  ------------------
  195|  3.87k|		return;
  196|       |
  197|      0|	switch((*data)->type) {
  198|      0|	case SC_AUX_DATA_TYPE_MD_CMAP_RECORD:
  ------------------
  |  |   36|      0|#define SC_AUX_DATA_TYPE_MD_CMAP_RECORD	    0x01
  ------------------
  |  Branch (198:2): [True: 0, False: 0]
  ------------------
  199|      0|		free(*data);
  200|      0|		break;
  201|      0|	default:
  ------------------
  |  Branch (201:2): [True: 0, False: 0]
  ------------------
  202|      0|		break;
  203|      0|	}
  204|       |
  205|      0|	*data = NULL;
  206|      0|}

sc_get_asepcos_driver:
 1086|  17.0k|{
 1087|  17.0k|	return sc_get_driver();
 1088|  17.0k|}
card-asepcos.c:sc_get_driver:
 1064|  17.0k|{
 1065|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1065:6): [True: 1, False: 17.0k]
  ------------------
 1066|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1067|  17.0k|	asepcos_ops = *iso_ops;
 1068|  17.0k|	asepcos_ops.match_card        = asepcos_match_card;
 1069|  17.0k|	asepcos_ops.init              = asepcos_init;
 1070|  17.0k|	asepcos_ops.select_file       = asepcos_select_file;
 1071|  17.0k|	asepcos_ops.set_security_env  = asepcos_set_security_env;
 1072|  17.0k|	asepcos_ops.decipher          = asepcos_decipher;
 1073|  17.0k|	asepcos_ops.compute_signature = asepcos_compute_signature;
 1074|  17.0k|	asepcos_ops.create_file       = asepcos_create_file;
 1075|  17.0k|	asepcos_ops.delete_file       = asepcos_delete_file;
 1076|  17.0k|	asepcos_ops.list_files        = asepcos_list_files;
 1077|  17.0k|	asepcos_ops.card_ctl          = asepcos_card_ctl;
 1078|  17.0k|	asepcos_ops.pin_cmd           = asepcos_pin_cmd;
 1079|  17.0k|	asepcos_ops.logout            = asepcos_logout;
 1080|  17.0k|	asepcos_ops.card_reader_lock_obtained = asepcos_card_reader_lock_obtained;
 1081|       |
 1082|  17.0k|	return &asepcos_drv;
 1083|  17.0k|}
card-asepcos.c:asepcos_match_card:
   47|  17.0k|{
   48|  17.0k|	int i = _sc_match_atr(card, asepcos_atrs, &card->type);
   49|  17.0k|	if (i < 0)
  ------------------
  |  Branch (49:6): [True: 17.0k, False: 0]
  ------------------
   50|  17.0k|		return 0;
   51|      0|	return 1;
   52|  17.0k|}

sc_get_atrust_acos_driver:
  814|  17.0k|{
  815|  17.0k|	return sc_get_driver();
  816|  17.0k|}
card-atrust-acos.c:sc_get_driver:
  789|  17.0k|{
  790|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  791|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (791:6): [True: 1, False: 17.0k]
  ------------------
  792|      1|		iso_ops = iso_drv->ops;
  793|       |
  794|  17.0k|	atrust_acos_ops = *iso_drv->ops;
  795|  17.0k|	atrust_acos_ops.match_card = atrust_acos_match_card;
  796|  17.0k|	atrust_acos_ops.init   = atrust_acos_init;
  797|  17.0k|	atrust_acos_ops.finish = atrust_acos_finish;
  798|  17.0k|	atrust_acos_ops.select_file = atrust_acos_select_file;
  799|  17.0k|	atrust_acos_ops.check_sw    = atrust_acos_check_sw;
  800|  17.0k|	atrust_acos_ops.create_file = NULL;
  801|  17.0k|	atrust_acos_ops.delete_file = NULL;
  802|  17.0k|	atrust_acos_ops.set_security_env  = atrust_acos_set_security_env;
  803|  17.0k|	atrust_acos_ops.compute_signature = atrust_acos_compute_signature;
  804|  17.0k|	atrust_acos_ops.decipher    = atrust_acos_decipher;
  805|  17.0k|	atrust_acos_ops.card_ctl    = atrust_acos_card_ctl;
  806|  17.0k|	atrust_acos_ops.logout      = atrust_acos_logout;
  807|       |
  808|  17.0k|	return &atrust_acos_drv;
  809|  17.0k|}
card-atrust-acos.c:atrust_acos_match_card:
   76|  17.0k|{
   77|  17.0k|	int		i, match = 0;
   78|       |
   79|       |
   80|  84.1k|	for (i = 0; atrust_acos_atrs[i] != NULL; i++)
  ------------------
  |  Branch (80:14): [True: 67.5k, False: 16.6k]
  ------------------
   81|  67.5k|	{
   82|  67.5k|		u8 defatr[SC_MAX_ATR_SIZE];
   83|  67.5k|		size_t len = sizeof(defatr);
   84|  67.5k|		const char *atrp = atrust_acos_atrs[i];
   85|       |
   86|  67.5k|		if (sc_hex_to_bin(atrp, defatr, &len))
  ------------------
  |  Branch (86:7): [True: 0, False: 67.5k]
  ------------------
   87|      0|			continue;
   88|       |		/* we may only verify part of ATR since */
   89|       |		/* part of the hist chars is variable */
   90|  67.5k|		if (len > card->atr.len)
  ------------------
  |  Branch (90:7): [True: 25.8k, False: 41.6k]
  ------------------
   91|  25.8k|			continue;
   92|  41.6k|		if (memcmp(card->atr.value, defatr, len) != 0)
  ------------------
  |  Branch (92:7): [True: 41.2k, False: 409]
  ------------------
   93|  41.2k|			continue;
   94|       |
   95|    409|		match = 1;
   96|    409|		card->name = atrust_acos_names[i];
   97|       |
   98|    409|		break;
   99|  41.6k|    }
  100|  17.0k|	return match;
  101|  17.0k|}
card-atrust-acos.c:atrust_acos_init:
  106|    409|{
  107|    409|	unsigned int flags;
  108|    409|	atrust_acos_ex_data *ex_data;
  109|       |
  110|    409|	ex_data = calloc(1, sizeof(atrust_acos_ex_data));
  111|    409|	if (ex_data == NULL)
  ------------------
  |  Branch (111:6): [True: 0, False: 409]
  ------------------
  112|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  113|       |
  114|    409|	card->cla  = 0x00;
  115|    409|	card->drv_data = (void *)ex_data;
  116|       |
  117|       |	/* set the supported algorithm */
  118|       |
  119|    409|	flags = SC_ALGORITHM_RSA_PAD_PKCS1
  ------------------
  |  |  111|    409|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    409|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    409|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  120|    409|		| SC_ALGORITHM_RSA_HASH_NONE
  ------------------
  |  |  133|    409|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  121|    409|		| SC_ALGORITHM_RSA_HASH_SHA1
  ------------------
  |  |  134|    409|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  122|    409|		| SC_ALGORITHM_RSA_HASH_MD5
  ------------------
  |  |  135|    409|#define SC_ALGORITHM_RSA_HASH_MD5	0x00000400
  ------------------
  123|    409|		| SC_ALGORITHM_RSA_HASH_RIPEMD160
  ------------------
  |  |  137|    409|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
  124|    409|		| SC_ALGORITHM_RSA_HASH_MD5_SHA1;
  ------------------
  |  |  136|    409|#define SC_ALGORITHM_RSA_HASH_MD5_SHA1	0x00000800
  ------------------
  125|       |
  126|    409|	if (card->name != NULL && !strcmp(card->name, ACOS_EMV_A05))
  ------------------
  |  |   37|    409|#define ACOS_EMV_A05		"A-TRUST ACOS A05"
  ------------------
  |  Branch (126:6): [True: 409, False: 0]
  |  Branch (126:28): [True: 221, False: 188]
  ------------------
  127|    221|		flags |= SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  138|    221|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  128|       |
  129|    409|	_sc_card_add_rsa_alg(card, 1536, flags, 0x10001);
  130|       |
  131|       |	/* we need read_binary&friends with max 128 bytes per read */
  132|    409|	card->max_send_size = 128;
  133|    409|	card->max_recv_size = 128;
  134|       |
  135|    409|	return 0;
  136|    409|}
card-atrust-acos.c:atrust_acos_finish:
  141|    409|{
  142|    409|	if (card->drv_data)
  ------------------
  |  Branch (142:6): [True: 409, False: 0]
  ------------------
  143|    409|		free((atrust_acos_ex_data *)card->drv_data);
  144|    409|	return 0;
  145|    409|}
card-atrust-acos.c:atrust_acos_select_file:
  364|  12.2k|{
  365|  12.2k|	u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  366|  12.2k|	int    r;
  367|  12.2k|	size_t i, pathlen;
  368|       |
  369|  12.2k|	memcpy(path, in_path->value, in_path->len);
  370|  12.2k|	pathlen = in_path->len;
  371|       |
  372|  12.2k|	if (in_path->type == SC_PATH_TYPE_FILE_ID) {
  ------------------
  |  |  117|  12.2k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (372:6): [True: 41, False: 12.1k]
  ------------------
  373|       |		/* SELECT EF/DF with ID */
  374|       |		/* Select with 2byte File-ID */
  375|     41|		if (pathlen != 2)
  ------------------
  |  Branch (375:7): [True: 0, False: 41]
  ------------------
  376|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  377|     41|		return atrust_acos_select_fid(card, path[0], path[1], file_out);
  378|  12.1k|	} else if (in_path->type == SC_PATH_TYPE_DF_NAME) {
  ------------------
  |  |  118|  12.1k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (378:13): [True: 836, False: 11.3k]
  ------------------
  379|       |		/* SELECT DF with AID */
  380|       |		/* Select with 1-16byte Application-ID */
  381|    836|		return atrust_acos_select_aid(card, pathbuf, pathlen, file_out);
  382|  11.3k|	} else if (in_path->type == SC_PATH_TYPE_PATH) {
  ------------------
  |  |  119|  11.3k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (382:13): [True: 11.3k, False: 0]
  ------------------
  383|  11.3k|		u8 n_pathbuf[SC_MAX_PATH_SIZE];
  384|       |
  385|       |		/* Select with path (sequence of File-IDs) */
  386|       |		/* ACOS only supports one
  387|       |		 * level of subdirectories, therefore a path is
  388|       |		 * at most 3 FID long (the last one being the FID
  389|       |		 * of a EF) => pathlen must be even and less than 6
  390|       |		 */
  391|  11.3k|		if (pathlen%2 != 0 || pathlen > 6 || pathlen <= 0)
  ------------------
  |  Branch (391:7): [True: 0, False: 11.3k]
  |  Branch (391:25): [True: 405, False: 10.9k]
  |  Branch (391:40): [True: 283, False: 10.6k]
  ------------------
  392|    688|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  153|    688|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    688|	int _ret = r; \
  |  |  155|    688|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 688, False: 0]
  |  |  ------------------
  |  |  156|    688|		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|    688|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 688, False: 0]
  |  |  ------------------
  |  |  157|    688|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    688|	} 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|    688|	return _ret; \
  |  |  163|    688|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  393|       |		/* if pathlen == 6 then the first FID must be MF (== 3F00) */
  394|  10.6k|		if (pathlen == 6 && ( path[0] != 0x3f || path[1] != 0x00 ))
  ------------------
  |  Branch (394:7): [True: 372, False: 10.2k]
  |  Branch (394:25): [True: 10, False: 362]
  |  Branch (394:44): [True: 11, False: 351]
  ------------------
  395|     21|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     21|	int _ret = r; \
  |  |  155|     21|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 21, False: 0]
  |  |  ------------------
  |  |  156|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 21, False: 0]
  |  |  ------------------
  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     21|	} 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|     21|	return _ret; \
  |  |  163|     21|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  396|       |
  397|       |		/* unify path (the first FID should be MF) */
  398|  10.6k|		if (path[0] != 0x3f || path[1] != 0x00)
  ------------------
  |  Branch (398:7): [True: 142, False: 10.4k]
  |  Branch (398:26): [True: 10, False: 10.4k]
  ------------------
  399|    152|		{
  400|    152|			n_pathbuf[0] = 0x3f;
  401|    152|			n_pathbuf[1] = 0x00;
  402|    152|			memcpy(n_pathbuf+2, path, pathlen);
  403|    152|			path = n_pathbuf;
  404|    152|			pathlen += 2;
  405|    152|		}
  406|       |
  407|  11.9k|		for (i = 0; i < pathlen - 2; i += 2) {
  ------------------
  |  Branch (407:15): [True: 10.6k, False: 1.24k]
  ------------------
  408|  10.6k|			r = atrust_acos_select_fid(card, path[i], path[i + 1], NULL);
  409|  10.6k|			LOG_TEST_RET(card->ctx, r, "SELECT FILE (DF-ID) failed");
  ------------------
  |  |  174|  10.6k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  10.6k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  10.6k|	int _ret = (r); \
  |  |  |  |  168|  10.6k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9.39k, False: 1.29k]
  |  |  |  |  ------------------
  |  |  |  |  169|  9.39k|		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|  9.39k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  9.39k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  9.39k|		return _ret; \
  |  |  |  |  172|  9.39k|	} \
  |  |  |  |  173|  10.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.29k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  410|  10.6k|		}
  411|  1.24k|		return atrust_acos_select_fid(card, path[pathlen - 2], path[pathlen - 1], file_out);
  412|  10.6k|	} else
  413|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  414|  12.2k|}
card-atrust-acos.c:atrust_acos_select_fid:
  282|  11.9k|{
  283|  11.9k|	sc_apdu_t apdu;
  284|  11.9k|	u8 data[] = {id_hi & 0xff, id_lo & 0xff};
  285|  11.9k|	u8 resp[SC_MAX_APDU_BUFFER_SIZE];
  286|  11.9k|	int bIsDF = 0, r;
  287|       |
  288|       |	/* request FCI to distinguish between EFs and DFs */
  289|  11.9k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  11.9k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  290|  11.9k|	apdu.resp = (u8*)resp;
  291|  11.9k|	apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|  11.9k|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
  292|  11.9k|	apdu.le = 256;
  293|  11.9k|	apdu.lc = 2;
  294|  11.9k|	apdu.data = (u8*)data;
  295|  11.9k|	apdu.datalen = 2;
  296|       |
  297|  11.9k|	r = sc_transmit_apdu(card, &apdu);
  298|  11.9k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  11.9k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  11.9k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  11.9k|	int _ret = (r); \
  |  |  |  |  168|  11.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 703, False: 11.2k]
  |  |  |  |  ------------------
  |  |  |  |  169|    703|		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|    703|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    703|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    703|		return _ret; \
  |  |  |  |  172|    703|	} \
  |  |  |  |  173|  11.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  299|       |
  300|  11.2k|	if (apdu.p2 == 0x00 && apdu.sw1 == 0x62 && apdu.sw2 == 0x84 ) {
  ------------------
  |  Branch (300:6): [True: 11.2k, False: 0]
  |  Branch (300:25): [True: 101, False: 11.1k]
  |  Branch (300:45): [True: 16, False: 85]
  ------------------
  301|       |		/* no FCI => we have a DF (see comment in process_fci()) */
  302|     16|		bIsDF = 1;
  303|     16|		apdu.p2 = 0x0C;
  304|     16|		apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|     16|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  305|     16|		apdu.resplen = 0;
  306|     16|		apdu.le = 0;
  307|     16|		r = sc_transmit_apdu(card, &apdu);
  308|     16|		LOG_TEST_RET(card->ctx, r, "APDU re-transmit failed");
  ------------------
  |  |  174|     16|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     16|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     16|	int _ret = (r); \
  |  |  |  |  168|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  309|  11.2k|    	} else if (apdu.sw1 == 0x61 || (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)) {
  ------------------
  |  Branch (309:17): [True: 0, False: 11.2k]
  |  Branch (309:38): [True: 2.51k, False: 8.74k]
  |  Branch (309:58): [True: 2.43k, False: 78]
  ------------------
  310|       |		/* SELECT returned some data (possible FCI) =>
  311|       |		 * try a READ BINARY to see if a EF is selected */
  312|  2.43k|		sc_apdu_t apdu2;
  313|  2.43k|		u8 resp2[2];
  314|  2.43k|		sc_format_apdu(card, &apdu2, SC_APDU_CASE_2_SHORT, 0xB0, 0, 0);
  ------------------
  |  |  292|  2.43k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  315|  2.43k|		apdu2.resp = (u8*)resp2;
  316|  2.43k|		apdu2.resplen = 2;
  317|  2.43k|		apdu2.le = 1;
  318|  2.43k|		apdu2.lc = 0;
  319|  2.43k|		r = sc_transmit_apdu(card, &apdu2);
  320|  2.43k|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.43k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.43k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.43k|	int _ret = (r); \
  |  |  |  |  168|  2.43k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 200, False: 2.23k]
  |  |  |  |  ------------------
  |  |  |  |  169|    200|		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|    200|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    200|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    200|		return _ret; \
  |  |  |  |  172|    200|	} \
  |  |  |  |  173|  2.43k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  321|  2.23k|		if (apdu2.sw1 == 0x69 && apdu2.sw2 == 0x86)
  ------------------
  |  Branch (321:7): [True: 58, False: 2.17k]
  |  Branch (321:28): [True: 32, False: 26]
  ------------------
  322|       |			/* no current EF is selected => we have a DF */
  323|     32|			bIsDF = 1;
  324|  2.23k|	}
  325|       |
  326|  11.0k|	if (apdu.sw1 != 0x61 && (apdu.sw1 != 0x90 || apdu.sw2 != 0x00))
  ------------------
  |  Branch (326:6): [True: 11.0k, False: 0]
  |  Branch (326:27): [True: 8.75k, False: 2.31k]
  |  Branch (326:47): [True: 78, False: 2.23k]
  ------------------
  327|  8.82k|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|  8.82k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  8.82k|	int _ret = r; \
  |  |  155|  8.82k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 8.82k, False: 0]
  |  |  ------------------
  |  |  156|  8.82k|		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|  8.82k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 8.82k, False: 0]
  |  |  ------------------
  |  |  157|  8.82k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  8.82k|	} 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|  8.82k|	return _ret; \
  |  |  163|  8.82k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  328|       |
  329|  2.23k|	if (file_out) {
  ------------------
  |  Branch (329:6): [True: 921, False: 1.31k]
  ------------------
  330|    921|		sc_file_t *file = sc_file_new();
  331|    921|		if (!file)
  ------------------
  |  Branch (331:7): [True: 0, False: 921]
  ------------------
  332|    921|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  333|    921|		file->id = (id_hi << 8) + id_lo;
  334|       |
  335|    921|		if (bIsDF) {
  ------------------
  |  Branch (335:7): [True: 13, False: 908]
  ------------------
  336|       |			/* we have a DF */
  337|     13|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     13|#define SC_FILE_TYPE_DF			0x04
  ------------------
  338|     13|			file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|     13|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  339|     13|			file->size = 0;
  340|     13|			file->namelen = 0;
  341|     13|			file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|     13|#define SC_FILE_MAGIC			0x14426950
  ------------------
  342|     13|			*file_out = file;
  343|    908|		} else {
  344|       |			/* ok, assume we have a EF */
  345|    908|			r = process_fci(card->ctx, file, apdu.resp,
  346|    908|					apdu.resplen);
  347|    908|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    908|#define SC_SUCCESS				0
  ------------------
  |  Branch (347:8): [True: 408, False: 500]
  ------------------
  348|    408|				sc_file_free(file);
  349|    408|				return r;
  350|    408|			}
  351|       |
  352|    500|			*file_out = file;
  353|    500|		}
  354|    921|	}
  355|       |
  356|  1.82k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|  1.82k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  1.82k|	int _ret = r; \
  |  |  155|  1.82k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1.82k, False: 0]
  |  |  ------------------
  |  |  156|  1.82k|		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: 1.82k]
  |  |  ------------------
  |  |  157|  1.82k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  1.82k|	} 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|  1.82k|	return _ret; \
  |  |  163|  1.82k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  357|  1.82k|}
card-atrust-acos.c:process_fci:
  151|    908|{
  152|       |
  153|    908|	size_t taglen, len = buflen;
  154|    908|	const u8 *tag = NULL, *p;
  155|       |
  156|    908|	sc_log(ctx,  "processing FCI bytes\n");
  ------------------
  |  |   71|    908|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  157|       |
  158|    908|	if (buflen < 2)
  ------------------
  |  Branch (158:6): [True: 108, False: 800]
  ------------------
  159|    108|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    108|#define SC_ERROR_INTERNAL			-1400
  ------------------
  160|    800|	if (buf[0] != 0x6f)					/* FCI template */
  ------------------
  |  Branch (160:6): [True: 289, False: 511]
  ------------------
  161|    289|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|    289|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  162|    511|	len = (size_t)buf[1];
  163|    511|	if (buflen - 2 < len)
  ------------------
  |  Branch (163:6): [True: 11, False: 500]
  ------------------
  164|     11|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     11|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  165|    500|	p = buf + 2;
  166|       |
  167|       |	/* defaults */
  168|    500|	file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    500|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  169|    500|	file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|    500|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  170|    500|	file->shareable = 0;
  171|    500|	file->record_length = 0;
  172|    500|	file->size = 0;
  173|       |
  174|       |	/* get file size */
  175|    500|	tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
  176|    500|	if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (176:6): [True: 225, False: 275]
  |  Branch (176:21): [True: 216, False: 9]
  ------------------
  177|    216|		int bytes = (tag[0] << 8) + tag[1];
  178|    216|		sc_log(ctx,  "  bytes in file: %d\n", bytes);
  ------------------
  |  |   71|    216|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  179|    216|		file->size = bytes;
  180|    216|	}
  181|       |
  182|       |	/* get file type */
  183|    500|  	tag = sc_asn1_find_tag(ctx, p, len, 0x82, &taglen);
  184|    500|	if (tag != NULL) {
  ------------------
  |  Branch (184:6): [True: 75, False: 425]
  ------------------
  185|     75|		const char *type = "unknown";
  186|     75|		const char *structure = "unknown";
  187|       |
  188|     75|		if (taglen == 1 && tag[0] == 0x01) {
  ------------------
  |  Branch (188:7): [True: 39, False: 36]
  |  Branch (188:22): [True: 23, False: 16]
  ------------------
  189|       |			/* transparent EF */
  190|     23|			type = "working EF";
  191|     23|			structure = "transparent";
  192|     23|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     23|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  193|     23|			file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     23|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  194|     52|		} else if (taglen == 1 && tag[0] == 0x11) {
  ------------------
  |  Branch (194:14): [True: 16, False: 36]
  |  Branch (194:29): [True: 1, False: 15]
  ------------------
  195|       |			/* object EF */
  196|      1|			type = "working EF";
  197|      1|			structure = "object";
  198|      1|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      1|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  199|      1|			file->ef_structure = SC_FILE_EF_TRANSPARENT; /* TODO */
  ------------------
  |  |  221|      1|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  200|     51|		} else if (taglen == 3 && tag[1] == 0x21) {
  ------------------
  |  Branch (200:14): [True: 27, False: 24]
  |  Branch (200:29): [True: 19, False: 8]
  ------------------
  201|     19|			type = "working EF";
  202|     19|			file->record_length = tag[2];
  203|     19|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     19|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  204|       |			/* linear fixed, cyclic or compute */
  205|     19|			switch ( tag[0] )
  206|     19|			{
  207|      7|				case 0x02:
  ------------------
  |  Branch (207:5): [True: 7, False: 12]
  ------------------
  208|      7|					structure = "linear fixed";
  209|      7|					file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|      7|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  210|      7|					break;
  211|      3|				case 0x07:
  ------------------
  |  Branch (211:5): [True: 3, False: 16]
  ------------------
  212|      3|					structure = "cyclic";
  213|      3|					file->ef_structure = SC_FILE_EF_CYCLIC;
  ------------------
  |  |  226|      3|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  214|      3|					break;
  215|      3|				case 0x17:
  ------------------
  |  Branch (215:5): [True: 3, False: 16]
  ------------------
  216|      3|					structure = "compute";
  217|      3|					file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      3|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  218|      3|					break;
  219|      6|				default:
  ------------------
  |  Branch (219:5): [True: 6, False: 13]
  ------------------
  220|      6|					structure = "unknown";
  221|      6|					file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      6|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  222|      6|					file->record_length = 0;
  223|      6|					break;
  224|     19|			}
  225|     19|		}
  226|       |
  227|     75|	 	sc_log(ctx,  "  type: %s\n", type);
  ------------------
  |  |   71|     75|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  228|     75|		sc_log(ctx,  "  EF structure: %s\n", structure);
  ------------------
  |  |   71|     75|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  229|     75|	}
  230|    500|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|    500|#define SC_FILE_MAGIC			0x14426950
  ------------------
  231|       |
  232|    500|	return SC_SUCCESS;
  ------------------
  |  |   28|    500|#define SC_SUCCESS				0
  ------------------
  233|    500|}
card-atrust-acos.c:atrust_acos_select_aid:
  240|    836|{
  241|    836|	sc_apdu_t apdu;
  242|    836|	int r;
  243|    836|	size_t i = 0;
  244|       |
  245|    836|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x04, 0x0C);
  ------------------
  |  |  293|    836|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  246|    836|	apdu.lc = len;
  247|    836|	apdu.data = (u8*)aid;
  248|    836|	apdu.datalen = len;
  249|    836|	apdu.resplen = 0;
  250|    836|	apdu.le = 0;
  251|    836|	r = sc_transmit_apdu(card, &apdu);
  252|    836|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    836|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    836|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    836|	int _ret = (r); \
  |  |  |  |  168|    836|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 22, False: 814]
  |  |  |  |  ------------------
  |  |  |  |  169|     22|		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|     22|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     22|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     22|		return _ret; \
  |  |  |  |  172|     22|	} \
  |  |  |  |  173|    836|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 814]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  253|       |
  254|       |	/* check return value */
  255|    814|	if (!(apdu.sw1 == 0x90 && apdu.sw2 == 0x00) && apdu.sw1 != 0x61)
  ------------------
  |  Branch (255:8): [True: 296, False: 518]
  |  Branch (255:28): [True: 253, False: 43]
  |  Branch (255:49): [True: 561, False: 0]
  ------------------
  256|    561|    		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|    561|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    561|	int _ret = r; \
  |  |  155|    561|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 561, False: 0]
  |  |  ------------------
  |  |  156|    561|		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|    561|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 561, False: 0]
  |  |  ------------------
  |  |  157|    561|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    561|	} 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|    561|	return _ret; \
  |  |  163|    561|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  257|       |
  258|    253|	if (file_out) {
  ------------------
  |  Branch (258:6): [True: 0, False: 253]
  ------------------
  259|      0|		sc_file_t *file = sc_file_new();
  260|      0|		if (!file)
  ------------------
  |  Branch (260:7): [True: 0, False: 0]
  ------------------
  261|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|      0|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  263|      0|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      0|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  264|      0|		file->path.len = 0;
  265|      0|		file->size = 0;
  266|       |		/* AID */
  267|      0|		for (i = 0; i < len; i++)
  ------------------
  |  Branch (267:15): [True: 0, False: 0]
  ------------------
  268|      0|			file->name[i] = aid[i];
  269|      0|		file->namelen = len;
  270|      0|		file->id = 0x0000;
  271|      0|		file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|      0|#define SC_FILE_MAGIC			0x14426950
  ------------------
  272|      0|		*file_out = file;
  273|      0|	}
  274|    253|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|    253|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    253|	int _ret = r; \
  |  |  155|    253|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 253, False: 0]
  |  |  ------------------
  |  |  156|    253|		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: 253]
  |  |  ------------------
  |  |  157|    253|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    253|	} 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|    253|	return _ret; \
  |  |  163|    253|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  275|    253|}
card-atrust-acos.c:atrust_acos_check_sw:
  693|  13.3k|{
  694|       |
  695|  13.3k|	sc_log(card->ctx,  "sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
  ------------------
  |  |   71|  13.3k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  696|       |
  697|  13.3k|	if (sw1 == 0x90 && sw2 == 0x00)
  ------------------
  |  Branch (697:6): [True: 3.28k, False: 10.1k]
  |  Branch (697:21): [True: 2.39k, False: 889]
  ------------------
  698|  2.39k|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.39k|#define SC_SUCCESS				0
  ------------------
  699|  10.9k|	if (sw1 == 0x63 && (sw2 & ~0x0fU) == 0xc0 )
  ------------------
  |  Branch (699:6): [True: 134, False: 10.8k]
  |  Branch (699:21): [True: 35, False: 99]
  ------------------
  700|     35|	{
  701|     35|		sc_log(card->ctx,  "Verification failed (remaining tries: %d)\n",
  ------------------
  |  |   71|     35|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  702|     35|		(sw2 & 0x0f));
  703|     35|		return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|     35|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  704|     35|	}
  705|       |
  706|       |	/* iso error */
  707|  10.9k|	return iso_ops->check_sw(card, sw1, sw2);
  708|  10.9k|}
card-atrust-acos.c:atrust_acos_card_ctl:
  748|    243|{
  749|       |
  750|    243|	switch (cmd)
  751|    243|	{
  752|     78|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (752:2): [True: 78, False: 165]
  ------------------
  753|     78|		return acos_get_serialnr(card, (sc_serial_number_t *)ptr);
  754|    165|	default:
  ------------------
  |  Branch (754:2): [True: 165, False: 78]
  ------------------
  755|    165|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    165|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  756|    243|	}
  757|    243|}
card-atrust-acos.c:acos_get_serialnr:
  713|     78|{
  714|     78|	int r;
  715|     78|	u8  rbuf[SC_MAX_APDU_BUFFER_SIZE];
  716|     78|	sc_apdu_t apdu;
  717|       |
  718|     78|	if (!serial)
  ------------------
  |  Branch (718:6): [True: 0, False: 78]
  ------------------
  719|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  720|       |	/* see if we have cached serial number */
  721|     78|	if (card->serialnr.len) {
  ------------------
  |  Branch (721:6): [True: 6, False: 72]
  ------------------
  722|      6|		memcpy(serial, &card->serialnr, sizeof(*serial));
  723|      6|		return SC_SUCCESS;
  ------------------
  |  |   28|      6|#define SC_SUCCESS				0
  ------------------
  724|      6|	}
  725|       |	/* get serial number via GET CARD DATA */
  726|     72|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xf6, 0x00, 0x00);
  ------------------
  |  |  292|     72|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  727|     72|	apdu.cla |= 0x80;
  728|     72|	apdu.resp = rbuf;
  729|     72|	apdu.resplen = sizeof(rbuf);
  730|     72|	apdu.le   = 256;
  731|     72|	apdu.lc   = 0;
  732|     72|	apdu.datalen = 0;
  733|     72|        r = sc_transmit_apdu(card, &apdu);
  734|     72|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     72|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     72|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     72|	int _ret = (r); \
  |  |  |  |  168|     72|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 15, False: 57]
  |  |  |  |  ------------------
  |  |  |  |  169|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     15|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     15|		return _ret; \
  |  |  |  |  172|     15|	} \
  |  |  |  |  173|     72|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  735|     57|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (735:6): [True: 21, False: 36]
  |  Branch (735:26): [True: 6, False: 30]
  ------------------
  736|     27|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     27|#define SC_ERROR_INTERNAL			-1400
  ------------------
  737|       |	/* cache serial number */
  738|     30|	memcpy(card->serialnr.value, apdu.resp, MIN(apdu.resplen, SC_MAX_SERIALNR));
  ------------------
  |  |   69|     30|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 28, False: 2]
  |  |  ------------------
  ------------------
  739|     30|	card->serialnr.len = MIN(apdu.resplen, SC_MAX_SERIALNR);
  ------------------
  |  |   69|     30|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 28, False: 2]
  |  |  ------------------
  ------------------
  740|       |	/* copy and return serial number */
  741|     30|	memcpy(serial, &card->serialnr, sizeof(*serial));
  742|     30|	return SC_SUCCESS;
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  743|     57|}

sc_get_authentic_driver:
 2155|  17.0k|{
 2156|  17.0k|	return sc_get_driver();
 2157|  17.0k|}
card-authentic.c:sc_get_driver:
 2120|  17.0k|{
 2121|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2122|       |
 2123|  17.0k|	if (!iso_ops)
  ------------------
  |  Branch (2123:6): [True: 1, False: 17.0k]
  ------------------
 2124|      1|		iso_ops = iso_drv->ops;
 2125|       |
 2126|  17.0k|	authentic_ops = *iso_ops;
 2127|       |
 2128|  17.0k|	authentic_ops.match_card = authentic_match_card;
 2129|  17.0k|	authentic_ops.init = authentic_init;
 2130|  17.0k|	authentic_ops.finish = authentic_finish;
 2131|  17.0k|	authentic_ops.read_binary = authentic_read_binary;
 2132|  17.0k|	authentic_ops.write_binary = authentic_write_binary;
 2133|  17.0k|	authentic_ops.update_binary = authentic_update_binary;
 2134|  17.0k|	authentic_ops.erase_binary = authentic_erase_binary;
 2135|       |	/* authentic_ops.resize_file = authentic_resize_file; */
 2136|  17.0k|	authentic_ops.select_file = authentic_select_file;
 2137|       |	/* get_response: Untested */
 2138|  17.0k|	authentic_ops.get_challenge = authentic_get_challenge;
 2139|  17.0k|	authentic_ops.set_security_env = authentic_set_security_env;
 2140|       |	/* decipher: Untested */
 2141|  17.0k|	authentic_ops.decipher = authentic_decipher;
 2142|       |	/* authentic_ops.compute_signature = authentic_compute_signature; */
 2143|  17.0k|	authentic_ops.create_file = authentic_create_file;
 2144|  17.0k|	authentic_ops.delete_file = authentic_delete_file;
 2145|  17.0k|	authentic_ops.card_ctl = authentic_card_ctl;
 2146|  17.0k|	authentic_ops.process_fci = authentic_process_fci;
 2147|  17.0k|	authentic_ops.pin_cmd = authentic_pin_cmd;
 2148|  17.0k|	authentic_ops.card_reader_lock_obtained = authentic_card_reader_lock_obtained;
 2149|       |
 2150|  17.0k|	return &authentic_drv;
 2151|  17.0k|}
card-authentic.c:authentic_match_card:
  396|  12.6k|{
  397|  12.6k|	struct sc_context *ctx = card->ctx;
  398|  12.6k|	int i;
  399|       |
  400|  12.6k|	sc_log_hex(ctx, "try to match card with ATR", card->atr.value, card->atr.len);
  ------------------
  |  |  129|  12.6k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  12.6k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  401|  12.6k|	i = _sc_match_atr(card, authentic_known_atrs, &card->type);
  402|  12.6k|	if (i < 0)   {
  ------------------
  |  Branch (402:6): [True: 12.2k, False: 321]
  ------------------
  403|  12.2k|		sc_log(ctx, "card not matched");
  ------------------
  |  |   71|  12.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  404|  12.2k|		return 0;
  405|  12.2k|	}
  406|       |
  407|    321|	sc_log(ctx, "'%s' card matched", authentic_known_atrs[i].name);
  ------------------
  |  |   71|    321|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  408|    321|	return 1;
  409|  12.6k|}
card-authentic.c:authentic_init:
  448|    321|{
  449|    321|	struct sc_context *ctx = card->ctx;
  450|    321|	int ii, rv = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|    321|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  451|       |
  452|    321|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    321|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    321|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    321|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    321|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 321]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  453|    321|	for(ii=0;authentic_known_atrs[ii].atr;ii++)   {
  ------------------
  |  Branch (453:11): [True: 321, False: 0]
  ------------------
  454|    321|		if (card->type == authentic_known_atrs[ii].type)   {
  ------------------
  |  Branch (454:7): [True: 321, False: 0]
  ------------------
  455|    321|			card->name = authentic_known_atrs[ii].name;
  456|    321|			card->flags = authentic_known_atrs[ii].flags;
  457|    321|			break;
  458|    321|		}
  459|    321|	}
  460|       |
  461|    321|	if (!authentic_known_atrs[ii].atr)
  ------------------
  |  Branch (461:6): [True: 0, False: 321]
  ------------------
  462|    321|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  463|       |
  464|    321|	card->cla  = 0x00;
  465|    321|	card->drv_data = (struct authentic_private_data *) calloc(1, sizeof(struct authentic_private_data));
  466|    321|	if (!card->drv_data)
  ------------------
  |  Branch (466:6): [True: 0, False: 321]
  ------------------
  467|    321|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  468|       |
  469|    321|	if (card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2)
  ------------------
  |  Branch (469:6): [True: 321, False: 0]
  ------------------
  470|    321|		rv = authentic_init_oberthur_authentic_3_2(card);
  471|       |
  472|    321|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|    321|#define SC_SUCCESS				0
  ------------------
  |  Branch (472:6): [True: 195, False: 126]
  ------------------
  473|    195|		rv = authentic_get_serialnr(card, NULL);
  474|       |
  475|    321|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|    321|#define SC_SUCCESS				0
  ------------------
  |  Branch (475:6): [True: 27, False: 294]
  ------------------
  476|     27|		rv = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     27|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  477|       |
  478|       |	/* Free private data on error */
  479|    321|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    321|#define SC_SUCCESS				0
  ------------------
  |  Branch (479:6): [True: 27, False: 294]
  ------------------
  480|     27|		free(card->drv_data);
  481|     27|		card->drv_data = NULL;
  482|     27|	}
  483|    321|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    321|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    321|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    321|	int _ret = r; \
  |  |  |  |  155|    321|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 321, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    321|		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|     27|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 27, False: 294]
  |  |  |  |  ------------------
  |  |  |  |  157|    321|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    321|	} 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|    321|	return _ret; \
  |  |  |  |  163|    321|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  484|    321|}
card-authentic.c:authentic_init_oberthur_authentic_3_2:
  414|    321|{
  415|    321|	struct sc_context *ctx = card->ctx;
  416|    321|	unsigned int flags;
  417|    321|	int rv = 0;
  418|       |
  419|    321|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    321|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    321|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    321|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    321|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 321]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  420|       |
  421|    321|	flags = AUTHENTIC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   43|    321|#define AUTHENTIC_CARD_DEFAULT_FLAGS ( 0		\
  |  |   44|    321|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|    321|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   45|    321|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|    321|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   46|    321|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|    321|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|    321|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    321|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   47|    321|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|    321|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   48|    321|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|    321|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   49|    321|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|    321|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  422|       |
  423|    321|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    321|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  424|    321|	card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|    321|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  425|    321|	card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  557|    321|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  426|       |
  427|    321|#ifdef ENABLE_SM
  428|    321|	card->sm_ctx.ops.open = authentic_sm_open;
  429|    321|	card->sm_ctx.ops.get_sm_apdu = authentic_sm_get_wrapped_apdu;
  430|    321|	card->sm_ctx.ops.free_sm_apdu = authentic_sm_free_wrapped_apdu;
  431|    321|#endif
  432|       |
  433|    321|	rv = iso7816_select_aid(card, aid_AuthentIC_3_2, sizeof(aid_AuthentIC_3_2), NULL, NULL);
  434|    321|	LOG_TEST_RET(ctx, rv, "AuthentIC application select error");
  ------------------
  |  |  174|    321|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    321|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    321|	int _ret = (r); \
  |  |  |  |  168|    321|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 182, False: 139]
  |  |  |  |  ------------------
  |  |  |  |  169|    182|		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|    182|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    182|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    182|		return _ret; \
  |  |  |  |  172|    182|	} \
  |  |  |  |  173|    321|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 139]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  435|       |
  436|    139|	rv = authentic_select_mf(card, NULL);
  437|    139|	LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|    139|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    139|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    139|	int _ret = (r); \
  |  |  |  |  168|    139|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 13, False: 126]
  |  |  |  |  ------------------
  |  |  |  |  169|     13|		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|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     13|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     13|		return _ret; \
  |  |  |  |  172|     13|	} \
  |  |  |  |  173|    139|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 126]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|       |
  439|    126|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  440|    126|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  441|       |
  442|    126|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    126|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    126|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    126|	int _ret = r; \
  |  |  |  |  155|    126|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 126, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    126|		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: 126]
  |  |  |  |  ------------------
  |  |  |  |  157|    126|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    126|	} 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|    126|	return _ret; \
  |  |  |  |  163|    126|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  443|    126|}
card-authentic.c:authentic_select_mf:
  550|    139|{
  551|    139|	struct sc_context *ctx = card->ctx;
  552|    139|	struct sc_path mfpath;
  553|    139|	int rv;
  554|       |
  555|    139|	struct sc_apdu apdu;
  556|    139|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  557|       |
  558|    139|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    139|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    139|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    139|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    139|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 139]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  559|       |
  560|    139|	sc_format_path("3F00", &mfpath);
  561|    139|	mfpath.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|    139|#define SC_PATH_TYPE_PATH		2
  ------------------
  562|       |
  563|    139|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  292|    139|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  564|       |
  565|    139|	apdu.resp = rbuf;
  566|    139|	apdu.resplen = sizeof(rbuf);
  567|       |
  568|    139|	rv = sc_transmit_apdu(card, &apdu);
  569|    139|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    139|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    139|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    139|	int _ret = (r); \
  |  |  |  |  168|    139|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 138]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|    139|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 138]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  570|    138|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  571|    138|	LOG_TEST_RET(ctx, rv, "authentic_select_file() check SW failed");
  ------------------
  |  |  174|    138|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    138|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    138|	int _ret = (r); \
  |  |  |  |  168|    138|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 132]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|    138|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 132]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  572|       |
  573|    132|	rv = authentic_set_current_files(card, &mfpath, apdu.resp, apdu.resplen, file_out);
  574|    132|	LOG_TEST_RET(ctx, rv, "authentic_select_file() cannot set 'current_file'");
  ------------------
  |  |  174|    132|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    132|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    132|	int _ret = (r); \
  |  |  |  |  168|    132|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 126]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|    132|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 126]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  575|       |
  576|    126|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    126|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    126|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    126|	int _ret = r; \
  |  |  |  |  155|    126|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 126, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    126|		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: 126]
  |  |  |  |  ------------------
  |  |  |  |  157|    126|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    126|	} 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|    126|	return _ret; \
  |  |  |  |  163|    126|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  577|    126|}
card-authentic.c:authentic_set_current_files:
  511|    879|{
  512|    879|	struct sc_context *ctx = card->ctx;
  513|    879|	struct sc_file *file = NULL;
  514|    879|	int rv;
  515|       |
  516|    879|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    879|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    879|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    879|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    879|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 879]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  517|    879|	if (resplen)   {
  ------------------
  |  Branch (517:6): [True: 381, False: 498]
  ------------------
  518|    381|		switch (resp[0]) {
  519|     32|		case 0x62:
  ------------------
  |  Branch (519:3): [True: 32, False: 349]
  ------------------
  520|    323|		case 0x6F:
  ------------------
  |  Branch (520:3): [True: 291, False: 90]
  ------------------
  521|    323|			file = sc_file_new();
  522|    323|			if (file == NULL)
  ------------------
  |  Branch (522:8): [True: 0, False: 323]
  ------------------
  523|    323|				LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  524|    323|			if (path)
  ------------------
  |  Branch (524:8): [True: 323, False: 0]
  ------------------
  525|    323|				file->path = *path;
  526|       |
  527|    323|			rv = authentic_process_fci(card, file, resp, resplen);
  528|    323|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    323|#define SC_SUCCESS				0
  ------------------
  |  Branch (528:8): [True: 49, False: 274]
  ------------------
  529|     49|				sc_file_free(file);
  530|     49|				LOG_TEST_RET(ctx, rv, "cannot set 'current file': FCI process error");
  ------------------
  |  |  174|     49|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     49|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     49|	int _ret = (r); \
  |  |  |  |  168|     49|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     49|		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|     49|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     49|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     49|		return _ret; \
  |  |  |  |  172|     49|	} \
  |  |  |  |  173|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  531|     49|			}
  532|       |
  533|    274|			break;
  534|    274|		default:
  ------------------
  |  Branch (534:3): [True: 58, False: 323]
  ------------------
  535|     58|			LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     58|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     58|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     58|	int _ret = r; \
  |  |  |  |  155|     58|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 58, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     58|		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|     58|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 58, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     58|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     58|	} 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|     58|	return _ret; \
  |  |  |  |  163|     58|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  536|    381|		}
  537|       |
  538|    274|		if (file_out)
  ------------------
  |  Branch (538:7): [True: 141, False: 133]
  ------------------
  539|    141|			*file_out = file;
  540|    133|		else
  541|    133|			sc_file_free(file);
  542|    274|	}
  543|       |
  544|    772|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    772|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    772|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    772|	int _ret = r; \
  |  |  |  |  155|    772|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 772, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    772|		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: 772]
  |  |  |  |  ------------------
  |  |  |  |  157|    772|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    772|	} 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|    772|	return _ret; \
  |  |  |  |  163|    772|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  545|    772|}
card-authentic.c:authentic_get_serialnr:
 1470|    358|{
 1471|    358|	struct sc_context *ctx = card->ctx;
 1472|    358|	struct authentic_private_data *prv_data = (struct authentic_private_data *) card->drv_data;
 1473|    358|	int rv;
 1474|       |
 1475|    358|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    358|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    358|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    358|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    358|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 358]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1476|    358|	if (!card->serialnr.len)   {
  ------------------
  |  Branch (1476:6): [True: 237, False: 121]
  ------------------
 1477|    237|		rv = authentic_get_cplc(card);
 1478|    237|		LOG_TEST_RET(ctx, rv, "get CPLC data error");
  ------------------
  |  |  174|    237|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    237|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    237|	int _ret = (r); \
  |  |  |  |  168|    237|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 63, False: 174]
  |  |  |  |  ------------------
  |  |  |  |  169|     63|		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|     63|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     63|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     63|		return _ret; \
  |  |  |  |  172|     63|	} \
  |  |  |  |  173|    237|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 174]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1479|       |
 1480|    174|		card->serialnr.len = 4;
 1481|    174|		memcpy(card->serialnr.value, prv_data->cplc.value + 15, 4);
 1482|       |
 1483|    174|		sc_log(ctx, "serial %02X%02X%02X%02X",
  ------------------
  |  |   71|    174|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1484|    174|				card->serialnr.value[0], card->serialnr.value[1],
 1485|    174|				card->serialnr.value[2], card->serialnr.value[3]);
 1486|    174|	}
 1487|       |
 1488|    295|	if (serial)
  ------------------
  |  Branch (1488:6): [True: 127, False: 168]
  ------------------
 1489|    127|		memcpy(serial, &card->serialnr, sizeof(*serial));
 1490|       |
 1491|    295|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    295|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    295|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    295|	int _ret = r; \
  |  |  |  |  155|    295|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 295, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    295|		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: 295]
  |  |  |  |  ------------------
  |  |  |  |  157|    295|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    295|	} 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|    295|	return _ret; \
  |  |  |  |  163|    295|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1492|    295|}
card-authentic.c:authentic_get_cplc:
  366|    237|{
  367|    237|	struct authentic_private_data *prv_data = (struct authentic_private_data *) card->drv_data;
  368|    237|	struct sc_apdu apdu;
  369|    237|	int rv, ii;
  370|    237|	unsigned char p1, p2;
  371|       |
  372|    237|	p1 = (SC_CPLC_TAG >> 8) & 0xFF;
  ------------------
  |  |  345|    237|#define SC_CPLC_TAG		0x9F7F
  ------------------
  373|    237|	p2 = SC_CPLC_TAG & 0xFF;
  ------------------
  |  |  345|    237|#define SC_CPLC_TAG		0x9F7F
  ------------------
  374|    237|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, p1, p2);
  ------------------
  |  |  292|    237|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  375|    240|	for (ii=0;ii<2;ii++)   {
  ------------------
  |  Branch (375:12): [True: 239, False: 1]
  ------------------
  376|    239|		apdu.le = SC_CPLC_DER_SIZE;
  ------------------
  |  |  346|    239|#define SC_CPLC_DER_SIZE	45
  ------------------
  377|    239|		apdu.resplen = sizeof(prv_data->cplc.value);
  378|    239|		apdu.resp = prv_data->cplc.value;
  379|       |
  380|    239|		rv = sc_transmit_apdu(card, &apdu);
  381|    239|		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    239|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    239|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    239|	int _ret = (r); \
  |  |  |  |  168|    239|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 233]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|    239|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 233]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|    233|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  383|    233|		if (rv != SC_ERROR_CLASS_NOT_SUPPORTED)
  ------------------
  |  |   53|    233|#define SC_ERROR_CLASS_NOT_SUPPORTED		-1203
  ------------------
  |  Branch (383:7): [True: 230, False: 3]
  ------------------
  384|    230|			break;
  385|       |
  386|      3|		apdu.cla = 0x80;
  387|      3|	}
  388|    231|        LOG_TEST_RET(card->ctx, rv, "'GET CPLC' error");
  ------------------
  |  |  174|    231|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    231|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    231|	int _ret = (r); \
  |  |  |  |  168|    231|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 57, False: 174]
  |  |  |  |  ------------------
  |  |  |  |  169|     57|		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|     57|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     57|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     57|		return _ret; \
  |  |  |  |  172|     57|	} \
  |  |  |  |  173|    231|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 174]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  389|       |
  390|    174|	prv_data->cplc.len = SC_CPLC_DER_SIZE;
  ------------------
  |  |  346|    174|#define SC_CPLC_DER_SIZE	45
  ------------------
  391|    174|	return SC_SUCCESS;
  ------------------
  |  |   28|    174|#define SC_SUCCESS				0
  ------------------
  392|    231|}
card-authentic.c:authentic_finish:
 1853|    294|{
 1854|    294|	struct sc_context *ctx = card->ctx;
 1855|       |
 1856|    294|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    294|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    294|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    294|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    294|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 294]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1857|       |
 1858|    294|#ifdef ENABLE_SM
 1859|    294|	if (card->sm_ctx.ops.close)
  ------------------
  |  Branch (1859:6): [True: 0, False: 294]
  ------------------
 1860|      0|		card->sm_ctx.ops.close(card);
 1861|    294|#endif
 1862|       |
 1863|    294|	if (card->drv_data)
  ------------------
  |  Branch (1863:6): [True: 294, False: 0]
  ------------------
 1864|    294|		free(card->drv_data);
 1865|    294|	card->drv_data = NULL;
 1866|    294|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    294|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    294|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    294|	int _ret = r; \
  |  |  |  |  155|    294|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 294, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    294|		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: 294]
  |  |  |  |  ------------------
  |  |  |  |  157|    294|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    294|	} 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|    294|	return _ret; \
  |  |  |  |  163|    294|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1867|    294|}
card-authentic.c:authentic_read_binary:
  649|    343|{
  650|    343|	struct sc_context *ctx = card->ctx;
  651|    343|	struct sc_apdu apdu;
  652|    343|	size_t sz, rest, ret_count = 0;
  653|    343|	int rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    343|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  654|       |
  655|    343|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    343|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    343|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    343|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    343|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 343]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  656|    343|	sc_log(ctx, "offs:%i,count:%zu,max_recv_size:%zu", idx, count, card->max_recv_size);
  ------------------
  |  |   71|    343|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  657|       |
  658|    343|	rest = count;
  659|  2.26k|	while(rest)   {
  ------------------
  |  Branch (659:8): [True: 1.92k, False: 335]
  ------------------
  660|  1.92k|		sz = rest > 256 ? 256 : rest;
  ------------------
  |  Branch (660:8): [True: 1.59k, False: 337]
  ------------------
  661|  1.92k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  292|  1.92k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  662|  1.92k|		apdu.le = sz;
  663|  1.92k|		apdu.resplen = sz;
  664|  1.92k|		apdu.resp = (buf + ret_count);
  665|       |
  666|  1.92k|		rv = sc_transmit_apdu(card, &apdu);
  667|  1.92k|		if(!rv)
  ------------------
  |  Branch (667:6): [True: 1.91k, False: 8]
  ------------------
  668|  1.91k|			ret_count += apdu.resplen;
  669|      8|		else
  670|      8|			break;
  671|       |
  672|  1.91k|		idx += sz;
  673|  1.91k|		rest -= sz;
  674|  1.91k|	}
  675|       |
  676|    343|	if (rv)   {
  ------------------
  |  Branch (676:6): [True: 8, False: 335]
  ------------------
  677|      8|		LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "authentic_read_binary() failed");
  ------------------
  |  |  174|      8|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      8|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      8|	int _ret = (r); \
  |  |  |  |  168|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      8|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      8|		return _ret; \
  |  |  |  |  172|      8|	} \
  |  |  |  |  173|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  678|      0|		LOG_FUNC_RETURN(ctx, (int)count);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  679|      0|	}
  680|       |
  681|    335|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  682|    335|	if (!rv)
  ------------------
  |  Branch (682:6): [True: 285, False: 50]
  ------------------
  683|    285|		count = ret_count;
  684|       |
  685|    335|	LOG_TEST_RET(ctx, rv, "authentic_read_binary() failed");
  ------------------
  |  |  174|    335|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    335|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    335|	int _ret = (r); \
  |  |  |  |  168|    335|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 50, False: 285]
  |  |  |  |  ------------------
  |  |  |  |  169|     50|		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|     50|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     50|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     50|		return _ret; \
  |  |  |  |  172|     50|	} \
  |  |  |  |  173|    335|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 285]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  686|    285|	LOG_FUNC_RETURN(ctx, (int)count);
  ------------------
  |  |  164|    285|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    285|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    285|	int _ret = r; \
  |  |  |  |  155|    285|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10, False: 275]
  |  |  |  |  ------------------
  |  |  |  |  156|     10|		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: 10]
  |  |  |  |  ------------------
  |  |  |  |  157|     10|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    275|	} else { \
  |  |  |  |  159|    275|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    275|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    275|	} \
  |  |  |  |  162|    285|	return _ret; \
  |  |  |  |  163|    285|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  687|    285|}
card-authentic.c:authentic_select_file:
  582|  1.83k|{
  583|  1.83k|	struct sc_context *ctx = card->ctx;
  584|  1.83k|	struct sc_apdu apdu;
  585|  1.83k|	struct sc_path lpath;
  586|  1.83k|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  587|  1.83k|	size_t pathlen;
  588|  1.83k|	int rv;
  589|       |
  590|  1.83k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.83k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.83k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.83k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.83k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  591|       |
  592|  1.83k|	memcpy(&lpath, path, sizeof(struct sc_path));
  593|       |
  594|  1.83k|	if (lpath.type == SC_PATH_TYPE_PATH && (lpath.len == 2))
  ------------------
  |  |  119|  3.66k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (594:6): [True: 950, False: 883]
  |  Branch (594:41): [True: 103, False: 847]
  ------------------
  595|    103|		lpath.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    103|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  596|       |
  597|  1.83k|	pathlen = lpath.len;
  598|  1.83k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  1.83k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  599|       |
  600|  1.83k|	if (card->type != SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2)
  ------------------
  |  Branch (600:6): [True: 0, False: 1.83k]
  ------------------
  601|  1.83k|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported card");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  602|       |
  603|  1.83k|	if (lpath.type == SC_PATH_TYPE_FILE_ID)   {
  ------------------
  |  |  117|  1.83k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (603:6): [True: 103, False: 1.73k]
  ------------------
  604|    103|		apdu.p1 = 0x00;
  605|    103|	}
  606|  1.73k|	else if (lpath.type == SC_PATH_TYPE_PATH)  {
  ------------------
  |  |  119|  1.73k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (606:11): [True: 847, False: 883]
  ------------------
  607|    847|		apdu.p1 = 0x08;
  608|    847|	}
  609|    883|	else if (lpath.type == SC_PATH_TYPE_FROM_CURRENT)  {
  ------------------
  |  |  122|    883|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (609:11): [True: 0, False: 883]
  ------------------
  610|      0|		apdu.p1 = 0x09;
  611|      0|	}
  612|    883|	else if (lpath.type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|    883|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (612:11): [True: 883, False: 0]
  ------------------
  613|    883|		apdu.p1 = 4;
  614|    883|	}
  615|      0|	else if (lpath.type == SC_PATH_TYPE_PARENT)   {
  ------------------
  |  |  123|      0|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (615:11): [True: 0, False: 0]
  ------------------
  616|      0|		apdu.p1 = 0x03;
  617|      0|		pathlen = 0;
  618|      0|		apdu.cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  619|      0|	}
  620|      0|	else   {
  621|      0|		sc_log(ctx, "Invalid PATH type: 0x%X", lpath.type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  622|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "authentic_select_file() invalid PATH type");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  623|      0|	}
  624|       |
  625|  1.83k|	apdu.lc = pathlen;
  626|  1.83k|	apdu.data = lpath.value;
  627|  1.83k|	apdu.datalen = pathlen;
  628|       |
  629|  1.83k|	if (apdu.cse == SC_APDU_CASE_4_SHORT || apdu.cse == SC_APDU_CASE_2_SHORT)   {
  ------------------
  |  |  294|  3.66k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              	if (apdu.cse == SC_APDU_CASE_4_SHORT || apdu.cse == SC_APDU_CASE_2_SHORT)   {
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  |  Branch (629:6): [True: 1.83k, False: 0]
  |  Branch (629:42): [True: 0, False: 0]
  ------------------
  630|  1.83k|		apdu.resp = rbuf;
  631|  1.83k|		apdu.resplen = sizeof(rbuf);
  632|  1.83k|		apdu.le = 256;
  633|  1.83k|	}
  634|       |
  635|  1.83k|	rv = sc_transmit_apdu(card, &apdu);
  636|  1.83k|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  1.83k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.83k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.83k|	int _ret = (r); \
  |  |  |  |  168|  1.83k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 32, False: 1.80k]
  |  |  |  |  ------------------
  |  |  |  |  169|     32|		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|     32|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     32|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     32|		return _ret; \
  |  |  |  |  172|     32|	} \
  |  |  |  |  173|  1.83k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.80k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  637|  1.80k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  638|  1.80k|	LOG_TEST_RET(ctx, rv, "authentic_select_file() check SW failed");
  ------------------
  |  |  174|  1.80k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.80k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.80k|	int _ret = (r); \
  |  |  |  |  168|  1.80k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.05k, False: 747]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.05k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.05k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.05k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.05k|		return _ret; \
  |  |  |  |  172|  1.05k|	} \
  |  |  |  |  173|  1.80k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 747]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  639|       |
  640|    747|	rv = authentic_set_current_files(card, &lpath, apdu.resp, apdu.resplen, file_out);
  641|    747|	LOG_TEST_RET(ctx, rv, "authentic_select_file() cannot set 'current_file'");
  ------------------
  |  |  174|    747|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    747|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    747|	int _ret = (r); \
  |  |  |  |  168|    747|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 101, False: 646]
  |  |  |  |  ------------------
  |  |  |  |  169|    101|		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|    101|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    101|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    101|		return _ret; \
  |  |  |  |  172|    101|	} \
  |  |  |  |  173|    747|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 646]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  642|       |
  643|    646|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    646|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    646|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    646|	int _ret = r; \
  |  |  |  |  155|    646|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 646, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    646|		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: 646]
  |  |  |  |  ------------------
  |  |  |  |  157|    646|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    646|	} 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|    646|	return _ret; \
  |  |  |  |  163|    646|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  644|    646|}
card-authentic.c:authentic_get_challenge:
 1497|    196|{
 1498|       |	/* 'GET CHALLENGE' returns always 24 bytes */
 1499|    196|	unsigned char rbuf[0x18];
 1500|    196|	size_t out_len;
 1501|    196|	int r;
 1502|       |
 1503|    196|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    196|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    196|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    196|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    196|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 196]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1504|       |
 1505|    196|	r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
 1506|    196|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE cmd failed");
  ------------------
  |  |  174|    196|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    196|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    196|	int _ret = (r); \
  |  |  |  |  168|    196|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 104, False: 92]
  |  |  |  |  ------------------
  |  |  |  |  169|    104|		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|    104|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    104|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    104|		return _ret; \
  |  |  |  |  172|    104|	} \
  |  |  |  |  173|    196|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 92]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1507|       |
 1508|     92|	if (len < (size_t) r) {
  ------------------
  |  Branch (1508:6): [True: 1, False: 91]
  ------------------
 1509|      1|		out_len = len;
 1510|     91|	} else {
 1511|     91|		out_len = (size_t) r;
 1512|     91|	}
 1513|     92|	memcpy(rnd, rbuf, out_len);
 1514|       |
 1515|     92|	LOG_FUNC_RETURN(card->ctx, (int)out_len);
  ------------------
  |  |  164|     92|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     92|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     92|	int _ret = r; \
  |  |  |  |  155|     92|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 88]
  |  |  |  |  ------------------
  |  |  |  |  156|      4|		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: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     88|	} else { \
  |  |  |  |  159|     88|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     88|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     88|	} \
  |  |  |  |  162|     92|	return _ret; \
  |  |  |  |  163|     92|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1516|     92|}
card-authentic.c:authentic_card_ctl:
 1744|    337|{
 1745|    337|	struct sc_context *ctx = card->ctx;
 1746|    337|	struct sc_authentic_sdo *sdo = (struct sc_authentic_sdo *) ptr;
 1747|       |
 1748|    337|	switch (cmd) {
  ------------------
  |  Branch (1748:10): [True: 163, False: 174]
  ------------------
 1749|    163|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1749:2): [True: 163, False: 174]
  ------------------
 1750|    163|		return authentic_get_serialnr(card, (struct sc_serial_number *)ptr);
 1751|      0|	case SC_CARDCTL_AUTHENTIC_SDO_CREATE:
  ------------------
  |  Branch (1751:2): [True: 0, False: 337]
  ------------------
 1752|      0|		sc_log(ctx, "CARDCTL SDO_CREATE: sdo(mech:%X,id:%X)", sdo->docp.mech, sdo->docp.id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1753|      0|		return authentic_manage_sdo(card, (struct sc_authentic_sdo *) ptr, cmd);
 1754|      0|	case SC_CARDCTL_AUTHENTIC_SDO_DELETE:
  ------------------
  |  Branch (1754:2): [True: 0, False: 337]
  ------------------
 1755|      0|		sc_log(ctx, "CARDCTL SDO_DELETE: sdo(mech:%X,id:%X)", sdo->docp.mech, sdo->docp.id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1756|      0|		return authentic_manage_sdo(card, (struct sc_authentic_sdo *) ptr, cmd);
 1757|      0|	case SC_CARDCTL_AUTHENTIC_SDO_STORE:
  ------------------
  |  Branch (1757:2): [True: 0, False: 337]
  ------------------
 1758|      0|		sc_log(ctx, "CARDCTL SDO_STORE: sdo(mech:%X,id:%X)", sdo->docp.mech, sdo->docp.id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1759|      0|		return authentic_manage_sdo(card, (struct sc_authentic_sdo *) ptr, cmd);
 1760|      0|	case SC_CARDCTL_AUTHENTIC_SDO_GENERATE:
  ------------------
  |  Branch (1760:2): [True: 0, False: 337]
  ------------------
 1761|      0|		sc_log(ctx, "CARDCTL SDO_GENERATE: sdo(mech:%X,id:%X)", sdo->docp.mech, sdo->docp.id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1762|      0|		return authentic_manage_sdo_generate(card, (struct sc_authentic_sdo *) ptr);
 1763|    337|	}
 1764|    174|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    174|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1765|    337|}
card-authentic.c:authentic_get_tagged_data:
  177|    156|{
  178|    156|	size_t size_len, tag_len, offs, size;
  179|    156|	int rv;
  180|    156|	unsigned tag;
  181|       |
  182|    156|	if (!out || !out_len)
  ------------------
  |  Branch (182:6): [True: 0, False: 156]
  |  Branch (182:14): [True: 0, False: 156]
  ------------------
  183|    156|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  184|       |
  185|    952|	for (offs = 0; offs < in_len; )   {
  ------------------
  |  Branch (185:17): [True: 880, False: 72]
  ------------------
  186|    880|		if ((*(in + offs) == 0x7F) || (*(in + offs) == 0x5F))   {
  ------------------
  |  Branch (186:7): [True: 105, False: 775]
  |  Branch (186:33): [True: 92, False: 683]
  ------------------
  187|    197|			if (offs + 1 >= in_len)
  ------------------
  |  Branch (187:8): [True: 11, False: 186]
  ------------------
  188|    197|				LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "parse error: invalid data");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|    186|			tag = *(in + offs) * 0x100 + *(in + offs + 1);
  190|    186|			tag_len = 2;
  191|    186|		}
  192|    683|		else   {
  193|    683|			tag = *(in + offs);
  194|    683|			tag_len = 1;
  195|    683|		}
  196|       |
  197|    869|		if (offs + tag_len >= in_len)
  ------------------
  |  Branch (197:7): [True: 21, False: 848]
  ------------------
  198|    869|			LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "parse error: invalid data");
  ------------------
  |  |  174|     21|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     21|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     21|	int _ret = (r); \
  |  |  |  |  168|     21|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     21|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     21|		return _ret; \
  |  |  |  |  172|     21|	} \
  |  |  |  |  173|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|       |
  200|    848|		rv = authentic_parse_size(in + offs + tag_len, in_len - (offs + tag_len), &size);
  201|    848|		LOG_TEST_RET(ctx, rv, "parse error: invalid size data");
  ------------------
  |  |  174|    848|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    848|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    848|	int _ret = (r); \
  |  |  |  |  168|    848|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 13, False: 835]
  |  |  |  |  ------------------
  |  |  |  |  169|     13|		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|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     13|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     13|		return _ret; \
  |  |  |  |  172|     13|	} \
  |  |  |  |  173|    848|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 835]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  202|    835|		size_len = rv;
  203|       |
  204|    835|		if (tag == in_tag)   {
  ------------------
  |  Branch (204:7): [True: 39, False: 796]
  ------------------
  205|     39|			if (in_len - (offs + tag_len + size_len) < size)
  ------------------
  |  Branch (205:8): [True: 1, False: 38]
  ------------------
  206|     39|				LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "parse error: invalid data");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|       |
  208|     38|			*out = in + offs + tag_len + size_len;
  209|     38|			*out_len = size;
  210|       |
  211|     38|			return SC_SUCCESS;
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  212|     39|		}
  213|       |
  214|    796|		offs += tag_len + size_len + size;
  215|    796|	}
  216|       |
  217|     72|	return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|     72|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
  218|    156|}
card-authentic.c:authentic_parse_size:
  149|    848|{
  150|    848|	if (!in || !out || in_len < 1)
  ------------------
  |  Branch (150:6): [True: 0, False: 848]
  |  Branch (150:13): [True: 0, False: 848]
  |  Branch (150:21): [True: 0, False: 848]
  ------------------
  151|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  152|       |
  153|    848|	if (*in < 0x80)   {
  ------------------
  |  Branch (153:6): [True: 668, False: 180]
  ------------------
  154|    668|		*out = *in;
  155|    668|		return 1;
  156|    668|	}
  157|    180|	else if (*in == 0x81)   {
  ------------------
  |  Branch (157:11): [True: 90, False: 90]
  ------------------
  158|     90|		if (in_len < 2)
  ------------------
  |  Branch (158:7): [True: 1, False: 89]
  ------------------
  159|      1|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  160|     89|		*out = *(in + 1);
  161|     89|		return 2;
  162|     90|	}
  163|     90|	else if (*in == 0x82)   {
  ------------------
  |  Branch (163:11): [True: 79, False: 11]
  ------------------
  164|     79|		if (in_len < 3)
  ------------------
  |  Branch (164:7): [True: 1, False: 78]
  ------------------
  165|      1|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  166|     78|		*out = *(in + 1) * 0x100 + *(in + 2);
  167|     78|		return 3;
  168|     79|	}
  169|       |
  170|     11|	return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     11|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  171|    848|}
card-authentic.c:authentic_process_fci:
  775|    323|{
  776|    323|	struct sc_context *ctx = card->ctx;
  777|    323|	size_t taglen;
  778|    323|	int rv;
  779|    323|	unsigned ii;
  780|    323|	const unsigned char *tag = NULL;
  781|    323|	unsigned char ops_DF[8] = {
  782|    323|		SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  169|    323|#define SC_AC_OP_CREATE			3
  ------------------
              		SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  168|    323|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  173|    323|#define SC_AC_OP_CRYPTO			7
  ------------------
  783|    323|	};
  784|    323|	unsigned char ops_EF[8] = {
  785|    323|		SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  188|    323|#define SC_AC_OP_READ			22
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  168|    323|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  189|    323|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  191|    323|#define SC_AC_OP_RESIZE			25
  ------------------
  786|    323|	};
  787|       |
  788|    323|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    323|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    323|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    323|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    323|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 323]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  789|       |
  790|    323|	tag = sc_asn1_find_tag(card->ctx,  buf, buflen, 0x6F, &taglen);
  791|    323|	if (tag != NULL) {
  ------------------
  |  Branch (791:6): [True: 262, False: 61]
  ------------------
  792|    262|		sc_log(ctx, "  FCP length %zu", taglen);
  ------------------
  |  |   71|    262|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  793|    262|		buf = tag;
  794|    262|		buflen = taglen;
  795|    262|	}
  796|       |
  797|    323|	tag = sc_asn1_find_tag(card->ctx,  buf, buflen, 0x62, &taglen);
  798|    323|	if (tag != NULL) {
  ------------------
  |  Branch (798:6): [True: 28, False: 295]
  ------------------
  799|     28|		sc_log(ctx, "  FCP length %zu", taglen);
  ------------------
  |  |   71|     28|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  800|     28|		buf = tag;
  801|     28|		buflen = taglen;
  802|     28|	}
  803|       |
  804|    323|	rv = iso_ops->process_fci(card, file, buf, buflen);
  805|    323|	LOG_TEST_RET(ctx, rv, "ISO parse FCI failed");
  ------------------
  |  |  174|    323|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    323|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    323|	int _ret = (r); \
  |  |  |  |  168|    323|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 323]
  |  |  |  |  ------------------
  |  |  |  |  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|    323|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 323]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  806|       |
  807|    323|	if (!file->sec_attr_len)   {
  ------------------
  |  Branch (807:6): [True: 118, False: 205]
  ------------------
  808|    118|		sc_log_hex(ctx, "ACLs not found in data", buf, buflen);
  ------------------
  |  |  129|    118|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    118|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  809|    118|		sc_log(ctx, "Path:%s; Type:%X; PathType:%X", sc_print_path(&file->path), file->type, file->path.type);
  ------------------
  |  |   71|    118|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  810|    118|		if (file->path.type == SC_PATH_TYPE_DF_NAME || file->type == SC_FILE_TYPE_DF)   {
  ------------------
  |  |  118|    236|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
              		if (file->path.type == SC_PATH_TYPE_DF_NAME || file->type == SC_FILE_TYPE_DF)   {
  ------------------
  |  |  214|     64|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (810:7): [True: 54, False: 64]
  |  Branch (810:50): [True: 15, False: 49]
  ------------------
  811|     69|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     69|#define SC_FILE_TYPE_DF			0x04
  ------------------
  812|     69|		}
  813|     49|		else   {
  814|     49|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "ACLs tag missing");
  ------------------
  |  |  174|     49|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     49|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     49|	int _ret = (r); \
  |  |  |  |  168|     49|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     49|		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|     49|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     49|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     49|		return _ret; \
  |  |  |  |  172|     49|	} \
  |  |  |  |  173|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  815|     49|		}
  816|    118|	}
  817|       |
  818|    274|	sc_log_hex(ctx, "ACL data", file->sec_attr, file->sec_attr_len);
  ------------------
  |  |  129|    274|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    274|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  819|    997|	for (ii = 0; ii < file->sec_attr_len / 2 && ii < sizeof ops_DF; ii++)  {
  ------------------
  |  Branch (819:15): [True: 724, False: 273]
  |  Branch (819:46): [True: 723, False: 1]
  ------------------
  820|    723|		unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii];
  ------------------
  |  |  214|    723|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (820:22): [True: 104, False: 619]
  ------------------
  821|    723|		unsigned char acl = *(file->sec_attr + ii*2);
  822|    723|		unsigned char cred_id = *(file->sec_attr + ii*2 + 1);
  823|    723|		unsigned sc = acl * 0x100 + cred_id;
  824|       |
  825|    723|		sc_log(ctx, "ACL(%i) op 0x%X, acl %X:%X", ii, op, acl, cred_id);
  ------------------
  |  |   71|    723|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  826|    723|		if (op == 0xFF)
  ------------------
  |  Branch (826:7): [True: 189, False: 534]
  ------------------
  827|    189|			;
  828|    534|		else if (!acl && !cred_id)
  ------------------
  |  Branch (828:12): [True: 183, False: 351]
  |  Branch (828:20): [True: 80, False: 103]
  ------------------
  829|     80|			sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|     80|#define SC_AC_NONE			0x00000000
  ------------------
  830|    454|		else if (acl == 0xFF)
  ------------------
  |  Branch (830:12): [True: 45, False: 409]
  ------------------
  831|     45|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|     45|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  832|    409|		else if (acl & AUTHENTIC_AC_SM_MASK)
  ------------------
  |  |  119|    409|#define AUTHENTIC_AC_SM_MASK	0x60
  ------------------
  |  Branch (832:12): [True: 181, False: 228]
  ------------------
  833|    181|			sc_file_add_acl_entry(file, op, SC_AC_SCB, sc);
  ------------------
  |  |  157|    181|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  834|    228|		else if (cred_id)
  ------------------
  |  Branch (834:12): [True: 147, False: 81]
  ------------------
  835|    147|			sc_file_add_acl_entry(file, op, SC_AC_CHV, cred_id);
  ------------------
  |  |  151|    147|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  836|     81|		else
  837|     81|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|     81|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  838|    723|	}
  839|       |
  840|    274|	LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  164|    274|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    274|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    274|	int _ret = r; \
  |  |  |  |  155|    274|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 274, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    274|		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: 274]
  |  |  |  |  ------------------
  |  |  |  |  157|    274|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    274|	} 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|    274|	return _ret; \
  |  |  |  |  163|    274|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  841|    274|}
card-authentic.c:authentic_pin_cmd:
 1438|    169|{
 1439|    169|	struct sc_context *ctx = card->ctx;
 1440|    169|	int rv = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    169|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1441|       |
 1442|    169|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    169|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    169|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    169|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    169|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 169]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1443|    169|	sc_log(ctx, "PIN-CMD:%X,PIN(type:%X,ret:%i)", data->cmd, data->pin_type, data->pin_reference);
  ------------------
  |  |   71|    169|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1444|    169|	sc_log(ctx, "PIN1(%p,len:%zu,tries-left:%i)", data->pin1.data, data->pin1.len, data->pin1.tries_left);
  ------------------
  |  |   71|    169|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1445|    169|	sc_log(ctx, "PIN2(%p,len:%zu)", data->pin2.data, data->pin2.len);
  ------------------
  |  |   71|    169|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1446|       |
 1447|    169|	switch (data->cmd)   {
 1448|      2|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|      2|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1448:2): [True: 2, False: 167]
  ------------------
 1449|      2|		rv = authentic_pin_verify(card, data);
 1450|      2|		break;
 1451|      1|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      1|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1451:2): [True: 1, False: 168]
  ------------------
 1452|      1|		rv = authentic_pin_change(card, data);
 1453|      1|		break;
 1454|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1454:2): [True: 0, False: 169]
  ------------------
 1455|      0|		rv = authentic_pin_reset(card, data);
 1456|      0|		break;
 1457|    166|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  418|    166|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1457:2): [True: 166, False: 3]
  ------------------
 1458|    166|		rv = authentic_pin_get_policy(card, data, NULL);
 1459|    166|		break;
 1460|      0|	default:
  ------------------
  |  Branch (1460:2): [True: 0, False: 169]
  ------------------
 1461|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported PIN command");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1462|    169|	}
 1463|       |
 1464|    169|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    169|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    169|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    169|	int _ret = r; \
  |  |  |  |  155|    169|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 169, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    169|		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|    166|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 166, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  157|    169|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    169|	} 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|    169|	return _ret; \
  |  |  |  |  163|    169|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1465|    169|}
card-authentic.c:authentic_pin_verify:
 1103|      2|{
 1104|      2|	struct sc_context *ctx = card->ctx;
 1105|      2|	struct authentic_private_data *prv_data = (struct authentic_private_data *) card->drv_data;
 1106|      2|	unsigned char pin_sha1[SHA_DIGEST_LENGTH];
 1107|      2|	int rv;
 1108|       |
 1109|      2|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|      2|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      2|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      2|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      2|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1110|      2|	sc_log(ctx, "PIN(type:%X,reference:%X,data:%p,length:%zu)",
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1111|      2|			pin_cmd->pin_type, pin_cmd->pin_reference, pin_cmd->pin1.data, pin_cmd->pin1.len);
 1112|       |
 1113|      2|	if (pin_cmd->pin_reference < 0 || pin_cmd->pin_reference >= AUTHENTIC_N_PINS) {
  ------------------
  |  |   64|      2|#define AUTHENTIC_N_PINS 8
  ------------------
  |  Branch (1113:6): [True: 0, False: 2]
  |  Branch (1113:36): [True: 0, False: 2]
  ------------------
 1114|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "PIN reference out of bounds");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1115|      0|	}
 1116|       |
 1117|      2|	if (pin_cmd->pin1.data && !pin_cmd->pin1.len)   {
  ------------------
  |  Branch (1117:6): [True: 2, False: 0]
  |  Branch (1117:28): [True: 0, False: 2]
  ------------------
 1118|      0|		pin_cmd->pin1.tries_left = -1;
 1119|      0|		rv = authentic_pin_is_verified(card, pin_cmd);
 1120|      0|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1121|      0|	}
 1122|       |
 1123|      2|	if (pin_cmd->pin1.data)
  ------------------
  |  Branch (1123:6): [True: 2, False: 0]
  ------------------
 1124|      2|		SHA1(pin_cmd->pin1.data, pin_cmd->pin1.len, pin_sha1);
 1125|      0|	else
 1126|      0|		SHA1((unsigned char *)"", 0, pin_sha1);
 1127|       |
 1128|      2|	if (!memcmp(pin_sha1, prv_data->pins_sha1[pin_cmd->pin_reference], SHA_DIGEST_LENGTH))   {
  ------------------
  |  Branch (1128:6): [True: 0, False: 2]
  ------------------
 1129|      0|		sc_log(ctx, "Already verified");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1130|      0|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1131|      0|	}
 1132|       |
 1133|      2|	memset(prv_data->pins_sha1[pin_cmd->pin_reference], 0, sizeof(prv_data->pins_sha1[0]));
 1134|       |
 1135|      2|	rv = authentic_pin_get_policy(card, pin_cmd, NULL);
 1136|      2|	LOG_TEST_RET(ctx, rv, "Get 'PIN policy' error");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1137|       |
 1138|      0|	if (pin_cmd->pin1.len > pin_cmd->pin1.max_length)
  ------------------
  |  Branch (1138:6): [True: 0, False: 0]
  ------------------
 1139|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_LENGTH, "PIN policy check failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1140|       |
 1141|      0|	pin_cmd->pin1.tries_left = -1;
 1142|      0|	rv = authentic_chv_verify(card, pin_cmd);
 1143|      0|	LOG_TEST_RET(ctx, rv, "PIN CHV verification error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1144|       |
 1145|      0|	memcpy(prv_data->pins_sha1[pin_cmd->pin_reference], pin_sha1, SHA_DIGEST_LENGTH);
 1146|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1147|      0|}
card-authentic.c:authentic_pin_change:
 1198|      1|{
 1199|      1|	struct sc_context *ctx = card->ctx;
 1200|      1|	struct authentic_private_data *prv_data = (struct authentic_private_data *) card->drv_data;
 1201|      1|	struct sc_apdu apdu;
 1202|      1|	unsigned char pin_data[SC_MAX_APDU_BUFFER_SIZE];
 1203|      1|	size_t offs;
 1204|      1|	int rv;
 1205|       |
 1206|      1|	rv = authentic_pin_get_policy(card, data, NULL);
 1207|      1|	LOG_TEST_RET(ctx, rv, "Get 'PIN policy' error");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1208|       |
 1209|      0|	if (data->pin_reference < 0 || data->pin_reference >= AUTHENTIC_N_PINS) {
  ------------------
  |  |   64|      0|#define AUTHENTIC_N_PINS 8
  ------------------
  |  Branch (1209:6): [True: 0, False: 0]
  |  Branch (1209:33): [True: 0, False: 0]
  ------------------
 1210|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "PIN reference out of bounds");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1211|      0|	}
 1212|       |
 1213|      0|	memset(prv_data->pins_sha1[data->pin_reference], 0, sizeof(prv_data->pins_sha1[0]));
 1214|       |
 1215|      0|	if (!data->pin1.data && !data->pin1.len && !data->pin2.data && !data->pin2.len)   {
  ------------------
  |  Branch (1215:6): [True: 0, False: 0]
  |  Branch (1215:26): [True: 0, False: 0]
  |  Branch (1215:45): [True: 0, False: 0]
  |  Branch (1215:65): [True: 0, False: 0]
  ------------------
 1216|      0|		if (!(card->reader->capabilities & SC_READER_CAP_PIN_PAD))
  ------------------
  |  |  376|      0|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (1216:7): [True: 0, False: 0]
  ------------------
 1217|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "PIN pad not supported");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1218|      0|		rv = authentic_pin_change_pinpad(card, data->pin_reference, &data->pin1.tries_left);
 1219|      0|		sc_log(ctx, "authentic_pin_cmd(SC_PIN_CMD_CHANGE) chv_change_pinpad returned %i", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1220|      0|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1221|      0|	}
 1222|       |
 1223|      0|	if (card->max_send_size && (data->pin1.len + data->pin2.len > card->max_send_size))
  ------------------
  |  Branch (1223:6): [True: 0, False: 0]
  |  Branch (1223:29): [True: 0, False: 0]
  ------------------
 1224|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_LENGTH, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1225|       |
 1226|      0|	memset(pin_data, data->pin1.pad_char, sizeof(pin_data));
 1227|      0|	offs = 0;
 1228|      0|	if (data->pin1.data && data->pin1.len)   {
  ------------------
  |  Branch (1228:6): [True: 0, False: 0]
  |  Branch (1228:25): [True: 0, False: 0]
  ------------------
 1229|      0|		if (data->pin1.pad_length > sizeof(pin_data) || data->pin1.len > sizeof(pin_data)) {
  ------------------
  |  Branch (1229:7): [True: 0, False: 0]
  |  Branch (1229:51): [True: 0, False: 0]
  ------------------
 1230|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "PIN length exceeds buffer");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1231|      0|		}
 1232|      0|		memcpy(pin_data, data->pin1.data, data->pin1.len);
 1233|      0|		offs += data->pin1.pad_length;
 1234|      0|	}
 1235|      0|	if (data->pin2.data && data->pin2.len) {
  ------------------
  |  Branch (1235:6): [True: 0, False: 0]
  |  Branch (1235:25): [True: 0, False: 0]
  ------------------
 1236|      0|		if (data->pin2.len + offs > sizeof(pin_data)) {
  ------------------
  |  Branch (1236:7): [True: 0, False: 0]
  ------------------
 1237|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "PIN2 length exceeds buffer");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1238|      0|		}
 1239|      0|		memcpy(pin_data + offs, data->pin2.data, data->pin2.len);
 1240|      0|	}
 1241|       |
 1242|      0|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x24, offs ? 0x00 : 0x01, data->pin_reference);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (1242:58): [True: 0, False: 0]
  ------------------
 1243|      0|	apdu.data = pin_data;
 1244|      0|	apdu.datalen = offs + data->pin1.pad_length;
 1245|      0|	apdu.lc = offs + data->pin1.pad_length;
 1246|       |
 1247|      0|	rv = sc_transmit_apdu(card, &apdu);
 1248|      0|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1249|      0|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1250|       |
 1251|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1252|      0|}
card-authentic.c:authentic_pin_get_policy:
 1299|    169|{
 1300|    169|	struct sc_context *ctx = card->ctx;
 1301|    169|	struct sc_apdu apdu;
 1302|    169|	unsigned char rbuf[0x100];
 1303|    169|	int ii, rv;
 1304|       |
 1305|    169|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    169|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    169|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    169|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    169|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 169]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1306|    169|	sc_log(ctx, "get PIN(type:%X,ref:%X,tries-left:%i)", data->pin_type, data->pin_reference, data->pin1.tries_left);
  ------------------
  |  |   71|    169|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1307|       |
 1308|    169|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x5F, data->pin_reference);
  ------------------
  |  |  292|    169|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1309|    172|	for (ii=0;ii<2;ii++)   {
  ------------------
  |  Branch (1309:12): [True: 171, False: 1]
  ------------------
 1310|    171|		apdu.le = sizeof(rbuf);
 1311|    171|		apdu.resp = rbuf;
 1312|    171|		apdu.resplen = sizeof(rbuf);
 1313|       |
 1314|    171|		rv = sc_transmit_apdu(card, &apdu);
 1315|    171|		LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    171|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    171|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    171|	int _ret = (r); \
  |  |  |  |  168|    171|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 160]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|    171|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 160]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1316|    160|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1317|       |
 1318|    160|		if (rv != SC_ERROR_CLASS_NOT_SUPPORTED)
  ------------------
  |  |   53|    160|#define SC_ERROR_CLASS_NOT_SUPPORTED		-1203
  ------------------
  |  Branch (1318:7): [True: 157, False: 3]
  ------------------
 1319|    157|			break;
 1320|       |
 1321|      3|		apdu.cla = 0x80;
 1322|      3|	}
 1323|    158|        LOG_TEST_RET(ctx, rv, "'GET DATA' error");
  ------------------
  |  |  174|    158|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    158|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    158|	int _ret = (r); \
  |  |  |  |  168|    158|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 34, False: 124]
  |  |  |  |  ------------------
  |  |  |  |  169|     34|		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|     34|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     34|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     34|		return _ret; \
  |  |  |  |  172|     34|	} \
  |  |  |  |  173|    158|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 124]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1324|       |
 1325|    124|	data->pin1.tries_left = -1;
 1326|       |
 1327|    124|	rv = authentic_parse_credential_data(ctx, data, acls, apdu.resp, apdu.resplen);
 1328|    124|        LOG_TEST_RET(ctx, rv, "Cannot parse credential data");
  ------------------
  |  |  174|    124|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    124|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    124|	int _ret = (r); \
  |  |  |  |  168|    124|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 121, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  169|    121|		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|    121|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    121|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    121|		return _ret; \
  |  |  |  |  172|    121|	} \
  |  |  |  |  173|    124|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1329|       |
 1330|      3|	data->pin1.encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|      3|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1331|      3|	data->pin1.offset = 5;
 1332|      3|	data->pin1.pad_char = 0xFF;
 1333|      3|	data->pin1.pad_length = data->pin1.max_length;
 1334|      3|	data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|      3|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 1335|       |
 1336|      3|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|      3|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1337|       |
 1338|      3|	sc_log(ctx, "PIN policy: size max/min/pad %zu/%zu/%zu, tries max/left %i/%i",
  ------------------
  |  |   71|      3|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1339|      3|			data->pin1.max_length, data->pin1.min_length, data->pin1.pad_length,
 1340|      3|			data->pin1.max_tries, data->pin1.tries_left);
 1341|       |
 1342|      3|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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: 3]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} 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|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1343|      3|}
card-authentic.c:authentic_parse_credential_data:
  286|    124|{
  287|    124|	unsigned char *data;
  288|    124|	size_t data_len;
  289|    124|	int rv, ii;
  290|    124|	unsigned tag = AUTHENTIC_TAG_CREDENTIAL | pin_cmd->pin_reference;
  ------------------
  |  |   94|    124|#define AUTHENTIC_TAG_CREDENTIAL			0x5F00
  ------------------
  291|       |
  292|    124|	rv = authentic_get_tagged_data(ctx, blob, blob_len, tag, &blob, &blob_len);
  293|    124|	LOG_TEST_RET(ctx, rv, "cannot get credential data");
  ------------------
  |  |  174|    124|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    124|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    124|	int _ret = (r); \
  |  |  |  |  168|    124|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 107, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  169|    107|		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|    107|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    107|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    107|		return _ret; \
  |  |  |  |  172|    107|	} \
  |  |  |  |  173|    124|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|       |
  295|     17|	rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_TRYLIMIT, &data, &data_len);
  ------------------
  |  |   95|     17|#define AUTHENTIC_TAG_CREDENTIAL_TRYLIMIT		0x91
  ------------------
  296|     17|	LOG_TEST_RET(ctx, rv, "cannot get try limit");
  ------------------
  |  |  174|     17|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     17|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     17|	int _ret = (r); \
  |  |  |  |  168|     17|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|     11|	if (data_len < 1)
  ------------------
  |  Branch (297:6): [True: 1, False: 10]
  ------------------
  298|     11|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "invalid try limit");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  299|     10|	pin_cmd->pin1.max_tries = *data;
  300|       |
  301|     10|	rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_DOCP_MECH, &data, &data_len);
  ------------------
  |  |   73|     10|#define AUTHENTIC_TAG_DOCP_MECH			0x80
  ------------------
  302|     10|	LOG_TEST_RET(ctx, rv, "cannot get PIN type");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  303|      9|	if (data_len > 0 && *data == 0)
  ------------------
  |  Branch (303:6): [True: 8, False: 1]
  |  Branch (303:22): [True: 3, False: 5]
  ------------------
  304|      3|		pin_cmd->pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      3|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  305|      6|	else if (data_len > 0 && *data >= 2 && *data <= 7)
  ------------------
  |  Branch (305:11): [True: 5, False: 1]
  |  Branch (305:27): [True: 4, False: 1]
  |  Branch (305:41): [True: 1, False: 3]
  ------------------
  306|      1|		pin_cmd->pin_type = SC_AC_AUT;
  ------------------
  |  |  154|      1|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  307|      5|	else
  308|      5|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "unsupported Credential type");
  ------------------
  |  |  174|      5|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      5|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      5|	int _ret = (r); \
  |  |  |  |  168|      5|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      5|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      5|		return _ret; \
  |  |  |  |  172|      5|	} \
  |  |  |  |  173|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  309|       |
  310|       |	/* Parse optional ACLs when requested */
  311|      4|	if (acls) {
  ------------------
  |  Branch (311:6): [True: 0, False: 4]
  ------------------
  312|      0|		rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_DOCP_ACLS, &data, &data_len);
  ------------------
  |  |   75|      0|#define AUTHENTIC_TAG_DOCP_ACLS			0x86
  ------------------
  313|      0|		LOG_TEST_RET(ctx, rv, "failed to get ACLs");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  314|      0|		sc_log(ctx, "data_len:%zu", data_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  315|      0|		if (data_len == 10)   {
  ------------------
  |  Branch (315:7): [True: 0, False: 0]
  ------------------
  316|      0|			for (ii=0; ii<5; ii++)   {
  ------------------
  |  Branch (316:15): [True: 0, False: 0]
  ------------------
  317|      0|				unsigned char acl = *(data + ii*2);
  318|      0|				unsigned char cred_id = *(data + ii*2 + 1);
  319|      0|				unsigned sc = acl * 0x100 + cred_id;
  320|       |
  321|      0|				sc_log(ctx, "%i: SC:%X", ii, sc);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  322|      0|				if (!sc)
  ------------------
  |  Branch (322:9): [True: 0, False: 0]
  ------------------
  323|      0|					continue;
  324|       |
  325|      0|				if (acl & AUTHENTIC_AC_SM_MASK)   {
  ------------------
  |  |  119|      0|#define AUTHENTIC_AC_SM_MASK	0x60
  ------------------
  |  Branch (325:9): [True: 0, False: 0]
  ------------------
  326|      0|					acls[ii].method = SC_AC_SCB;
  ------------------
  |  |  157|      0|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  327|      0|					acls[ii].key_ref = sc;
  328|      0|				}
  329|      0|				else if (acl!=0xFF && cred_id)   {
  ------------------
  |  Branch (329:14): [True: 0, False: 0]
  |  Branch (329:27): [True: 0, False: 0]
  ------------------
  330|      0|					sc_log(ctx, "%i: ACL(method:SC_AC_CHV,id:%i)", ii, cred_id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  331|      0|					acls[ii].method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  332|      0|					acls[ii].key_ref = cred_id;
  333|      0|				}
  334|      0|				else   {
  335|      0|					acls[ii].method = SC_AC_NEVER;
  ------------------
  |  |  163|      0|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  336|      0|					acls[ii].key_ref = 0;
  337|      0|				}
  338|      0|			}
  339|      0|		}
  340|      0|	}
  341|       |
  342|      4|	rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_PINPOLICY, &data, &data_len);
  ------------------
  |  |   96|      4|#define AUTHENTIC_TAG_CREDENTIAL_PINPOLICY		0xA1
  ------------------
  343|      4|	if (!rv)   {
  ------------------
  |  Branch (343:6): [True: 1, False: 3]
  ------------------
  344|      1|		blob = data;
  345|      1|		blob_len = data_len;
  346|       |
  347|      1|		rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MAXLENGTH, &data, &data_len);
  ------------------
  |  |   97|      1|#define AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MAXLENGTH	0x83
  ------------------
  348|      1|		LOG_TEST_RET(ctx, rv, "failed to get PIN max.length value");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  349|      0|		if (data_len < 1)
  ------------------
  |  Branch (349:7): [True: 0, False: 0]
  ------------------
  350|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "invalid PIN max.length value");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|      0|		pin_cmd->pin1.max_length = *data;
  352|       |
  353|      0|		rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MINLENGTH, &data, &data_len);
  ------------------
  |  |   98|      0|#define AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MINLENGTH	0x84
  ------------------
  354|      0|		LOG_TEST_RET(ctx, rv, "failed to get PIN min.length value");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|      0|		if (data_len < 1)
  ------------------
  |  Branch (355:7): [True: 0, False: 0]
  ------------------
  356|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "invalid PIN min.length value");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  357|      0|		pin_cmd->pin1.min_length = *data;
  358|      0|	}
  359|       |
  360|      3|	return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  361|      4|}
card-authentic.c:authentic_card_reader_lock_obtained:
 1871|  1.65k|{
 1872|  1.65k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  1.65k|#define SC_SUCCESS				0
  ------------------
 1873|       |
 1874|  1.65k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.65k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.65k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.65k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.65k]
  |  |  ------------------
  ------------------
 1875|       |
 1876|  1.65k|	if (was_reset > 0
  ------------------
  |  Branch (1876:6): [True: 0, False: 1.65k]
  ------------------
 1877|      0|			&& card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2) {
  ------------------
  |  Branch (1877:7): [True: 0, False: 0]
  ------------------
 1878|      0|		r = iso7816_select_aid(card, aid_AuthentIC_3_2, sizeof(aid_AuthentIC_3_2), NULL, NULL);
 1879|      0|	}
 1880|       |
 1881|  1.65k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.65k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.65k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.65k|	int _ret = r; \
  |  |  |  |  155|  1.65k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.65k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.65k|		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: 1.65k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.65k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.65k|	} 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|  1.65k|	return _ret; \
  |  |  |  |  163|  1.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1882|  1.65k|}

sc_get_belpic_driver:
  437|  17.0k|{
  438|  17.0k|	return sc_get_driver();
  439|  17.0k|}
card-belpic.c:sc_get_driver:
  414|  17.0k|{
  415|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (415:6): [True: 1, False: 17.0k]
  ------------------
  416|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  417|       |
  418|  17.0k|	belpic_ops.match_card = belpic_match_card;
  419|  17.0k|	belpic_ops.init = belpic_init;
  420|       |
  421|  17.0k|	belpic_ops.update_binary = iso_ops->update_binary;
  422|  17.0k|	belpic_ops.select_file = belpic_select_file;
  423|  17.0k|	belpic_ops.read_binary = belpic_read_binary;
  424|  17.0k|	belpic_ops.pin_cmd = belpic_pin_cmd;
  425|  17.0k|	belpic_ops.set_security_env = belpic_set_security_env;
  426|       |
  427|  17.0k|	belpic_ops.compute_signature = iso_ops->compute_signature;
  428|  17.0k|	belpic_ops.get_challenge = iso_ops->get_challenge;
  429|  17.0k|	belpic_ops.get_response = iso_ops->get_response;
  430|  17.0k|	belpic_ops.check_sw = iso_ops->check_sw;
  431|       |
  432|  17.0k|	return &belpic_drv;
  433|  17.0k|}
card-belpic.c:belpic_match_card:
  204|  11.3k|{
  205|  11.3k|	int i;
  206|       |
  207|  11.3k|	i = _sc_match_atr(card, belpic_atrs, &card->type);
  208|  11.3k|	if (i < 0)
  ------------------
  |  Branch (208:6): [True: 11.2k, False: 105]
  ------------------
  209|  11.2k|		return 0;
  210|    105|	return 1;
  211|  11.3k|}
card-belpic.c:belpic_init:
  214|    105|{
  215|    105|	int key_size = 1024;
  216|    105|	unsigned long flags = 0;
  217|       |
  218|    105|	sc_log(card->ctx,  "Belpic V%s\n", BELPIC_VERSION);
  ------------------
  |  |   71|    105|#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)
  |  |  ------------------
  |  |  |  |  218|    105|	sc_log(card->ctx,  "Belpic V%s\n", BELPIC_VERSION);
  |  |  |  |  ------------------
  |  |  |  |  |  |   93|    105|#define BELPIC_VERSION			"1.4"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|       |
  220|    105|	if (card->type < 0)
  ------------------
  |  Branch (220:6): [True: 0, False: 105]
  ------------------
  221|      0|		card->type = SC_CARD_TYPE_BELPIC_EID;	/* Unknown card: assume it's the Belpic Card */
  222|       |
  223|    105|	card->cla = 0x00;
  224|    105|	if (card->type == SC_CARD_TYPE_BELPIC_EID) {
  ------------------
  |  Branch (224:6): [True: 105, False: 0]
  ------------------
  225|    105|		u8 carddata[BELPIC_CARDDATA_RESP_LEN];
  226|    105|		memset(carddata, 0, sizeof(carddata));
  227|       |
  228|    105|		if(get_carddata(card, carddata, sizeof(carddata)) < 0) {
  ------------------
  |  Branch (228:6): [True: 13, False: 92]
  ------------------
  229|     13|			return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     13|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  230|     13|		}
  231|     92|		if (carddata[BELPIC_CARDDATA_OFF_APPLETVERS] >= 0x18) {
  ------------------
  |  |  127|     92|#define BELPIC_CARDDATA_OFF_APPLETVERS 21
  ------------------
  |  Branch (231:7): [True: 64, False: 28]
  ------------------
  232|     64|			flags = SC_ALGORITHM_ECDSA_HASH_NONE | SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  175|     64|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|     64|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
              			flags = SC_ALGORITHM_ECDSA_HASH_NONE | SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|     64|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  233|     64|			_sc_card_add_ec_alg(card, 256, flags, 0, NULL);
  234|     64|			_sc_card_add_ec_alg(card, 384, flags, 0, NULL);
  235|     64|			_sc_card_add_ec_alg(card, 512, flags, 0, NULL);
  236|     64|			_sc_card_add_ec_alg(card, 521, flags, 0, NULL);
  237|     64|		} else {
  238|     28|			if (carddata[BELPIC_CARDDATA_OFF_APPLETVERS] >= 0x17) {
  ------------------
  |  |  127|     28|#define BELPIC_CARDDATA_OFF_APPLETVERS 21
  ------------------
  |  Branch (238:8): [True: 1, False: 27]
  ------------------
  239|      1|				key_size = 2048;
  240|      1|			}
  241|     28|			_sc_card_add_rsa_alg(card, key_size,
  242|     28|					SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE, 0);
  ------------------
  |  |  111|     28|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     28|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     28|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              					SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE, 0);
  ------------------
  |  |  133|     28|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  243|     28|		}
  244|     92|	}
  245|       |
  246|       |	/* State that we have an RNG */
  247|     92|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|     92|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  248|       |
  249|     92|	card->max_pin_len = BELPIC_MAX_USER_PIN_LEN;
  ------------------
  |  |  102|     92|#define BELPIC_MAX_USER_PIN_LEN		12
  ------------------
  250|       |
  251|     92|	return 0;
  252|    105|}
card-belpic.c:get_carddata:
  166|    105|{
  167|    105|	sc_apdu_t apdu;
  168|    105|	u8 carddata_cmd[] = { 0x80, 0xE4, 0x00, 0x00, 0x1C };
  169|    105|	int r;
  170|       |
  171|    105|	if (carddataloc_len != BELPIC_CARDDATA_RESP_LEN)
  ------------------
  |  |  139|    105|#define BELPIC_CARDDATA_RESP_LEN 28
  ------------------
  |  Branch (171:6): [True: 0, False: 105]
  ------------------
  172|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  173|       |
  174|    105|	r = sc_bytes2apdu(card->ctx, carddata_cmd, sizeof(carddata_cmd), &apdu);
  175|    105|	if(r) {
  ------------------
  |  Branch (175:5): [True: 0, False: 105]
  ------------------
  176|      0|		sc_log(card->ctx,  "bytes to APDU conversion failed: %d\n", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  177|      0|		return r;
  178|      0|	}
  179|       |
  180|    105|	apdu.resp = carddata_loc;
  181|    105|	apdu.resplen = carddataloc_len;
  182|       |
  183|    105|	r = sc_transmit_apdu(card, &apdu);
  184|    105|	if(r) {
  ------------------
  |  Branch (184:5): [True: 5, False: 100]
  ------------------
  185|      5|		sc_log(card->ctx,  "GetCardData command failed: %d\n", r);
  ------------------
  |  |   71|      5|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  186|      5|		return r;
  187|      5|	}
  188|       |
  189|    100|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  190|    100|	if(r) {
  ------------------
  |  Branch (190:5): [True: 7, False: 93]
  ------------------
  191|      7|		sc_log(card->ctx,  "GetCardData: card returned %d\n", r);
  ------------------
  |  |   71|      7|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  192|      7|		return r;
  193|      7|	}
  194|     93|	if(apdu.resplen < carddataloc_len) {
  ------------------
  |  Branch (194:5): [True: 1, False: 92]
  ------------------
  195|      1|		sc_log(card->ctx, "GetCardData: card returned %zu bytes rather than expected %d",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  196|      1|				apdu.resplen, carddataloc_len);
  197|      1|		return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      1|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  198|      1|	}
  199|       |
  200|     92|	return 0;
  201|     93|}
card-belpic.c:belpic_select_file:
  256|    455|{
  257|    455|	sc_apdu_t apdu;
  258|    455|	u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  259|    455|	int r;
  260|    455|	size_t pathlen;
  261|    455|	sc_file_t *file = NULL;
  262|       |
  263|    455|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (263:6): [True: 0, False: 455]
  |  Branch (263:22): [True: 0, False: 455]
  ------------------
  264|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  265|    455|	memcpy(path, in_path->value, in_path->len);
  266|    455|	pathlen = in_path->len;
  267|       |
  268|    455|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x08, 0x0C);
  ------------------
  |  |  293|    455|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  269|       |
  270|    455|	apdu.lc = pathlen;
  271|    455|	apdu.data = path;
  272|    455|	apdu.datalen = pathlen;
  273|       |
  274|    455|	apdu.resplen = 0;
  275|    455|	apdu.le = 0;
  276|       |
  277|    455|	r = sc_transmit_apdu(card, &apdu);
  278|       |
  279|    455|	LOG_TEST_RET(card->ctx, r, "Select File APDU transmit failed");
  ------------------
  |  |  174|    455|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    455|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    455|	int _ret = (r); \
  |  |  |  |  168|    455|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 16, False: 439]
  |  |  |  |  ------------------
  |  |  |  |  169|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     16|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     16|		return _ret; \
  |  |  |  |  172|     16|	} \
  |  |  |  |  173|    455|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 439]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  280|       |
  281|    439|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  282|    439|	if (r)
  ------------------
  |  Branch (282:6): [True: 207, False: 232]
  ------------------
  283|    207|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    207|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    207|	int _ret = r; \
  |  |  155|    207|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 207, False: 0]
  |  |  ------------------
  |  |  156|    207|		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|    207|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 207, False: 0]
  |  |  ------------------
  |  |  157|    207|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    207|	} 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|    207|	return _ret; \
  |  |  163|    207|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  284|       |
  285|    232|	next_idx = (size_t)-1;		/* reset */
  286|       |
  287|    232|	if (file_out != NULL) {
  ------------------
  |  Branch (287:6): [True: 153, False: 79]
  ------------------
  288|    153|		file = sc_file_new();
  289|    153|		file->path = *in_path;
  290|    153|		if (pathlen >= 2)
  ------------------
  |  Branch (290:7): [True: 153, False: 0]
  ------------------
  291|    153|			file->id = (in_path->value[pathlen - 2] << 8) | in_path->value[pathlen - 1];
  292|    153|		file->size = BELPIC_MAX_FILE_SIZE;
  ------------------
  |  |   99|    153|#define BELPIC_MAX_FILE_SIZE		65535
  ------------------
  293|    153|		file->shareable = 1;
  294|    153|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|    153|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  295|    153|		if (pathlen == 2 && memcmp("\x3F\x00", in_path->value, 2) == 0)
  ------------------
  |  Branch (295:7): [True: 54, False: 99]
  |  Branch (295:23): [True: 1, False: 53]
  ------------------
  296|      1|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      1|#define SC_FILE_TYPE_DF			0x04
  ------------------
  297|    152|		else
  298|    152|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    152|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  299|    153|		*file_out = file;
  300|    153|	}
  301|       |
  302|    232|	return 0;
  303|    439|}
card-belpic.c:belpic_read_binary:
  307|    452|{
  308|    452|	int r;
  309|       |
  310|    452|	if (next_idx == idx)
  ------------------
  |  Branch (310:6): [True: 69, False: 383]
  ------------------
  311|     69|		return 0;	/* File was already read entirely */
  312|       |
  313|    383|	r = iso_ops->read_binary(card, idx, buf, count, flags);
  314|       |
  315|       |	/* If the 'next_idx trick' shouldn't work, we hope this error
  316|       |	 * means that an attempt was made to read beyond the file's
  317|       |	 * contents, so we'll return 0 to end the loop in sc_read_binary()*/
  318|    383|	if (r == SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   55|    383|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (318:6): [True: 7, False: 376]
  ------------------
  319|      7|		return 0;
  320|       |
  321|    376|	if (r >= 0 && (size_t)r < count)
  ------------------
  |  Branch (321:6): [True: 311, False: 65]
  |  Branch (321:16): [True: 81, False: 230]
  ------------------
  322|     81|		next_idx = idx + (size_t)r;
  323|       |
  324|    376|	return r;
  325|    383|}
card-belpic.c:belpic_pin_cmd:
  328|      2|{
  329|      2|	data->pin1.encoding = data->pin2.encoding = BELPIC_PIN_ENCODING;
  ------------------
  |  |  103|      2|#define BELPIC_PIN_ENCODING		SC_PIN_ENCODING_GLP
  |  |  ------------------
  |  |  |  |  427|      2|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  |  |  ------------------
  ------------------
  330|      2|	data->pin1.pad_char = data->pin2.pad_char = BELPIC_PAD_CHAR;
  ------------------
  |  |  104|      2|#define BELPIC_PAD_CHAR			0xFF
  ------------------
  331|      2|	data->pin1.min_length = data->pin2.min_length = BELPIC_MIN_USER_PIN_LEN;
  ------------------
  |  |  101|      2|#define BELPIC_MIN_USER_PIN_LEN		4
  ------------------
  332|      2|	data->pin1.max_length = data->pin2.max_length = BELPIC_MAX_USER_PIN_LEN;
  ------------------
  |  |  102|      2|#define BELPIC_MAX_USER_PIN_LEN		12
  ------------------
  333|      2|	data->apdu = NULL;
  334|       |
  335|      2|	return iso_ops->pin_cmd(card, data);
  336|      2|}

get_cac_label:
   62|  3.46k|{
   63|  3.46k|	if (index < 0 || index >= MAX_CAC_SLOTS)
  ------------------
  |  |   70|  3.46k|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (63:6): [True: 0, False: 3.46k]
  |  Branch (63:19): [True: 0, False: 3.46k]
  ------------------
   64|      0|		return NULL;
   65|       |
   66|  3.46k|	return cac_labels[index];
   67|  3.46k|}
cac_new_private_data:
   83|  1.29k|{
   84|  1.29k|	cac_private_data_t *priv;
   85|       |
   86|  1.29k|	priv = calloc(1, sizeof(cac_private_data_t));
   87|  1.29k|	if (priv == NULL)
  ------------------
  |  Branch (87:6): [True: 0, False: 1.29k]
  ------------------
   88|      0|		return NULL;
   89|       |
   90|       |	/* Initialize PKI Applets list */
   91|  1.29k|	if (list_init(&priv->pki_list) != 0 ||
  ------------------
  |  Branch (91:6): [True: 0, False: 1.29k]
  ------------------
   92|  1.29k|	    list_attributes_comparator(&priv->pki_list, cac_list_compare_path) != 0 ||
  ------------------
  |  Branch (92:6): [True: 0, False: 1.29k]
  ------------------
   93|  1.29k|	    list_attributes_copy(&priv->pki_list, cac_list_meter, 1) != 0) {
  ------------------
  |  Branch (93:6): [True: 0, False: 1.29k]
  ------------------
   94|      0|		cac_free_private_data(priv);
   95|      0|		return NULL;
   96|      0|	}
   97|       |
   98|       |	/* Initialize General Applets List */
   99|  1.29k|	if (list_init(&priv->general_list) != 0 ||
  ------------------
  |  Branch (99:6): [True: 0, False: 1.29k]
  ------------------
  100|  1.29k|	    list_attributes_comparator(&priv->general_list, cac_list_compare_path) != 0 ||
  ------------------
  |  Branch (100:6): [True: 0, False: 1.29k]
  ------------------
  101|  1.29k|	    list_attributes_copy(&priv->general_list, cac_list_meter, 1) != 0) {
  ------------------
  |  Branch (101:6): [True: 0, False: 1.29k]
  ------------------
  102|      0|		cac_free_private_data(priv);
  103|      0|		return NULL;
  104|      0|	}
  105|       |
  106|  1.29k|	return priv;
  107|  1.29k|}
cac_free_private_data:
  110|  1.29k|{
  111|  1.29k|	free(priv->cac_id);
  112|  1.29k|	free(priv->cache_buf);
  113|  1.29k|	free(priv->aca_path);
  114|  1.29k|	list_destroy(&priv->pki_list);
  115|  1.29k|	list_destroy(&priv->general_list);
  116|  1.29k|	free(priv);
  117|  1.29k|	return;
  118|  1.29k|}
cac_add_object_to_list:
  121|  3.48k|{
  122|  3.48k|	if (list_append(list, object) < 0)
  ------------------
  |  Branch (122:6): [True: 0, False: 3.48k]
  ------------------
  123|      0|		return SC_ERROR_UNKNOWN;
  ------------------
  |  |  130|      0|#define SC_ERROR_UNKNOWN			-1900
  ------------------
  124|  3.48k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.48k|#define SC_SUCCESS				0
  ------------------
  125|  3.48k|}
card-cac-common.c:cac_list_compare_path:
   70|  29.6k|{
   71|  29.6k|	if (a == NULL || b == NULL)
  ------------------
  |  Branch (71:6): [True: 0, False: 29.6k]
  |  Branch (71:19): [True: 0, False: 29.6k]
  ------------------
   72|      0|		return 1;
   73|  29.6k|	return memcmp( &((cac_object_t *) a)->path,
   74|  29.6k|		&((cac_object_t *) b)->path, sizeof(sc_path_t));
   75|  29.6k|}
card-cac-common.c:cac_list_meter:
   78|  3.48k|static size_t cac_list_meter(const void *el) {
   79|  3.48k|	return sizeof(cac_object_t);
   80|  3.48k|}

sc_get_cac_driver:
 1911|  34.0k|{
 1912|  34.0k|	return sc_get_driver();
 1913|  34.0k|}
card-cac.c:sc_get_driver:
 1885|  34.0k|{
 1886|  34.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1887|       |
 1888|  34.0k|	cac_ops = *iso_drv->ops;
 1889|  34.0k|	cac_ops.match_card = cac_match_card;
 1890|  34.0k|	cac_ops.init = cac_init;
 1891|  34.0k|	cac_ops.finish = cac_finish;
 1892|       |
 1893|  34.0k|	cac_ops.select_file =  cac_select_file; /* need to record object type */
 1894|  34.0k|	cac_ops.get_challenge = cac_get_challenge;
 1895|  34.0k|	cac_ops.read_binary = cac_read_binary;
 1896|       |	/* CAC driver is read only */
 1897|  34.0k|	cac_ops.write_binary = NULL;
 1898|  34.0k|	cac_ops.set_security_env = cac_set_security_env;
 1899|  34.0k|	cac_ops.restore_security_env = cac_restore_security_env;
 1900|  34.0k|	cac_ops.compute_signature = cac_compute_signature;
 1901|  34.0k|	cac_ops.decipher =  cac_decipher;
 1902|  34.0k|	cac_ops.card_ctl = cac_card_ctl;
 1903|  34.0k|	cac_ops.pin_cmd = cac_pin_cmd;
 1904|  34.0k|	cac_ops.logout = cac_logout;
 1905|       |
 1906|  34.0k|	return &cac_drv;
 1907|  34.0k|}
card-cac.c:cac_match_card:
 1796|  4.83k|{
 1797|  4.83k|	int r;
 1798|  4.83k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  4.83k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  4.83k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  4.83k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 4.83k]
  |  |  ------------------
  ------------------
 1799|       |
 1800|  4.83k|	r = cac_find_and_initialize(card, 0);
 1801|  4.83k|	return (r == SC_SUCCESS); /* never match */
  ------------------
  |  |   28|  4.83k|#define SC_SUCCESS				0
  ------------------
 1802|  4.83k|}
card-cac.c:cac_find_and_initialize:
 1719|  5.95k|{
 1720|  5.95k|	int r, index;
 1721|  5.95k|	cac_private_data_t *priv = NULL;
 1722|       |
 1723|       |	/* already initialized? */
 1724|  5.95k|	if (card->drv_data) {
  ------------------
  |  Branch (1724:6): [True: 0, False: 5.95k]
  ------------------
 1725|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1726|      0|	}
 1727|       |
 1728|       |	/* is this a CAC-2 specified in NIST Interagency Report 6887 -
 1729|       |	 * "Government Smart Card Interoperability Specification v2.1 July 2003" */
 1730|  5.95k|	r = cac_select_CCC(card);
 1731|  5.95k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  5.95k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1731:6): [True: 1.44k, False: 4.51k]
  ------------------
 1732|  1.44k|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "CCC found, is CAC-2");
  ------------------
  |  |   70|  1.44k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1733|  1.44k|		if (!initialize) /* match card only */
  ------------------
  |  Branch (1733:7): [True: 989, False: 452]
  ------------------
 1734|    989|			return r;
 1735|       |
 1736|    452|		priv = cac_new_private_data();
 1737|    452|		if (!priv)
  ------------------
  |  Branch (1737:7): [True: 0, False: 452]
  ------------------
 1738|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1739|    452|		r = cac_process_CCC(card, priv, 0);
 1740|    452|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    452|#define SC_SUCCESS				0
  ------------------
  |  Branch (1740:7): [True: 262, False: 190]
  ------------------
 1741|    262|			card->type = SC_CARD_TYPE_CAC_II;
 1742|    262|			card->drv_data = priv;
 1743|    262|			return r;
 1744|    262|		}
 1745|    452|	}
 1746|       |
 1747|       |	/* Even some ALT tokens can be missing CCC so we should try with ACA */
 1748|  4.70k|	r = cac_select_ACA(card);
 1749|  4.70k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  4.70k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1749:6): [True: 601, False: 4.10k]
  ------------------
 1750|    601|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "ACA found, is CAC-2 without CCC");
  ------------------
  |  |   70|    601|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1751|    601|		if (!initialize) /* match card only */
  ------------------
  |  Branch (1751:7): [True: 98, False: 503]
  ------------------
 1752|     98|			return r;
 1753|       |
 1754|    503|		if (!priv) {
  ------------------
  |  Branch (1754:7): [True: 465, False: 38]
  ------------------
 1755|    465|			priv = cac_new_private_data();
 1756|    465|			if (!priv)
  ------------------
  |  Branch (1756:8): [True: 0, False: 465]
  ------------------
 1757|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1758|    465|		}
 1759|    503|		r = cac_process_ACA(card, priv);
 1760|    503|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    503|#define SC_SUCCESS				0
  ------------------
  |  Branch (1760:7): [True: 448, False: 55]
  ------------------
 1761|    448|			card->type = SC_CARD_TYPE_CAC_ALT_HID;
 1762|    448|			card->drv_data = priv;
 1763|    448|			return r;
 1764|    448|		}
 1765|    503|	}
 1766|       |
 1767|       |	/* is this a CAC Alt token without any accompanying structures */
 1768|  4.16k|	r = cac_find_first_pki_applet(card, &index);
 1769|  4.16k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  4.16k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1769:6): [True: 222, False: 3.93k]
  ------------------
 1770|    222|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "PKI applet found, is bare CAC Alt");
  ------------------
  |  |   70|    222|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1771|    222|		if (!initialize) /* match card only */
  ------------------
  |  Branch (1771:7): [True: 31, False: 191]
  ------------------
 1772|     31|			return r;
 1773|       |
 1774|    191|		if (!priv) {
  ------------------
  |  Branch (1774:7): [True: 157, False: 34]
  ------------------
 1775|    157|			priv = cac_new_private_data();
 1776|    157|			if (!priv)
  ------------------
  |  Branch (1776:8): [True: 0, False: 157]
  ------------------
 1777|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1778|    157|		}
 1779|    191|		card->drv_data = priv; /* needed for the read_binary() */
 1780|    191|		r = cac_populate_cac_alt(card, index, priv);
 1781|    191|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    191|#define SC_SUCCESS				0
  ------------------
  |  Branch (1781:7): [True: 131, False: 60]
  ------------------
 1782|    131|			card->type = SC_CARD_TYPE_CAC_II;
 1783|    131|			return r;
 1784|    131|		}
 1785|     60|		card->drv_data = NULL; /* reset on failure */
 1786|     60|	}
 1787|  3.99k|	if (priv) {
  ------------------
  |  Branch (1787:6): [True: 233, False: 3.76k]
  ------------------
 1788|    233|		cac_free_private_data(priv);
 1789|    233|	}
 1790|  3.99k|	return r;
 1791|  4.16k|}
card-cac.c:cac_select_CCC:
 1218|  5.95k|{
 1219|       |	return cac_select_file_by_type(card, &cac_CCC_Path, NULL);
 1220|  5.95k|}
card-cac.c:cac_select_file_by_type:
 1023|  83.5k|{
 1024|  83.5k|	struct sc_context *ctx;
 1025|  83.5k|	struct sc_apdu apdu;
 1026|  83.5k|	unsigned char buf[SC_MAX_APDU_BUFFER_SIZE];
 1027|  83.5k|	unsigned char pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
 1028|  83.5k|	int r, pathtype;
 1029|  83.5k|	size_t pathlen;
 1030|  83.5k|	struct sc_file *file = NULL;
 1031|  83.5k|	cac_private_data_t *priv;
 1032|       |
 1033|  83.5k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (1033:6): [True: 0, False: 83.5k]
  |  Branch (1033:22): [True: 0, False: 83.5k]
  ------------------
 1034|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1035|       |
 1036|  83.5k|	priv = CAC_DATA(card);
  ------------------
  |  |   61|  83.5k|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
 1037|  83.5k|	ctx = card->ctx;
 1038|       |
 1039|  83.5k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  83.5k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  83.5k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  83.5k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 83.5k]
  |  |  ------------------
  ------------------
 1040|       |
 1041|  83.5k|	memcpy(path, in_path->value, in_path->len);
 1042|  83.5k|	pathlen = in_path->len;
 1043|  83.5k|	pathtype = in_path->type;
 1044|       |
 1045|  83.5k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  83.5k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1046|  83.5k|	    "path=%s, path->value=%s path->type=%d (%x)",
 1047|  83.5k|	    sc_print_path(in_path),
 1048|  83.5k|	    sc_dump_hex(in_path->value, in_path->len),
 1049|  83.5k|	    in_path->type, in_path->type);
 1050|  83.5k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "file_out=%p index=%d count=%d\n",
  ------------------
  |  |   70|  83.5k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1051|  83.5k|	    file_out, in_path->index, in_path->count);
 1052|       |
 1053|       |	/* Sigh, iso7816_select_file expects paths to keys to have specific
 1054|       |	 * formats. There is no override. We have to add some bytes to the
 1055|       |	 * path to make it happy.
 1056|       |	 * We only need to do this for private keys.
 1057|       |	 */
 1058|  83.5k|	if ((pathlen > 2) && (pathlen <= 4) && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (1058:6): [True: 2.52k, False: 80.9k]
  |  Branch (1058:23): [True: 2.52k, False: 0]
  |  Branch (1058:41): [True: 2.52k, False: 0]
  ------------------
 1059|  2.52k|		path += 2;
 1060|  2.52k|		pathlen -= 2;
 1061|  2.52k|	}
 1062|       |
 1063|       |
 1064|       |	/* CAC has multiple different type of objects that aren't PKCS #15. When we read
 1065|       |	 * them we need convert them to something PKCS #15 would understand. Find the object
 1066|       |	 * and object type here:
 1067|       |	 */
 1068|  83.5k|	if (priv) { /* don't record anything if we haven't been initialized yet */
  ------------------
  |  Branch (1068:6): [True: 8.21k, False: 75.3k]
  ------------------
 1069|  8.21k|		priv->object_type = CAC_OBJECT_TYPE_GENERIC;
  ------------------
  |  |  172|  8.21k|#define CAC_OBJECT_TYPE_GENERIC		5
  ------------------
 1070|  8.21k|		if (cac_is_cert(priv, in_path)) {
  ------------------
  |  Branch (1070:7): [True: 1.78k, False: 6.43k]
  ------------------
 1071|  1.78k|			priv->object_type = CAC_OBJECT_TYPE_CERT;
  ------------------
  |  |  170|  1.78k|#define CAC_OBJECT_TYPE_CERT		1
  ------------------
 1072|  1.78k|		}
 1073|       |
 1074|       |		/* forget any old cached values */
 1075|  8.21k|		if (priv->cache_buf) {
  ------------------
  |  Branch (1075:7): [True: 30, False: 8.18k]
  ------------------
 1076|     30|			free(priv->cache_buf);
 1077|     30|			priv->cache_buf = NULL;
 1078|     30|		}
 1079|  8.21k|		priv->cache_buf_len = 0;
 1080|  8.21k|		priv->cached = 0;
 1081|  8.21k|	}
 1082|       |
 1083|  83.5k|	if (in_path->aid.len) {
  ------------------
  |  Branch (1083:6): [True: 80.9k, False: 2.52k]
  ------------------
 1084|  80.9k|		if (!pathlen) {
  ------------------
  |  Branch (1084:7): [True: 79.6k, False: 1.39k]
  ------------------
 1085|  79.6k|			memcpy(path, in_path->aid.value, in_path->aid.len);
 1086|  79.6k|			pathlen = in_path->aid.len;
 1087|  79.6k|			pathtype = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  79.6k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 1088|  79.6k|		} else {
 1089|       |			/* First, select the application */
 1090|  1.39k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"select application" );
  ------------------
  |  |   70|  1.39k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1091|  1.39k|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
  ------------------
  |  |  293|  1.39k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1092|  1.39k|			apdu.data = in_path->aid.value;
 1093|  1.39k|			apdu.datalen = in_path->aid.len;
 1094|  1.39k|			apdu.lc = in_path->aid.len;
 1095|       |
 1096|  1.39k|			r = sc_transmit_apdu(card, &apdu);
 1097|  1.39k|			LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.39k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.39k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.39k|	int _ret = (r); \
  |  |  |  |  168|  1.39k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 18, False: 1.37k]
  |  |  |  |  ------------------
  |  |  |  |  169|     18|		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|     18|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     18|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     18|		return _ret; \
  |  |  |  |  172|     18|	} \
  |  |  |  |  173|  1.39k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|  1.37k|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1099|  1.37k|			if (r)
  ------------------
  |  Branch (1099:8): [True: 477, False: 899]
  ------------------
 1100|  1.37k|				LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    477|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    477|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    477|	int _ret = r; \
  |  |  |  |  155|    477|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 477, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    477|		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|    477|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 477, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    477|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    477|	} 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|    477|	return _ret; \
  |  |  |  |  163|    477|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1101|       |
 1102|  1.37k|		}
 1103|  80.9k|	}
 1104|       |
 1105|  83.0k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  294|  83.0k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1106|       |
 1107|  83.0k|	switch (pathtype) {
 1108|       |	/* ideally we would had SC_PATH_TYPE_OBJECT_ID and add code to the iso7816 select.
 1109|       |	 * Unfortunately we'd also need to update the caching code as well. For now just
 1110|       |	 * use FILE_ID and change p1 here */
 1111|    899|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|    899|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1111:2): [True: 899, False: 82.1k]
  ------------------
 1112|    899|		apdu.p1 = 2;
 1113|    899|		if (pathlen != 2)
  ------------------
  |  Branch (1113:7): [True: 0, False: 899]
  ------------------
 1114|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1115|    899|		break;
 1116|  79.6k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  79.6k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1116:2): [True: 79.6k, False: 3.42k]
  ------------------
 1117|  79.6k|		apdu.p1 = 4;
 1118|  79.6k|		break;
 1119|  2.52k|	default:
  ------------------
  |  Branch (1119:2): [True: 2.52k, False: 80.5k]
  ------------------
 1120|  2.52k|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|  2.52k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.52k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.52k|	int _ret = r; \
  |  |  |  |  155|  2.52k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.52k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.52k|		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|  2.52k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.52k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.52k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.52k|	} 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|  2.52k|	return _ret; \
  |  |  |  |  163|  2.52k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1121|  83.0k|	}
 1122|  80.5k|	apdu.lc = pathlen;
 1123|  80.5k|	apdu.data = path;
 1124|  80.5k|	apdu.datalen = pathlen;
 1125|  80.5k|	apdu.resp = buf;
 1126|  80.5k|	apdu.resplen = sizeof(buf);
 1127|  80.5k|	apdu.le = sc_get_max_recv_size(card) < 256 ? sc_get_max_recv_size(card) : 256;
  ------------------
  |  Branch (1127:12): [True: 0, False: 80.5k]
  ------------------
 1128|       |
 1129|  80.5k|	if (file_out != NULL) {
  ------------------
  |  Branch (1129:6): [True: 1.20k, False: 79.2k]
  ------------------
 1130|  1.20k|		apdu.p2 = 0;		/* first record, return FCI */
 1131|  1.20k|	}
 1132|  79.2k|	else {
 1133|  79.2k|		apdu.p2 = 0x0C;
 1134|  79.2k|	}
 1135|       |
 1136|  80.5k|	r = sc_transmit_apdu(card, &apdu);
 1137|  80.5k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  80.5k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  80.5k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  80.5k|	int _ret = (r); \
  |  |  |  |  168|  80.5k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 555, False: 79.9k]
  |  |  |  |  ------------------
  |  |  |  |  169|    555|		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|    555|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    555|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    555|		return _ret; \
  |  |  |  |  172|    555|	} \
  |  |  |  |  173|  80.5k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 79.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1138|       |
 1139|  79.9k|	if (file_out == NULL) {
  ------------------
  |  Branch (1139:6): [True: 78.7k, False: 1.19k]
  ------------------
 1140|       |		/* For some cards 'SELECT' can be only with request to return FCI/FCP. */
 1141|  78.7k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1142|  78.7k|		if (apdu.sw1 == 0x6A && apdu.sw2 == 0x86)   {
  ------------------
  |  Branch (1142:7): [True: 225, False: 78.5k]
  |  Branch (1142:27): [True: 161, False: 64]
  ------------------
 1143|    161|			apdu.p2 = 0x00;
 1144|    161|			apdu.resplen = sizeof(buf);
 1145|    161|			if (sc_transmit_apdu(card, &apdu) == SC_SUCCESS)
  ------------------
  |  |   28|    161|#define SC_SUCCESS				0
  ------------------
  |  Branch (1145:8): [True: 104, False: 57]
  ------------------
 1146|    104|				r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1147|    161|		}
 1148|  78.7k|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (1148:7): [True: 57, False: 78.6k]
  ------------------
 1149|  78.7k|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     57|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     57|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     57|	int _ret = r; \
  |  |  |  |  155|     57|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 57, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     57|		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: 57]
  |  |  |  |  ------------------
  |  |  |  |  157|     57|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     57|	} 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|     57|	return _ret; \
  |  |  |  |  163|     57|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1150|  78.6k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  78.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  78.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  78.6k|	int _ret = r; \
  |  |  |  |  155|  78.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 78.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  78.6k|		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|  73.8k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 73.8k, False: 4.85k]
  |  |  |  |  ------------------
  |  |  |  |  157|  78.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  78.6k|	} 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|  78.6k|	return _ret; \
  |  |  |  |  163|  78.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1151|  78.6k|	}
 1152|       |
 1153|  1.19k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1154|  1.19k|	if (r)
  ------------------
  |  Branch (1154:6): [True: 537, False: 662]
  ------------------
 1155|  1.19k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    537|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    537|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    537|	int _ret = r; \
  |  |  |  |  155|    537|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 537, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    537|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    537|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 537, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    537|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    537|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    537|	return _ret; \
  |  |  |  |  163|    537|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1156|       |
 1157|       |	/* This needs to come after the applet selection */
 1158|    662|	if (priv && in_path->len >= 2) {
  ------------------
  |  Branch (1158:6): [True: 662, False: 0]
  |  Branch (1158:14): [True: 322, False: 340]
  ------------------
 1159|       |		/* get applet properties to know if we can treat the
 1160|       |		 * buffer as SimpleLTV and if we have PKI applet.
 1161|       |		 *
 1162|       |		 * Do this only if we select applets for reading
 1163|       |		 * (not during driver initialization)
 1164|       |		 */
 1165|    322|		cac_properties_t prop = {0};
 1166|    322|		size_t i = -1;
 1167|       |
 1168|    322|		r = cac_get_properties(card, &prop);
 1169|    322|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    322|#define SC_SUCCESS				0
  ------------------
  |  Branch (1169:7): [True: 280, False: 42]
  ------------------
 1170|    370|			for (i = 0; i < prop.num_objects; i++) {
  ------------------
  |  Branch (1170:16): [True: 184, False: 186]
  ------------------
 1171|    184|				sc_log(card->ctx, "Searching for our OID: 0x%02x 0x%02x = 0x%02x 0x%02x",
  ------------------
  |  |   71|    184|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1172|    184|				    prop.objects[i].oid[0], prop.objects[i].oid[1],
 1173|    184|					in_path->value[0], in_path->value[1]);
 1174|    184|				if (memcmp(prop.objects[i].oid,
  ------------------
  |  Branch (1174:9): [True: 94, False: 90]
  ------------------
 1175|    184|				    in_path->value, 2) == 0)
 1176|     94|					break;
 1177|    184|			}
 1178|    280|		}
 1179|    322|		if (i < prop.num_objects) {
  ------------------
  |  Branch (1179:7): [True: 94, False: 228]
  ------------------
 1180|     94|			if (prop.objects[i].privatekey)
  ------------------
  |  Branch (1180:8): [True: 24, False: 70]
  ------------------
 1181|     24|				priv->object_type = CAC_OBJECT_TYPE_CERT;
  ------------------
  |  |  170|     24|#define CAC_OBJECT_TYPE_CERT		1
  ------------------
 1182|     70|			else if (prop.objects[i].simpletlv == 0)
  ------------------
  |  Branch (1182:13): [True: 64, False: 6]
  ------------------
 1183|     64|				priv->object_type = CAC_OBJECT_TYPE_TLV_FILE;
  ------------------
  |  |  171|     64|#define CAC_OBJECT_TYPE_TLV_FILE	4
  ------------------
 1184|     94|		}
 1185|    322|	}
 1186|       |
 1187|       |	/* CAC cards never return FCI, fake one */
 1188|    662|	file = sc_file_new();
 1189|    662|	if (file == NULL)
  ------------------
  |  Branch (1189:6): [True: 0, False: 662]
  ------------------
 1190|    662|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1191|    662|	file->path = *in_path;
 1192|    662|	file->size = CAC_MAX_SIZE; /* we don't know how big, just give a large size until we can read the file */
  ------------------
  |  |   26|    662|#define CAC_MAX_SIZE 4096		/* arbitrary, just needs to be 'large enough' */
  ------------------
 1193|       |
 1194|    662|	*file_out = file;
 1195|    662|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    662|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    662|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    662|	int _ret = r; \
  |  |  |  |  155|    662|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 662, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    662|		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: 662]
  |  |  |  |  ------------------
  |  |  |  |  157|    662|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    662|	} 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|    662|	return _ret; \
  |  |  |  |  163|    662|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1196|       |
 1197|    662|}
card-cac.c:cac_is_cert:
  231|  8.21k|{
  232|  8.21k|	cac_object_t test_obj = {0};
  233|  8.21k|	test_obj.path = *in_path;
  234|  8.21k|	test_obj.path.index = 0;
  235|  8.21k|	test_obj.path.count = 0;
  236|       |
  237|  8.21k|	return (list_contains(&priv->pki_list, &test_obj) != 0);
  238|  8.21k|}
card-cac.c:cac_get_properties:
  919|    562|{
  920|    562|	u8 *rbuf = NULL;
  921|    562|	size_t rbuflen = 0, len;
  922|    562|	const u8 *val, *val_end;
  923|    562|	u8 tag;
  924|    562|	size_t i = 0;
  925|    562|	int r;
  926|    562|	prop->num_objects = 0;
  927|       |
  928|    562|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    562|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    562|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    562|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 562]
  |  |  ------------------
  ------------------
  929|       |
  930|    562|	r = cac_apdu_io(card, CAC_INS_GET_PROPERTIES, 0x01, 0x00, NULL, 0,
  ------------------
  |  |   63|    562|#define CAC_INS_GET_PROPERTIES        0x56
  ------------------
  931|    562|		&rbuf, &rbuflen);
  932|    562|	if (r < 0)
  ------------------
  |  Branch (932:6): [True: 48, False: 514]
  ------------------
  933|     48|		return r;
  934|       |
  935|    514|	val = rbuf;
  936|    514|	val_end = val + rbuflen;
  937|  22.3k|	for (; val < val_end; val += len) {
  ------------------
  |  Branch (937:9): [True: 22.1k, False: 196]
  ------------------
  938|       |		/* get the tag and the length */
  939|  22.1k|		if (sc_simpletlv_read_tag(&val, val_end - val, &tag, &len) != SC_SUCCESS)
  ------------------
  |  |   28|  22.1k|#define SC_SUCCESS				0
  ------------------
  |  Branch (939:7): [True: 290, False: 21.8k]
  ------------------
  940|    290|			break;
  941|       |
  942|  21.8k|		switch (tag) {
  943|  1.16k|		case CAC_TAG_APPLET_INFORMATION:
  ------------------
  |  |   89|  1.16k|#define CAC_TAG_APPLET_INFORMATION    0x01
  ------------------
  |  Branch (943:3): [True: 1.16k, False: 20.6k]
  ------------------
  944|  1.16k|			if (len != 5) {
  ------------------
  |  Branch (944:8): [True: 947, False: 221]
  ------------------
  945|    947|				sc_log(card->ctx, "TAG: Applet Information: Invalid length %zu", len);
  ------------------
  |  |   71|    947|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  946|    947|				break;
  947|    947|			}
  948|    221|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    221|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  949|    221|			    "TAG: Applet Information: Family: 0x%0x", val[0]);
  950|    221|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    221|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  951|    221|			    "     Applet Version: 0x%02x 0x%02x 0x%02x 0x%02x",
  952|    221|			    val[1], val[2], val[3], val[4]);
  953|    221|			break;
  954|       |
  955|  1.98k|		case CAC_TAG_NUMBER_OF_OBJECTS:
  ------------------
  |  |   90|  1.98k|#define CAC_TAG_NUMBER_OF_OBJECTS     0x40
  ------------------
  |  Branch (955:3): [True: 1.98k, False: 19.8k]
  ------------------
  956|  1.98k|			if (len != 1) {
  ------------------
  |  Branch (956:8): [True: 281, False: 1.70k]
  ------------------
  957|    281|				sc_log(card->ctx, "TAG: Num objects: Invalid length %zu", len);
  ------------------
  |  |   71|    281|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  958|    281|				break;
  959|    281|			}
  960|  1.70k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  1.70k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  961|  1.70k|			    "TAG: Num objects = %hhd", *val);
  962|       |			/* make sure we do not overrun buffer */
  963|  1.70k|			prop->num_objects = MIN(val[0], CAC_MAX_OBJECTS);
  ------------------
  |  |   69|  1.70k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 213, False: 1.48k]
  |  |  ------------------
  ------------------
  964|  1.70k|			break;
  965|       |
  966|  1.74k|		case CAC_TAG_TV_BUFFER:
  ------------------
  |  |   91|  1.74k|#define CAC_TAG_TV_BUFFER             0x50
  ------------------
  |  Branch (966:3): [True: 1.74k, False: 20.0k]
  ------------------
  967|  1.74k|			if (len != 17) {
  ------------------
  |  Branch (967:8): [True: 462, False: 1.28k]
  ------------------
  968|    462|				sc_log(card->ctx, "TAG: TV Object: Invalid length %zu", len);
  ------------------
  |  |   71|    462|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  969|    462|				break;
  970|    462|			}
  971|  1.28k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "TAG: TV Object nr. %zu", i);
  ------------------
  |  |   70|  1.28k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  972|  1.28k|			if (i >= CAC_MAX_OBJECTS) {
  ------------------
  |  |  145|  1.28k|#define CAC_MAX_OBJECTS 16
  ------------------
  |  Branch (972:8): [True: 3, False: 1.28k]
  ------------------
  973|      3|				free(rbuf);
  974|      3|				return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  975|      3|			}
  976|       |
  977|  1.28k|			if (cac_parse_properties_object(card, tag, val, len,
  ------------------
  |  Branch (977:8): [True: 58, False: 1.22k]
  ------------------
  978|  1.28k|			    &prop->objects[i]) == SC_SUCCESS)
  ------------------
  |  |   28|  1.28k|#define SC_SUCCESS				0
  ------------------
  979|     58|				i++;
  980|  1.28k|			break;
  981|       |
  982|  2.66k|		case CAC_TAG_PKI_OBJECT:
  ------------------
  |  |   92|  2.66k|#define CAC_TAG_PKI_OBJECT            0x51
  ------------------
  |  Branch (982:3): [True: 2.66k, False: 19.1k]
  ------------------
  983|  2.66k|			if (len != 17) {
  ------------------
  |  Branch (983:8): [True: 334, False: 2.33k]
  ------------------
  984|    334|				sc_log(card->ctx, "TAG: PKI Object: Invalid length %zu", len);
  ------------------
  |  |   71|    334|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  985|    334|				break;
  986|    334|			}
  987|  2.33k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "TAG: PKI Object nr. %zu", i);
  ------------------
  |  |   70|  2.33k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  988|  2.33k|			if (i >= CAC_MAX_OBJECTS) {
  ------------------
  |  |  145|  2.33k|#define CAC_MAX_OBJECTS 16
  ------------------
  |  Branch (988:8): [True: 25, False: 2.30k]
  ------------------
  989|     25|				free(rbuf);
  990|     25|				return SC_SUCCESS;
  ------------------
  |  |   28|     25|#define SC_SUCCESS				0
  ------------------
  991|     25|			}
  992|       |
  993|  2.30k|			if (cac_parse_properties_object(card, tag, val, len,
  ------------------
  |  Branch (993:8): [True: 1.16k, False: 1.14k]
  ------------------
  994|  2.30k|			    &prop->objects[i]) == SC_SUCCESS)
  ------------------
  |  |   28|  2.30k|#define SC_SUCCESS				0
  ------------------
  995|  1.16k|				i++;
  996|  2.30k|			break;
  997|       |
  998|  14.2k|		default:
  ------------------
  |  Branch (998:3): [True: 14.2k, False: 7.55k]
  ------------------
  999|       |			/* ignore tags we don't understand */
 1000|  14.2k|			sc_log(card->ctx, "TAG: Unknown (0x%02x), len=%zu", tag, len);
  ------------------
  |  |   71|  14.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1001|  14.2k|			break;
 1002|  21.8k|		}
 1003|  21.8k|	}
 1004|    486|	free(rbuf);
 1005|       |	/* sanity */
 1006|    486|	if (i != prop->num_objects)
  ------------------
  |  Branch (1006:6): [True: 188, False: 298]
  ------------------
 1007|    188|		sc_log(card->ctx, "The announced number of objects (%zu) did not match reality (%zu)",
  ------------------
  |  |   71|    188|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1008|    486|				prop->num_objects, i);
 1009|    486|	prop->num_objects = i;
 1010|       |
 1011|    486|	return SC_SUCCESS;
  ------------------
  |  |   28|    486|#define SC_SUCCESS				0
  ------------------
 1012|    514|}
card-cac.c:cac_apdu_io:
  253|  13.2k|{
  254|  13.2k|	int r;
  255|  13.2k|	sc_apdu_t apdu = {0};
  256|  13.2k|	u8 rbufinitbuf[CAC_MAX_SIZE];
  257|  13.2k|	u8 *rbuf;
  258|  13.2k|	size_t rbuflen;
  259|  13.2k|	unsigned int apdu_case = SC_APDU_CASE_1;
  ------------------
  |  |  291|  13.2k|#define SC_APDU_CASE_1			0x01
  ------------------
  260|       |
  261|       |
  262|  13.2k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  13.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  13.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  13.2k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 13.2k]
  |  |  ------------------
  ------------------
  263|       |
  264|  13.2k|	sc_log(card->ctx, "%02x %02x %02x %zu : %zu %zu",
  ------------------
  |  |   71|  13.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  265|  13.2k|			ins, p1, p2, sendbuflen, card->max_send_size, card->max_recv_size);
  266|       |
  267|  13.2k|	rbuf = rbufinitbuf;
  268|  13.2k|	rbuflen = sizeof(rbufinitbuf);
  269|       |
  270|       |	/* if caller provided a buffer and length */
  271|  13.2k|	if (recvbuf && *recvbuf && recvbuflen && *recvbuflen) {
  ------------------
  |  Branch (271:6): [True: 13.2k, False: 0]
  |  Branch (271:17): [True: 12.1k, False: 1.06k]
  |  Branch (271:29): [True: 12.1k, False: 0]
  |  Branch (271:43): [True: 12.1k, False: 0]
  ------------------
  272|  12.1k|		rbuf = *recvbuf;
  273|  12.1k|		rbuflen = *recvbuflen;
  274|  12.1k|	}
  275|       |
  276|  13.2k|	if (recvbuf) {
  ------------------
  |  Branch (276:6): [True: 13.2k, False: 0]
  ------------------
  277|  13.2k|		if (sendbuf)
  ------------------
  |  Branch (277:7): [True: 11.2k, False: 1.98k]
  ------------------
  278|  11.2k|			apdu_case = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|  11.2k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  279|  1.98k|		else
  280|  1.98k|			apdu_case = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|  1.98k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  281|  13.2k|	} else if (sendbuf)
  ------------------
  |  Branch (281:13): [True: 0, False: 0]
  ------------------
  282|      0|		apdu_case = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  283|       |
  284|       |
  285|  13.2k|	sc_format_apdu(card, &apdu, apdu_case, ins, p1, p2);
  286|       |
  287|  13.2k|	apdu.lc = sendbuflen;
  288|  13.2k|	apdu.datalen = sendbuflen;
  289|  13.2k|	apdu.data = sendbuf;
  290|       |
  291|  13.2k|	if (recvbuf) {
  ------------------
  |  Branch (291:6): [True: 13.2k, False: 0]
  ------------------
  292|  13.2k|		apdu.resp = rbuf;
  293|  13.2k|		apdu.le = (rbuflen > 255) ? 255 : rbuflen;
  ------------------
  |  Branch (293:13): [True: 1.06k, False: 12.1k]
  ------------------
  294|  13.2k|		apdu.resplen = rbuflen;
  295|  13.2k|	} else {
  296|      0|		 apdu.resp =  rbuf;
  297|      0|		 apdu.le = 0;
  298|      0|		 apdu.resplen = 0;
  299|      0|	}
  300|       |
  301|  13.2k|	sc_log(card->ctx, "calling sc_transmit_apdu flags=%lx le=%zu, resplen=%zu, resp=%p",
  ------------------
  |  |   71|  13.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  302|  13.2k|			apdu.flags, apdu.le, apdu.resplen, apdu.resp);
  303|       |
  304|       |	/* with new adpu.c and chaining, this actually reads the whole object */
  305|  13.2k|	r = sc_transmit_apdu(card, &apdu);
  306|       |
  307|  13.2k|	sc_log(card->ctx, "result r=%d apdu.resplen=%zu sw1=%02x sw2=%02x",
  ------------------
  |  |   71|  13.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  308|  13.2k|			r, apdu.resplen, apdu.sw1, apdu.sw2);
  309|  13.2k|	if (r < 0) {
  ------------------
  |  Branch (309:6): [True: 107, False: 13.1k]
  ------------------
  310|    107|		sc_log(card->ctx, "Transmit failed");
  ------------------
  |  |   71|    107|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  311|    107|		goto err;
  312|    107|	}
  313|       |
  314|  13.1k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  315|       |
  316|  13.1k|	if (r < 0) {
  ------------------
  |  Branch (316:6): [True: 966, False: 12.1k]
  ------------------
  317|    966|		sc_log(card->ctx,  "Card returned error ");
  ------------------
  |  |   71|    966|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  318|    966|		goto err;
  319|    966|	}
  320|       |
  321|  12.1k|	if (recvbuflen) {
  ------------------
  |  Branch (321:6): [True: 12.1k, False: 0]
  ------------------
  322|  12.1k|		if (recvbuf && *recvbuf == NULL) {
  ------------------
  |  Branch (322:7): [True: 12.1k, False: 0]
  |  Branch (322:18): [True: 986, False: 11.1k]
  ------------------
  323|    986|			*recvbuf =  malloc(apdu.resplen);
  324|    986|			if (*recvbuf == NULL) {
  ------------------
  |  Branch (324:8): [True: 0, False: 986]
  ------------------
  325|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  326|      0|				goto err;
  327|      0|			}
  328|    986|			memcpy(*recvbuf, rbuf, apdu.resplen);
  329|    986|		}
  330|  12.1k|		*recvbuflen =  apdu.resplen;
  331|  12.1k|		r = (int)*recvbuflen;
  332|  12.1k|	}
  333|       |
  334|  13.2k|err:
  335|  13.2k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  13.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  13.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  13.2k|	int _ret = r; \
  |  |  |  |  155|  13.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.43k, False: 11.7k]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.43k|		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|  1.07k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.07k, False: 363]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.43k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  11.7k|	} else { \
  |  |  |  |  159|  11.7k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  11.7k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  11.7k|	} \
  |  |  |  |  162|  13.2k|	return _ret; \
  |  |  |  |  163|  13.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  336|  13.2k|}
card-cac.c:cac_parse_properties_object:
  844|  3.58k|{
  845|  3.58k|	size_t len;
  846|  3.58k|	const u8 *val, *val_end;
  847|  3.58k|	u8 tag;
  848|  3.58k|	int parsed = 0;
  849|       |
  850|  3.58k|	if (data_len < 11)
  ------------------
  |  Branch (850:6): [True: 0, False: 3.58k]
  ------------------
  851|      0|		return -1;
  852|       |
  853|       |	/* Initialize: non-PKI applet */
  854|  3.58k|	object->privatekey = 0;
  855|       |
  856|  3.58k|	val = data;
  857|  3.58k|	val_end = data + data_len;
  858|  16.9k|	for (; val < val_end; val += len) {
  ------------------
  |  Branch (858:9): [True: 15.3k, False: 1.58k]
  ------------------
  859|       |		/* get the tag and the length */
  860|  15.3k|		if (sc_simpletlv_read_tag(&val, val_end - val, &tag, &len) != SC_SUCCESS)
  ------------------
  |  |   28|  15.3k|#define SC_SUCCESS				0
  ------------------
  |  Branch (860:7): [True: 2.00k, False: 13.3k]
  ------------------
  861|  2.00k|			break;
  862|       |
  863|  13.3k|		switch (tag) {
  864|  2.26k|		case CAC_TAG_OBJECT_ID:
  ------------------
  |  |   93|  2.26k|#define CAC_TAG_OBJECT_ID             0x41
  ------------------
  |  Branch (864:3): [True: 2.26k, False: 11.0k]
  ------------------
  865|  2.26k|			if (len != 2) {
  ------------------
  |  Branch (865:8): [True: 697, False: 1.56k]
  ------------------
  866|    697|				sc_log(card->ctx, "TAG: Object ID: Invalid length %zu", len);
  ------------------
  |  |   71|    697|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  867|    697|				break;
  868|    697|			}
  869|  1.56k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  1.56k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  870|  1.56k|			    "TAG: Object ID = 0x%02x 0x%02x", val[0], val[1]);
  871|  1.56k|			memcpy(&object->oid, val, 2);
  872|  1.56k|			parsed++;
  873|  1.56k|			break;
  874|       |
  875|  2.02k|		case CAC_TAG_BUFFER_PROPERTIES:
  ------------------
  |  |   94|  2.02k|#define CAC_TAG_BUFFER_PROPERTIES     0x42
  ------------------
  |  Branch (875:3): [True: 2.02k, False: 11.3k]
  ------------------
  876|  2.02k|			if (len != 5) {
  ------------------
  |  Branch (876:8): [True: 578, False: 1.45k]
  ------------------
  877|    578|				sc_log(card->ctx, "TAG: Buffer Properties: Invalid length %zu", len);
  ------------------
  |  |   71|    578|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  878|    578|				break;
  879|    578|			}
  880|       |			/* First byte is "Type of Tag Supported" */
  881|  1.45k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  1.45k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  882|  1.45k|			    "TAG: Buffer Properties: Type of Tag Supported = 0x%02x",
  883|  1.45k|			    val[0]);
  884|  1.45k|			object->simpletlv = val[0];
  885|  1.45k|			parsed++;
  886|  1.45k|			break;
  887|       |
  888|  2.19k|		case CAC_TAG_PKI_PROPERTIES:
  ------------------
  |  |   95|  2.19k|#define CAC_TAG_PKI_PROPERTIES        0x43
  ------------------
  |  Branch (888:3): [True: 2.19k, False: 11.1k]
  ------------------
  889|       |			/* 4th byte is "Private Key Initialized" */
  890|  2.19k|			if (len != 4) {
  ------------------
  |  Branch (890:8): [True: 983, False: 1.21k]
  ------------------
  891|    983|				sc_log(card->ctx, "TAG: PKI Properties: Invalid length %zu", len);
  ------------------
  |  |   71|    983|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  892|    983|				break;
  893|    983|			}
  894|  1.21k|			if (type != CAC_TAG_PKI_OBJECT) {
  ------------------
  |  |   92|  1.21k|#define CAC_TAG_PKI_OBJECT            0x51
  ------------------
  |  Branch (894:8): [True: 423, False: 793]
  ------------------
  895|    423|				sc_log(card->ctx, "TAG: PKI Properties outside of PKI Object");
  ------------------
  |  |   71|    423|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  896|    423|				break;
  897|    423|			}
  898|    793|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    793|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  899|    793|			    "TAG: PKI Properties: Private Key Initialized = 0x%02x",
  900|    793|			    val[2]);
  901|    793|			object->privatekey = val[2];
  902|    793|			parsed++;
  903|    793|			break;
  904|       |
  905|  6.86k|		default:
  ------------------
  |  Branch (905:3): [True: 6.86k, False: 6.49k]
  ------------------
  906|       |			/* ignore tags we don't understand */
  907|  6.86k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  6.86k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  908|  6.86k|			    "TAG: Unknown (0x%02x)",tag );
  909|  6.86k|			break;
  910|  13.3k|		}
  911|  13.3k|	}
  912|  3.58k|	if (parsed < 2)
  ------------------
  |  Branch (912:6): [True: 2.36k, False: 1.21k]
  ------------------
  913|  2.36k|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|  2.36k|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  914|       |
  915|  1.21k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.21k|#define SC_SUCCESS				0
  ------------------
  916|  3.58k|}
card-cac.c:cac_process_CCC:
 1498|  1.00k|{
 1499|  1.00k|	u8 *tl = NULL, *val = NULL;
 1500|  1.00k|	size_t tl_len = 0, val_len = 0;
 1501|  1.00k|	int r;
 1502|       |
 1503|  1.00k|	if (depth > CAC_MAX_CCC_DEPTH) {
  ------------------
  |  |  106|  1.00k|#define CAC_MAX_CCC_DEPTH             16
  ------------------
  |  Branch (1503:6): [True: 3, False: 997]
  ------------------
 1504|      3|		sc_log(card->ctx, "Too much recursive CCC found. Exiting");
  ------------------
  |  |   71|      3|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1505|      3|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      3|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1506|      3|	}
 1507|       |
 1508|    997|	r = cac_read_file(card, CAC_FILE_TAG, &tl, &tl_len);
  ------------------
  |  |   66|    997|#define CAC_FILE_TAG    1
  ------------------
 1509|    997|	if (r < 0)
  ------------------
  |  Branch (1509:6): [True: 119, False: 878]
  ------------------
 1510|    119|		goto done;
 1511|       |
 1512|    878|	r = cac_read_file(card, CAC_FILE_VALUE, &val, &val_len);
  ------------------
  |  |   67|    878|#define CAC_FILE_VALUE  2
  ------------------
 1513|    878|	if (r < 0)
  ------------------
  |  Branch (1513:6): [True: 15, False: 863]
  ------------------
 1514|     15|		goto done;
 1515|       |
 1516|    863|	r = cac_parse_CCC(card, priv, tl, tl_len, val, val_len, depth);
 1517|    997|done:
 1518|    997|	if (tl)
  ------------------
  |  Branch (1518:6): [True: 878, False: 119]
  ------------------
 1519|    878|		free(tl);
 1520|    997|	if (val)
  ------------------
  |  Branch (1520:6): [True: 863, False: 134]
  ------------------
 1521|    863|		free(val);
 1522|    997|	return r;
 1523|    863|}
card-cac.c:cac_read_file:
  385|  2.94k|{
  386|  2.94k|	u8 params[2];
  387|  2.94k|	u8 count[2] = {0};
  388|  2.94k|	u8 *out = NULL;
  389|  2.94k|	u8 *out_ptr = NULL;
  390|  2.94k|	size_t offset = 0;
  391|  2.94k|	size_t size = 0;
  392|  2.94k|	size_t left = 0;
  393|  2.94k|	size_t len = 0;
  394|  2.94k|	int r;
  395|       |
  396|  2.94k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  2.94k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.94k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.94k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.94k]
  |  |  ------------------
  ------------------
  397|       |
  398|  2.94k|	params[0] = file_type;
  399|  2.94k|	params[1] = 2;
  400|       |
  401|       |	/* get the size */
  402|  2.94k|	len = sizeof(count);
  403|  2.94k|	out_ptr = count;
  404|  2.94k|	r = cac_apdu_io(card, CAC_INS_READ_FILE, 0, 0, &params[0], sizeof(params), &out_ptr, &len);
  ------------------
  |  |   61|  2.94k|#define CAC_INS_READ_FILE             0x52  /* read a TL or V file */
  ------------------
  405|  2.94k|	if (len == 0) {
  ------------------
  |  Branch (405:6): [True: 199, False: 2.74k]
  ------------------
  406|    199|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|    199|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  407|    199|	}
  408|  2.94k|	if (r < 0)
  ------------------
  |  Branch (408:6): [True: 431, False: 2.51k]
  ------------------
  409|    431|		goto fail;
  410|       |
  411|  2.51k|	left = size = lebytes2ushort(count);
  412|  2.51k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  2.51k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  413|  2.51k|			"got %zu bytes out_ptr=%p count&=%p count[0]=0x%02x count[1]=0x%02x, len=0x%04zx (%zu)",
  414|  2.51k|			len, out_ptr, &count, count[0], count[1], size, size);
  415|  2.51k|	out = out_ptr = malloc(size);
  416|  2.51k|	if (out == NULL) {
  ------------------
  |  Branch (416:6): [True: 0, False: 2.51k]
  ------------------
  417|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  418|      0|		goto fail;
  419|      0|	}
  420|  10.1k|	for (offset += 2; left > 0; offset += len, left -= len, out_ptr += len) {
  ------------------
  |  Branch (420:20): [True: 7.84k, False: 2.33k]
  ------------------
  421|  7.84k|		len = MIN(left, CAC_MAX_CHUNK_SIZE);
  ------------------
  |  |   69|  7.84k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 3.64k, False: 4.19k]
  |  |  ------------------
  ------------------
  422|  7.84k|		params[1] = len;
  423|  7.84k|		r = cac_apdu_io(card, CAC_INS_READ_FILE, HIGH_BYTE_OF_SHORT(offset), LOW_BYTE_OF_SHORT(offset),
  ------------------
  |  |   61|  7.84k|#define CAC_INS_READ_FILE             0x52  /* read a TL or V file */
  ------------------
              		r = cac_apdu_io(card, CAC_INS_READ_FILE, HIGH_BYTE_OF_SHORT(offset), LOW_BYTE_OF_SHORT(offset),
  ------------------
  |  |  382|  7.84k|#define HIGH_BYTE_OF_SHORT(x) (((x)>> 8) & 0xff)
  ------------------
              		r = cac_apdu_io(card, CAC_INS_READ_FILE, HIGH_BYTE_OF_SHORT(offset), LOW_BYTE_OF_SHORT(offset),
  ------------------
  |  |  383|  7.84k|#define LOW_BYTE_OF_SHORT(x) ((x) & 0xff)
  ------------------
  424|  7.84k|						&params[0], sizeof(params), &out_ptr, &len);
  425|       |		/* if there is no data, assume there is no file */
  426|  7.84k|		if (len == 0) {
  ------------------
  |  Branch (426:7): [True: 44, False: 7.79k]
  ------------------
  427|     44|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     44|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  428|     44|		}
  429|  7.84k|		if (r < 0) {
  ------------------
  |  Branch (429:7): [True: 179, False: 7.66k]
  ------------------
  430|    179|			goto fail;
  431|    179|		}
  432|  7.84k|	}
  433|  2.33k|	*out_len = size;
  434|  2.33k|	*out_buf = out;
  435|  2.33k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  2.33k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.33k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.33k|	int _ret = r; \
  |  |  |  |  155|  2.33k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.33k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.33k|		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: 2.33k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.33k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.33k|	} 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|  2.33k|	return _ret; \
  |  |  |  |  163|  2.33k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|    610|fail:
  437|    610|	if (out)
  ------------------
  |  Branch (437:6): [True: 179, False: 431]
  ------------------
  438|    179|		free(out);
  439|    610|	*out_len = 0;
  440|    610|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    610|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    610|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    610|	int _ret = r; \
  |  |  |  |  155|    610|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 610, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    610|		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|    610|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 610, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    610|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    610|	} 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|    610|	return _ret; \
  |  |  |  |  163|    610|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|    610|}
card-cac.c:cac_parse_CCC:
 1391|    863|{
 1392|    863|	size_t len = 0;
 1393|    863|	const u8 *tl_end = tl + tl_len;
 1394|    863|	const u8 *val_end = val + val_len;
 1395|    863|	sc_path_t new_path;
 1396|    863|	int r;
 1397|       |
 1398|       |
 1399|  8.82k|	for (; (tl < tl_end) && (val< val_end); val += len) {
  ------------------
  |  Branch (1399:9): [True: 8.71k, False: 104]
  |  Branch (1399:26): [True: 8.67k, False: 48]
  ------------------
 1400|       |		/* get the tag and the length */
 1401|  8.67k|		u8 tag;
 1402|  8.67k|		r = sc_simpletlv_read_tag(&tl, tl_end - tl, &tag, &len);
 1403|  8.67k|		if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS) {
  ------------------
  |  |   28|  17.3k|#define SC_SUCCESS				0
  ------------------
              		if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS) {
  ------------------
  |  |   99|  1.40k|#define SC_ERROR_TLV_END_OF_CONTENTS	-1418
  ------------------
  |  Branch (1403:7): [True: 1.40k, False: 7.26k]
  |  Branch (1403:26): [True: 50, False: 1.35k]
  ------------------
 1404|     50|			sc_log(card->ctx, "Failed to parse tag from buffer");
  ------------------
  |  |   71|     50|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1405|     50|			break;
 1406|     50|		}
 1407|  8.62k|		if (val + len > val_end) {
  ------------------
  |  Branch (1407:7): [True: 349, False: 8.27k]
  ------------------
 1408|    349|			sc_log(card->ctx, "Invalid length %zu", len);
  ------------------
  |  |   71|    349|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1409|    349|			break;
 1410|    349|		}
 1411|  8.27k|		switch (tag) {
 1412|    419|		case CAC_TAG_CUID:
  ------------------
  |  |   72|    419|#define CAC_TAG_CUID                  0xF0
  ------------------
  |  Branch (1412:3): [True: 419, False: 7.85k]
  ------------------
 1413|    419|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG:CUID");
  ------------------
  |  |   70|    419|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1414|    419|			r = cac_parse_cuid(card, priv, (cac_cuid_t *)val, len);
 1415|    419|			if (r < 0)
  ------------------
  |  Branch (1415:8): [True: 7, False: 412]
  ------------------
 1416|      7|				return r;
 1417|    412|			break;
 1418|    556|		case CAC_TAG_CC_VERSION_NUMBER:
  ------------------
  |  |   73|    556|#define CAC_TAG_CC_VERSION_NUMBER     0xF1
  ------------------
  |  Branch (1418:3): [True: 556, False: 7.71k]
  ------------------
 1419|    556|			if (len != 1) {
  ------------------
  |  Branch (1419:8): [True: 82, False: 474]
  ------------------
 1420|     82|				sc_log(card->ctx, "TAG: CC Version: Invalid length %zu", len);
  ------------------
  |  |   71|     82|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1421|     82|				break;
 1422|     82|			}
 1423|       |			/* ignore the version numbers for now */
 1424|    474|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    474|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1425|    474|				"TAG: CC Version = 0x%02x", *val);
 1426|    474|			break;
 1427|    430|		case CAC_TAG_GRAMMAR_VERION_NUMBER:
  ------------------
  |  |   74|    430|#define CAC_TAG_GRAMMAR_VERION_NUMBER 0xF2
  ------------------
  |  Branch (1427:3): [True: 430, False: 7.84k]
  ------------------
 1428|    430|			if (len != 1) {
  ------------------
  |  Branch (1428:8): [True: 135, False: 295]
  ------------------
 1429|    135|				sc_log(card->ctx, "TAG: Grammar Version: Invalid length %zu", len);
  ------------------
  |  |   71|    135|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1430|    135|				break;
 1431|    135|			}
 1432|       |			/* ignore the version numbers for now */
 1433|    295|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    295|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1434|    295|				"TAG: Grammar Version = 0x%02x", *val);
 1435|    295|			break;
 1436|  2.20k|		case CAC_TAG_CARDURL:
  ------------------
  |  |   75|  2.20k|#define CAC_TAG_CARDURL               0xF3
  ------------------
  |  Branch (1436:3): [True: 2.20k, False: 6.06k]
  ------------------
 1437|  2.20k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG:CARDURL");
  ------------------
  |  |   70|  2.20k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1438|  2.20k|			r = cac_parse_cardurl(card, priv, (cac_card_url_t *)val, len);
 1439|  2.20k|			if (r < 0)
  ------------------
  |  Branch (1439:8): [True: 11, False: 2.19k]
  ------------------
 1440|     11|				return r;
 1441|  2.19k|			break;
 1442|       |		/*
 1443|       |		 * The following are really for file systems cards. This code only cares about CAC VM cards
 1444|       |		 */
 1445|  2.19k|		case CAC_TAG_PKCS15:
  ------------------
  |  |   76|    203|#define CAC_TAG_PKCS15                0xF4
  ------------------
  |  Branch (1445:3): [True: 203, False: 8.06k]
  ------------------
 1446|    203|			if (len != 1) {
  ------------------
  |  Branch (1446:8): [True: 74, False: 129]
  ------------------
 1447|     74|				sc_log(card->ctx, "TAG: PKCS15: Invalid length %zu", len);
  ------------------
  |  |   71|     74|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1448|     74|				break;
 1449|     74|			}
 1450|       |			/* TODO should verify that this is '0'. If it's not
 1451|       |			 * zero, we should drop out of here and let the PKCS 15
 1452|       |			 * code handle this card */
 1453|    129|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG: PKCS15 = 0x%02x", *val);
  ------------------
  |  |   70|    129|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1454|    129|			break;
 1455|     52|		case CAC_TAG_DATA_MODEL:
  ------------------
  |  |   78|     52|#define CAC_TAG_DATA_MODEL            0xF5
  ------------------
  |  Branch (1455:3): [True: 52, False: 8.21k]
  ------------------
 1456|     52|			if (len != 1) {
  ------------------
  |  Branch (1456:8): [True: 24, False: 28]
  ------------------
 1457|     24|				sc_log(card->ctx, "TAG: Registered Data Model Number: Invalid length %zu", len);
  ------------------
  |  |   71|     24|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1458|     24|				break;
 1459|     24|			}
 1460|     28|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG: Registered Data Model Number (0x%02x)", *val);
  ------------------
  |  |   70|     28|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1461|     28|			break;
 1462|     98|		case CAC_TAG_CARD_APDU:
  ------------------
  |  |   79|     98|#define CAC_TAG_CARD_APDU             0xF7
  ------------------
  |  Branch (1462:3): [True: 98, False: 8.17k]
  ------------------
 1463|    223|		case CAC_TAG_CAPABILITY_TUPLES:
  ------------------
  |  |   81|    223|#define CAC_TAG_CAPABILITY_TUPLES     0xFB
  ------------------
  |  Branch (1463:3): [True: 125, False: 8.14k]
  ------------------
 1464|    296|		case CAC_TAG_STATUS_TUPLES:
  ------------------
  |  |   82|    296|#define CAC_TAG_STATUS_TUPLES         0xFC
  ------------------
  |  Branch (1464:3): [True: 73, False: 8.19k]
  ------------------
 1465|    365|		case CAC_TAG_REDIRECTION:
  ------------------
  |  |   80|    365|#define CAC_TAG_REDIRECTION           0xFA
  ------------------
  |  Branch (1465:3): [True: 69, False: 8.20k]
  ------------------
 1466|    434|		case CAC_TAG_ERROR_CODES:
  ------------------
  |  |   84|    434|#define CAC_TAG_ERROR_CODES           0xFE
  ------------------
  |  Branch (1466:3): [True: 69, False: 8.20k]
  ------------------
 1467|    434|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG: FSSpecific(0x%02x)", tag);
  ------------------
  |  |   70|    434|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1468|    434|			break;
 1469|    153|		case CAC_TAG_ACCESS_CONTROL:
  ------------------
  |  |   77|    153|#define CAC_TAG_ACCESS_CONTROL        0xF6
  ------------------
  |  Branch (1469:3): [True: 153, False: 8.11k]
  ------------------
 1470|       |			/* TODO handle access control later */
 1471|    153|			sc_log_hex(card->ctx, "TAG:ACCESS Control", val, len);
  ------------------
  |  |  129|    153|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    153|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1472|    153|			break;
 1473|    583|		case CAC_TAG_NEXT_CCC:
  ------------------
  |  |   83|    583|#define CAC_TAG_NEXT_CCC              0xFD
  ------------------
  |  Branch (1473:3): [True: 583, False: 7.68k]
  ------------------
 1474|    583|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG:NEXT CCC");
  ------------------
  |  |   70|    583|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1475|    583|			r = cac_path_from_cardurl(card, &new_path, (cac_card_url_t *)val, len);
 1476|    583|			if (r < 0)
  ------------------
  |  Branch (1476:8): [True: 3, False: 580]
  ------------------
 1477|      3|				return r;
 1478|       |
 1479|    580|			r = cac_select_file_by_type(card, &new_path, NULL);
 1480|    580|			if (r < 0)
  ------------------
  |  Branch (1480:8): [True: 32, False: 548]
  ------------------
 1481|     32|				return r;
 1482|       |
 1483|       |			/* Increase depth to avoid infinite recursion */
 1484|    548|			r = cac_process_CCC(card, priv, depth + 1);
 1485|    548|			if (r < 0)
  ------------------
  |  Branch (1485:8): [True: 259, False: 289]
  ------------------
 1486|    259|				return r;
 1487|    289|			break;
 1488|  3.23k|		default:
  ------------------
  |  Branch (1488:3): [True: 3.23k, False: 5.03k]
  ------------------
 1489|       |			/* ignore tags we don't understand */
 1490|  3.23k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG:Unknown (0x%02x)",tag );
  ------------------
  |  |   70|  3.23k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1491|  3.23k|			break;
 1492|  8.27k|		}
 1493|  8.27k|	}
 1494|    551|	return SC_SUCCESS;
  ------------------
  |  |   28|    551|#define SC_SUCCESS				0
  ------------------
 1495|    863|}
card-cac.c:cac_parse_cuid:
 1364|    419|{
 1365|    419|	size_t card_id_len;
 1366|       |
 1367|    419|	if (len < sizeof(cac_cuid_t) || len > 256) {
  ------------------
  |  Branch (1367:6): [True: 7, False: 412]
  |  Branch (1367:34): [True: 0, False: 412]
  ------------------
 1368|      7|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      7|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1369|      7|	}
 1370|       |
 1371|    412|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "gsc_rid=%s", sc_dump_hex(val->gsc_rid, sizeof(val->gsc_rid)));
  ------------------
  |  |   70|    412|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1372|    412|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "manufacture id=%x", val->manufacturer_id);
  ------------------
  |  |   70|    412|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1373|    412|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "cac_type=%d", val->card_type);
  ------------------
  |  |   70|    412|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1374|    412|	card_id_len = len - (&val->card_id - (u8 *)val);
 1375|    412|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "card_id=%s (%zu)",
  ------------------
  |  |   70|    412|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1376|    412|			sc_dump_hex(&val->card_id, card_id_len), card_id_len);
 1377|    412|	priv->cuid = *val;
 1378|    412|	free(priv->cac_id);
 1379|    412|	priv->cac_id = malloc(card_id_len);
 1380|    412|	if (priv->cac_id == NULL) {
  ------------------
  |  Branch (1380:6): [True: 0, False: 412]
  ------------------
 1381|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1382|      0|	}
 1383|    412|	memcpy(priv->cac_id, &val->card_id, card_id_len);
 1384|    412|	priv->cac_id_len = card_id_len;
 1385|    412|	return SC_SUCCESS;
  ------------------
  |  |   28|    412|#define SC_SUCCESS				0
  ------------------
 1386|    412|}
card-cac.c:cac_parse_cardurl:
 1318|  2.20k|{
 1319|  2.20k|	cac_object_t new_object;
 1320|  2.20k|	const cac_object_t *obj;
 1321|  2.20k|	unsigned short object_id;
 1322|  2.20k|	int r;
 1323|       |
 1324|  2.20k|	r = cac_path_from_cardurl(card, &new_object.path, val, len);
 1325|  2.20k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  2.20k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1325:6): [True: 11, False: 2.19k]
  ------------------
 1326|     11|		return r;
 1327|     11|	}
 1328|  2.19k|	switch (val->cardApplicationType) {
 1329|  1.01k|	case CAC_APP_TYPE_PKI:
  ------------------
  |  |   99|  1.01k|#define CAC_APP_TYPE_PKI              0x04
  ------------------
  |  Branch (1329:2): [True: 1.01k, False: 1.17k]
  ------------------
 1330|       |		/* we don't want to overflow the cac_label array. This test could
 1331|       |		 * go way if we create a label function that will create a unique label
 1332|       |		 * from a cert index.
 1333|       |		 */
 1334|  1.01k|		if (priv->cert_next >= MAX_CAC_SLOTS)
  ------------------
  |  |   70|  1.01k|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (1334:7): [True: 269, False: 750]
  ------------------
 1335|    269|			break; /* don't fail just because we have more certs than we can support */
 1336|    750|		new_object.name = get_cac_label(priv->cert_next);
 1337|    750|		new_object.fd = priv->cert_next+1;
 1338|    750|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"CARDURL: pki_object found, cert_next=%d (%s),", priv->cert_next, new_object.name);
  ------------------
  |  |   70|    750|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1339|    750|		cac_add_object_to_list(&priv->pki_list, &new_object);
 1340|    750|		priv->cert_next++;
 1341|    750|		break;
 1342|    246|	case CAC_APP_TYPE_GENERAL:
  ------------------
  |  |   97|    246|#define CAC_APP_TYPE_GENERAL          0x01
  ------------------
  |  Branch (1342:2): [True: 246, False: 1.95k]
  ------------------
 1343|    246|		object_id = bebytes2ushort(val->objectID);
 1344|    246|		obj = cac_find_obj_by_id(object_id);
 1345|    246|		if (obj == NULL)
  ------------------
  |  Branch (1345:7): [True: 233, False: 13]
  ------------------
 1346|    233|			break; /* don't fail just because we don't recognize the object */
 1347|     13|		new_object.name = obj->name;
 1348|     13|		new_object.fd = 0;
 1349|     13|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"CARDURL: gen_object found, objectID=%x (%s),", object_id, new_object.name);
  ------------------
  |  |   70|     13|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1350|     13|		cac_add_object_to_list(&priv->general_list, &new_object);
 1351|     13|		break;
 1352|    127|	case CAC_APP_TYPE_SKI:
  ------------------
  |  |   98|    127|#define CAC_APP_TYPE_SKI              0x02
  ------------------
  |  Branch (1352:2): [True: 127, False: 2.07k]
  ------------------
 1353|    127|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"CARDURL: ski_object found");
  ------------------
  |  |   70|    127|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1354|    127|	break;
 1355|    806|	default:
  ------------------
  |  Branch (1355:2): [True: 806, False: 1.39k]
  ------------------
 1356|    806|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"CARDURL: unknown object_object found (type=0x%02x)", val->cardApplicationType);
  ------------------
  |  |   70|    806|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1357|       |		/* don't fail just because there is an unknown object in the CCC */
 1358|    806|		break;
 1359|  2.19k|	}
 1360|  2.19k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.19k|#define SC_SUCCESS				0
  ------------------
 1361|  2.19k|}
card-cac.c:cac_find_obj_by_id:
  216|    246|{
  217|    246|	int i;
  218|       |
  219|  1.66k|	for (i = 0; i < cac_object_count; i++) {
  ------------------
  |  Branch (219:14): [True: 1.43k, False: 233]
  ------------------
  220|  1.43k|		if (cac_objects[i].fd == object_id) {
  ------------------
  |  Branch (220:7): [True: 13, False: 1.42k]
  ------------------
  221|     13|			return &cac_objects[i];
  222|     13|		}
  223|  1.43k|	}
  224|    233|	return NULL;
  225|    246|}
card-cac.c:cac_path_from_cardurl:
 1229|  2.79k|{
 1230|  2.79k|	if (len < 10) {
  ------------------
  |  Branch (1230:6): [True: 14, False: 2.77k]
  ------------------
 1231|     14|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     14|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1232|     14|	}
 1233|  2.77k|	sc_mem_clear(path, sizeof(sc_path_t));
 1234|  2.77k|	memcpy(path->aid.value, &val->rid, sizeof(val->rid));
 1235|  2.77k|	memcpy(&path->aid.value[5], val->applicationID, sizeof(val->applicationID));
 1236|  2.77k|	path->aid.len = sizeof(val->rid) + sizeof(val->applicationID);
 1237|  2.77k|	memcpy(path->value, val->objectID, sizeof(val->objectID));
 1238|  2.77k|	path->len = sizeof(val->objectID);
 1239|  2.77k|	path->type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  2.77k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1240|  2.77k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  2.77k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1241|  2.77k|			"path->aid=%x %x %x %x %x %x %x  len=%zu, path->value = %x %x len=%zu path->type=%d (%x)",
 1242|  2.77k|			path->aid.value[0], path->aid.value[1], path->aid.value[2], path->aid.value[3],
 1243|  2.77k|			path->aid.value[4], path->aid.value[5], path->aid.value[6], path->aid.len,
 1244|  2.77k|			path->value[0], path->value[1], path->len, path->type, path->type);
 1245|  2.77k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  2.77k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1246|  2.77k|			"rid=%x %x %x %x %x  len=%zu appid= %x %x len=%zu objid= %x %x len=%zu",
 1247|  2.77k|			val->rid[0], val->rid[1], val->rid[2], val->rid[3], val->rid[4],
 1248|  2.77k|			sizeof(val->rid), val->applicationID[0], val->applicationID[1],
 1249|  2.77k|			sizeof(val->applicationID), val->objectID[0], val->objectID[1], sizeof(val->objectID));
 1250|       |
 1251|  2.77k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.77k|#define SC_SUCCESS				0
  ------------------
 1252|  2.79k|}
card-cac.c:cac_select_ACA:
 1224|  4.70k|{
 1225|       |	return cac_select_file_by_type(card, &cac_ACA_Path, NULL);
 1226|  4.70k|}
card-cac.c:cac_process_ACA:
 1688|    503|{
 1689|    503|	int r;
 1690|    503|	u8 *val = NULL;
 1691|    503|	size_t val_len;
 1692|       |
 1693|    503|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    503|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    503|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    503|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 503]
  |  |  ------------------
  ------------------
 1694|       |
 1695|       |	/* Assuming ACA is already selected */
 1696|    503|	r = cac_get_acr(card, CAC_ACR_SERVICE, &val, &val_len);
  ------------------
  |  |  104|    503|#define CAC_ACR_SERVICE               0x21
  ------------------
 1697|    503|	if (r < 0)
  ------------------
  |  Branch (1697:6): [True: 34, False: 469]
  ------------------
 1698|     34|		goto done;
 1699|       |
 1700|    469|	r = cac_parse_ACA_service(card, priv, val, val_len);
 1701|    469|        if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    469|#define SC_SUCCESS				0
  ------------------
  |  Branch (1701:13): [True: 448, False: 21]
  ------------------
 1702|    448|		priv->aca_path = malloc(sizeof(sc_path_t));
 1703|    448|		if (!priv->aca_path) {
  ------------------
  |  Branch (1703:7): [True: 0, False: 448]
  ------------------
 1704|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1705|      0|			goto done;
 1706|      0|		}
 1707|    448|		memcpy(priv->aca_path, &cac_ACA_Path, sizeof(sc_path_t));
 1708|    448|	}
 1709|    503|done:
 1710|    503|	if (val)
  ------------------
  |  Branch (1710:6): [True: 469, False: 34]
  ------------------
 1711|    469|		free(val);
 1712|    503|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    503|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    503|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    503|	int _ret = r; \
  |  |  |  |  155|    503|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 503, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    503|		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|     55|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 55, False: 448]
  |  |  |  |  ------------------
  |  |  |  |  157|    503|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    503|	} 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|    503|	return _ret; \
  |  |  |  |  163|    503|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1713|    503|}
card-cac.c:cac_get_acr:
  344|    503|{
  345|    503|	u8 *out = NULL;
  346|       |	/* XXX assuming it will not be longer than 255 B */
  347|    503|	size_t len = 256;
  348|    503|	int r;
  349|       |
  350|    503|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    503|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    503|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    503|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 503]
  |  |  ------------------
  ------------------
  351|       |
  352|       |	/* for simplicity we support only ACR without arguments now */
  353|    503|	if (acr_type != 0x00 && acr_type != 0x10
  ------------------
  |  Branch (353:6): [True: 503, False: 0]
  |  Branch (353:26): [True: 503, False: 0]
  ------------------
  354|    503|	    && acr_type != 0x20 && acr_type != 0x21) {
  ------------------
  |  Branch (354:9): [True: 503, False: 0]
  |  Branch (354:29): [True: 0, False: 503]
  ------------------
  355|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  356|      0|	}
  357|       |
  358|    503|	r = cac_apdu_io(card, CAC_INS_GET_ACR, acr_type, 0, NULL, 0, &out, &len);
  ------------------
  |  |   62|    503|#define CAC_INS_GET_ACR               0x4c
  ------------------
  359|    503|	if (len == 0) {
  ------------------
  |  Branch (359:6): [True: 3, False: 500]
  ------------------
  360|      3|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      3|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  361|      3|	}
  362|    503|	if (r < 0)
  ------------------
  |  Branch (362:6): [True: 34, False: 469]
  ------------------
  363|     34|		goto fail;
  364|       |
  365|    469|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "got %zu bytes out=%p", len, out);
  ------------------
  |  |   70|    469|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  366|       |
  367|    469|	*out_len = len;
  368|    469|	*out_buf = out;
  369|    469|	return SC_SUCCESS;
  ------------------
  |  |   28|    469|#define SC_SUCCESS				0
  ------------------
  370|       |
  371|     34|fail:
  372|     34|	if (out)
  ------------------
  |  Branch (372:6): [True: 3, False: 31]
  ------------------
  373|      3|		free(out);
  374|       |	*out_buf = NULL;
  375|     34|	*out_len = 0;
  376|     34|	return r;
  377|    503|}
card-cac.c:cac_parse_ACA_service:
 1530|    469|{
 1531|    469|	size_t len = 0;
 1532|    469|	const u8 *val_end = val + val_len;
 1533|    469|	int r;
 1534|       |
 1535|    469|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    469|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    469|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    469|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 469]
  |  |  ------------------
  ------------------
 1536|       |
 1537|  5.52k|	for (; val < val_end; val += len) {
  ------------------
  |  Branch (1537:9): [True: 5.44k, False: 77]
  ------------------
 1538|       |		/* get the tag and the length */
 1539|  5.44k|		u8 tag;
 1540|  5.44k|		if (sc_simpletlv_read_tag(&val, val_end - val, &tag, &len) != SC_SUCCESS)
  ------------------
  |  |   28|  5.44k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1540:7): [True: 371, False: 5.07k]
  ------------------
 1541|    371|			break;
 1542|       |
 1543|  5.07k|		switch (tag) {
 1544|    562|		case CAC_TAG_APPLET_FAMILY:
  ------------------
  |  |   85|    562|#define CAC_TAG_APPLET_FAMILY         0x01
  ------------------
  |  Branch (1544:3): [True: 562, False: 4.51k]
  ------------------
 1545|    562|			if (len != 5) {
  ------------------
  |  Branch (1545:8): [True: 367, False: 195]
  ------------------
 1546|    367|				sc_log(card->ctx, "TAG: Applet Information: bad length %zu", len);
  ------------------
  |  |   71|    367|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1547|    367|				break;
 1548|    367|			}
 1549|    195|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    195|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1550|    195|			    "TAG: Applet Information: Family: 0x%02x", val[0]);
 1551|    195|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    195|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1552|    195|			    "     Applet Version: 0x%02x 0x%02x 0x%02x 0x%02x",
 1553|    195|			    val[1], val[2], val[3], val[4]);
 1554|    195|			break;
 1555|    721|		case CAC_TAG_NUMBER_APPLETS:
  ------------------
  |  |   86|    721|#define CAC_TAG_NUMBER_APPLETS        0x94
  ------------------
  |  Branch (1555:3): [True: 721, False: 4.35k]
  ------------------
 1556|    721|			if (len != 1) {
  ------------------
  |  Branch (1556:8): [True: 526, False: 195]
  ------------------
 1557|    526|				sc_log(card->ctx, "TAG: Num applets: bad length %zu", len);
  ------------------
  |  |   71|    526|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1558|    526|				break;
 1559|    526|			}
 1560|    195|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    195|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1561|    195|			    "TAG: Num applets = %hhd", *val);
 1562|    195|			break;
 1563|  1.35k|		case CAC_TAG_APPLET_ENTRY:
  ------------------
  |  |   87|  1.35k|#define CAC_TAG_APPLET_ENTRY          0x93
  ------------------
  |  Branch (1563:3): [True: 1.35k, False: 3.72k]
  ------------------
 1564|       |			/* Make sure we match the outer length */
 1565|  1.35k|			if (len < 3 || val[2] != len - 3) {
  ------------------
  |  Branch (1565:8): [True: 237, False: 1.11k]
  |  Branch (1565:19): [True: 436, False: 683]
  ------------------
 1566|    673|				sc_log(card->ctx, "TAG: Applet Entry: bad length (%zu) or length of internal buffer", len);
  ------------------
  |  |   71|    673|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1567|    673|				break;
 1568|    673|			}
 1569|    683|			sc_debug_hex(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  127|    683|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1570|    683|			    "TAG: Applet Entry: AID", val + 3, val[2]);
 1571|       |			/* This is SimpleTLV prefixed with applet ID (1B) */
 1572|    683|			r = cac_parse_aid(card, priv, val + 3, val[2]);
 1573|    683|			if (r < 0)
  ------------------
  |  Branch (1573:8): [True: 21, False: 662]
  ------------------
 1574|     21|				return r;
 1575|    662|			break;
 1576|  2.43k|		default:
  ------------------
  |  Branch (1576:3): [True: 2.43k, False: 2.63k]
  ------------------
 1577|       |			/* ignore tags we don't understand */
 1578|  2.43k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  2.43k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1579|  2.43k|			    "TAG: Unknown (0x%02x)", tag);
 1580|  2.43k|			break;
 1581|  5.07k|		}
 1582|  5.07k|	}
 1583|    448|	return SC_SUCCESS;
  ------------------
  |  |   28|    448|#define SC_SUCCESS				0
  ------------------
 1584|    469|}
card-cac.c:cac_parse_aid:
 1255|    683|{
 1256|    683|	cac_object_t new_object;
 1257|    683|	cac_properties_t prop = {0};
 1258|    683|	size_t i;
 1259|    683|	int r;
 1260|       |
 1261|    683|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    683|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    683|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    683|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 683]
  |  |  ------------------
  ------------------
 1262|       |
 1263|    683|	if (aid_len < 0 || aid_len > SC_MAX_AID_SIZE) {
  ------------------
  |  |   43|    683|#define SC_MAX_AID_SIZE			16
  ------------------
  |  Branch (1263:6): [True: 0, False: 683]
  |  Branch (1263:21): [True: 1, False: 682]
  ------------------
 1264|      1|		sc_log(card->ctx, "AID length too large (%d)", aid_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1265|      1|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1266|      1|	}
 1267|       |
 1268|       |	/* Search for PKI applets (7 B). Ignore generic objects for now */
 1269|    682|	if (aid_len != 7 || (memcmp(aid, CAC_1_RID "\x01", 6) != 0
  ------------------
  |  |   66|    480|#define CAC_1_RID "\xA0\x00\x00\x00\x79"
  ------------------
  |  Branch (1269:6): [True: 202, False: 480]
  |  Branch (1269:23): [True: 434, False: 46]
  ------------------
 1270|    434|	    && memcmp(aid, CAC_1_RID "\x00", 6) != 0))
  ------------------
  |  |   66|    434|#define CAC_1_RID "\xA0\x00\x00\x00\x79"
  ------------------
  |  Branch (1270:9): [True: 226, False: 208]
  ------------------
 1271|    428|		return SC_SUCCESS;
  ------------------
  |  |   28|    428|#define SC_SUCCESS				0
  ------------------
 1272|       |
 1273|    254|	sc_mem_clear(&new_object.path, sizeof(sc_path_t));
 1274|    254|	memcpy(new_object.path.aid.value, aid, aid_len);
 1275|    254|	new_object.path.aid.len = aid_len;
 1276|       |
 1277|       |	/* Call without OID set will just select the AID without subsequent
 1278|       |	 * OID selection, which we need to figure out just now
 1279|       |	 */
 1280|    254|	r = cac_select_file_by_type(card, &new_object.path, NULL);
 1281|    254|	LOG_TEST_RET(card->ctx, r, "Cannot select AID");
  ------------------
  |  |  174|    254|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    254|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    254|	int _ret = (r); \
  |  |  |  |  168|    254|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 240]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|    254|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 240]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1282|    240|	r = cac_get_properties(card, &prop);
 1283|    240|	LOG_TEST_RET(card->ctx, r, "Cannot get CAC properties");
  ------------------
  |  |  174|    240|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    240|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    240|	int _ret = (r); \
  |  |  |  |  168|    240|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 234]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|    240|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 234]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1284|       |
 1285|    674|	for (i = 0; i < prop.num_objects; i++) {
  ------------------
  |  Branch (1285:14): [True: 460, False: 214]
  ------------------
 1286|       |		/* don't fail just because we have more certs than we can support */
 1287|    460|		if (priv->cert_next >= MAX_CAC_SLOTS)
  ------------------
  |  |   70|    460|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (1287:7): [True: 20, False: 440]
  ------------------
 1288|     20|			return SC_SUCCESS;
  ------------------
  |  |   28|     20|#define SC_SUCCESS				0
  ------------------
 1289|       |
 1290|    440|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    440|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1291|    440|		    "ACA: pki_object found, cert_next=%d (%s), privkey=%d",
 1292|    440|		    priv->cert_next, get_cac_label(priv->cert_next),
 1293|    440|		    prop.objects[i].privatekey);
 1294|       |
 1295|       |		/* If the private key is not initialized, we can safely
 1296|       |		 * ignore this object here, but increase the pointer to follow
 1297|       |		 * the certificate labels
 1298|       |		 */
 1299|    440|		if (!prop.objects[i].privatekey) {
  ------------------
  |  Branch (1299:7): [True: 166, False: 274]
  ------------------
 1300|    166|			priv->cert_next++;
 1301|    166|			continue;
 1302|    166|		}
 1303|       |
 1304|       |		/* OID here has always 2B */
 1305|    274|		memcpy(new_object.path.value, &prop.objects[i].oid, 2);
 1306|    274|		new_object.path.len = 2;
 1307|    274|		new_object.path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    274|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1308|    274|		new_object.name = get_cac_label(priv->cert_next);
 1309|    274|		new_object.fd = priv->cert_next+1;
 1310|    274|		cac_add_object_to_list(&priv->pki_list, &new_object);
 1311|    274|		priv->cert_next++;
 1312|    274|	}
 1313|       |
 1314|    214|	return SC_SUCCESS;
  ------------------
  |  |   28|    214|#define SC_SUCCESS				0
  ------------------
 1315|    234|}
card-cac.c:cac_find_first_pki_applet:
 1598|  4.16k|{
 1599|  4.16k|	int r, i;
 1600|  67.7k|	for (i = 0; i < MAX_CAC_SLOTS; i++) {
  ------------------
  |  |   70|  67.7k|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (1600:14): [True: 63.8k, False: 3.93k]
  ------------------
 1601|  63.8k|		r = cac_select_pki_applet(card, i);
 1602|  63.8k|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  63.8k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1602:7): [True: 465, False: 63.3k]
  ------------------
 1603|       |			/* Try to read first two bytes of the buffer to
 1604|       |			 * make sure it is not just malfunctioning card
 1605|       |			 */
 1606|    465|			u8 params[2] = {CAC_FILE_TAG, 2};
  ------------------
  |  |   66|    465|#define CAC_FILE_TAG    1
  ------------------
 1607|    465|			u8 data[2], *out_ptr = data;
 1608|    465|			size_t len = 2;
 1609|    465|			r = cac_apdu_io(card, CAC_INS_READ_FILE, 0, 0,
  ------------------
  |  |   61|    465|#define CAC_INS_READ_FILE             0x52  /* read a TL or V file */
  ------------------
 1610|    465|			    &params[0], sizeof(params), &out_ptr, &len);
 1611|    465|			if (r != 2)
  ------------------
  |  Branch (1611:8): [True: 243, False: 222]
  ------------------
 1612|    243|				continue;
 1613|       |
 1614|    222|			*index_out = i;
 1615|    222|			return SC_SUCCESS;
  ------------------
  |  |   28|    222|#define SC_SUCCESS				0
  ------------------
 1616|    465|		}
 1617|  63.8k|	}
 1618|  3.93k|	return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|  3.93k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1619|  4.16k|}
card-cac.c:cac_select_pki_applet:
 1588|  66.6k|{
 1589|  66.6k|	sc_path_t applet_path = cac_cac_pki_obj.path;
 1590|  66.6k|	applet_path.aid.value[applet_path.aid.len-1] = index;
 1591|       |	return cac_select_file_by_type(card, &applet_path, NULL);
 1592|  66.6k|}
card-cac.c:cac_populate_cac_alt:
 1625|    191|{
 1626|    191|	int r, i;
 1627|    191|	cac_object_t pki_obj = cac_cac_pki_obj;
 1628|    191|	u8 buf[100];
 1629|    191|	u8 *val;
 1630|       |
 1631|       |	/* populate PKI objects */
 1632|  2.85k|	for (i = index; i < MAX_CAC_SLOTS; i++) {
  ------------------
  |  |   70|  2.85k|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (1632:18): [True: 2.65k, False: 191]
  ------------------
 1633|  2.65k|		r = cac_select_pki_applet(card, i);
 1634|  2.65k|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  2.65k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1634:7): [True: 1.03k, False: 1.62k]
  ------------------
 1635|  1.03k|			pki_obj.name = get_cac_label(i);
 1636|  1.03k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  1.03k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1637|  1.03k|			    "CAC: pki_object found, cert_next=%d (%s),", i, pki_obj.name);
 1638|  1.03k|			pki_obj.path.aid.value[pki_obj.path.aid.len-1] = i;
 1639|  1.03k|			pki_obj.fd = i+1; /* don't use id of zero */
 1640|  1.03k|			cac_add_object_to_list(&priv->pki_list, &pki_obj);
 1641|  1.03k|		}
 1642|  2.65k|	}
 1643|       |
 1644|       |	/* populate non-PKI objects */
 1645|  1.33k|	for (i=0; i < cac_object_count; i++) {
  ------------------
  |  Branch (1645:12): [True: 1.14k, False: 191]
  ------------------
 1646|  1.14k|		r = cac_select_file_by_type(card, &cac_objects[i].path, NULL);
 1647|  1.14k|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  1.14k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1647:7): [True: 443, False: 703]
  ------------------
 1648|    443|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    443|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1649|    443|			    "CAC: obj_object found, cert_next=%d (%s),",
 1650|    443|			    i, cac_objects[i].name);
 1651|    443|			cac_add_object_to_list(&priv->general_list, &cac_objects[i]);
 1652|    443|		}
 1653|  1.14k|	}
 1654|       |
 1655|       |	/*
 1656|       |	 * create a cuid to simulate the cac 2 cuid.
 1657|       |	 */
 1658|    191|	priv->cuid = cac_cac_cuid;
 1659|       |	/* create a serial number by hashing the first 100 bytes of the
 1660|       |	 * first certificate on the card */
 1661|    191|	r = cac_select_pki_applet(card, index);
 1662|    191|	if (r < 0) {
  ------------------
  |  Branch (1662:6): [True: 60, False: 131]
  ------------------
 1663|     60|		return r; /* shouldn't happen unless the card has been removed or is malfunctioning */
 1664|     60|	}
 1665|    131|	val = buf;
 1666|    131|	r = cac_read_binary(card, 0, val, sizeof(buf), 0);
 1667|    131|	if (r > 0) {
  ------------------
  |  Branch (1667:6): [True: 2, False: 129]
  ------------------
 1668|      2|#ifdef ENABLE_OPENSSL
 1669|      2|		size_t val_len = r;
 1670|      2|		free(priv->cac_id);
 1671|      2|		priv->cac_id = malloc(20);
 1672|      2|		if (priv->cac_id == NULL) {
  ------------------
  |  Branch (1672:7): [True: 0, False: 2]
  ------------------
 1673|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1674|      0|		}
 1675|      2|		SHA1(val, val_len, priv->cac_id);
 1676|      2|		priv->cac_id_len = 20;
 1677|      2|		sc_debug_hex(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  127|      2|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1678|      2|		    "cuid", priv->cac_id, priv->cac_id_len);
 1679|       |#else
 1680|       |		sc_log(card->ctx, "OpenSSL Required");
 1681|       |		return SC_ERROR_NOT_SUPPORTED;
 1682|       |#endif /* ENABLE_OPENSSL */
 1683|      2|	}
 1684|    131|	return SC_SUCCESS;
  ------------------
  |  |   28|    131|#define SC_SUCCESS				0
  ------------------
 1685|    131|}
card-cac.c:cac_init:
 1806|  1.11k|{
 1807|  1.11k|	int r;
 1808|  1.11k|	unsigned long flags;
 1809|       |
 1810|  1.11k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.11k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.11k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.11k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.11k]
  |  |  ------------------
  ------------------
 1811|       |
 1812|  1.11k|	r = cac_find_and_initialize(card, 1);
 1813|  1.11k|	if (r < 0) {
  ------------------
  |  Branch (1813:6): [True: 277, False: 841]
  ------------------
 1814|    277|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|    277|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    277|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    277|	int _ret = r; \
  |  |  |  |  155|    277|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 277, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    277|		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|    277|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 277, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    277|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    277|	} 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|    277|	return _ret; \
  |  |  |  |  163|    277|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1815|    277|	}
 1816|    841|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|    841|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
 1817|       |
 1818|    841|	_sc_card_add_rsa_alg(card, 1024, flags, 0); /* mandatory */
 1819|    841|	_sc_card_add_rsa_alg(card, 2048, flags, 0); /* optional */
 1820|    841|	_sc_card_add_rsa_alg(card, 3072, flags, 0); /* optional */
 1821|       |
 1822|    841|	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  550|    841|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    841|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
 1823|       |
 1824|    841|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    841|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    841|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    841|	int _ret = r; \
  |  |  |  |  155|    841|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 841, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    841|		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: 841]
  |  |  |  |  ------------------
  |  |  |  |  157|    841|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    841|	} 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|    841|	return _ret; \
  |  |  |  |  163|    841|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1825|    841|}
card-cac.c:cac_finish:
 1205|    841|{
 1206|    841|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|    841|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
 1207|       |
 1208|    841|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    841|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    841|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    841|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 841]
  |  |  ------------------
  ------------------
 1209|    841|	if (priv) {
  ------------------
  |  Branch (1209:6): [True: 841, False: 0]
  ------------------
 1210|    841|		cac_free_private_data(priv);
 1211|    841|	}
 1212|    841|	return SC_SUCCESS;
  ------------------
  |  |   28|    841|#define SC_SUCCESS				0
  ------------------
 1213|    841|}
card-cac.c:cac_select_file:
 1200|  4.22k|{
 1201|  4.22k|	return cac_select_file_by_type(card, in_path, file_out);
 1202|  4.22k|}
card-cac.c:cac_get_challenge:
  705|    916|{
  706|       |	/* CAC requires 8 byte response */
  707|    916|	u8 rbuf[8];
  708|    916|	u8 *rbufp = &rbuf[0];
  709|    916|	size_t out_len = sizeof rbuf;
  710|    916|	int r;
  711|       |
  712|    916|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    916|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    916|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    916|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    916|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 916]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  713|       |
  714|    916|	r = cac_apdu_io(card, 0x84, 0x00, 0x00, NULL, 0, &rbufp, &out_len);
  715|    916|	LOG_TEST_RET(card->ctx, r, "Could not get challenge");
  ------------------
  |  |  174|    916|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    916|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    916|	int _ret = (r); \
  |  |  |  |  168|    916|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 455, False: 461]
  |  |  |  |  ------------------
  |  |  |  |  169|    455|		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|    455|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    455|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    455|		return _ret; \
  |  |  |  |  172|    455|	} \
  |  |  |  |  173|    916|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 461]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  716|       |
  717|    461|	if (len < out_len) {
  ------------------
  |  Branch (717:6): [True: 2, False: 459]
  ------------------
  718|      2|		out_len = len;
  719|      2|	}
  720|    461|	memcpy(rnd, rbuf, out_len);
  721|       |
  722|    461|	LOG_FUNC_RETURN(card->ctx, (int) out_len);
  ------------------
  |  |  164|    461|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    461|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    461|	int _ret = r; \
  |  |  |  |  155|    461|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11, False: 450]
  |  |  |  |  ------------------
  |  |  |  |  156|     11|		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: 11]
  |  |  |  |  ------------------
  |  |  |  |  157|     11|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    450|	} else { \
  |  |  |  |  159|    450|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    450|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    450|	} \
  |  |  |  |  162|    461|	return _ret; \
  |  |  |  |  163|    461|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  723|    461|}
card-cac.c:cac_read_binary:
  451|    872|{
  452|    872|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|    872|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  453|    872|	int r = 0;
  454|    872|	u8 *tl = NULL, *val = NULL;
  455|    872|	const u8 *tl_ptr, *val_ptr, *tl_start;
  456|    872|	u8 *tlv_ptr;
  457|    872|	const u8 *cert_ptr;
  458|    872|	size_t tl_len = 0, val_len = 0, tlv_len;
  459|    872|	size_t len, tl_head_len, cert_len;
  460|    872|	u8 cert_type, tag;
  461|       |
  462|    872|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    872|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    872|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    872|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 872]
  |  |  ------------------
  ------------------
  463|       |
  464|       |	/* if we didn't return it all last time, return the remainder */
  465|    872|	if (priv->cached) {
  ------------------
  |  Branch (465:6): [True: 113, False: 759]
  ------------------
  466|    113|		sc_log(card->ctx, "returning cached value idx=%d count=%zu", idx, count);
  ------------------
  |  |   71|    113|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  467|    113|		if (idx > priv->cache_buf_len) {
  ------------------
  |  Branch (467:7): [True: 0, False: 113]
  ------------------
  468|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_END_REACHED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  469|      0|		}
  470|    113|		len = MIN(count, priv->cache_buf_len-idx);
  ------------------
  |  |   69|    113|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 31, False: 82]
  |  |  ------------------
  ------------------
  471|    113|		memcpy(buf, &priv->cache_buf[idx], len);
  472|    113|		LOG_FUNC_RETURN(card->ctx, (int)len);
  ------------------
  |  |  164|    113|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    113|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    113|	int _ret = r; \
  |  |  |  |  155|    113|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 70, False: 43]
  |  |  |  |  ------------------
  |  |  |  |  156|     70|		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: 70]
  |  |  |  |  ------------------
  |  |  |  |  157|     70|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     70|	} else { \
  |  |  |  |  159|     43|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     43|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     43|	} \
  |  |  |  |  162|    113|	return _ret; \
  |  |  |  |  163|    113|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|    113|	}
  474|       |
  475|    759|	sc_log(card->ctx, "clearing cache idx=%d count=%zu", idx, count);
  ------------------
  |  |   71|    759|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  476|    759|	if (priv->cache_buf) {
  ------------------
  |  Branch (476:6): [True: 0, False: 759]
  ------------------
  477|      0|		free(priv->cache_buf);
  478|      0|		priv->cache_buf = NULL;
  479|      0|		priv->cache_buf_len = 0;
  480|      0|	}
  481|       |
  482|       |
  483|    759|	if (priv->object_type <= 0)
  ------------------
  |  Branch (483:6): [True: 0, False: 759]
  ------------------
  484|    759|		 LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  485|       |
  486|    759|	r = cac_read_file(card, CAC_FILE_TAG, &tl, &tl_len);
  ------------------
  |  |   66|    759|#define CAC_FILE_TAG    1
  ------------------
  487|    759|	if (r < 0)  {
  ------------------
  |  Branch (487:6): [True: 445, False: 314]
  ------------------
  488|    445|		goto done;
  489|    445|	}
  490|       |
  491|    314|	r = cac_read_file(card, CAC_FILE_VALUE, &val, &val_len);
  ------------------
  |  |   67|    314|#define CAC_FILE_VALUE  2
  ------------------
  492|    314|	if (r < 0)
  ------------------
  |  Branch (492:6): [True: 31, False: 283]
  ------------------
  493|     31|		goto done;
  494|       |
  495|    283|	switch (priv->object_type) {
  496|     48|	case CAC_OBJECT_TYPE_TLV_FILE:
  ------------------
  |  |  171|     48|#define CAC_OBJECT_TYPE_TLV_FILE	4
  ------------------
  |  Branch (496:2): [True: 48, False: 235]
  ------------------
  497|     48|		tlv_len = tl_len + val_len;
  498|     48|		priv->cache_buf = malloc(tlv_len);
  499|     48|		if (priv->cache_buf == NULL) {
  ------------------
  |  Branch (499:7): [True: 0, False: 48]
  ------------------
  500|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  501|      0|			goto done;
  502|      0|		}
  503|     48|		priv->cache_buf_len = tlv_len;
  504|       |
  505|     48|		for (tl_ptr = tl, val_ptr = val, tlv_ptr = priv->cache_buf;
  506|  4.34k|				tl_len >= 2 && tlv_len > 0;
  ------------------
  |  Branch (506:5): [True: 4.30k, False: 42]
  |  Branch (506:20): [True: 4.30k, False: 0]
  ------------------
  507|  4.30k|				val_len -= len, tlv_len -= len, val_ptr += len, tlv_ptr += len) {
  508|       |			/* get the tag and the length */
  509|  4.30k|			tl_start = tl_ptr;
  510|  4.30k|			r = sc_simpletlv_read_tag(&tl_ptr, tl_len, &tag, &len);
  511|  4.30k|			if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS)
  ------------------
  |  |   28|  8.61k|#define SC_SUCCESS				0
  ------------------
              			if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS)
  ------------------
  |  |   99|  1.04k|#define SC_ERROR_TLV_END_OF_CONTENTS	-1418
  ------------------
  |  Branch (511:8): [True: 1.04k, False: 3.25k]
  |  Branch (511:27): [True: 6, False: 1.04k]
  ------------------
  512|      6|				break;
  513|  4.30k|			tl_head_len = (tl_ptr - tl_start);
  514|  4.30k|			sc_simpletlv_put_tag(tag, len, tlv_ptr, tlv_len, &tlv_ptr);
  515|  4.30k|			tlv_len -= tl_head_len;
  516|  4.30k|			tl_len -= tl_head_len;
  517|       |
  518|       |			/* don't crash on bad data */
  519|  4.30k|			if (val_len < len) {
  ------------------
  |  Branch (519:8): [True: 3.18k, False: 1.11k]
  ------------------
  520|  3.18k|				sc_log(card->ctx, "Received too long value %zu, while only %zu left. Truncating",
  ------------------
  |  |   71|  3.18k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  521|  3.18k|						len, val_len);
  522|  3.18k|				len = val_len;
  523|  3.18k|			}
  524|       |			/* if we run out of return space, truncate */
  525|  4.30k|			if (tlv_len < len) {
  ------------------
  |  Branch (525:8): [True: 0, False: 4.30k]
  ------------------
  526|      0|				len = tlv_len;
  527|      0|			}
  528|  4.30k|			memcpy(tlv_ptr, val_ptr, len);
  529|  4.30k|		}
  530|       |		/* fixup the cache_buf_le to reflect for the bad data ignored above */
  531|     48|		priv->cache_buf_len = (tlv_ptr - priv->cache_buf);
  532|     48|		break;
  533|       |
  534|    220|	case CAC_OBJECT_TYPE_CERT:
  ------------------
  |  |  170|    220|#define CAC_OBJECT_TYPE_CERT		1
  ------------------
  |  Branch (534:2): [True: 220, False: 63]
  ------------------
  535|       |		/* read file */
  536|    220|		sc_log(card->ctx, " obj= cert_file, val_len=%zu (0x%04zx)", val_len, val_len);
  ------------------
  |  |   71|    220|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  537|    220|		cert_len = 0;
  538|    220|		cert_ptr = NULL;
  539|    220|		cert_type = 0;
  540|  1.18k|		for (tl_ptr = tl, val_ptr = val; tl_len >= 2;
  ------------------
  |  Branch (540:36): [True: 1.08k, False: 105]
  ------------------
  541|  1.08k|		    val_len -= len, val_ptr += len, tl_len -= tl_head_len) {
  542|  1.08k|			tl_start = tl_ptr;
  543|  1.08k|			r = sc_simpletlv_read_tag(&tl_ptr, tl_len, &tag, &len);
  544|  1.08k|			if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS)
  ------------------
  |  |   28|  2.16k|#define SC_SUCCESS				0
  ------------------
              			if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS)
  ------------------
  |  |   99|    183|#define SC_ERROR_TLV_END_OF_CONTENTS	-1418
  ------------------
  |  Branch (544:8): [True: 183, False: 899]
  |  Branch (544:27): [True: 10, False: 173]
  ------------------
  545|     10|				break;
  546|  1.07k|			tl_head_len = tl_ptr - tl_start;
  547|       |
  548|       |			/* incomplete value */
  549|  1.07k|			if (val_len < len) {
  ------------------
  |  Branch (549:8): [True: 105, False: 967]
  ------------------
  550|    105|				sc_log(card->ctx, "Read incomplete value %zu, while only %zu left",
  ------------------
  |  |   71|    105|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  551|    105|						len, val_len);
  552|    105|				break;
  553|    105|			}
  554|       |
  555|    967|			if (tag == CAC_TAG_CERTIFICATE) {
  ------------------
  |  |   69|    967|#define CAC_TAG_CERTIFICATE           0x70
  ------------------
  |  Branch (555:8): [True: 45, False: 922]
  ------------------
  556|     45|				cert_len = len;
  557|     45|				cert_ptr = val_ptr;
  558|     45|			}
  559|    967|			if (tag == CAC_TAG_CERTINFO) {
  ------------------
  |  |   70|    967|#define CAC_TAG_CERTINFO              0x71
  ------------------
  |  Branch (559:8): [True: 36, False: 931]
  ------------------
  560|     36|				if ((len >= 1) && (val_len >=1)) {
  ------------------
  |  Branch (560:9): [True: 26, False: 10]
  |  Branch (560:23): [True: 26, False: 0]
  ------------------
  561|     26|					cert_type = *val_ptr;
  562|     26|				}
  563|     36|			}
  564|    967|			if (tag == CAC_TAG_MSCUID) {
  ------------------
  |  |   71|    967|#define CAC_TAG_MSCUID                0x72
  ------------------
  |  Branch (564:8): [True: 19, False: 948]
  ------------------
  565|     19|				sc_log_hex(card->ctx, "MSCUID", val_ptr, len);
  ------------------
  |  |  129|     19|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     19|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|     19|			}
  567|    967|		}
  568|       |		/* if the info byte is 1, then the cert is compressed, decompress it */
  569|    220|		if ((cert_type & 0x3) == 1 && flags) {
  ------------------
  |  Branch (569:7): [True: 13, False: 207]
  |  Branch (569:33): [True: 11, False: 2]
  ------------------
  570|     11|			*flags |= SC_FILE_FLAG_COMPRESSED_AUTO;
  ------------------
  |  |  230|     11|#define SC_FILE_FLAG_COMPRESSED_AUTO		0x01
  ------------------
  571|     11|		}
  572|    220|		if (cert_len > 0) {
  ------------------
  |  Branch (572:7): [True: 27, False: 193]
  ------------------
  573|     27|			priv->cache_buf = malloc(cert_len);
  574|     27|			if (priv->cache_buf == NULL) {
  ------------------
  |  Branch (574:8): [True: 0, False: 27]
  ------------------
  575|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  576|      0|				goto done;
  577|      0|			}
  578|     27|			priv->cache_buf_len = cert_len;
  579|     27|			memcpy(priv->cache_buf, cert_ptr, cert_len);
  580|    193|		} else {
  581|    193|			sc_log(card->ctx, "Can't read zero-length certificate");
  ------------------
  |  |   71|    193|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  582|    193|			goto done;
  583|    193|		}
  584|     27|		break;
  585|     27|	case CAC_OBJECT_TYPE_GENERIC:
  ------------------
  |  |  172|     15|#define CAC_OBJECT_TYPE_GENERIC		5
  ------------------
  |  Branch (585:2): [True: 15, False: 268]
  ------------------
  586|       |		/* TODO
  587|       |		 * We have some two buffers in unknown encoding that we
  588|       |		 * need to present in PKCS#15 layer.
  589|       |		 */
  590|     15|	default:
  ------------------
  |  Branch (590:2): [True: 0, False: 283]
  ------------------
  591|       |		/* Unknown object type */
  592|     15|		sc_log(card->ctx, "Unknown object type: %x", priv->object_type);
  ------------------
  |  |   71|     15|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  593|     15|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     15|#define SC_ERROR_INTERNAL			-1400
  ------------------
  594|     15|		goto done;
  595|    283|	}
  596|       |
  597|       |	/* OK we've read the data, now copy the required portion out to the callers buffer */
  598|     75|	priv->cached = 1;
  599|     75|	len = MIN(count, priv->cache_buf_len-idx);
  ------------------
  |  |   69|     75|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 14, False: 61]
  |  |  ------------------
  ------------------
  600|     75|	memcpy(buf, &priv->cache_buf[idx], len);
  601|     75|	r = (int)len;
  602|    759|done:
  603|    759|	if (tl)
  ------------------
  |  Branch (603:6): [True: 314, False: 445]
  ------------------
  604|    314|		free(tl);
  605|    759|	if (val)
  ------------------
  |  Branch (605:6): [True: 283, False: 476]
  ------------------
  606|    283|		free(val);
  607|    759|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    759|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    759|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    759|	int _ret = r; \
  |  |  |  |  155|    759|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 686, False: 73]
  |  |  |  |  ------------------
  |  |  |  |  156|    686|		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|    568|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 568, False: 118]
  |  |  |  |  ------------------
  |  |  |  |  157|    686|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    686|	} else { \
  |  |  |  |  159|     73|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     73|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     73|	} \
  |  |  |  |  162|    759|	return _ret; \
  |  |  |  |  163|    759|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  608|    759|}
card-cac.c:cac_card_ctl:
  673|  10.1k|{
  674|  10.1k|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|  10.1k|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  675|       |
  676|  10.1k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  10.1k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  10.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  10.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  10.1k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  677|  10.1k|	sc_log(card->ctx, "cmd=%ld ptr=%p", cmd, ptr);
  ------------------
  |  |   71|  10.1k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  678|       |
  679|  10.1k|	if (priv == NULL) {
  ------------------
  |  Branch (679:6): [True: 0, False: 10.1k]
  ------------------
  680|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  681|      0|	}
  682|  10.1k|	switch(cmd) {
  ------------------
  |  Branch (682:9): [True: 9.13k, False: 1.06k]
  ------------------
  683|  1.03k|		case SC_CARDCTL_CAC_GET_ACA_PATH:
  ------------------
  |  Branch (683:3): [True: 1.03k, False: 9.15k]
  ------------------
  684|  1.03k|			return cac_get_ACA_path(card, (sc_path_t *) ptr);
  685|  1.03k|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (685:3): [True: 1.03k, False: 9.15k]
  ------------------
  686|  1.03k|			return cac_get_serial_nr_from_CUID(card, (sc_serial_number_t *) ptr);
  687|  1.03k|		case SC_CARDCTL_CAC_INIT_GET_GENERIC_OBJECTS:
  ------------------
  |  Branch (687:3): [True: 1.03k, False: 9.15k]
  ------------------
  688|  1.03k|			return cac_get_init_and_get_count(&priv->general_list, &priv->general_current, (int *)ptr);
  689|  1.03k|		case SC_CARDCTL_CAC_INIT_GET_CERT_OBJECTS:
  ------------------
  |  Branch (689:3): [True: 1.03k, False: 9.15k]
  ------------------
  690|  1.03k|			return cac_get_init_and_get_count(&priv->pki_list, &priv->pki_current, (int *)ptr);
  691|    399|		case SC_CARDCTL_CAC_GET_NEXT_GENERIC_OBJECT:
  ------------------
  |  Branch (691:3): [True: 399, False: 9.79k]
  ------------------
  692|    399|			return cac_fill_object_info(&priv->general_list, &priv->general_current, (sc_pkcs15_data_info_t *)ptr);
  693|  2.52k|		case SC_CARDCTL_CAC_GET_NEXT_CERT_OBJECT:
  ------------------
  |  Branch (693:3): [True: 2.52k, False: 7.66k]
  ------------------
  694|  2.52k|			return cac_fill_object_info(&priv->pki_list, &priv->pki_current, (sc_pkcs15_data_info_t *)ptr);
  695|  1.03k|		case SC_CARDCTL_CAC_FINAL_GET_GENERIC_OBJECTS:
  ------------------
  |  Branch (695:3): [True: 1.03k, False: 9.15k]
  ------------------
  696|  1.03k|			return cac_final_iterator(&priv->general_list);
  697|  1.03k|		case SC_CARDCTL_CAC_FINAL_GET_CERT_OBJECTS:
  ------------------
  |  Branch (697:3): [True: 1.03k, False: 9.15k]
  ------------------
  698|  1.03k|			return cac_final_iterator(&priv->pki_list);
  699|  10.1k|	}
  700|       |
  701|  1.06k|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|  1.06k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.06k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.06k|	int _ret = r; \
  |  |  |  |  155|  1.06k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.06k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.06k|		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|  1.06k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.06k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.06k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.06k|	} 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|  1.06k|	return _ret; \
  |  |  |  |  163|  1.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  702|  1.06k|}
card-cac.c:cac_get_ACA_path:
  662|  1.03k|{
  663|  1.03k|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|  1.03k|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  664|       |
  665|  1.03k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.03k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.03k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.03k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.03k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  666|  1.03k|	if (priv->aca_path) {
  ------------------
  |  Branch (666:6): [True: 448, False: 587]
  ------------------
  667|    448|		*path = *priv->aca_path;
  668|    448|	}
  669|  1.03k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.03k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.03k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.03k|	int _ret = r; \
  |  |  |  |  155|  1.03k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.03k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.03k|		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: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.03k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.03k|	} 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|  1.03k|	return _ret; \
  |  |  |  |  163|  1.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  670|  1.03k|}
card-cac.c:cac_get_serial_nr_from_CUID:
  645|  1.03k|{
  646|  1.03k|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|  1.03k|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  647|       |
  648|  1.03k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.03k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.03k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.03k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.03k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  649|  1.03k|        if (card->serialnr.len)   {
  ------------------
  |  Branch (649:13): [True: 0, False: 1.03k]
  ------------------
  650|      0|                *serial = card->serialnr;
  651|      0|                LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|      0|        }
  653|  1.03k|	if (priv->cac_id_len) {
  ------------------
  |  Branch (653:6): [True: 196, False: 839]
  ------------------
  654|    196|		serial->len = MIN(priv->cac_id_len, SC_MAX_SERIALNR);
  ------------------
  |  |   69|    196|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 195, False: 1]
  |  |  ------------------
  ------------------
  655|    196|		memcpy(serial->value, priv->cac_id, serial->len);
  656|    196|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    196|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    196|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    196|	int _ret = r; \
  |  |  |  |  155|    196|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 196, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    196|		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: 196]
  |  |  |  |  ------------------
  |  |  |  |  157|    196|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    196|	} 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|    196|	return _ret; \
  |  |  |  |  163|    196|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  657|    196|	}
  658|    839|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|    839|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    839|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    839|	int _ret = r; \
  |  |  |  |  155|    839|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 839, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    839|		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|    839|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 839, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    839|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    839|	} 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|    839|	return _ret; \
  |  |  |  |  163|    839|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  659|    839|}
card-cac.c:cac_get_init_and_get_count:
  612|  2.07k|{
  613|  2.07k|	*countp = list_size(list);
  614|  2.07k|	list_iterator_start(list);
  615|  2.07k|	*entry = list_iterator_next(list);
  616|  2.07k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.07k|#define SC_SUCCESS				0
  ------------------
  617|  2.07k|}
card-cac.c:cac_fill_object_info:
  628|  2.92k|{
  629|  2.92k|	memset(obj_info, 0, sizeof(sc_pkcs15_data_info_t));
  630|  2.92k|	if (*entry == NULL) {
  ------------------
  |  Branch (630:6): [True: 0, False: 2.92k]
  ------------------
  631|      0|		return SC_ERROR_FILE_END_REACHED;
  ------------------
  |  |   69|      0|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  632|      0|	}
  633|       |
  634|  2.92k|	obj_info->path = (*entry)->path;
  635|  2.92k|	obj_info->path.count = CAC_MAX_SIZE-1; /* read something from the object */
  ------------------
  |  |   26|  2.92k|#define CAC_MAX_SIZE 4096		/* arbitrary, just needs to be 'large enough' */
  ------------------
  636|  2.92k|	obj_info->id.value[0] = ((*entry)->fd >> 8) & 0xff;
  637|  2.92k|	obj_info->id.value[1] = (*entry)->fd & 0xff;
  638|  2.92k|	obj_info->id.len = 2;
  639|  2.92k|	strncpy(obj_info->app_label, (*entry)->name, SC_PKCS15_MAX_LABEL_SIZE-1);
  ------------------
  |  |   35|  2.92k|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  640|  2.92k|	*entry = list_iterator_next(list);
  641|  2.92k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.92k|#define SC_SUCCESS				0
  ------------------
  642|  2.92k|}
card-cac.c:cac_final_iterator:
  621|  2.07k|{
  622|  2.07k|	list_iterator_stop(list);
  623|  2.07k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.07k|#define SC_SUCCESS				0
  ------------------
  624|  2.07k|}
card-cac.c:cac_pin_cmd:
 1834|    123|{
 1835|       |	/* CAC, like PIV needs Extra validation of (new) PIN during
 1836|       |	 * a PIN change request, to ensure it's not outside the
 1837|       |	 * FIPS 201 4.1.6.1 (numeric only) and * FIPS 140-2
 1838|       |	 * (6 character minimum) requirements.
 1839|       |	 */
 1840|    123|	sc_apdu_t apdu;
 1841|    123|	u8  sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1842|    123|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1843|    123|	int rv;
 1844|       |
 1845|    123|	if (data->cmd == SC_PIN_CMD_CHANGE) {
  ------------------
  |  |  416|    123|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1845:6): [True: 13, False: 110]
  ------------------
 1846|     13|		size_t i = 0;
 1847|     13|		if (data->pin2.len < 6) {
  ------------------
  |  Branch (1847:7): [True: 5, False: 8]
  ------------------
 1848|      5|			return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      5|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
 1849|      5|		}
 1850|     46|		for(i=0; i < data->pin2.len; ++i) {
  ------------------
  |  Branch (1850:12): [True: 41, False: 5]
  ------------------
 1851|     41|			if (!isdigit(data->pin2.data[i])) {
  ------------------
  |  Branch (1851:8): [True: 3, False: 38]
  ------------------
 1852|      3|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      3|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1853|      3|			}
 1854|     41|		}
 1855|       |
 1856|       |		/* We can change the PIN of Giesecke & Devrient CAC ALT tokens
 1857|       |		 * with a bit non-standard APDU */
 1858|      5|		if (card->type == SC_CARD_TYPE_CAC_ALT_HID) {
  ------------------
  |  Branch (1858:7): [True: 1, False: 4]
  ------------------
 1859|      1|			int r = 0;
 1860|      1|			r = iso7816_build_pin_apdu(card, &apdu, data, sbuf, sizeof(sbuf));
 1861|      1|			if (r < 0)
  ------------------
  |  Branch (1861:8): [True: 0, False: 1]
  ------------------
 1862|      0|				return r;
 1863|       |			/* it requires P1 = 0x01 completely against the ISO specs */
 1864|      1|			apdu.p1 = 0x01;
 1865|      1|			data->apdu = &apdu;
 1866|      1|		}
 1867|      5|	}
 1868|       |
 1869|    115|	rv = iso_drv->ops->pin_cmd(card, data);
 1870|       |
 1871|       |	data->apdu = NULL;
 1872|    115|	return rv;
 1873|    123|}

sc_get_cac1_driver:
  554|  17.0k|{
  555|  17.0k|	return sc_get_driver();
  556|  17.0k|}
card-cac1.c:sc_get_driver:
  536|  17.0k|{
  537|       |	/* Inherit most of the things from the CAC driver */
  538|  17.0k|	struct sc_card_driver *cac_drv = sc_get_cac_driver();
  539|       |
  540|  17.0k|	cac_ops = *cac_drv->ops;
  541|  17.0k|	cac_ops.match_card = cac_match_card;
  542|  17.0k|	cac_ops.init = cac_init;
  543|  17.0k|	cac_ops.finish = cac_finish;
  544|       |
  545|  17.0k|	cac_ops.select_file =  cac_select_file; /* need to record object type */
  546|  17.0k|	cac_ops.read_binary = cac_read_binary;
  547|  17.0k|	cac_ops.logout = cac_logout;
  548|       |
  549|  17.0k|	return &cac1_drv;
  550|  17.0k|}
card-cac1.c:cac_match_card:
  489|  2.78k|{
  490|  2.78k|	int r;
  491|  2.78k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  2.78k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.78k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.78k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.78k]
  |  |  ------------------
  ------------------
  492|       |
  493|  2.78k|	r = cac_find_and_initialize(card, 0);
  494|  2.78k|	return (r == SC_SUCCESS); /* never match */
  ------------------
  |  |   28|  2.78k|#define SC_SUCCESS				0
  ------------------
  495|  2.78k|}
card-cac1.c:cac_find_and_initialize:
  451|  3.02k|{
  452|  3.02k|	int r, index;
  453|  3.02k|	cac_private_data_t *priv = NULL;
  454|       |
  455|       |	/* already initialized? */
  456|  3.02k|	if (card->drv_data) {
  ------------------
  |  Branch (456:6): [True: 0, False: 3.02k]
  ------------------
  457|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  458|      0|	}
  459|       |
  460|       |	/* is this a CAC Alt token without any accompanying structures */
  461|  3.02k|	r = cac_find_first_pki_applet(card, &index);
  462|  3.02k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  3.02k|#define SC_SUCCESS				0
  ------------------
  |  Branch (462:6): [True: 456, False: 2.56k]
  ------------------
  463|    456|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "PKI applet found, is bare CAC-1");
  ------------------
  |  |   70|    456|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  464|    456|		if (!initialize) /* match card only */
  ------------------
  |  Branch (464:7): [True: 231, False: 225]
  ------------------
  465|    231|			return r;
  466|       |
  467|    225|		if (!priv) {
  ------------------
  |  Branch (467:7): [True: 225, False: 0]
  ------------------
  468|    225|			priv = cac_new_private_data();
  469|    225|			if (!priv)
  ------------------
  |  Branch (469:8): [True: 0, False: 225]
  ------------------
  470|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  471|    225|		}
  472|    225|		card->drv_data = priv; /* needed for the read_binary() */
  473|    225|		r = cac_populate_cac1(card, index, priv);
  474|    225|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    225|#define SC_SUCCESS				0
  ------------------
  |  Branch (474:7): [True: 194, False: 31]
  ------------------
  475|    194|			card->type = SC_CARD_TYPE_CAC_I;
  476|    194|			return r;
  477|    194|		}
  478|     31|		card->drv_data = NULL; /* reset on failure */
  479|     31|	}
  480|  2.59k|	if (priv) {
  ------------------
  |  Branch (480:6): [True: 31, False: 2.56k]
  ------------------
  481|     31|		cac_free_private_data(priv);
  482|     31|	}
  483|  2.59k|	return r;
  484|  3.02k|}
card-cac1.c:cac_find_first_pki_applet:
  365|  3.02k|{
  366|  3.02k|	int r, i;
  367|       |
  368|  44.5k|	for (i = 0; i < MAX_CAC_SLOTS; i++) {
  ------------------
  |  |   70|  44.5k|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (368:14): [True: 41.9k, False: 2.56k]
  ------------------
  369|  41.9k|		r = cac_select_pki_applet(card, i);
  370|  41.9k|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  41.9k|#define SC_SUCCESS				0
  ------------------
  |  Branch (370:7): [True: 544, False: 41.4k]
  ------------------
  371|    544|			u8 data[2];
  372|    544|			sc_apdu_t apdu;
  373|       |
  374|       |			/* Try to read first two bytes of the buffer to
  375|       |			 * make sure it is not just malfunctioning card
  376|       |			 */
  377|    544|			sc_format_apdu(card, &apdu, SC_APDU_CASE_2,
  ------------------
  |  |  301|    544|#define SC_APDU_CASE_2			0x22
  ------------------
  378|    544|				CAC_INS_GET_CERTIFICATE, 0x00, 0x00);
  ------------------
  |  |   59|    544|#define CAC_INS_GET_CERTIFICATE       0x36  /* CAC1 command to read a certificate */
  ------------------
  379|    544|			apdu.le = 0x02;
  380|    544|			apdu.resplen = 2;
  381|    544|			apdu.resp = data;
  382|    544|			r = sc_transmit_apdu(card, &apdu);
  383|       |			/* SW1 = 0x63 means more data in CAC1 */
  384|    544|			if (r == SC_SUCCESS && apdu.sw1 != 0x63)
  ------------------
  |  |   28|  1.08k|#define SC_SUCCESS				0
  ------------------
  |  Branch (384:8): [True: 421, False: 123]
  |  Branch (384:27): [True: 88, False: 333]
  ------------------
  385|     88|				continue;
  386|       |
  387|    456|			*index_out = i;
  388|    456|			return SC_SUCCESS;
  ------------------
  |  |   28|    456|#define SC_SUCCESS				0
  ------------------
  389|    544|		}
  390|  41.9k|	}
  391|  2.56k|	return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|  2.56k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  392|  3.02k|}
card-cac1.c:cac_select_pki_applet:
  355|  45.4k|{
  356|  45.4k|	sc_path_t applet_path = cac_cac_pki_obj.path;
  357|  45.4k|	applet_path.aid.value[applet_path.aid.len-1] = index;
  358|       |	return cac_select_file_by_type(card, &applet_path, NULL);
  359|  45.4k|}
card-cac1.c:cac_select_file_by_type:
  201|  46.8k|{
  202|  46.8k|	struct sc_context *ctx;
  203|  46.8k|	struct sc_apdu apdu;
  204|  46.8k|	unsigned char buf[SC_MAX_APDU_BUFFER_SIZE];
  205|  46.8k|	unsigned char pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  206|  46.8k|	int r, pathtype;
  207|  46.8k|	size_t pathlen;
  208|  46.8k|	struct sc_file *file = NULL;
  209|  46.8k|	cac_private_data_t *priv;
  210|       |
  211|  46.8k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (211:6): [True: 0, False: 46.8k]
  |  Branch (211:22): [True: 0, False: 46.8k]
  ------------------
  212|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  213|       |
  214|  46.8k|	ctx = card->ctx;
  215|  46.8k|	priv = CAC_DATA(card);
  ------------------
  |  |   61|  46.8k|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  216|       |
  217|  46.8k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  46.8k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  46.8k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  46.8k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 46.8k]
  |  |  ------------------
  ------------------
  218|       |
  219|  46.8k|	memcpy(path, in_path->value, in_path->len);
  220|  46.8k|	pathlen = in_path->len;
  221|  46.8k|	pathtype = in_path->type;
  222|       |
  223|  46.8k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  46.8k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  224|  46.8k|		"path=%s, path->value=%s path->type=%d (%x)",
  225|  46.8k|		sc_print_path(in_path),
  226|  46.8k|		sc_dump_hex(in_path->value, in_path->len),
  227|  46.8k|		in_path->type, in_path->type);
  228|  46.8k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "file_out=%p index=%d count=%d\n",
  ------------------
  |  |   70|  46.8k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  229|  46.8k|		file_out, in_path->index, in_path->count);
  230|       |
  231|       |	/* Sigh, iso7816_select_file expects paths to keys to have specific
  232|       |	 * formats. There is no override. We have to add some bytes to the
  233|       |	 * path to make it happy.
  234|       |	 * We only need to do this for private keys.
  235|       |	 */
  236|  46.8k|	if ((pathlen > 2) && (pathlen <= 4) && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (236:6): [True: 582, False: 46.3k]
  |  Branch (236:23): [True: 582, False: 0]
  |  Branch (236:41): [True: 582, False: 0]
  ------------------
  237|    582|		path += 2;
  238|    582|		pathlen -= 2;
  239|    582|	}
  240|       |
  241|       |
  242|       |	/* CAC has multiple different type of objects that aren't PKCS #15. When we read
  243|       |	 * them we need convert them to something PKCS #15 would understand. Find the object
  244|       |	 * and object type here:
  245|       |	 */
  246|  46.8k|	if (priv) { /* don't record anything if we haven't been initialized yet */
  ------------------
  |  Branch (246:6): [True: 4.90k, False: 41.9k]
  ------------------
  247|       |		/* forget any old cached values */
  248|  4.90k|		if (priv->cache_buf) {
  ------------------
  |  Branch (248:7): [True: 202, False: 4.69k]
  ------------------
  249|    202|			free(priv->cache_buf);
  250|    202|			priv->cache_buf = NULL;
  251|    202|		}
  252|  4.90k|		priv->cache_buf_len = 0;
  253|  4.90k|		priv->cached = 0;
  254|  4.90k|	}
  255|       |
  256|  46.8k|	if (in_path->aid.len) {
  ------------------
  |  Branch (256:6): [True: 46.3k, False: 582]
  ------------------
  257|  46.3k|		if (!pathlen) {
  ------------------
  |  Branch (257:7): [True: 46.3k, False: 0]
  ------------------
  258|  46.3k|			memcpy(path, in_path->aid.value, in_path->aid.len);
  259|  46.3k|			pathlen = in_path->aid.len;
  260|  46.3k|			pathtype = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  46.3k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  261|  46.3k|		} else {
  262|       |			/* First, select the application */
  263|      0|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"select application" );
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  264|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  265|      0|			apdu.data = in_path->aid.value;
  266|      0|			apdu.datalen = in_path->aid.len;
  267|      0|			apdu.lc = in_path->aid.len;
  268|       |
  269|      0|			r = sc_transmit_apdu(card, &apdu);
  270|      0|			LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|      0|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  272|      0|			if (r)
  ------------------
  |  Branch (272:8): [True: 0, False: 0]
  ------------------
  273|      0|				LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  274|       |
  275|      0|		}
  276|  46.3k|	}
  277|       |
  278|  46.8k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  294|  46.8k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  279|       |
  280|  46.8k|	switch (pathtype) {
  281|       |	/* ideally we would had SC_PATH_TYPE_OBJECT_ID and add code to the iso7816 select.
  282|       |	 * Unfortunately we'd also need to update the caching code as well. For now just
  283|       |	 * use FILE_ID and change p1 here */
  284|      0|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (284:2): [True: 0, False: 46.8k]
  ------------------
  285|      0|		apdu.p1 = 2;
  286|      0|		if (pathlen != 2)
  ------------------
  |  Branch (286:7): [True: 0, False: 0]
  ------------------
  287|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  288|      0|		break;
  289|  46.3k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  46.3k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (289:2): [True: 46.3k, False: 582]
  ------------------
  290|  46.3k|		apdu.p1 = 4;
  291|  46.3k|		break;
  292|    582|	default:
  ------------------
  |  Branch (292:2): [True: 582, False: 46.3k]
  ------------------
  293|    582|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|    582|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    582|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    582|	int _ret = r; \
  |  |  |  |  155|    582|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 582, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    582|		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|    582|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 582, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    582|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    582|	} 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|    582|	return _ret; \
  |  |  |  |  163|    582|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|  46.8k|	}
  295|  46.3k|	apdu.lc = pathlen;
  296|  46.3k|	apdu.data = path;
  297|  46.3k|	apdu.datalen = pathlen;
  298|  46.3k|	apdu.resp = buf;
  299|  46.3k|	apdu.resplen = sizeof(buf);
  300|  46.3k|	apdu.le = sc_get_max_recv_size(card) < 256 ? sc_get_max_recv_size(card) : 256;
  ------------------
  |  Branch (300:12): [True: 0, False: 46.3k]
  ------------------
  301|  46.3k|	apdu.p2 = 0x00;
  302|       |
  303|  46.3k|	r = sc_transmit_apdu(card, &apdu);
  304|  46.3k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  46.3k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  46.3k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  46.3k|	int _ret = (r); \
  |  |  |  |  168|  46.3k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 200, False: 46.1k]
  |  |  |  |  ------------------
  |  |  |  |  169|    200|		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|    200|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    200|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    200|		return _ret; \
  |  |  |  |  172|    200|	} \
  |  |  |  |  173|  46.3k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 46.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  305|       |
  306|  46.1k|	if (file_out == NULL) {
  ------------------
  |  Branch (306:6): [True: 45.2k, False: 885]
  ------------------
  307|       |		/* For some cards 'SELECT' can be only with request to return FCI/FCP. */
  308|  45.2k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  309|  45.2k|		if (apdu.sw1 == 0x6A && apdu.sw2 == 0x86)   {
  ------------------
  |  Branch (309:7): [True: 179, False: 45.0k]
  |  Branch (309:27): [True: 87, False: 92]
  ------------------
  310|     87|			apdu.p2 = 0x00;
  311|     87|			apdu.resplen = sizeof(buf);
  312|     87|			if (sc_transmit_apdu(card, &apdu) == SC_SUCCESS)
  ------------------
  |  |   28|     87|#define SC_SUCCESS				0
  ------------------
  |  Branch (312:8): [True: 39, False: 48]
  ------------------
  313|     39|				r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  314|     87|		}
  315|  45.2k|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (315:7): [True: 48, False: 45.1k]
  ------------------
  316|  45.2k|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     48|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     48|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     48|	int _ret = r; \
  |  |  |  |  155|     48|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 48, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     48|		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: 48]
  |  |  |  |  ------------------
  |  |  |  |  157|     48|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     48|	} 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|     48|	return _ret; \
  |  |  |  |  163|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|  45.1k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  45.1k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  45.1k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  45.1k|	int _ret = r; \
  |  |  |  |  155|  45.1k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 45.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  45.1k|		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|  43.5k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 43.5k, False: 1.65k]
  |  |  |  |  ------------------
  |  |  |  |  157|  45.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  45.1k|	} 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|  45.1k|	return _ret; \
  |  |  |  |  163|  45.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  318|  45.1k|	}
  319|       |
  320|    885|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  321|    885|	if (r)
  ------------------
  |  Branch (321:6): [True: 455, False: 430]
  ------------------
  322|    885|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    455|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    455|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    455|	int _ret = r; \
  |  |  |  |  155|    455|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 455, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    455|		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|    455|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 455, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    455|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    455|	} 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|    455|	return _ret; \
  |  |  |  |  163|    455|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  323|       |
  324|       |	/* CAC cards never return FCI, fake one */
  325|    430|	file = sc_file_new();
  326|    430|	if (file == NULL)
  ------------------
  |  Branch (326:6): [True: 0, False: 430]
  ------------------
  327|    430|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  328|    430|	file->path = *in_path;
  329|    430|	file->size = CAC_MAX_SIZE; /* we don't know how big, just give a large size until we can read the file */
  ------------------
  |  |   26|    430|#define CAC_MAX_SIZE 4096		/* arbitrary, just needs to be 'large enough' */
  ------------------
  330|       |
  331|    430|	*file_out = file;
  332|    430|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    430|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    430|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    430|	int _ret = r; \
  |  |  |  |  155|    430|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 430, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    430|		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: 430]
  |  |  |  |  ------------------
  |  |  |  |  157|    430|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    430|	} 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|    430|	return _ret; \
  |  |  |  |  163|    430|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  333|       |
  334|    430|}
card-cac1.c:cac_populate_cac1:
  395|    225|{
  396|    225|	int r, i;
  397|    225|	cac_object_t pki_obj = cac_cac_pki_obj;
  398|    225|	u8 buf[100];
  399|    225|	u8 *val;
  400|    225|	size_t val_len;
  401|       |
  402|       |	/* populate PKI objects */
  403|  3.43k|	for (i = index; i < MAX_CAC_SLOTS; i++) {
  ------------------
  |  |   70|  3.43k|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (403:18): [True: 3.20k, False: 225]
  ------------------
  404|  3.20k|		r = cac_select_pki_applet(card, i);
  405|  3.20k|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  3.20k|#define SC_SUCCESS				0
  ------------------
  |  Branch (405:7): [True: 965, False: 2.24k]
  ------------------
  406|    965|			pki_obj.name = get_cac_label(i);
  407|    965|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    965|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  408|    965|				"CAC: pki_object found, cert_next=%d (%s)",
  409|    965|				i, pki_obj.name);
  410|    965|			pki_obj.path.aid.value[pki_obj.path.aid.len-1] = i;
  411|    965|			pki_obj.fd = i+1; /* don't use id of zero */
  412|    965|			cac_add_object_to_list(&priv->pki_list, &pki_obj);
  413|    965|		}
  414|  3.20k|	}
  415|       |
  416|       |	/*
  417|       |	 * create a cuid to simulate the cac 2 cuid.
  418|       |	 */
  419|    225|	priv->cuid = cac_cac_cuid;
  420|       |	/* create a serial number by hashing the first 100 bytes of the
  421|       |	 * first certificate on the card */
  422|    225|	r = cac_select_pki_applet(card, index);
  423|    225|	if (r < 0) {
  ------------------
  |  Branch (423:6): [True: 31, False: 194]
  ------------------
  424|     31|		return r; /* shouldn't happen unless the card has been removed or is malfunctioning */
  425|     31|	}
  426|    194|	val = buf;
  427|    194|	val_len = sizeof(buf);
  428|    194|	r = cac_cac1_get_certificate(card, &val, &val_len);
  429|    194|	if (r >= 0) {
  ------------------
  |  Branch (429:6): [True: 57, False: 137]
  ------------------
  430|     57|		priv->cac_id = malloc(20);
  431|     57|		if (priv->cac_id == NULL) {
  ------------------
  |  Branch (431:7): [True: 0, False: 57]
  ------------------
  432|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  433|      0|		}
  434|     57|#ifdef ENABLE_OPENSSL
  435|     57|		SHA1(val, val_len, priv->cac_id);
  436|     57|		priv->cac_id_len = 20;
  437|     57|		sc_debug_hex(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  127|     57|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  438|     57|			"cuid", priv->cac_id, priv->cac_id_len);
  439|       |#else
  440|       |		sc_log(card->ctx, "OpenSSL Required");
  441|       |		return SC_ERROR_NOT_SUPPORTED;
  442|       |#endif /* ENABLE_OPENSSL */
  443|     57|	}
  444|    194|	return SC_SUCCESS;
  ------------------
  |  |   28|    194|#define SC_SUCCESS				0
  ------------------
  445|    194|}
card-cac1.c:cac_cac1_get_certificate:
   65|    624|{
   66|    624|	u8 buf[CAC_MAX_SIZE];
   67|    624|	u8 *out_ptr;
   68|    624|	size_t size = 0;
   69|    624|	size_t left = 0;
   70|    624|	size_t len;
   71|    624|	sc_apdu_t apdu;
   72|    624|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    624|#define SC_SUCCESS				0
  ------------------
   73|    624|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    624|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    624|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    624|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 624]
  |  |  ------------------
  ------------------
   74|       |	/* get the size */
   75|    624|	size = left = *out_buf ? *out_len : sizeof(buf);
  ------------------
  |  Branch (75:16): [True: 194, False: 430]
  ------------------
   76|    624|	out_ptr = *out_buf ? *out_buf : buf;
  ------------------
  |  Branch (76:12): [True: 194, False: 430]
  ------------------
   77|    624|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, CAC_INS_GET_CERTIFICATE, 0, 0 );
  ------------------
  |  |  292|    624|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
              	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, CAC_INS_GET_CERTIFICATE, 0, 0 );
  ------------------
  |  |   59|    624|#define CAC_INS_GET_CERTIFICATE       0x36  /* CAC1 command to read a certificate */
  ------------------
   78|    624|	len = MIN(left, 100);
  ------------------
  |  |   69|    624|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 624]
  |  |  ------------------
  ------------------
   79|    721|	while (left > 0) {
  ------------------
  |  Branch (79:9): [True: 711, False: 10]
  ------------------
   80|    711|		apdu.resp = out_ptr;
   81|    711|		apdu.le = len;
   82|    711|		apdu.resplen = left;
   83|    711|		r = sc_transmit_apdu(card, &apdu);
   84|    711|		if (r < 0) {
  ------------------
  |  Branch (84:7): [True: 49, False: 662]
  ------------------
   85|     49|			break;
   86|     49|		}
   87|    662|		if (apdu.resplen == 0) {
  ------------------
  |  Branch (87:7): [True: 178, False: 484]
  ------------------
   88|    178|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    178|#define SC_ERROR_INTERNAL			-1400
  ------------------
   89|    178|			break;
   90|    178|		}
   91|       |		/* in the old CAC-1, 0x63 means 'more data' in addition to 'pin failed' */
   92|    484|		if (apdu.sw1 != 0x63 || apdu.sw2 < 1)  {
  ------------------
  |  Branch (92:7): [True: 377, False: 107]
  |  Branch (92:27): [True: 10, False: 97]
  ------------------
   93|       |			/* we've either finished reading, or hit an error, break */
   94|    387|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
   95|    387|			left -= apdu.resplen;
   96|    387|			break;
   97|    387|		}
   98|       |		/* Adjust the lengths */
   99|     97|		left -= apdu.resplen;
  100|     97|		out_ptr += apdu.resplen;
  101|     97|		len = MIN(left, apdu.sw2);
  ------------------
  |  |   69|     97|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 49, False: 48]
  |  |  ------------------
  ------------------
  102|     97|	}
  103|    624|	if (r < 0) {
  ------------------
  |  Branch (103:6): [True: 262, False: 362]
  ------------------
  104|    262|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    262|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    262|	int _ret = r; \
  |  |  155|    262|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 262, False: 0]
  |  |  ------------------
  |  |  156|    262|		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|    262|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 262, False: 0]
  |  |  ------------------
  |  |  157|    262|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    262|	} 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|    262|	return _ret; \
  |  |  163|    262|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  105|    262|	}
  106|    362|	r = (int)(size - left);
  107|    362|	if (*out_buf == NULL) {
  ------------------
  |  Branch (107:6): [True: 305, False: 57]
  ------------------
  108|    305|		*out_buf = malloc(r);
  109|    305|		if (*out_buf == NULL) {
  ------------------
  |  Branch (109:7): [True: 0, False: 305]
  ------------------
  110|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  111|      0|				SC_ERROR_OUT_OF_MEMORY);
  112|      0|		}
  113|    305|		memcpy(*out_buf, buf, r);
  114|    305|	}
  115|    362|	*out_len = r;
  116|    362|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    362|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    362|	int _ret = r; \
  |  |  155|    362|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 362]
  |  |  ------------------
  |  |  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|    362|	} else { \
  |  |  159|    362|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|    362|			"returning with: %d\n", _ret); \
  |  |  161|    362|	} \
  |  |  162|    362|	return _ret; \
  |  |  163|    362|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  117|    362|}
card-cac1.c:cac_init:
  499|    231|{
  500|    231|	int r;
  501|    231|	unsigned long flags;
  502|       |
  503|    231|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    231|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    231|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    231|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 231]
  |  |  ------------------
  ------------------
  504|       |
  505|    231|	r = cac_find_and_initialize(card, 1);
  506|    231|	if (r < 0) {
  ------------------
  |  Branch (506:6): [True: 37, False: 194]
  ------------------
  507|     37|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|     37|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     37|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     37|	int _ret = r; \
  |  |  |  |  155|     37|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 37, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     37|		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|     37|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 37, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     37|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     37|	} 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|     37|	return _ret; \
  |  |  |  |  163|     37|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  508|     37|	}
  509|    194|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|    194|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  510|       |
  511|    194|	_sc_card_add_rsa_alg(card, 1024, flags, 0); /* mandatory */
  512|    194|	_sc_card_add_rsa_alg(card, 2048, flags, 0); /* optional */
  513|    194|	_sc_card_add_rsa_alg(card, 3072, flags, 0); /* optional */
  514|       |
  515|    194|	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  550|    194|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    194|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  516|       |
  517|    194|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    194|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    194|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    194|	int _ret = r; \
  |  |  |  |  155|    194|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 194, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    194|		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: 194]
  |  |  |  |  ------------------
  |  |  |  |  157|    194|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    194|	} 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|    194|	return _ret; \
  |  |  |  |  163|    194|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|    194|}
card-cac1.c:cac_finish:
  342|    194|{
  343|    194|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|    194|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  344|       |
  345|    194|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    194|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    194|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    194|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 194]
  |  |  ------------------
  ------------------
  346|    194|	if (priv) {
  ------------------
  |  Branch (346:6): [True: 194, False: 0]
  ------------------
  347|    194|		cac_free_private_data(priv);
  348|    194|	}
  349|    194|	return SC_SUCCESS;
  ------------------
  |  |   28|    194|#define SC_SUCCESS				0
  ------------------
  350|    194|}
card-cac1.c:cac_select_file:
  337|  1.47k|{
  338|  1.47k|	return cac_select_file_by_type(card, in_path, file_out);
  339|  1.47k|}
card-cac1.c:cac_read_binary:
  126|  1.59k|{
  127|  1.59k|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|  1.59k|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  128|  1.59k|	int r = 0;
  129|  1.59k|	u8 *val = NULL;
  130|  1.59k|	u8 *cert_ptr;
  131|  1.59k|	size_t val_len = 0;
  132|  1.59k|	size_t len, cert_len;
  133|  1.59k|	u8 cert_type;
  134|       |
  135|  1.59k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.59k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.59k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.59k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.59k]
  |  |  ------------------
  ------------------
  136|       |
  137|       |	/* if we didn't return it all last time, return the remainder */
  138|  1.59k|	if (priv->cached) {
  ------------------
  |  Branch (138:6): [True: 1.16k, False: 430]
  ------------------
  139|  1.16k|		sc_log(card->ctx, "returning cached value idx=%d count=%zu", idx, count);
  ------------------
  |  |   71|  1.16k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  140|  1.16k|		if (idx > priv->cache_buf_len) {
  ------------------
  |  Branch (140:7): [True: 0, False: 1.16k]
  ------------------
  141|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_END_REACHED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  142|      0|		}
  143|  1.16k|		len = MIN(count, priv->cache_buf_len-idx);
  ------------------
  |  |   69|  1.16k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 822, False: 338]
  |  |  ------------------
  ------------------
  144|  1.16k|		memcpy(buf, &priv->cache_buf[idx], len);
  145|  1.16k|		LOG_FUNC_RETURN(card->ctx, (int)len);
  ------------------
  |  |  164|  1.16k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.16k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.16k|	int _ret = r; \
  |  |  |  |  155|  1.16k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 222, False: 938]
  |  |  |  |  ------------------
  |  |  |  |  156|    222|		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: 222]
  |  |  |  |  ------------------
  |  |  |  |  157|    222|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    938|	} else { \
  |  |  |  |  159|    938|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    938|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    938|	} \
  |  |  |  |  162|  1.16k|	return _ret; \
  |  |  |  |  163|  1.16k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  146|  1.16k|	}
  147|       |
  148|    430|	sc_log(card->ctx, "clearing cache idx=%d count=%zu", idx, count);
  ------------------
  |  |   71|    430|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  149|    430|	free(priv->cache_buf);
  150|    430|	priv->cache_buf = NULL;
  151|    430|	priv->cache_buf_len = 0;
  152|       |
  153|    430|	r = cac_cac1_get_certificate(card, &val, &val_len);
  154|    430|	if (r < 0)
  ------------------
  |  Branch (154:6): [True: 125, False: 305]
  ------------------
  155|    125|		goto done;
  156|    305|	if (val_len < 1) {
  ------------------
  |  Branch (156:6): [True: 0, False: 305]
  ------------------
  157|      0|		r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  158|      0|		goto done;
  159|      0|	}
  160|       |
  161|    305|	cert_type = val[0];
  162|    305|	cert_ptr = val + 1;
  163|    305|	cert_len = val_len - 1;
  164|       |
  165|       |	/* if the info byte is 1, then the cert is compressed, decompress it */
  166|    305|	if ((cert_type & 0x3) == 1) {
  ------------------
  |  Branch (166:6): [True: 154, False: 151]
  ------------------
  167|    154|		if (flags)
  ------------------
  |  Branch (167:7): [True: 154, False: 0]
  ------------------
  168|    154|			*flags |= SC_FILE_FLAG_COMPRESSED_AUTO;
  ------------------
  |  |  230|    154|#define SC_FILE_FLAG_COMPRESSED_AUTO		0x01
  ------------------
  169|    154|	}
  170|    305|	if (cert_len > 0) {
  ------------------
  |  Branch (170:6): [True: 257, False: 48]
  ------------------
  171|    257|		priv->cache_buf = malloc(cert_len);
  172|    257|		if (priv->cache_buf == NULL) {
  ------------------
  |  Branch (172:7): [True: 0, False: 257]
  ------------------
  173|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  174|      0|			goto done;
  175|      0|		}
  176|    257|		priv->cache_buf_len = cert_len;
  177|    257|		memcpy(priv->cache_buf, cert_ptr, cert_len);
  178|    257|	}
  179|       |
  180|       |	/* OK we've read the data, now copy the required portion out to the callers buffer */
  181|    305|	priv->cached = 1;
  182|    305|	len = MIN(count, priv->cache_buf_len-idx);
  ------------------
  |  |   69|    305|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 116, False: 189]
  |  |  ------------------
  ------------------
  183|    305|	if (len && priv->cache_buf)
  ------------------
  |  Branch (183:6): [True: 257, False: 48]
  |  Branch (183:13): [True: 257, False: 0]
  ------------------
  184|    257|		memcpy(buf, &priv->cache_buf[idx], len);
  185|    305|	r = (int)len;
  186|    430|done:
  187|    430|	if (val)
  ------------------
  |  Branch (187:6): [True: 305, False: 125]
  ------------------
  188|    305|		free(val);
  189|    430|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    430|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    430|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    430|	int _ret = r; \
  |  |  |  |  155|    430|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 173, False: 257]
  |  |  |  |  ------------------
  |  |  |  |  156|    173|		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|    125|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 125, False: 48]
  |  |  |  |  ------------------
  |  |  |  |  157|    173|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    257|	} else { \
  |  |  |  |  159|    257|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    257|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    257|	} \
  |  |  |  |  162|    430|	return _ret; \
  |  |  |  |  163|    430|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  190|    430|}

sc_get_cardos_driver:
 1594|  17.0k|{
 1595|  17.0k|	return sc_get_driver();
 1596|  17.0k|}
card-cardos.c:sc_get_driver:
 1569|  17.0k|{
 1570|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1570:6): [True: 1, False: 17.0k]
  ------------------
 1571|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1572|  17.0k|	cardos_ops = *iso_ops;
 1573|  17.0k|	cardos_ops.match_card = cardos_match_card;
 1574|  17.0k|	cardos_ops.init = cardos_init;
 1575|  17.0k|	cardos_ops.finish = cardos_finish;
 1576|  17.0k|	cardos_ops.select_file = cardos_select_file;
 1577|  17.0k|	cardos_ops.create_file = cardos_create_file;
 1578|  17.0k|	cardos_ops.set_security_env = cardos_set_security_env;
 1579|  17.0k|	cardos_ops.restore_security_env = cardos_restore_security_env;
 1580|  17.0k|	cardos_ops.compute_signature = cardos_compute_signature;
 1581|  17.0k|	cardos_ops.decipher = cardos_decipher;
 1582|       |
 1583|  17.0k|	cardos_ops.list_files = cardos_list_files;
 1584|  17.0k|	cardos_ops.check_sw = cardos_check_sw;
 1585|  17.0k|	cardos_ops.card_ctl = cardos_card_ctl;
 1586|  17.0k|	cardos_ops.pin_cmd = cardos_pin_cmd;
 1587|  17.0k|	cardos_ops.logout  = cardos_logout;
 1588|       |
 1589|  17.0k|	return &cardos_drv;
 1590|  17.0k|}
card-cardos.c:cardos_match_card:
   82|  16.3k|{
   83|  16.3k|	unsigned char atr[SC_MAX_ATR_SIZE] = {0};
   84|  16.3k|	int i;
   85|       |
   86|  16.3k|	i = _sc_match_atr(card, cardos_atrs, &card->type);
   87|  16.3k|	if (i < 0)
  ------------------
  |  Branch (87:6): [True: 15.5k, False: 736]
  ------------------
   88|  15.5k|		return 0;
   89|       |
   90|    736|	memcpy(atr, card->atr.value, card->atr.len);
   91|       |
   92|       |	/* Do not change card type for CIE! */
   93|    736|	if (card->type == SC_CARD_TYPE_CARDOS_CIE_V1)
  ------------------
  |  Branch (93:6): [True: 0, False: 736]
  ------------------
   94|      0|		return 1;
   95|    736|	if (card->type == SC_CARD_TYPE_CARDOS_M4_4)
  ------------------
  |  Branch (95:6): [True: 0, False: 736]
  ------------------
   96|      0|		return 1;
   97|    736|	if (card->type == SC_CARD_TYPE_CARDOS_V5_0)
  ------------------
  |  Branch (97:6): [True: 15, False: 721]
  ------------------
   98|     15|		return 1;
   99|    721|	if (card->type == SC_CARD_TYPE_CARDOS_V5_3)
  ------------------
  |  Branch (99:6): [True: 601, False: 120]
  ------------------
  100|    601|		return 1;
  101|    120|	if (card->type == SC_CARD_TYPE_CARDOS_M4_2) {
  ------------------
  |  Branch (101:6): [True: 120, False: 0]
  ------------------
  102|    120|		int rv;
  103|    120|		sc_apdu_t apdu = {0};
  104|    120|		u8 rbuf[SC_MAX_APDU_BUFFER_SIZE] = {0};
  105|       |		/* first check some additional ATR bytes */
  106|    120|		if ((atr[4] != 0xff && atr[4] != 0x02) ||
  ------------------
  |  Branch (106:8): [True: 102, False: 18]
  |  Branch (106:26): [True: 9, False: 93]
  ------------------
  107|    111|		    (atr[6] != 0x10 && atr[6] != 0x0a) ||
  ------------------
  |  Branch (107:8): [True: 29, False: 82]
  |  Branch (107:26): [True: 9, False: 20]
  ------------------
  108|    102|		    (atr[9] != 0x55 && atr[9] != 0x58))
  ------------------
  |  Branch (108:8): [True: 96, False: 6]
  |  Branch (108:26): [True: 13, False: 83]
  ------------------
  109|     31|			return 0;
  110|       |		/* get the os version using GET DATA and compare it with
  111|       |		 * version in the ATR */
  112|     89|		sc_log(card->ctx,  "checking cardos version ...");
  ------------------
  |  |   71|     89|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  113|     89|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x82);
  ------------------
  |  |  292|     89|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  114|     89|		apdu.resp = rbuf;
  115|     89|		apdu.resplen = sizeof(rbuf);
  116|     89|		apdu.le = 256;
  117|     89|		apdu.lc = 0;
  118|     89|		rv = sc_transmit_apdu(card, &apdu);
  119|     89|		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|     89|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     89|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     89|	int _ret = (r); \
  |  |  |  |  168|     89|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 86]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|     89|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 86]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  120|     86|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00 || apdu.resplen < 2)
  ------------------
  |  Branch (120:7): [True: 9, False: 77]
  |  Branch (120:27): [True: 6, False: 71]
  |  Branch (120:47): [True: 1, False: 70]
  ------------------
  121|     16|			return 0;
  122|     70|		if (apdu.resp[0] != atr[10] ||
  ------------------
  |  Branch (122:7): [True: 10, False: 60]
  ------------------
  123|     60|		    apdu.resp[1] != atr[11])
  ------------------
  |  Branch (123:7): [True: 9, False: 51]
  ------------------
  124|       |			/* version mismatch */
  125|     19|			return 0;
  126|     51|		if (atr[11] <= 0x04) {
  ------------------
  |  Branch (126:7): [True: 19, False: 32]
  ------------------
  127|     19|			sc_log(card->ctx,  "found cardos m4.01");
  ------------------
  |  |   71|     19|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  128|     19|			card->type = SC_CARD_TYPE_CARDOS_M4_01;
  129|     32|		} else if (atr[11] == 0x08) {
  ------------------
  |  Branch (129:14): [True: 1, False: 31]
  ------------------
  130|      1|			sc_log(card->ctx,  "found cardos v4.3b");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  131|      1|			card->type = SC_CARD_TYPE_CARDOS_M4_3;
  132|     31|		} else if (atr[11] == 0x09) {
  ------------------
  |  Branch (132:14): [True: 1, False: 30]
  ------------------
  133|      1|			sc_log(card->ctx,  "found cardos v4.2b");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  134|      1|			card->type = SC_CARD_TYPE_CARDOS_M4_2B;
  135|     30|		} else if (atr[11] >= 0x0B) {
  ------------------
  |  Branch (135:14): [True: 8, False: 22]
  ------------------
  136|      8|			sc_log(card->ctx,  "found cardos v4.2c or higher");
  ------------------
  |  |   71|      8|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  137|      8|			card->type = SC_CARD_TYPE_CARDOS_M4_2C;
  138|     22|		} else {
  139|     22|			sc_log(card->ctx,  "found cardos m4.2");
  ------------------
  |  |   71|     22|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  140|     22|		}
  141|     51|	}
  142|     51|	return 1;
  143|    120|}
card-cardos.c:cardos_init:
  218|    667|{
  219|    667|	cardos_data_t * priv = NULL;
  220|    667|	unsigned long flags = 0;
  221|    667|	size_t data_field_length;
  222|    667|	sc_apdu_t apdu;
  223|    667|	u8 rbuf[2];
  224|    667|	int r;
  225|       |
  226|    667|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    667|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    667|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    667|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 667]
  |  |  ------------------
  ------------------
  227|       |
  228|    667|	priv = calloc(1, sizeof(cardos_data_t));
  229|    667|	if (!priv)
  ------------------
  |  Branch (229:6): [True: 0, False: 667]
  ------------------
  230|    667|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  231|    667|	card->drv_data = priv;
  232|       |
  233|    667|	card->name = "Atos CardOS";
  234|    667|	card->cla = 0x00;
  235|       |
  236|       |	/* let user override flags and type from opensc.conf */
  237|       |	/* user can override card->type too.*/
  238|    667|	if (card->flags) {
  ------------------
  |  Branch (238:6): [True: 0, False: 667]
  ------------------
  239|      0|	    flags = card->flags;
  240|    667|	} else {
  241|       |
  242|       |		/* Set up algorithm info. */
  243|    667|		flags = 0;
  244|    667|		if (card->type == SC_CARD_TYPE_CARDOS_V5_0) {
  ------------------
  |  Branch (244:7): [True: 15, False: 652]
  ------------------
  245|     15|			flags |= SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  111|     15|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     15|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     15|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              			flags |= SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  107|     15|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  246|    652|		} else if(card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (246:13): [True: 601, False: 51]
  ------------------
  247|    601|			flags |= SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PSS | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    601|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              			flags |= SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PSS | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  133|    601|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              			flags |= SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PSS | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  107|    601|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
              			flags |= SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PSS | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    601|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  248|    601|		} else {
  249|     51|			flags |= SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  102|     51|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  250|     51|				| SC_ALGORITHM_RSA_HASH_NONE
  ------------------
  |  |  133|     51|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  251|     51|				| SC_ALGORITHM_NEED_USAGE
  ------------------
  |  |   95|     51|#define SC_ALGORITHM_NEED_USAGE		0x40000000
  ------------------
  252|     51|				| SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|     51|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  253|     51|		}
  254|    667|	}
  255|       |
  256|    667|	priv->flags = flags;
  257|       |
  258|    667|	if (card->type == SC_CARD_TYPE_CARDOS_M4_2) {
  ------------------
  |  Branch (258:6): [True: 22, False: 645]
  ------------------
  259|     22|		r = cardos_have_2048bit_package(card);
  260|     22|		if (r < 0) {
  ------------------
  |  Branch (260:7): [True: 2, False: 20]
  ------------------
  261|      2|			r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      2|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  262|      2|			goto err;
  263|      2|		}
  264|     20|		if (r == 1)
  ------------------
  |  Branch (264:7): [True: 1, False: 19]
  ------------------
  265|      1|			priv->rsa_2048 = 1;
  266|     20|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|     20|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  267|    645|	} else if (card->type == SC_CARD_TYPE_CARDOS_M4_3
  ------------------
  |  Branch (267:13): [True: 1, False: 644]
  ------------------
  268|    644|		|| card->type == SC_CARD_TYPE_CARDOS_M4_2B
  ------------------
  |  Branch (268:6): [True: 1, False: 643]
  ------------------
  269|    643|		|| card->type == SC_CARD_TYPE_CARDOS_M4_2C
  ------------------
  |  Branch (269:6): [True: 8, False: 635]
  ------------------
  270|    635|		|| card->type == SC_CARD_TYPE_CARDOS_M4_4
  ------------------
  |  Branch (270:6): [True: 0, False: 635]
  ------------------
  271|    635|		|| card->type == SC_CARD_TYPE_CARDOS_V5_0
  ------------------
  |  Branch (271:6): [True: 15, False: 620]
  ------------------
  272|    626|		|| card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (272:6): [True: 601, False: 19]
  ------------------
  273|    626|		priv->rsa_2048 = 1;
  274|    626|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|    626|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  275|       |		/* TODO check this. EC only if in supported_algo */
  276|    626|		priv->ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  201|    626|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              		priv->ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  202|    626|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  277|    626|	}
  278|       |
  279|       |	/* probe DATA FIELD LENGTH with GET DATA */
  280|    665|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x8D);
  ------------------
  |  |  292|    665|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  281|    665|	apdu.le = sizeof rbuf;
  282|    665|	apdu.resp = rbuf;
  283|    665|	apdu.resplen = sizeof(rbuf);
  284|       |
  285|    665|	r = sc_transmit_apdu(card, &apdu);
  286|    665|	if (r < 0)
  ------------------
  |  Branch (286:6): [True: 6, False: 659]
  ------------------
  287|    665|		LOG_TEST_GOTO_ERR(card->ctx,
  ------------------
  |  |  184|      6|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      6|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      6|	int _ret = (r); \
  |  |  |  |  178|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      6|		goto err; \
  |  |  |  |  182|      6|	} \
  |  |  |  |  183|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  288|    659|				SC_ERROR_INVALID_CARD,
  289|    659|				"APDU transmit failed");
  290|    659|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  291|    659|	if (r < 0)
  ------------------
  |  Branch (291:6): [True: 92, False: 567]
  ------------------
  292|    659|		LOG_TEST_GOTO_ERR(card->ctx,
  ------------------
  |  |  184|     92|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     92|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     92|	int _ret = (r); \
  |  |  |  |  178|     92|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 92, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     92|		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|     92|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     92|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     92|		goto err; \
  |  |  |  |  182|     92|	} \
  |  |  |  |  183|     92|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|    567|				SC_ERROR_INVALID_CARD,
  294|    567|				"GET DATA command returned error");
  295|    567|	if (apdu.resplen != 2) {
  ------------------
  |  Branch (295:6): [True: 6, False: 561]
  ------------------
  296|      6|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      6|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  297|      6|		goto err;
  298|      6|	}
  299|    561|	data_field_length = ((rbuf[0] << 8) | rbuf[1]);
  300|       |
  301|       |	/* TODO is this really needed? strip the length of possible Lc and Le bytes */
  302|       |
  303|       |	/* Use Min card sizes and reader too. for V5_3 at least*/
  304|       |
  305|    561|	if (card->type == SC_CARD_TYPE_CARDOS_V5_0 || card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (305:6): [True: 13, False: 548]
  |  Branch (305:48): [True: 527, False: 21]
  ------------------
  306|    540|		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,
  ------------------
  |  |   70|    540|#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)
  |  |  ------------------
  |  |  |  |  309|    540|				data_field_length, card->reader->max_send_size, card->reader->max_recv_size,
  |  |  |  |  310|    540|				(card->caps & SC_CARD_CAP_APDU_EXT) ? "SC_CARD_CAP_APDU_EXT" : " ");
  |  |  |  |  ------------------
  |  |  |  |  |  |  547|    540|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  307|    540|				"data_field_length:%zu card->reader->max_send_size:%zu "
  308|    540|				"card->reader->max_recv_size:%zu %s",
  309|    540|				data_field_length, card->reader->max_send_size, card->reader->max_recv_size,
  310|    540|				(card->caps & SC_CARD_CAP_APDU_EXT) ? "SC_CARD_CAP_APDU_EXT" : " ");
  311|       |
  312|    540|		if (card->caps & SC_CARD_CAP_APDU_EXT) {
  ------------------
  |  |  547|    540|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (312:7): [True: 540, False: 0]
  ------------------
  313|    540|			card->max_send_size  = data_field_length - 6;
  314|       |#ifdef _WIN32
  315|       |			/* Windows does not support PCSC PART_10 and may have forced reader to 255/256
  316|       |			 * https://github.com/OpenSC/OpenSC/commit/eddea6f3c2d3dafc2c09eba6695c745a61b5186f
  317|       |			 * may have reset this. if so, will override and force extended
  318|       |			 * Most, if not all, cardos cards do extended, but not chaining
  319|       |			 */
  320|       |			if (card->reader->max_send_size == 255 && card->reader->max_recv_size == 256) {
  321|       |				sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "resetting reader to use data_field_length");
  322|       |				card->reader->max_send_size = data_field_length - 6;
  323|       |				card->reader->max_recv_size = data_field_length - 3;
  324|       |			}
  325|       |#endif
  326|    540|		} else
  327|      0|			card->max_send_size = data_field_length - 3;
  328|       |
  329|    540|		card->max_send_size = sc_get_max_send_size(card); /* include reader sizes and protocol */
  330|    540|		card->max_recv_size = data_field_length - 2;
  331|    540|		card->max_recv_size = sc_get_max_recv_size(card);
  332|    540|	} else {
  333|       |		/* old way, disregards reader capabilities */
  334|     21|		if (card->caps & SC_CARD_CAP_APDU_EXT)
  ------------------
  |  |  547|     21|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (334:7): [True: 4, False: 17]
  ------------------
  335|      4|			card->max_send_size = data_field_length - 6;
  336|     17|		else
  337|     17|			card->max_send_size = data_field_length - 3;
  338|       |		/* strip the length of SW bytes */
  339|     21|		card->max_recv_size = data_field_length - 2;
  340|     21|	}
  341|       |
  342|       |	/*for new cards, wait till after sc_pkcs15_bind_internal reads tokeninfo */
  343|    561|	if (card->type != SC_CARD_TYPE_CARDOS_V5_0 && card->type != SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (343:6): [True: 548, False: 13]
  |  Branch (343:48): [True: 21, False: 527]
  ------------------
  344|     21|		r = cardos_add_algs(card, flags, 0, 0);
  345|     21|	}
  346|       |
  347|    667|err:
  348|    667|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    667|#define SC_SUCCESS				0
  ------------------
  |  Branch (348:6): [True: 106, False: 561]
  ------------------
  349|    106|		free(priv);
  350|    106|		card->drv_data = NULL;
  351|    106|	}
  352|       |
  353|    667|	return r;
  354|    561|}
card-cardos.c:cardos_have_2048bit_package:
  146|     22|{
  147|     22|	sc_apdu_t apdu;
  148|     22|        u8        rbuf[SC_MAX_APDU_BUFFER_SIZE];
  149|     22|        int       r;
  150|     22|	const u8  *p = rbuf, *q, *pp;
  151|     22|	size_t    len, tlen = 0, ilen = 0;
  152|       |
  153|     22|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x88);
  ------------------
  |  |  292|     22|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  154|     22|	apdu.resp    = rbuf;
  155|     22|	apdu.resplen = sizeof(rbuf);
  156|     22|	apdu.lc = 0;
  157|     22|	apdu.le = 256;
  158|     22|	r = sc_transmit_apdu(card, &apdu);
  159|     22|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     22|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     22|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     22|	int _ret = (r); \
  |  |  |  |  168|     22|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|       |
  161|     20|	if ((len = apdu.resplen) == 0)
  ------------------
  |  Branch (161:6): [True: 3, False: 17]
  ------------------
  162|       |		/* looks like no package has been installed  */
  163|      3|		return 0;
  164|       |
  165|     51|	while (len != 0) {
  ------------------
  |  Branch (165:9): [True: 45, False: 6]
  ------------------
  166|     45|		pp = sc_asn1_find_tag(card->ctx, p, len, 0xe1, &tlen);
  167|     45|		if (pp == NULL)
  ------------------
  |  Branch (167:7): [True: 7, False: 38]
  ------------------
  168|      7|			return 0;
  169|     38|		q = sc_asn1_find_tag(card->ctx, pp, tlen, 0x01, &ilen);
  170|     38|		if (q == NULL || ilen != 4)
  ------------------
  |  Branch (170:7): [True: 1, False: 37]
  |  Branch (170:20): [True: 2, False: 35]
  ------------------
  171|      3|			return 0;
  172|     35|		if (q[0] == 0x1c)
  ------------------
  |  Branch (172:7): [True: 1, False: 34]
  ------------------
  173|      1|			return 1;
  174|     34|		p   += tlen;
  175|     34|		len -= tlen + 2;
  176|     34|	}
  177|       |
  178|      6|	return 0;
  179|     17|}
card-cardos.c:cardos_add_algs:
  185|     31|{
  186|       |
  187|     31|	cardos_data_t * priv = (cardos_data_t *)card->drv_data;
  188|       |
  189|     31|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     31|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     31|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     31|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 31]
  |  |  ------------------
  ------------------
  190|       |
  191|     31|	_sc_card_add_rsa_alg(card,  512, flags, 0);
  192|     31|	_sc_card_add_rsa_alg(card,  768, flags, 0);
  193|     31|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  194|     31|	if (priv->rsa_2048 == 1) {
  ------------------
  |  Branch (194:6): [True: 11, False: 20]
  ------------------
  195|     11|		_sc_card_add_rsa_alg(card, 1280, flags, 0);
  196|     11|		_sc_card_add_rsa_alg(card, 1536, flags, 0);
  197|     11|		_sc_card_add_rsa_alg(card, 1792, flags, 0);
  198|     11|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  199|     11|	}
  200|       |
  201|     31|	if (card->type == SC_CARD_TYPE_CARDOS_V5_0 || card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (201:6): [True: 3, False: 28]
  |  Branch (201:48): [True: 7, False: 21]
  ------------------
  202|       |		/* Starting with CardOS 5, the card supports PIN query commands */
  203|     10|		card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|     10|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  204|     10|		_sc_card_add_rsa_alg(card, 3072, flags, 0);
  205|     10|		_sc_card_add_rsa_alg(card, 4096, flags, 0);
  206|     10|	}
  207|       |
  208|       |	/* TODO need to get sizes from supported_algos too */
  209|     31|	if (ec_flags != 0) {
  ------------------
  |  Branch (209:6): [True: 0, False: 31]
  ------------------
  210|      0|		 _sc_card_add_ec_alg(card, 256, ec_flags, priv->ext_flags, NULL);
  211|      0|		 _sc_card_add_ec_alg(card, 384, ec_flags, priv->ext_flags, NULL);
  212|      0|	}
  213|       |
  214|     31|	return 0;
  215|     31|}
card-cardos.c:cardos_finish:
  381|    561|{
  382|    561|	int r = 0;
  383|       |
  384|    561|	if (card == NULL )
  ------------------
  |  Branch (384:6): [True: 0, False: 561]
  ------------------
  385|      0|		return 0;
  386|       |
  387|    561|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    561|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    561|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    561|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 561]
  |  |  ------------------
  ------------------
  388|       |
  389|       |	/* free priv data */
  390|    561|	if (card->drv_data) { /* priv */
  ------------------
  |  Branch (390:6): [True: 561, False: 0]
  ------------------
  391|    561|		free(card->drv_data);
  392|    561|		card->drv_data = NULL;
  393|    561|	}
  394|       |
  395|    561|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    561|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    561|	int _ret = r; \
  |  |  155|    561|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 561, False: 0]
  |  |  ------------------
  |  |  156|    561|		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: 561]
  |  |  ------------------
  |  |  157|    561|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    561|	} 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|    561|	return _ret; \
  |  |  163|    561|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  396|    561|}
card-cardos.c:cardos_select_file:
  638|  3.76k|{
  639|  3.76k|	int r;
  640|       |
  641|  3.76k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.76k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.76k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.76k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.76k]
  |  |  ------------------
  ------------------
  642|  3.76k|	r = iso_ops->select_file(card, in_path, file);
  643|  3.76k|	if (r >= 0 && file)
  ------------------
  |  Branch (643:6): [True: 938, False: 2.82k]
  |  Branch (643:16): [True: 583, False: 355]
  ------------------
  644|    583|		parse_sec_attr((*file), (*file)->sec_attr, (*file)->sec_attr_len);
  645|  3.76k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  3.76k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.76k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.76k|	int _ret = r; \
  |  |  |  |  155|  3.76k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.76k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.76k|		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|  2.82k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.82k, False: 938]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.76k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.76k|	} 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|  3.76k|	return _ret; \
  |  |  |  |  163|  3.76k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  646|  3.76k|}
card-cardos.c:parse_sec_attr:
  623|    583|{
  624|    583|	size_t i;
  625|    583|	const int *idx;
  626|       |
  627|    583|	idx = (file->type == SC_FILE_TYPE_DF) ?  df_acl : ef_acl;
  ------------------
  |  |  214|    583|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (627:8): [True: 18, False: 565]
  ------------------
  628|       |
  629|       |	/* acl defaults to 0xFF if unspecified */
  630|  5.83k|	for (i = 0; i < 9; i++)
  ------------------
  |  Branch (630:14): [True: 5.24k, False: 583]
  ------------------
  631|  5.24k|		if (idx[i] != -1)
  ------------------
  |  Branch (631:7): [True: 4.06k, False: 1.18k]
  ------------------
  632|  4.06k|			add_acl_entry(file, idx[i], (u8)((i < len) ? buf[i] : 0xFF));
  ------------------
  |  Branch (632:37): [True: 235, False: 3.82k]
  ------------------
  633|    583|}
card-cardos.c:add_acl_entry:
  550|  4.06k|{
  551|  4.06k|	unsigned int method, key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  4.06k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  552|       |
  553|  4.06k|	switch (byte) {
  554|     63|	case 0x00:
  ------------------
  |  Branch (554:2): [True: 63, False: 4.00k]
  ------------------
  555|     63|		method = SC_AC_NONE;
  ------------------
  |  |  150|     63|#define SC_AC_NONE			0x00000000
  ------------------
  556|     63|		break;
  557|  3.83k|	case 0xFF:
  ------------------
  |  Branch (557:2): [True: 3.83k, False: 227]
  ------------------
  558|  3.83k|		method = SC_AC_NEVER;
  ------------------
  |  |  163|  3.83k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  559|  3.83k|		break;
  560|    164|	default:
  ------------------
  |  Branch (560:2): [True: 164, False: 3.89k]
  ------------------
  561|    164|		if (byte > 0x7F) {
  ------------------
  |  Branch (561:7): [True: 70, False: 94]
  ------------------
  562|     70|			method = SC_AC_UNKNOWN;
  ------------------
  |  |  162|     70|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  563|     94|		} else {
  564|     94|			method = SC_AC_CHV;
  ------------------
  |  |  151|     94|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  565|     94|			key_ref = byte;
  566|     94|		}
  567|    164|		break;
  568|  4.06k|	}
  569|  4.06k|	sc_file_add_acl_entry(file, op, method, key_ref);
  570|  4.06k|}
card-cardos.c:cardos_check_sw:
  462|  7.86k|{
  463|  7.86k|	const int err_count = sizeof(cardos_errors)/sizeof(cardos_errors[0]);
  464|  7.86k|	int i;
  465|       |
  466|   192k|	for (i = 0; i < err_count; i++) {
  ------------------
  |  Branch (466:14): [True: 192k, False: 349]
  ------------------
  467|   192k|		if (cardos_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (467:7): [True: 7.51k, False: 184k]
  ------------------
  468|  7.51k|			if ( cardos_errors[i].errorstr )
  ------------------
  |  Branch (468:9): [True: 3.32k, False: 4.18k]
  ------------------
  469|  3.32k|				sc_log(card->ctx,  "%s\n",
  ------------------
  |  |   71|  3.32k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  470|  7.51k|				 	cardos_errors[i].errorstr);
  471|  7.51k|			return cardos_errors[i].errorno;
  472|  7.51k|		}
  473|   192k|	}
  474|       |
  475|    349|        sc_log(card->ctx,  "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
  ------------------
  |  |   71|    349|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  476|    349|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|    349|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  477|  7.86k|}
card-cardos.c:cardos_card_ctl:
 1475|    178|{
 1476|    178|	switch (cmd) {
  ------------------
  |  Branch (1476:10): [True: 102, False: 76]
  ------------------
 1477|      0|	case SC_CARDCTL_CARDOS_PUT_DATA_FCI:
  ------------------
  |  Branch (1477:2): [True: 0, False: 178]
  ------------------
 1478|      0|		break;
 1479|      0|	case SC_CARDCTL_CARDOS_PUT_DATA_OCI:
  ------------------
  |  Branch (1479:2): [True: 0, False: 178]
  ------------------
 1480|      0|		return cardos_put_data_oci(card,
 1481|      0|			(struct sc_cardctl_cardos_obj_info *) ptr);
 1482|      0|		break;
 1483|      0|	case SC_CARDCTL_CARDOS_PUT_DATA_SECI:
  ------------------
  |  Branch (1483:2): [True: 0, False: 178]
  ------------------
 1484|      0|		return cardos_put_data_seci(card,
 1485|      0|			(struct sc_cardctl_cardos_obj_info *) ptr);
 1486|      0|		break;
 1487|      0|	case SC_CARDCTL_CARDOS_GENERATE_KEY:
  ------------------
  |  Branch (1487:2): [True: 0, False: 178]
  ------------------
 1488|      0|		return cardos_generate_key(card,
 1489|      0|			(struct sc_cardctl_cardos_genkey_info *) ptr);
 1490|     20|	case  SC_CARDCTL_CARDOS_PASS_ALGO_FLAGS:
  ------------------
  |  Branch (1490:2): [True: 20, False: 158]
  ------------------
 1491|     20|		return cardos_pass_algo_flags(card,
 1492|     20|			(struct sc_cardctl_cardos_pass_algo_flags *) ptr);
 1493|      0|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1493:2): [True: 0, False: 178]
  ------------------
 1494|      0|		return cardos_lifecycle_get(card, (int *) ptr);
 1495|     16|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (1495:2): [True: 16, False: 162]
  ------------------
 1496|     16|		return cardos_lifecycle_set(card, (int *) ptr);
 1497|     66|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1497:2): [True: 66, False: 112]
  ------------------
 1498|     66|		return cardos_get_serialnr(card, (sc_serial_number_t *)ptr);
 1499|    178|	}
 1500|     76|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     76|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1501|    178|}
card-cardos.c:cardos_pass_algo_flags:
  357|     20|{
  358|     20|	cardos_data_t * priv = (cardos_data_t *)card->drv_data;
  359|     20|	int r = 0;
  360|       |
  361|     20|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     20|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     20|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     20|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 20]
  |  |  ------------------
  ------------------
  362|     20|	switch (ptr->pass) {
  363|     10|		case 1:
  ------------------
  |  Branch (363:3): [True: 10, False: 10]
  ------------------
  364|     10|			ptr->card_flags = card->flags;
  365|     10|			ptr->used_flags = priv->flags;
  366|     10|			ptr->ec_flags = priv->ec_flags;
  367|     10|			ptr->ext_flags = priv->ext_flags;
  368|     10|			break;
  369|     10|		case 2:
  ------------------
  |  Branch (369:3): [True: 10, False: 10]
  ------------------
  370|     10|			r = cardos_add_algs(card,ptr->new_flags, ptr->ec_flags, ptr->ext_flags);
  371|     10|			break;
  372|      0|		default:
  ------------------
  |  Branch (372:3): [True: 0, False: 20]
  ------------------
  373|      0|			sc_log(card->ctx, "ptr->pass: %ul invalid", ptr->pass);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  374|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  375|     20|	}
  376|     20|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     20|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     20|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     20|	int _ret = r; \
  |  |  |  |  155|     20|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     20|		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: 20]
  |  |  |  |  ------------------
  |  |  |  |  157|     20|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     20|	} 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|     20|	return _ret; \
  |  |  |  |  163|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  377|     20|}
card-cardos.c:cardos_lifecycle_get:
 1275|     16|{
 1276|     16|	sc_apdu_t	apdu;
 1277|     16|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1278|     16|	int		r;
 1279|       |
 1280|     16|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     16|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     16|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     16|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 16]
  |  |  ------------------
  ------------------
 1281|       |
 1282|     16|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x83);
  ------------------
  |  |  292|     16|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1283|     16|	apdu.cla = 0x00;
 1284|     16|	apdu.le = 256;
 1285|     16|	apdu.resplen = sizeof(rbuf);
 1286|     16|	apdu.resp = rbuf;
 1287|       |
 1288|     16|	r = sc_transmit_apdu(card, &apdu);
 1289|     16|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     16|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     16|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     16|	int _ret = (r); \
  |  |  |  |  168|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1290|       |
 1291|     14|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1292|     14|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  169|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      7|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      7|		return _ret; \
  |  |  |  |  172|      7|	} \
  |  |  |  |  173|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1293|       |
 1294|      7|	if (apdu.resplen < 1) {
  ------------------
  |  Branch (1294:6): [True: 1, False: 6]
  ------------------
 1295|      1|		LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Lifecycle byte not in response");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1296|      1|	}
 1297|       |
 1298|      6|	r = SC_SUCCESS;
  ------------------
  |  |   28|      6|#define SC_SUCCESS				0
  ------------------
 1299|      6|	switch (rbuf[0]) {
 1300|      3|	case 0x10:
  ------------------
  |  Branch (1300:2): [True: 3, False: 3]
  ------------------
 1301|      3|		*mode = SC_CARDCTRL_LIFECYCLE_USER;
 1302|      3|		break;
 1303|      1|	case 0x20:
  ------------------
  |  Branch (1303:2): [True: 1, False: 5]
  ------------------
 1304|      1|		*mode = SC_CARDCTRL_LIFECYCLE_ADMIN;
 1305|      1|		break;
 1306|      1|	case 0x34: /* MANUFACTURING */
  ------------------
  |  Branch (1306:2): [True: 1, False: 5]
  ------------------
 1307|      1|		*mode = SC_CARDCTRL_LIFECYCLE_OTHER;
 1308|      1|		break;
 1309|      1|	default:
  ------------------
  |  Branch (1309:2): [True: 1, False: 5]
  ------------------
 1310|      1|		sc_log(card->ctx,  "Unknown lifecycle byte %d", rbuf[0]);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1311|      1|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      1|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1312|      6|	}
 1313|       |
 1314|      6|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1315|      6|}
card-cardos.c:cardos_lifecycle_set:
 1319|     16|{
 1320|     16|	sc_apdu_t	apdu;
 1321|     16|	int		r;
 1322|       |
 1323|     16|	int current;
 1324|     16|	int target;
 1325|       |
 1326|     16|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     16|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     16|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     16|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 16]
  |  |  ------------------
  ------------------
 1327|       |
 1328|     16|	target = *mode;
 1329|       |
 1330|     16|	r = cardos_lifecycle_get(card, &current);
 1331|       |
 1332|     16|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     16|#define SC_SUCCESS				0
  ------------------
  |  Branch (1332:6): [True: 11, False: 5]
  ------------------
 1333|     11|		return r;
 1334|       |
 1335|      5|	if (current == target || current == SC_CARDCTRL_LIFECYCLE_OTHER)
  ------------------
  |  Branch (1335:6): [True: 1, False: 4]
  |  Branch (1335:27): [True: 1, False: 3]
  ------------------
 1336|      2|		return SC_SUCCESS;
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
 1337|       |
 1338|      3|	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x10, 0, 0);
  ------------------
  |  |  291|      3|#define SC_APDU_CASE_1			0x01
  ------------------
 1339|      3|	apdu.cla = 0x80;
 1340|      3|	apdu.le = 0;
 1341|      3|	apdu.resplen = 0;
 1342|      3|	apdu.resp = NULL;
 1343|       |
 1344|      3|	r = sc_transmit_apdu(card, &apdu);
 1345|      3|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1346|       |
 1347|      2|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1348|      2|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1349|       |
 1350|      1|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1351|      1|}
card-cardos.c:cardos_get_serialnr:
 1442|     66|{
 1443|     66|	int r;
 1444|     66|	sc_apdu_t apdu;
 1445|     66|	u8  rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1446|       |
 1447|     66|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x81);
  ------------------
  |  |  292|     66|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1448|     66|	apdu.resp = rbuf;
 1449|     66|	apdu.resplen = sizeof(rbuf);
 1450|     66|	apdu.le   = 256;
 1451|     66|	r = sc_transmit_apdu(card, &apdu);
 1452|     66|	LOG_TEST_RET(card->ctx, r,  "APDU transmit failed");
  ------------------
  |  |  174|     66|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     66|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     66|	int _ret = (r); \
  |  |  |  |  168|     66|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 54]
  |  |  |  |  ------------------
  |  |  |  |  169|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     12|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     12|		return _ret; \
  |  |  |  |  172|     12|	} \
  |  |  |  |  173|     66|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1453|     54|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1453:6): [True: 24, False: 30]
  |  Branch (1453:26): [True: 8, False: 22]
  ------------------
 1454|     32|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     32|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1455|     22|	if ((apdu.resplen == 8) && (card->type == SC_CARD_TYPE_CARDOS_V5_0 || card->type == SC_CARD_TYPE_CARDOS_V5_3)) {
  ------------------
  |  Branch (1455:6): [True: 5, False: 17]
  |  Branch (1455:30): [True: 1, False: 4]
  |  Branch (1455:72): [True: 3, False: 1]
  ------------------
 1456|       |		/* cache serial number */
 1457|      4|		memcpy(card->serialnr.value, rbuf, 8);
 1458|      4|		card->serialnr.len = 8;
 1459|     18|	} else if (apdu.resplen == 32) {
  ------------------
  |  Branch (1459:13): [True: 1, False: 17]
  ------------------
 1460|       |		/* cache serial number */
 1461|      1|		memcpy(card->serialnr.value, &rbuf[10], 6);
 1462|      1|		card->serialnr.len = 6;
 1463|     17|	} else {
 1464|     17|		sc_log(card->ctx,  "unexpected response to GET DATA serial"
  ------------------
  |  |   71|     17|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1465|     17|				" number\n");
 1466|     17|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     17|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1467|     17|	}
 1468|       |	/* copy and return serial number */
 1469|      5|	memcpy(serial, &card->serialnr, sizeof(*serial));
 1470|      5|	return SC_SUCCESS;
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
 1471|     22|}
card-cardos.c:cardos_pin_cmd:
 1510|     66|{
 1511|     66|	struct sc_context *ctx = card->ctx;
 1512|     66|	int rv;
 1513|       |
 1514|     66|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     66|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     66|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     66|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     66|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 66]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1515|       |
 1516|     66|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|     66|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1517|     66|	data->pin_reference |= 0x80;
 1518|       |
 1519|     66|	sc_log(ctx, "PIN_CMD(cmd:%i, ref:%i)", data->cmd, data->pin_reference);
  ------------------
  |  |   71|     66|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1520|     66|	sc_log(ctx, "PIN1(max:%zu, min:%zu)", data->pin1.max_length, data->pin1.min_length);
  ------------------
  |  |   71|     66|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1521|     66|	sc_log(ctx, "PIN2(max:%zu, min:%zu)", data->pin2.max_length, data->pin2.min_length);
  ------------------
  |  |   71|     66|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1522|       |
 1523|       |	/* FIXME: the following values depend on what pin length was
 1524|       |	 * used when creating the BS objects */
 1525|     66|	if (data->pin1.max_length == 0)
  ------------------
  |  Branch (1525:6): [True: 66, False: 0]
  ------------------
 1526|     66|		data->pin1.max_length = 8;
 1527|     66|	if (data->pin2.max_length == 0)
  ------------------
  |  Branch (1527:6): [True: 66, False: 0]
  ------------------
 1528|     66|		data->pin2.max_length = 8;
 1529|       |
 1530|     66|	rv = iso_ops->pin_cmd(card, data);
 1531|     66|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     66|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     66|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     66|	int _ret = r; \
  |  |  |  |  155|     66|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 66, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     66|		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|     64|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 64, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|     66|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     66|	} 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|     66|	return _ret; \
  |  |  |  |  163|     66|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1532|     66|}

sc_get_cedulauy_driver:
  292|  17.0k|{
  293|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  294|       |
  295|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (295:6): [True: 1, False: 17.0k]
  ------------------
  296|      1|		iso_ops = iso_drv->ops;
  297|       |
  298|  17.0k|	cedulauy_ops = *iso_ops;
  299|  17.0k|	cedulauy_ops.match_card = cedulauy_match_card;
  300|  17.0k|	cedulauy_ops.init = cedulauy_init;
  301|  17.0k|	cedulauy_ops.select_file = cedulauy_select_file;
  302|  17.0k|	cedulauy_ops.set_security_env = cedulauy_set_security_env;
  303|  17.0k|	cedulauy_ops.compute_signature = cedulauy_compute_signature;
  304|  17.0k|	cedulauy_ops.decipher = NULL; /* the signing key is sign-only */
  305|  17.0k|	cedulauy_ops.get_challenge = cedulauy_get_challenge;
  306|  17.0k|	cedulauy_ops.logout = cedulauy_logout;
  307|  17.0k|	cedulauy_ops.card_reader_lock_obtained = cedulauy_card_reader_lock_obtained;
  308|       |
  309|  17.0k|	return &cedulauy_drv;
  310|  17.0k|}
card-cedulauy.c:cedulauy_match_card:
  112|  8.73k|{
  113|  8.73k|	int i = _sc_match_atr(card, cedulauy_atrs, &card->type);
  114|       |
  115|  8.73k|	if (i < 0)
  ------------------
  |  Branch (115:6): [True: 8.63k, False: 101]
  ------------------
  116|  8.63k|		return 0;
  117|    101|	card->name = cedulauy_atrs[i].name;
  118|    101|	return 1;
  119|  8.73k|}
card-cedulauy.c:cedulauy_init:
  123|    101|{
  124|    101|	unsigned long flags;
  125|    101|	int r;
  126|       |
  127|    101|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    101|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    101|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    101|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    101|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 101]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|       |
  129|    101|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    101|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  130|       |
  131|    101|	r = cedulauy_select_app(card);
  132|    101|	LOG_TEST_RET(card->ctx, r, "Cannot select the eID application");
  ------------------
  |  |  174|    101|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    101|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    101|	int _ret = (r); \
  |  |  |  |  168|    101|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 17, False: 84]
  |  |  |  |  ------------------
  |  |  |  |  169|     17|		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|     17|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     17|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     17|		return _ret; \
  |  |  |  |  172|     17|	} \
  |  |  |  |  173|    101|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 84]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|       |
  134|       |	/* The card builds the DigestInfo on-card only for SHA-256 (algorithm
  135|       |	 * reference 0x42).  Everything else is signed as raw PKCS#1 v1.5 over
  136|       |	 * a DigestInfo built in software (algorithm reference 0x02). */
  137|     84|	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  111|     84|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     84|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     84|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  133|     84|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  138|     84|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  138|     84|	r = _sc_card_add_rsa_alg(card, 2048, flags, 0);
  139|       |
  140|     84|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     84|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     84|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     84|	int _ret = r; \
  |  |  |  |  155|     84|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 84, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     84|		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: 84]
  |  |  |  |  ------------------
  |  |  |  |  157|     84|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     84|	} 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|     84|	return _ret; \
  |  |  |  |  163|     84|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|     84|}
card-cedulauy.c:cedulauy_select_app:
   97|    101|{
   98|    101|	struct sc_apdu apdu;
   99|    101|	unsigned char resp[SC_MAX_APDU_RESP_SIZE];
  100|       |
  101|    101|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    101|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    101|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    101|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    101|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 101]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  102|       |
  103|    101|	sc_format_apdu_ex(&apdu, card->cla, 0xA4, 0x04, 0x00,
  104|    101|			cedulauy_aid, sizeof cedulauy_aid, resp, sizeof resp);
  105|    101|	SC_TRANSMIT_TEST_RET(card, apdu, "Cannot select the eID application");
  ------------------
  |  |   90|    101|	do { \
  |  |   91|    101|		LOG_TEST_RET(card->ctx, sc_transmit_apdu(card, &apdu), "APDU transmit failed"); \
  |  |  ------------------
  |  |  |  |  174|    101|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|    101|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  |  |  167|    101|	int _ret = (r); \
  |  |  |  |  |  |  168|    101|	if (_ret < 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (168:6): [True: 5, False: 96]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  170|      5|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  |  |  171|      5|		return _ret; \
  |  |  |  |  |  |  172|      5|	} \
  |  |  |  |  |  |  173|    101|} while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [Folded, False: 96]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   92|    101|		LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), text); \
  |  |  ------------------
  |  |  |  |  174|     96|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|     96|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  |  |  167|     96|	int _ret = (r); \
  |  |  |  |  |  |  168|     96|	if (_ret < 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (168:6): [True: 12, False: 84]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  170|     12|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  |  |  171|     12|		return _ret; \
  |  |  |  |  |  |  172|     12|	} \
  |  |  |  |  |  |  173|     96|} while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [Folded, False: 84]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   93|     96|	} while (0)
  |  |  ------------------
  |  |  |  Branch (93:11): [Folded, False: 84]
  |  |  ------------------
  ------------------
  106|       |
  107|     84|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     84|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     84|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     84|	int _ret = r; \
  |  |  |  |  155|     84|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 84, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     84|		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: 84]
  |  |  |  |  ------------------
  |  |  |  |  157|     84|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     84|	} 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|     84|	return _ret; \
  |  |  |  |  163|     84|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  108|     84|}
card-cedulauy.c:cedulauy_select_file:
  170|    264|{
  171|    264|	struct sc_path path = *in_path;
  172|       |
  173|    264|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    264|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    264|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    264|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    264|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 264]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  174|       |
  175|    264|	if (path.aid.len == sizeof cedulauy_aid && 0 == memcmp(path.aid.value, cedulauy_aid, sizeof cedulauy_aid)) {
  ------------------
  |  Branch (175:6): [True: 180, False: 84]
  |  Branch (175:45): [True: 180, False: 0]
  ------------------
  176|       |		/* swallow cedula AID, it is always selected via init() */
  177|    180|		path.aid.len = 0;
  178|    180|	}
  179|    264|	if (path.type == SC_PATH_TYPE_PATH && path.len >= 2 && path.value[0] == 0x3F && path.value[1] == 0x00) {
  ------------------
  |  |  119|    528|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (179:6): [True: 84, False: 180]
  |  Branch (179:40): [True: 84, False: 0]
  |  Branch (179:57): [True: 84, False: 0]
  |  Branch (179:82): [True: 84, False: 0]
  ------------------
  180|       |		/* swallow MF, everything resides within the Application DF */
  181|     84|		memmove(path.value, path.value + 2, path.len - 2);
  182|     84|		path.len -= 2;
  183|     84|	}
  184|    264|	if (path.type == SC_PATH_TYPE_PATH && path.len == 0) {
  ------------------
  |  |  119|    528|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (184:6): [True: 84, False: 180]
  |  Branch (184:40): [True: 0, False: 84]
  ------------------
  185|       |		/* Selection of MF was requested */
  186|      0|		sc_file_dup(file_out, cedulauy_get_mf());
  187|      0|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|      0|	}
  189|       |
  190|    264|	LOG_FUNC_RETURN(card->ctx, iso_ops->select_file(card, &path, file_out));
  ------------------
  |  |  164|    264|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    264|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    264|	int _ret = r; \
  |  |  |  |  155|    264|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 264, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    264|		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|    232|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 232, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  157|    264|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    264|	} 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|    264|	return _ret; \
  |  |  |  |  163|    264|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  191|    264|}
card-cedulauy.c:cedulauy_set_security_env:
  196|     13|{
  197|     13|	struct sc_apdu apdu;
  198|       |	/* MSE SET, Digital Signature Template: key reference and algorithm */
  199|     13|	unsigned char mse_data[] = {0x84, 0x01, 0xFF, 0x80, 0x01, CEDULAUY_ALGO_RSA_PKCS1};
  ------------------
  |  |   61|     13|#define CEDULAUY_ALGO_RSA_PKCS1	       (CEDULAUY_ALGO_HASH_NONE | CEDULAUY_ALGO_PAD_PKCS1)
  |  |  ------------------
  |  |  |  |   57|     13|#define CEDULAUY_ALGO_HASH_NONE	  0x00 /* DigestInfo built in software */
  |  |  ------------------
  |  |               #define CEDULAUY_ALGO_RSA_PKCS1	       (CEDULAUY_ALGO_HASH_NONE | CEDULAUY_ALGO_PAD_PKCS1)
  |  |  ------------------
  |  |  |  |   59|     13|#define CEDULAUY_ALGO_PAD_PKCS1	  0x02 /* PKCS#1 v1.5 */
  |  |  ------------------
  ------------------
  200|       |
  201|     13|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     13|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     13|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     13|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     13|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  202|       |
  203|     13|	if (env == NULL)
  ------------------
  |  Branch (203:6): [True: 0, False: 13]
  ------------------
  204|     13|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  205|     13|	if (env->operation != SC_SEC_OPERATION_SIGN)
  ------------------
  |  |   48|     13|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (205:6): [True: 0, False: 13]
  ------------------
  206|     13|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|     13|	if ((env->flags & SC_SEC_ENV_ALG_PRESENT) && env->algorithm != SC_ALGORITHM_RSA)
  ------------------
  |  |   60|     13|#define SC_SEC_ENV_ALG_PRESENT		0x0010
  ------------------
              	if ((env->flags & SC_SEC_ENV_ALG_PRESENT) && env->algorithm != SC_ALGORITHM_RSA)
  ------------------
  |  |   69|     13|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (207:6): [True: 13, False: 0]
  |  Branch (207:47): [True: 0, False: 13]
  ------------------
  208|     13|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  209|     13|	if (env->key_ref_len != 1)
  ------------------
  |  Branch (209:6): [True: 0, False: 13]
  ------------------
  210|     13|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  211|       |
  212|     13|	mse_data[2] = env->key_ref[0];
  213|     13|	if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA256)
  ------------------
  |  |  138|     13|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  |  Branch (213:6): [True: 4, False: 9]
  ------------------
  214|      4|		mse_data[5] = CEDULAUY_ALGO_RSA_PKCS1_SHA256;
  ------------------
  |  |   62|      4|#define CEDULAUY_ALGO_RSA_PKCS1_SHA256 (CEDULAUY_ALGO_HASH_SHA256 | CEDULAUY_ALGO_PAD_PKCS1)
  |  |  ------------------
  |  |  |  |   58|      4|#define CEDULAUY_ALGO_HASH_SHA256 0x40 /* card builds the DigestInfo */
  |  |  ------------------
  |  |               #define CEDULAUY_ALGO_RSA_PKCS1_SHA256 (CEDULAUY_ALGO_HASH_SHA256 | CEDULAUY_ALGO_PAD_PKCS1)
  |  |  ------------------
  |  |  |  |   59|      4|#define CEDULAUY_ALGO_PAD_PKCS1	  0x02 /* PKCS#1 v1.5 */
  |  |  ------------------
  ------------------
  215|       |
  216|     13|	sc_format_apdu_ex(&apdu, card->cla, 0x22, 0x41, 0xB6,
  217|     13|			mse_data, sizeof mse_data, NULL, 0);
  218|     13|	SC_TRANSMIT_TEST_RET(card, apdu, "MSE SET DST failed");
  ------------------
  |  |   90|     13|	do { \
  |  |   91|     13|		LOG_TEST_RET(card->ctx, sc_transmit_apdu(card, &apdu), "APDU transmit failed"); \
  |  |  ------------------
  |  |  |  |  174|     13|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|     13|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  |  |  167|     13|	int _ret = (r); \
  |  |  |  |  |  |  168|     13|	if (_ret < 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (168:6): [True: 1, False: 12]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  |  |  172|      1|	} \
  |  |  |  |  |  |  173|     13|} while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [Folded, False: 12]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   92|     13|		LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), text); \
  |  |  ------------------
  |  |  |  |  174|     12|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|     12|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  |  |  167|     12|	int _ret = (r); \
  |  |  |  |  |  |  168|     12|	if (_ret < 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (168:6): [True: 4, False: 8]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  170|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  |  |  171|      4|		return _ret; \
  |  |  |  |  |  |  172|      4|	} \
  |  |  |  |  |  |  173|     12|} while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   93|     12|	} while (0)
  |  |  ------------------
  |  |  |  Branch (93:11): [Folded, False: 8]
  |  |  ------------------
  ------------------
  219|       |
  220|      8|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      8|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      8|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      8|	int _ret = r; \
  |  |  |  |  155|      8|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      8|		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: 8]
  |  |  |  |  ------------------
  |  |  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      8|	} 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|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  221|      8|}
card-cedulauy.c:cedulauy_compute_signature:
  226|      8|{
  227|      8|	struct sc_apdu apdu;
  228|      8|	unsigned char sbuf[64];
  229|      8|	unsigned char rbuf[256]; /* RSA 2048 */
  230|      8|	size_t offs = 0;
  231|       |
  232|      8|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      8|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      8|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      8|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      8|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|       |
  234|      8|	if (data == NULL || out == NULL)
  ------------------
  |  Branch (234:6): [True: 0, False: 8]
  |  Branch (234:22): [True: 0, False: 8]
  ------------------
  235|      8|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|       |
  237|       |	/* What is loaded here matches the algorithm set in set_security_env:
  238|       |	 * for 0x42 'data' is the bare SHA-256 digest and the card builds the
  239|       |	 * DigestInfo; for 0x02 'data' is a complete DigestInfo built in
  240|       |	 * software, which the card pads (PKCS#1 v1.5) as-is. */
  241|      8|	if (datalen == 0 || datalen > sizeof(sbuf) - 2)
  ------------------
  |  Branch (241:6): [True: 0, False: 8]
  |  Branch (241:22): [True: 0, False: 8]
  ------------------
  242|      8|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|      8|				"Unsupported hash/DigestInfo length");
  244|       |
  245|       |	/* PSO HASH: load the digest */
  246|      8|	sbuf[offs++] = 0x90;
  247|      8|	sbuf[offs++] = (unsigned char)datalen;
  248|      8|	memcpy(sbuf + offs, data, datalen);
  249|      8|	offs += datalen;
  250|      8|	sc_format_apdu_ex(&apdu, card->cla, 0x2A, 0x90, 0xA0, sbuf, offs, NULL, 0);
  251|      8|	SC_TRANSMIT_TEST_RET(card, apdu, "PSO HASH failed");
  ------------------
  |  |   90|      8|	do { \
  |  |   91|      8|		LOG_TEST_RET(card->ctx, sc_transmit_apdu(card, &apdu), "APDU transmit failed"); \
  |  |  ------------------
  |  |  |  |  174|      8|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|      8|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  |  |  167|      8|	int _ret = (r); \
  |  |  |  |  |  |  168|      8|	if (_ret < 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (168:6): [True: 1, False: 7]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  |  |  172|      1|	} \
  |  |  |  |  |  |  173|      8|} while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   92|      8|		LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), text); \
  |  |  ------------------
  |  |  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (168:6): [True: 2, False: 5]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  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|      7|} while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   93|      7|	} while (0)
  |  |  ------------------
  |  |  |  Branch (93:11): [Folded, False: 5]
  |  |  ------------------
  ------------------
  252|       |
  253|       |	/* PSO COMPUTE DIGITAL SIGNATURE */
  254|      5|	sc_format_apdu_ex(&apdu, card->cla, 0x2A, 0x9E, 0x9A, NULL, 0, rbuf, sizeof rbuf);
  255|      5|	SC_TRANSMIT_TEST_RET(card, apdu, "PSO COMPUTE DIGITAL SIGNATURE failed");
  ------------------
  |  |   90|      5|	do { \
  |  |   91|      5|		LOG_TEST_RET(card->ctx, sc_transmit_apdu(card, &apdu), "APDU transmit failed"); \
  |  |  ------------------
  |  |  |  |  174|      5|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|      5|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  |  |  167|      5|	int _ret = (r); \
  |  |  |  |  |  |  168|      5|	if (_ret < 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (168:6): [True: 1, False: 4]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  |  |  172|      1|	} \
  |  |  |  |  |  |  173|      5|} while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   92|      5|		LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), text); \
  |  |  ------------------
  |  |  |  |  174|      4|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  |  |  ------------------
  |  |  |  |  |  |  166|      4|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  |  |  167|      4|	int _ret = (r); \
  |  |  |  |  |  |  168|      4|	if (_ret < 0) { \
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (168:6): [True: 2, False: 2]
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  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|      4|} while(0)
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   93|      4|	} while (0)
  |  |  ------------------
  |  |  |  Branch (93:11): [Folded, False: 2]
  |  |  ------------------
  ------------------
  256|       |
  257|      2|	if (apdu.resplen > outlen)
  ------------------
  |  Branch (257:6): [True: 0, False: 2]
  ------------------
  258|      2|		LOG_TEST_RET(card->ctx, SC_ERROR_BUFFER_TOO_SMALL,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  259|      2|				"Signature buffer too small");
  260|      2|	memcpy(out, apdu.resp, apdu.resplen);
  261|      2|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} else { \
  |  |  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      1|	} \
  |  |  |  |  162|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|      2|}
card-cedulauy.c:cedulauy_get_challenge:
  266|    258|{
  267|       |	/* As on other IAS/ECC cards, GET CHALLENGE only handles a length of 8 */
  268|    258|	unsigned char rbuf[8];
  269|    258|	int r;
  270|       |
  271|    258|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    258|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    258|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    258|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    258|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  272|       |
  273|    258|	r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
  274|    258|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE failed");
  ------------------
  |  |  174|    258|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    258|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    258|	int _ret = (r); \
  |  |  |  |  168|    258|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 52, False: 206]
  |  |  |  |  ------------------
  |  |  |  |  169|     52|		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|     52|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     52|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     52|		return _ret; \
  |  |  |  |  172|     52|	} \
  |  |  |  |  173|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 206]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  275|       |
  276|    206|	if (len < (size_t)r)
  ------------------
  |  Branch (276:6): [True: 1, False: 205]
  ------------------
  277|      1|		r = (int)len;
  278|    206|	memcpy(rnd, rbuf, (size_t)r);
  279|       |
  280|    206|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    206|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    206|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    206|	int _ret = r; \
  |  |  |  |  155|    206|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 205]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    205|	} else { \
  |  |  |  |  159|    205|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    205|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    205|	} \
  |  |  |  |  162|    206|	return _ret; \
  |  |  |  |  163|    206|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  281|    206|}
card-cedulauy.c:cedulauy_card_reader_lock_obtained:
  145|    478|{
  146|    478|	if (was_reset)
  ------------------
  |  Branch (146:6): [True: 0, False: 478]
  ------------------
  147|    478|		LOG_FUNC_RETURN(card->ctx, cedulauy_select_app(card));
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  148|    478|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    478|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    478|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    478|	int _ret = r; \
  |  |  |  |  155|    478|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 478, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    478|		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: 478]
  |  |  |  |  ------------------
  |  |  |  |  157|    478|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    478|	} 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|    478|	return _ret; \
  |  |  |  |  163|    478|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|    478|}

sc_get_chipdocit_driver:
  486|  17.0k|{
  487|  17.0k|	struct sc_card_driver *iso = sc_get_iso7816_driver();
  488|  17.0k|	chipdocit_ops = *iso->ops;
  489|  17.0k|	chipdocit_ops.match_card = chipdocit_match_card;
  490|  17.0k|	chipdocit_ops.init = chipdocit_init;
  491|  17.0k|	chipdocit_ops.finish = chipdocit_finish;
  492|  17.0k|	chipdocit_ops.pin_cmd = chipdocit_pin_cmd;
  493|  17.0k|	chipdocit_ops.set_security_env = chipdocit_set_security_env;
  494|  17.0k|	chipdocit_ops.compute_signature = chipdocit_compute_signature;
  495|  17.0k|	return &chipdocit_drv;
  496|  17.0k|}
card-chipdocit.c:chipdocit_match_card:
  149|  3.99k|{
  150|  3.99k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.99k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.99k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.99k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.99k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.99k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  151|  3.99k|	if (_sc_match_atr(card, chipdocit_atrs, &card->type) < 0)
  ------------------
  |  Branch (151:6): [True: 3.99k, False: 0]
  ------------------
  152|  3.99k|		LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  3.99k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.99k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.99k|	int _ret = r; \
  |  |  |  |  155|  3.99k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.99k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.99k|		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: 3.99k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.99k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.99k|	} 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|  3.99k|	return _ret; \
  |  |  |  |  163|  3.99k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  153|       |	/* The ATR is shared with other Italian CNS cards; confirm this is the NXP
  154|       |	 * ChipDoc so the others fall through to the generic CNS driver. First select
  155|       |	 * the IAS-ECC application: this activates the card (its applets are otherwise
  156|       |	 * unreachable on a card not yet opened by other software). That AID is not a
  157|       |	 * discriminator on its own -- it is also the ICAO eMRTD application AID and
  158|       |	 * is present on other IAS-ECC cards, answering 90 00 on unrelated documents.
  159|       |	 * Then confirm the ChipDoc by selecting its Bit4id SSCD application, which is
  160|       |	 * absent elsewhere (6A 82 on an eMRTD), so the match does not become too
  161|       |	 * broad. */
  162|      0|	if (iso7816_select_aid(card, CHIPDOCIT_IAS_AID, sizeof CHIPDOCIT_IAS_AID, NULL, NULL) != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (162:6): [True: 0, False: 0]
  ------------------
  163|      0|		LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|      0|	if (iso7816_select_aid(card, CHIPDOCIT_SSCD_AID, sizeof CHIPDOCIT_SSCD_AID, NULL, NULL) != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (164:6): [True: 0, False: 0]
  ------------------
  165|      0|		LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  166|      0|	LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|      0|}

coolkey_get_attribute_data:
  603|  1.27k|{
  604|       |	/* handle the V0 objects first */
  605|  1.27k|	if (object_record_type == COOLKEY_V0_OBJECT) {
  ------------------
  |  |  229|  1.27k|#define COOLKEY_V0_OBJECT 0
  ------------------
  |  Branch (605:6): [True: 252, False: 1.02k]
  ------------------
  606|    252|		return coolkey_v0_get_attribute_data(attr, buf_len, attr_out);
  607|    252|	}
  608|       |
  609|       |	/* don't crash if we encounter some new or corrupted coolkey device */
  610|  1.02k|	if (object_record_type != COOLKEY_V1_OBJECT) {
  ------------------
  |  |  230|  1.02k|#define COOLKEY_V1_OBJECT 1
  ------------------
  |  Branch (610:6): [True: 0, False: 1.02k]
  ------------------
  611|      0|		return SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|      0|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
  612|      0|	}
  613|       |
  614|  1.02k|	return coolkey_v1_get_attribute_data(attr, buf_len, attr_out);
  615|       |
  616|  1.02k|}
coolkey_compare_id:
  758|   127k|{
  759|   127k|	if (a == NULL || b == NULL)
  ------------------
  |  Branch (759:6): [True: 0, False: 127k]
  |  Branch (759:19): [True: 0, False: 127k]
  ------------------
  760|      0|		return 1;
  761|   127k|	return ((sc_cardctl_coolkey_object_t *)a)->id
  762|   127k|	    != ((sc_cardctl_coolkey_object_t *)b)->id;
  763|   127k|}
coolkey_list_meter:
  766|  5.67k|size_t coolkey_list_meter(const void *el) {
  767|  5.67k|	return sizeof(sc_cardctl_coolkey_object_t);
  768|  5.67k|}
coolkey_fill_object:
 1365|  26.4k|{
 1366|  26.4k|	int r;
 1367|  26.4k|	size_t buf_len = obj->length;
 1368|  26.4k|	u8 *new_obj_data = NULL;
 1369|  26.4k|	sc_cardctl_coolkey_object_t *obj_entry;
 1370|  26.4k|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|  26.4k|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1371|       |
 1372|  26.4k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  26.4k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  26.4k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  26.4k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  26.4k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 26.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1373|       |
 1374|  26.4k|	if (obj->data != NULL) {
  ------------------
  |  Branch (1374:6): [True: 0, False: 26.4k]
  ------------------
 1375|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1376|      0|	}
 1377|  26.4k|	new_obj_data = malloc(buf_len);
 1378|  26.4k|	if (new_obj_data == NULL) {
  ------------------
  |  Branch (1378:6): [True: 0, False: 26.4k]
  ------------------
 1379|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1380|      0|	}
 1381|  26.4k|	r = coolkey_read_object(card, obj->id, 0, new_obj_data, buf_len,
 1382|  26.4k|				priv->nonce, sizeof(priv->nonce));
 1383|  26.4k|	if (r != (int)buf_len) {
  ------------------
  |  Branch (1383:6): [True: 23.7k, False: 2.75k]
  ------------------
 1384|  23.7k|		free(new_obj_data);
 1385|  23.7k|		if (r < 0) {
  ------------------
  |  Branch (1385:7): [True: 23.7k, False: 0]
  ------------------
 1386|  23.7k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  23.7k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  23.7k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  23.7k|	int _ret = r; \
  |  |  |  |  155|  23.7k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 23.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  23.7k|		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|  23.7k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 23.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  23.7k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  23.7k|	} 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|  23.7k|	return _ret; \
  |  |  |  |  163|  23.7k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1387|  23.7k|		}
 1388|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_CORRUPTED_DATA);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1389|      0|	}
 1390|  2.75k|	obj_entry = coolkey_find_object_by_id(&priv->objects_list, obj->id);
 1391|  2.75k|	if (obj_entry == NULL) {
  ------------------
  |  Branch (1391:6): [True: 0, False: 2.75k]
  ------------------
 1392|      0|		free(new_obj_data);
 1393|      0|		return SC_ERROR_INTERNAL; /* shouldn't happen */
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1394|      0|	}
 1395|  2.75k|	if (obj_entry->data != NULL) {
  ------------------
  |  Branch (1395:6): [True: 0, False: 2.75k]
  ------------------
 1396|      0|		free(new_obj_data);
 1397|      0|		return SC_ERROR_INTERNAL; /* shouldn't happen */
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1398|      0|	}
 1399|       |	/* Make sure we will not go over the allocated limits in the other
 1400|       |	 * objects if they somehow got different lengths in matching objects */
 1401|  2.75k|	if (obj_entry->length != obj->length) {
  ------------------
  |  Branch (1401:6): [True: 0, False: 2.75k]
  ------------------
 1402|      0|		free(new_obj_data);
 1403|      0|		return SC_ERROR_INTERNAL; /* shouldn't happen */
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1404|      0|	}
 1405|  2.75k|	obj_entry->data = new_obj_data;
 1406|  2.75k|	obj->data = new_obj_data;
 1407|  2.75k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  2.75k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.75k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.75k|	int _ret = r; \
  |  |  |  |  155|  2.75k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.75k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.75k|		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: 2.75k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.75k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.75k|	} 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|  2.75k|	return _ret; \
  |  |  |  |  163|  2.75k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1408|  2.75k|}
coolkey_find_object_by_template:
 1497|  1.87k|{
 1498|  1.87k|	list_t *list;
 1499|  1.87k|	sc_cardctl_coolkey_object_t *current, *rv = NULL;
 1500|  1.87k|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|  1.87k|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1501|  1.87k|	int i, r;
 1502|  1.87k|	unsigned int tmp_pos = (unsigned int) -1;
 1503|       |
 1504|  1.87k|	list = &priv->objects_list;
 1505|  1.87k|	if (list->iter_active) {
  ------------------
  |  Branch (1505:6): [True: 1.87k, False: 0]
  ------------------
 1506|       |		/* workaround missing functionality of second iterator */
 1507|  1.87k|		tmp_pos = list->iter_pos;
 1508|  1.87k|		list_iterator_stop(list);
 1509|  1.87k|	}
 1510|       |
 1511|  1.87k|	list_iterator_start(list);
 1512|  31.3k|	while (list_iterator_hasnext(list)) {
  ------------------
  |  Branch (1512:9): [True: 30.1k, False: 1.24k]
  ------------------
 1513|  30.1k|		sc_cardctl_coolkey_attribute_t attribute;
 1514|  30.1k|		current = list_iterator_next(list);
 1515|  30.1k|		attribute.object = current;
 1516|       |
 1517|  32.9k|		for (i=0; i < count; i++) {
  ------------------
  |  Branch (1517:13): [True: 32.3k, False: 638]
  ------------------
 1518|  32.3k|			attribute.attribute_type = template[i].attribute_type;
 1519|  32.3k|			r = coolkey_find_attribute(card, &attribute);
 1520|  32.3k|			if (r < 0) {
  ------------------
  |  Branch (1520:8): [True: 16.8k, False: 15.4k]
  ------------------
 1521|  16.8k|				break;
 1522|  16.8k|			}
 1523|  15.4k|			if (template[i].attribute_data_type != attribute.attribute_data_type) {
  ------------------
  |  Branch (1523:8): [True: 280, False: 15.2k]
  ------------------
 1524|    280|				break;
 1525|    280|			}
 1526|  15.2k|			if (template[i].attribute_length != attribute.attribute_length) {
  ------------------
  |  Branch (1526:8): [True: 6, False: 15.2k]
  ------------------
 1527|      6|				break;
 1528|      6|			}
 1529|  15.2k|			if (memcmp(attribute.attribute_value, template[i].attribute_value,
  ------------------
  |  Branch (1529:8): [True: 12.4k, False: 2.79k]
  ------------------
 1530|  15.2k|							attribute.attribute_length) != 0) {
 1531|  12.4k|				break;
 1532|  12.4k|			}
 1533|  15.2k|		}
 1534|       |		/* just return the first one */
 1535|  30.1k|		if (i == count) {
  ------------------
  |  Branch (1535:7): [True: 638, False: 29.5k]
  ------------------
 1536|    638|			rv = current;
 1537|    638|			break;
 1538|    638|		}
 1539|  30.1k|	}
 1540|       |
 1541|  1.87k|	list_iterator_stop(list);
 1542|  1.87k|	if (tmp_pos != (unsigned int)-1) {
  ------------------
  |  Branch (1542:6): [True: 1.87k, False: 0]
  ------------------
 1543|       |		/* workaround missing functionality of second iterator */
 1544|  1.87k|		list_iterator_start(list);
 1545|  22.4k|		while (list_iterator_hasnext(list) && list->iter_pos < tmp_pos)
  ------------------
  |  Branch (1545:10): [True: 22.1k, False: 224]
  |  Branch (1545:41): [True: 20.5k, False: 1.65k]
  ------------------
 1546|  20.5k|			(void) list_iterator_next(list);
 1547|  1.87k|	}
 1548|  1.87k|	return rv;
 1549|  1.87k|}
sc_get_coolkey_driver:
 2469|  17.0k|{
 2470|  17.0k|	return sc_get_driver();
 2471|  17.0k|}
card-coolkey.c:coolkey_v0_get_attribute_data:
  518|    252|{
  519|       |	/* we need to manually detect types CK_ULONG */
  520|    252|	CK_ATTRIBUTE_TYPE attr_type = coolkey_get_attribute_type(attr, COOLKEY_V0_OBJECT, buf_len);
  ------------------
  |  |  229|    252|#define COOLKEY_V0_OBJECT 0
  ------------------
  521|    252|	int r;
  522|    252|	size_t len;
  523|       |
  524|    252|	attr_out->attribute_data_type = SC_CARDCTL_COOLKEY_ATTR_TYPE_STRING;
  ------------------
  |  | 1068|    252|#define SC_CARDCTL_COOLKEY_ATTR_TYPE_STRING 0
  ------------------
  525|    252|	attr_out->attribute_length = 0;
  526|    252|	attr_out->attribute_value = NULL;
  527|       |
  528|    252|	r = coolkey_v0_get_attribute_len(attr, buf_len, &len);
  529|    252|	if (r < 0) {
  ------------------
  |  Branch (529:6): [True: 0, False: 252]
  ------------------
  530|      0|		return r;
  531|      0|	}
  532|    252|	if (len + sizeof(coolkey_v0_attribute_header_t) > buf_len) {
  ------------------
  |  Branch (532:6): [True: 52, False: 200]
  ------------------
  533|     52|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|     52|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  534|     52|	}
  535|    200|	if ((attr_type == CKA_CLASS) || (attr_type == CKA_CERTIFICATE_TYPE)
  ------------------
  |  |  137|    200|#define CKA_CLASS 0x00000000UL
  ------------------
              	if ((attr_type == CKA_CLASS) || (attr_type == CKA_CERTIFICATE_TYPE)
  ------------------
  |  |  145|     28|#define CKA_CERTIFICATE_TYPE 0x00000080UL
  ------------------
  |  Branch (535:6): [True: 172, False: 28]
  |  Branch (535:34): [True: 0, False: 28]
  ------------------
  536|    175|									 || (attr_type == CKA_KEY_TYPE)) {
  ------------------
  |  |  159|     28|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  |  Branch (536:14): [True: 3, False: 25]
  ------------------
  537|    175|		if (len != 4) {
  ------------------
  |  Branch (537:7): [True: 124, False: 51]
  ------------------
  538|    124|			return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|    124|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  539|    124|		}
  540|     51|		attr_out->attribute_data_type = SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG;
  ------------------
  |  | 1069|     51|#define SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG 1
  ------------------
  541|     51|	}
  542|       |	/* return the length and the data */
  543|     76|	attr_out->attribute_length = len;
  544|     76|	attr_out->attribute_value = attr + sizeof(coolkey_v0_attribute_header_t);
  545|     76|	return SC_SUCCESS;
  ------------------
  |  |   28|     76|#define SC_SUCCESS				0
  ------------------
  546|    200|}
card-coolkey.c:coolkey_get_attribute_type:
  411|  12.4k|{
  412|  12.4k|	coolkey_attribute_header_t *attribute_header = (coolkey_attribute_header_t *) attr;
  413|       |
  414|  12.4k|	return bebytes2ulong(attribute_header->attribute_attr_type);
  415|  12.4k|}
card-coolkey.c:coolkey_v0_get_attribute_len:
  351|  7.00k|{
  352|  7.00k|	coolkey_v0_attribute_header_t *attribute_head = (coolkey_v0_attribute_header_t *)attr;
  353|       |	/* don't reference beyond our buffer */
  354|  7.00k|	if (buf_len < sizeof(coolkey_v0_attribute_header_t)) {
  ------------------
  |  Branch (354:6): [True: 331, False: 6.67k]
  ------------------
  355|    331|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|    331|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  356|    331|	}
  357|  6.67k|	*len = bebytes2ushort(attribute_head->attribute_data_len);
  358|  6.67k|	return SC_SUCCESS;
  ------------------
  |  |   28|  6.67k|#define SC_SUCCESS				0
  ------------------
  359|  7.00k|}
card-coolkey.c:coolkey_v1_get_attribute_data:
  553|  1.02k|{
  554|  1.02k|	int r;
  555|  1.02k|	size_t len;
  556|  1.02k|	coolkey_attribute_header_t *attribute_head = (coolkey_attribute_header_t *)attr;
  557|       |
  558|  1.02k|	if (buf_len < sizeof(coolkey_attribute_header_t)) {
  ------------------
  |  Branch (558:6): [True: 11, False: 1.01k]
  ------------------
  559|     11|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|     11|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  560|     11|	}
  561|       |
  562|       |	/* we must have type V1. Process according to data type */
  563|  1.01k|	switch (attribute_head->attribute_data_type) {
  564|       |	/* ULONG has implied length of 4 */
  565|    124|	case COOLKEY_ATTR_TYPE_INTEGER:
  ------------------
  |  |  248|    124|#define COOLKEY_ATTR_TYPE_INTEGER     1
  ------------------
  |  Branch (565:2): [True: 124, False: 888]
  ------------------
  566|    124|		if (buf_len < (sizeof(coolkey_attribute_header_t) + 4)) {
  ------------------
  |  Branch (566:7): [True: 35, False: 89]
  ------------------
  567|     35|			return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|     35|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  568|     35|		}
  569|     89|		attr_out->attribute_data_type = SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG;
  ------------------
  |  | 1069|     89|#define SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG 1
  ------------------
  570|     89|		attr_out->attribute_length = 4;
  571|     89|		attr_out->attribute_value = attr + sizeof(coolkey_attribute_header_t);
  572|     89|		return SC_SUCCESS;
  ------------------
  |  |   28|     89|#define SC_SUCCESS				0
  ------------------
  573|       |	/* BOOL_FALSE and BOOL_TRUE have implied length and data */
  574|       |	/* return type STRING for BOOLS */
  575|    117|	case COOLKEY_ATTR_TYPE_BOOL_FALSE:
  ------------------
  |  |  249|    117|#define COOLKEY_ATTR_TYPE_BOOL_FALSE  2
  ------------------
  |  Branch (575:2): [True: 117, False: 895]
  ------------------
  576|    117|		attr_out->attribute_length = 1;
  577|    117|		attr_out->attribute_value =  &coolkey_static_false;
  578|    117|		return SC_SUCCESS;
  ------------------
  |  |   28|    117|#define SC_SUCCESS				0
  ------------------
  579|     35|	case COOLKEY_ATTR_TYPE_BOOL_TRUE:
  ------------------
  |  |  250|     35|#define COOLKEY_ATTR_TYPE_BOOL_TRUE   3
  ------------------
  |  Branch (579:2): [True: 35, False: 977]
  ------------------
  580|     35|		attr_out->attribute_length = 1;
  581|     35|		attr_out->attribute_value =  &coolkey_static_true;
  582|     35|		return SC_SUCCESS;
  ------------------
  |  |   28|     35|#define SC_SUCCESS				0
  ------------------
  583|       |	/* string type has encoded length */
  584|    365|	case COOLKEY_ATTR_TYPE_STRING:
  ------------------
  |  |  247|    365|#define COOLKEY_ATTR_TYPE_STRING      0
  ------------------
  |  Branch (584:2): [True: 365, False: 647]
  ------------------
  585|    365|		r = coolkey_v1_get_attribute_len(attr, buf_len, &len, 0);
  586|    365|		if (r < SC_SUCCESS) {
  ------------------
  |  |   28|    365|#define SC_SUCCESS				0
  ------------------
  |  Branch (586:7): [True: 35, False: 330]
  ------------------
  587|     35|			return r;
  588|     35|		}
  589|    330|		if (buf_len < (len + sizeof(coolkey_attribute_header_t) + 2)) {
  ------------------
  |  Branch (589:7): [True: 70, False: 260]
  ------------------
  590|     70|			return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|     70|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  591|     70|		}
  592|    260|		attr_out->attribute_value = attr+sizeof(coolkey_attribute_header_t)+2;
  593|    260|		attr_out->attribute_length = len;
  594|    260|		return SC_SUCCESS;
  ------------------
  |  |   28|    260|#define SC_SUCCESS				0
  ------------------
  595|    371|	default:
  ------------------
  |  Branch (595:2): [True: 371, False: 641]
  ------------------
  596|    371|		break;
  597|  1.01k|	}
  598|    371|	return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|    371|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  599|  1.01k|}
card-coolkey.c:coolkey_v1_get_attribute_len:
  314|   121k|{
  315|   121k|	coolkey_attribute_header_t *attribute_head = (coolkey_attribute_header_t *)attr;
  316|       |
  317|   121k|	*len = 0;
  318|       |	/* don't reference beyond our buffer */
  319|   121k|	if (buf_len < sizeof(coolkey_attribute_header_t)) {
  ------------------
  |  Branch (319:6): [True: 112k, False: 9.22k]
  ------------------
  320|   112k|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|   112k|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  321|   112k|	}
  322|  9.22k|	switch (attribute_head->attribute_data_type) {
  323|  2.62k|	case COOLKEY_ATTR_TYPE_STRING:
  ------------------
  |  |  247|  2.62k|#define COOLKEY_ATTR_TYPE_STRING      0
  ------------------
  |  Branch (323:2): [True: 2.62k, False: 6.59k]
  ------------------
  324|  2.62k|		if (buf_len < (sizeof(coolkey_attribute_header_t) +2)) {
  ------------------
  |  Branch (324:7): [True: 138, False: 2.48k]
  ------------------
  325|    138|			break;
  326|    138|		}
  327|  2.48k|		*len = bebytes2ushort(attr + sizeof(coolkey_attribute_header_t));
  328|  2.48k|		if (encoded_len) {
  ------------------
  |  Branch (328:7): [True: 2.15k, False: 330]
  ------------------
  329|  2.15k|			*len += 2;
  330|  2.15k|		}
  331|  2.48k|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.48k|#define SC_SUCCESS				0
  ------------------
  332|    569|	case COOLKEY_ATTR_TYPE_BOOL_FALSE:
  ------------------
  |  |  249|    569|#define COOLKEY_ATTR_TYPE_BOOL_FALSE  2
  ------------------
  |  Branch (332:2): [True: 569, False: 8.65k]
  ------------------
  333|    983|	case COOLKEY_ATTR_TYPE_BOOL_TRUE:
  ------------------
  |  |  250|    983|#define COOLKEY_ATTR_TYPE_BOOL_TRUE   3
  ------------------
  |  Branch (333:2): [True: 414, False: 8.80k]
  ------------------
  334|       |		/* NOTE: there is no encoded data from TYPE_BOOL_XXX, so we return length 0, but the length
  335|       |		 * of the attribute is actually 1 byte, so if encoded_len == false, return 1 */
  336|    983|		*len = encoded_len ? 0: 1;
  ------------------
  |  Branch (336:10): [True: 983, False: 0]
  ------------------
  337|    983|		return SC_SUCCESS;
  ------------------
  |  |   28|    983|#define SC_SUCCESS				0
  ------------------
  338|      0|		break;
  339|  4.74k|	case COOLKEY_ATTR_TYPE_INTEGER:
  ------------------
  |  |  248|  4.74k|#define COOLKEY_ATTR_TYPE_INTEGER     1
  ------------------
  |  Branch (339:2): [True: 4.74k, False: 4.47k]
  ------------------
  340|  4.74k|		*len = 4; /* length is 4 in both encoded length and attribute length */
  341|  4.74k|		return SC_SUCCESS;
  ------------------
  |  |   28|  4.74k|#define SC_SUCCESS				0
  ------------------
  342|    870|	default:
  ------------------
  |  Branch (342:2): [True: 870, False: 8.35k]
  ------------------
  343|    870|		break;
  344|  9.22k|	}
  345|  1.00k|	return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|  1.00k|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  346|  9.22k|}
card-coolkey.c:coolkey_read_object:
 1097|  26.5k|{
 1098|  26.5k|	coolkey_read_object_param_t params;
 1099|  26.5k|	u8 *out_ptr;
 1100|  26.5k|	size_t left = 0;
 1101|  26.5k|	size_t len;
 1102|  26.5k|	int r;
 1103|       |
 1104|  26.5k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  26.5k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  26.5k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  26.5k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 26.5k]
  |  |  ------------------
  ------------------
 1105|       |
 1106|  26.5k|	ulong2bebytes(&params.object_id[0], object_id);
 1107|       |
 1108|  26.5k|	out_ptr = out_buf;
 1109|  26.5k|	left = out_len;
 1110|  28.7k|	do {
 1111|  28.7k|		ulong2bebytes(&params.offset[0], offset);
 1112|  28.7k|		params.length = MIN(left, COOLKEY_MAX_CHUNK_SIZE);
  ------------------
  |  |   69|  28.7k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 22.1k, False: 6.69k]
  |  |  ------------------
  ------------------
 1113|  28.7k|		len = left;
 1114|  28.7k|		r = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_READ_OBJECT, 0, 0,
  ------------------
  |  |   73|  28.7k|#define COOLKEY_CLASS           0xb0
  ------------------
              		r = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_READ_OBJECT, 0, 0,
  ------------------
  |  |   89|  28.7k|#define COOLKEY_INS_READ_OBJECT                0x56
  ------------------
 1115|  28.7k|			(u8 *)&params, sizeof(params), &out_ptr, &len, nonce, nonce_size);
 1116|  28.7k|		if (r < 0) {
  ------------------
  |  Branch (1116:7): [True: 23.3k, False: 5.42k]
  ------------------
 1117|  23.3k|			goto fail;
 1118|  23.3k|		}
 1119|       |		/* sanity check to make sure we don't overflow left */
 1120|  5.42k|		if ((left < len) || (len == 0)) {
  ------------------
  |  Branch (1120:7): [True: 118, False: 5.30k]
  |  Branch (1120:23): [True: 282, False: 5.02k]
  ------------------
 1121|    400|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    400|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1122|    400|			goto fail;
 1123|    400|		}
 1124|  5.02k|		out_ptr += len;
 1125|  5.02k|		offset += len;
 1126|  5.02k|		left -= len;
 1127|  5.02k|	} while (left != 0);
  ------------------
  |  Branch (1127:11): [True: 2.21k, False: 2.81k]
  ------------------
 1128|       |
 1129|  2.81k|	return (int)out_len;
 1130|       |
 1131|  23.7k|fail:
 1132|  23.7k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  23.7k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  23.7k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  23.7k|	int _ret = r; \
  |  |  |  |  155|  23.7k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 23.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  23.7k|		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|  23.7k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 23.7k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  23.7k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  23.7k|	} 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|  23.7k|	return _ret; \
  |  |  |  |  163|  23.7k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1133|  23.7k|}
card-coolkey.c:coolkey_apdu_io:
  913|  52.4k|{
  914|  52.4k|	int r;
  915|  52.4k|	sc_apdu_t apdu;
  916|  52.4k|	u8 rbufinitbuf[COOLKEY_MAX_SIZE];
  917|  52.4k|	u8 rsendbuf[COOLKEY_MAX_SIZE];
  918|  52.4k|	u8 *rbuf;
  919|  52.4k|	size_t rbuflen;
  920|  52.4k|	int cse = 0;
  921|       |
  922|       |
  923|  52.4k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  52.4k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  52.4k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  52.4k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 52.4k]
  |  |  ------------------
  ------------------
  924|       |
  925|  52.4k|	sc_log(card->ctx, "%02x %02x %02x %zu : %zu %zu",
  ------------------
  |  |   71|  52.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  926|  52.4k|			ins, p1, p2, sendbuflen, card->max_send_size, card->max_recv_size);
  927|       |
  928|  52.4k|	rbuf = rbufinitbuf;
  929|  52.4k|	rbuflen = sizeof(rbufinitbuf);
  930|       |
  931|       |	/* if caller provided a buffer and length */
  932|  52.4k|	if (recvbuf && *recvbuf && recvbuflen && *recvbuflen) {
  ------------------
  |  Branch (932:6): [True: 41.0k, False: 11.3k]
  |  Branch (932:17): [True: 41.0k, False: 0]
  |  Branch (932:29): [True: 41.0k, False: 0]
  |  Branch (932:43): [True: 40.2k, False: 836]
  ------------------
  933|  40.2k|		rbuf = *recvbuf;
  934|  40.2k|		rbuflen = *recvbuflen;
  935|  40.2k|	}
  936|       |
  937|  52.4k|	if (sendbuf || nonce) {
  ------------------
  |  Branch (937:6): [True: 40.1k, False: 12.2k]
  |  Branch (937:17): [True: 0, False: 12.2k]
  ------------------
  938|  40.1k|		if (recvbuf) {
  ------------------
  |  Branch (938:7): [True: 28.7k, False: 11.3k]
  ------------------
  939|  28.7k|			cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|  28.7k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  940|  28.7k|		} else {
  941|  11.3k|			cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  11.3k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  942|  11.3k|		}
  943|  40.1k|	} else {
  944|  12.2k|		if (recvbuf) {
  ------------------
  |  Branch (944:7): [True: 12.2k, False: 0]
  ------------------
  945|  12.2k|			cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|  12.2k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  946|  12.2k|		} else {
  947|      0|			cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  948|      0|		}
  949|  12.2k|	}
  950|       |
  951|       |	/* append the nonce if we have it. Coolkey just blindly puts this at the end
  952|       |	 * of the APDU (while adjusting lc). This converts case 1 to case 3. coolkey
  953|       |	 * also always drops le in case 4 (which happens when proto = T0). nonces are
  954|       |	 * never used on case 2 commands, so we can simply append the nonce to the data
  955|       |	 * and we should be fine */
  956|  52.4k|	if (nonce) {
  ------------------
  |  Branch (956:6): [True: 28.7k, False: 23.6k]
  ------------------
  957|  28.7k|		u8 *buf = rsendbuf;
  958|  28.7k|		if (sendbuf) {
  ------------------
  |  Branch (958:7): [True: 28.7k, False: 0]
  ------------------
  959|  28.7k|			sendbuflen = MIN(sendbuflen,sizeof(rsendbuf)-nonce_len);
  ------------------
  |  |   69|  28.7k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 28.7k, False: 0]
  |  |  ------------------
  ------------------
  960|  28.7k|			memcpy(rsendbuf, sendbuf, sendbuflen);
  961|  28.7k|			buf += sendbuflen;
  962|  28.7k|		}
  963|  28.7k|		memcpy(buf, nonce, nonce_len);
  964|  28.7k|		sendbuflen += nonce_len;
  965|  28.7k|		sendbuf =rsendbuf;
  966|  28.7k|	}
  967|       |
  968|  52.4k|	sc_format_apdu(card, &apdu, cse, ins, p1, p2);
  969|       |
  970|  52.4k|	apdu.lc = sendbuflen;
  971|  52.4k|	apdu.datalen = sendbuflen;
  972|  52.4k|	apdu.data = sendbuf;
  973|       |
  974|       |
  975|       |	/* coolkey uses non-standard classes */
  976|  52.4k|	apdu.cla = cla;
  977|       |
  978|  52.4k|	if (recvbuf) {
  ------------------
  |  Branch (978:6): [True: 41.0k, False: 11.3k]
  ------------------
  979|  41.0k|		apdu.resp = rbuf;
  980|  41.0k|		apdu.le = (rbuflen > 255) ? 255 : rbuflen;
  ------------------
  |  Branch (980:13): [True: 5.94k, False: 35.1k]
  ------------------
  981|  41.0k|		apdu.resplen = rbuflen;
  982|  41.0k|	} else {
  983|  11.3k|		 apdu.resp =  rbuf;
  984|  11.3k|		 apdu.le = 0;
  985|  11.3k|		 apdu.resplen = 0;
  986|  11.3k|	}
  987|       |
  988|  52.4k|	sc_log(card->ctx, "calling sc_transmit_apdu flags=%lx le=%zu, resplen=%zu, resp=%p",
  ------------------
  |  |   71|  52.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  989|  52.4k|			apdu.flags, apdu.le, apdu.resplen, apdu.resp);
  990|       |
  991|       |	/* with new adpu.c and chaining, this actually reads the whole object */
  992|  52.4k|	r = sc_transmit_apdu(card, &apdu);
  993|       |
  994|  52.4k|	sc_log(card->ctx, "result r=%d apdu.resplen=%zu sw1=%02x sw2=%02x",
  ------------------
  |  |   71|  52.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  995|  52.4k|			r, apdu.resplen, apdu.sw1, apdu.sw2);
  996|       |
  997|  52.4k|	if (r < 0) {
  ------------------
  |  Branch (997:6): [True: 935, False: 51.4k]
  ------------------
  998|    935|		sc_log(card->ctx, "Transmit failed");
  ------------------
  |  |   71|    935|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  999|    935|		goto err;
 1000|    935|	}
 1001|  51.4k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1002|  51.4k|	if (r < 0) {
  ------------------
  |  Branch (1002:6): [True: 32.4k, False: 19.0k]
  ------------------
 1003|  32.4k|		sc_log(card->ctx, "Transmit failed");
  ------------------
  |  |   71|  32.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1004|  32.4k|		goto err;
 1005|  32.4k|	}
 1006|       |
 1007|  19.0k|	if (recvbuflen) {
  ------------------
  |  Branch (1007:6): [True: 16.4k, False: 2.57k]
  ------------------
 1008|  16.4k|		if (recvbuf && *recvbuf == NULL) {
  ------------------
  |  Branch (1008:7): [True: 16.4k, False: 0]
  |  Branch (1008:18): [True: 0, False: 16.4k]
  ------------------
 1009|      0|			*recvbuf =  malloc(apdu.resplen);
 1010|      0|			if (*recvbuf == NULL) {
  ------------------
  |  Branch (1010:8): [True: 0, False: 0]
  ------------------
 1011|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1012|      0|				goto err;
 1013|      0|			}
 1014|      0|			memcpy(*recvbuf, rbuf, apdu.resplen);
 1015|      0|		}
 1016|  16.4k|		*recvbuflen =  apdu.resplen;
 1017|  16.4k|		r = (int)*recvbuflen;
 1018|  16.4k|	}
 1019|       |
 1020|  52.4k|err:
 1021|  52.4k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  52.4k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  52.4k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  52.4k|	int _ret = r; \
  |  |  |  |  155|  52.4k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 36.2k, False: 16.1k]
  |  |  |  |  ------------------
  |  |  |  |  156|  36.2k|		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|  33.3k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 33.3k, False: 2.87k]
  |  |  |  |  ------------------
  |  |  |  |  157|  36.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  36.2k|	} else { \
  |  |  |  |  159|  16.1k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  16.1k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  16.1k|	} \
  |  |  |  |  162|  52.4k|	return _ret; \
  |  |  |  |  163|  52.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1022|  52.4k|}
card-coolkey.c:coolkey_find_object_by_id:
  826|  13.5k|{
  827|  13.5k|	int pos;
  828|  13.5k|	static sc_cardctl_coolkey_object_t cmp = {{
  829|  13.5k|		"", 0, 0, 0, SC_PATH_TYPE_DF_NAME,
  ------------------
  |  |  118|  13.5k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  830|  13.5k|		{ COOLKEY_AID, sizeof(COOLKEY_AID)-1 }
  ------------------
  |  |  823|  13.5k|#define COOLKEY_AID "\xA0\x00\x00\x01\x16"
  ------------------
              		{ COOLKEY_AID, sizeof(COOLKEY_AID)-1 }
  ------------------
  |  |  823|  13.5k|#define COOLKEY_AID "\xA0\x00\x00\x01\x16"
  ------------------
  831|  13.5k|	}, 0, 0, NULL};
  832|       |
  833|  13.5k|	cmp.id = object_id;
  834|  13.5k|	if ((pos = list_locate(list, &cmp)) < 0)
  ------------------
  |  Branch (834:6): [True: 6.38k, False: 7.21k]
  ------------------
  835|  6.38k|		return NULL;
  836|       |
  837|  7.21k|	return list_get_at(list, pos);
  838|  13.5k|}
card-coolkey.c:coolkey_find_attribute:
 1417|  79.9k|{
 1418|  79.9k|	u8 object_record_type;
 1419|  79.9k|	CK_ATTRIBUTE_TYPE attr_type = attribute->attribute_type;
 1420|  79.9k|	const u8 *obj = attribute->object->data;
 1421|  79.9k|	const u8 *attr = NULL;
 1422|  79.9k|	size_t buf_len = attribute->object->length;
 1423|  79.9k|	coolkey_object_header_t *object_head;
 1424|  79.9k|	int attribute_count,i;
 1425|  79.9k|	attribute->attribute_data_type = SC_CARDCTL_COOLKEY_ATTR_TYPE_STRING;
  ------------------
  |  | 1068|  79.9k|#define SC_CARDCTL_COOLKEY_ATTR_TYPE_STRING 0
  ------------------
 1426|  79.9k|	attribute->attribute_length = 0;
 1427|  79.9k|	attribute->attribute_value = NULL;
 1428|       |
 1429|  79.9k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  79.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  79.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  79.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  79.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 79.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1430|       |
 1431|  79.9k|	if (obj == NULL) {
  ------------------
  |  Branch (1431:6): [True: 26.4k, False: 53.5k]
  ------------------
 1432|       |		/* cast away const so we can cache the data value */
 1433|  26.4k|		int r = coolkey_fill_object(card, (sc_cardctl_coolkey_object_t *)attribute->object);
 1434|  26.4k|		if (r < 0) {
  ------------------
  |  Branch (1434:7): [True: 23.7k, False: 2.73k]
  ------------------
 1435|  23.7k|			return r;
 1436|  23.7k|		}
 1437|  2.73k|		obj = attribute->object->data;
 1438|  2.73k|		if (obj == NULL) {
  ------------------
  |  Branch (1438:7): [True: 0, False: 2.73k]
  ------------------
 1439|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1440|      0|		}
 1441|  2.73k|	}
 1442|       |
 1443|       |	/* should be a static assert so we catch this at compile time */
 1444|  79.9k|	static_assert(sizeof(coolkey_object_header_t) >= sizeof(coolkey_v0_object_header_t), "internal error");
 1445|       |	/* make sure we have enough of the object to read the record_type */
 1446|  56.2k|	if (buf_len <= sizeof(coolkey_v0_object_header_t)) {
  ------------------
  |  Branch (1446:6): [True: 170, False: 56.0k]
  ------------------
 1447|    170|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|    170|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 1448|    170|	}
 1449|  56.0k|	object_head = (coolkey_object_header_t *)obj;
 1450|  56.0k|	object_record_type = object_head->record_type;
 1451|       |	/* make sure it's a type we recognize */
 1452|  56.0k|	if ((object_record_type != COOLKEY_V1_OBJECT) && (object_record_type != COOLKEY_V0_OBJECT)) {
  ------------------
  |  |  230|  56.0k|#define COOLKEY_V1_OBJECT 1
  ------------------
              	if ((object_record_type != COOLKEY_V1_OBJECT) && (object_record_type != COOLKEY_V0_OBJECT)) {
  ------------------
  |  |  229|  5.06k|#define COOLKEY_V0_OBJECT 0
  ------------------
  |  Branch (1452:6): [True: 5.06k, False: 51.0k]
  |  Branch (1452:51): [True: 2.69k, False: 2.36k]
  ------------------
 1453|  2.69k|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|  2.69k|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 1454|  2.69k|	}
 1455|       |
 1456|       |	/*
 1457|       |	 * now loop through all the attributes in the list. first find the start of the list
 1458|       |	 */
 1459|  53.3k|	attr = coolkey_attribute_start(obj, object_record_type, buf_len);
 1460|  53.3k|	if (attr == NULL) {
  ------------------
  |  Branch (1460:6): [True: 67, False: 53.3k]
  ------------------
 1461|     67|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|     67|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 1462|     67|	}
 1463|  53.3k|	buf_len -= (attr-obj);
 1464|       |
 1465|       |	/* now get the count */
 1466|  53.3k|	attribute_count = coolkey_get_attribute_count(obj, object_record_type, buf_len);
 1467|  64.2k|	for (i=0; i < attribute_count; i++) {
  ------------------
  |  Branch (1467:12): [True: 12.9k, False: 51.3k]
  ------------------
 1468|  12.9k|		size_t record_len = coolkey_get_attribute_record_len(attr, object_record_type, buf_len);
 1469|       |		/* make sure we have the complete record */
 1470|  12.9k|		if (buf_len < record_len || record_len < 4) {
  ------------------
  |  Branch (1470:7): [True: 0, False: 12.9k]
  |  Branch (1470:31): [True: 737, False: 12.1k]
  ------------------
 1471|    737|			return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|    737|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 1472|    737|		}
 1473|       |		/* does the attribute match the one we are looking for */
 1474|  12.1k|		if (attr_type == coolkey_get_attribute_type(attr, object_record_type, record_len)) {
  ------------------
  |  Branch (1474:7): [True: 1.27k, False: 10.8k]
  ------------------
 1475|       |			/* yup, return it */
 1476|  1.27k|			return coolkey_get_attribute_data(attr, object_record_type, record_len, attribute);
 1477|  1.27k|		}
 1478|       |		/* go to the next attribute on the list */
 1479|  10.8k|		buf_len -= record_len;
 1480|  10.8k|		attr += record_len;
 1481|  10.8k|	}
 1482|       |	/* not find in attribute list, check the fixed attribute record */
 1483|  51.3k|	if (object_record_type == COOLKEY_V1_OBJECT) {
  ------------------
  |  |  230|  51.3k|#define COOLKEY_V1_OBJECT 1
  ------------------
  |  Branch (1483:6): [True: 49.1k, False: 2.11k]
  ------------------
 1484|  49.1k|		unsigned long fixed_attributes = bebytes2ulong(object_head->fixed_attributes_values);
 1485|       |
 1486|  49.1k|		return coolkey_get_attribute_data_fixed(attr_type, fixed_attributes, attribute);
 1487|  49.1k|	}
 1488|  2.11k|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_DATA_OBJECT_NOT_FOUND);
  ------------------
  |  |  164|  2.11k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.11k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.11k|	int _ret = r; \
  |  |  |  |  155|  2.11k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.11k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.11k|		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|  2.11k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.11k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.11k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.11k|	} 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|  2.11k|	return _ret; \
  |  |  |  |  163|  2.11k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1489|  2.11k|}
card-coolkey.c:coolkey_attribute_start:
  422|  54.6k|{
  423|  54.6k|	size_t offset = object_record_type == COOLKEY_V1_OBJECT ? sizeof(coolkey_object_header_t) :
  ------------------
  |  |  230|  54.6k|#define COOLKEY_V1_OBJECT 1
  ------------------
  |  Branch (423:18): [True: 51.0k, False: 3.67k]
  ------------------
  424|  54.6k|			sizeof(coolkey_v0_object_header_t);
  425|       |
  426|  54.6k|	if ((object_record_type != COOLKEY_V1_OBJECT) && (object_record_type != COOLKEY_V0_OBJECT)) {
  ------------------
  |  |  230|  54.6k|#define COOLKEY_V1_OBJECT 1
  ------------------
              	if ((object_record_type != COOLKEY_V1_OBJECT) && (object_record_type != COOLKEY_V0_OBJECT)) {
  ------------------
  |  |  229|  3.67k|#define COOLKEY_V0_OBJECT 0
  ------------------
  |  Branch (426:6): [True: 3.67k, False: 51.0k]
  |  Branch (426:51): [True: 0, False: 3.67k]
  ------------------
  427|      0|		return NULL;
  428|      0|	}
  429|  54.6k|	if (offset > buf_len) {
  ------------------
  |  Branch (429:6): [True: 67, False: 54.6k]
  ------------------
  430|     67|		return NULL;
  431|     67|	}
  432|  54.6k|	return obj + offset;
  433|  54.6k|}
card-coolkey.c:coolkey_get_attribute_count:
  503|  53.3k|{
  504|  53.3k|	if (object_record_type == COOLKEY_V0_OBJECT) {
  ------------------
  |  |  229|  53.3k|#define COOLKEY_V0_OBJECT 0
  ------------------
  |  Branch (504:6): [True: 2.36k, False: 50.9k]
  ------------------
  505|  2.36k|		return coolkey_v0_get_attribute_count(obj, buf_len);
  506|  2.36k|	}
  507|  50.9k|	if (object_record_type != COOLKEY_V1_OBJECT) {
  ------------------
  |  |  230|  50.9k|#define COOLKEY_V1_OBJECT 1
  ------------------
  |  Branch (507:6): [True: 0, False: 50.9k]
  ------------------
  508|      0|		return 0;
  509|      0|	}
  510|  50.9k|	return coolkey_v1_get_attribute_count(obj, buf_len);
  511|  50.9k|}
card-coolkey.c:coolkey_v0_get_attribute_count:
  441|  2.36k|{
  442|  2.36k|	coolkey_v0_object_header_t *object_head = (coolkey_v0_object_header_t *)obj;
  443|  2.36k|	const u8 *attr;
  444|  2.36k|	int count = 0;
  445|  2.36k|	size_t attribute_data_len;
  446|       |
  447|       |	/* make sure we have enough of the object to read the record_type */
  448|  2.36k|	if (buf_len <= sizeof(coolkey_v0_object_header_t)) {
  ------------------
  |  Branch (448:6): [True: 1.05k, False: 1.30k]
  ------------------
  449|  1.05k|		return 0;
  450|  1.05k|	}
  451|       |	/*
  452|       |	 * now loop through all the attributes in the list. first find the start of the list
  453|       |	 */
  454|  1.30k|	attr = coolkey_attribute_start(obj, COOLKEY_V0_OBJECT, buf_len);
  ------------------
  |  |  229|  1.30k|#define COOLKEY_V0_OBJECT 0
  ------------------
  455|  1.30k|	if (attr == NULL) {
  ------------------
  |  Branch (455:6): [True: 0, False: 1.30k]
  ------------------
  456|      0|		return 0;
  457|      0|	}
  458|       |
  459|  1.30k|	buf_len -= (attr-obj);
  460|  1.30k|	attribute_data_len = bebytes2ushort(object_head->attribute_data_len);
  461|  1.30k|	if (buf_len < attribute_data_len) {
  ------------------
  |  Branch (461:6): [True: 172, False: 1.13k]
  ------------------
  462|    172|		return 0;
  463|    172|	}
  464|       |
  465|  4.65k|	while (attribute_data_len) {
  ------------------
  |  Branch (465:9): [True: 3.78k, False: 864]
  ------------------
  466|  3.78k|		size_t len = coolkey_v0_get_attribute_record_len(attr, buf_len);
  467|       |
  468|  3.78k|		if (len == 0) {
  ------------------
  |  Branch (468:7): [True: 0, False: 3.78k]
  ------------------
  469|      0|			break;
  470|      0|		}
  471|       |		/*  This is an error in the token data, don't parse the last attribute */
  472|  3.78k|		if (len > attribute_data_len) {
  ------------------
  |  Branch (472:7): [True: 270, False: 3.51k]
  ------------------
  473|    270|			break;
  474|    270|		}
  475|       |		/* we know that coolkey_v0_get_attribute_record_len never
  476|       |		 * 	returns more than buf_len, so we can safely assert that.
  477|       |		 * 	If the assert is true, you can easily see that the loop
  478|       |		 * 	will eventually break with len == 0, even if attribute_data_len
  479|       |		 * 	was invalid */
  480|  3.51k|		if (len > buf_len)
  ------------------
  |  Branch (480:7): [True: 0, False: 3.51k]
  ------------------
  481|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  482|  3.51k|		count++;
  483|  3.51k|		attr += len;
  484|  3.51k|		buf_len -= len;
  485|  3.51k|		attribute_data_len -= len;
  486|  3.51k|	}
  487|  1.13k|	return count;
  488|  1.13k|}
card-coolkey.c:coolkey_v0_get_attribute_record_len:
  381|  6.75k|{
  382|  6.75k|	size_t attribute_len = sizeof(coolkey_v0_attribute_header_t);
  383|  6.75k|	size_t len;
  384|  6.75k|	int r;
  385|       |
  386|  6.75k|	r = coolkey_v0_get_attribute_len(attr, buf_len, &len);
  387|  6.75k|	if (r < 0) {
  ------------------
  |  Branch (387:6): [True: 331, False: 6.42k]
  ------------------
  388|    331|		return buf_len; /* skip to the end, ignore the rest of the record */
  389|    331|	}
  390|  6.42k|	return MIN(buf_len,attribute_len+len);
  ------------------
  |  |   69|  6.42k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 691, False: 5.73k]
  |  |  ------------------
  ------------------
  391|  6.75k|}
card-coolkey.c:coolkey_v1_get_attribute_count:
  492|  50.9k|{
  493|  50.9k|	coolkey_object_header_t *object_head = (coolkey_object_header_t *)obj;
  494|       |
  495|  50.9k|	if (buf_len <= sizeof(coolkey_object_header_t)) {
  ------------------
  |  Branch (495:6): [True: 43.6k, False: 7.30k]
  ------------------
  496|  43.6k|		return 0;
  497|  43.6k|	}
  498|  7.30k|	return bebytes2ushort(object_head->attribute_count);
  499|  50.9k|}
card-coolkey.c:coolkey_get_attribute_record_len:
  395|  12.9k|{
  396|  12.9k|	if (obj_record_type ==  COOLKEY_V0_OBJECT) {
  ------------------
  |  |  229|  12.9k|#define COOLKEY_V0_OBJECT 0
  ------------------
  |  Branch (396:6): [True: 2.96k, False: 9.94k]
  ------------------
  397|  2.96k|		return coolkey_v0_get_attribute_record_len(attr, buf_len);
  398|  2.96k|	}
  399|  9.94k|	if (obj_record_type != COOLKEY_V1_OBJECT) {
  ------------------
  |  |  230|  9.94k|#define COOLKEY_V1_OBJECT 1
  ------------------
  |  Branch (399:6): [True: 0, False: 9.94k]
  ------------------
  400|      0|		return buf_len; /* skip to the end */
  401|      0|	}
  402|  9.94k|	return coolkey_v1_get_attribute_record_len(attr, buf_len);
  403|  9.94k|}
card-coolkey.c:coolkey_v1_get_attribute_record_len:
  365|   120k|{
  366|   120k|	size_t attribute_len = sizeof(coolkey_attribute_header_t);
  367|   120k|	size_t len = 0;
  368|   120k|	int r;
  369|       |
  370|   120k|	r = coolkey_v1_get_attribute_len(attr, buf_len, &len, 1);
  371|   120k|	if (r < 0) {
  ------------------
  |  Branch (371:6): [True: 113k, False: 7.88k]
  ------------------
  372|   113k|		return buf_len; /* skip to the end, ignore the rest of the record */
  373|   113k|	}
  374|       |
  375|  7.88k|	return MIN(buf_len,attribute_len+len);
  ------------------
  |  |   69|  7.88k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 596, False: 7.28k]
  |  |  ------------------
  ------------------
  376|   120k|}
card-coolkey.c:coolkey_get_attribute_data_fixed:
  675|  49.1k|																sc_cardctl_coolkey_attribute_t *attr_out) {
  676|  49.1k|	unsigned long cka_id = fixed_attributes & 0xf;
  677|  49.1k|	unsigned long cka_class = ((fixed_attributes) >> 4) & 0x7;
  678|  49.1k|	unsigned long mask, bit;
  679|       |
  680|  49.1k|	if (attr_type == CKA_ID) {
  ------------------
  |  |  161|  49.1k|#define CKA_ID 0x00000102UL
  ------------------
  |  Branch (680:6): [True: 5.80k, False: 43.3k]
  ------------------
  681|  5.80k|		attr_out->attribute_length = 1;
  682|  5.80k|		attr_out->attribute_value= &coolkey_static_cka_id[cka_id];
  683|  5.80k|		return SC_SUCCESS;
  ------------------
  |  |   28|  5.80k|#define SC_SUCCESS				0
  ------------------
  684|  5.80k|	}
  685|  43.3k|	if (attr_type == CKA_CLASS) {
  ------------------
  |  |  137|  43.3k|#define CKA_CLASS 0x00000000UL
  ------------------
  |  Branch (685:6): [True: 14.9k, False: 28.4k]
  ------------------
  686|  14.9k|		attr_out->attribute_data_type = SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG;
  ------------------
  |  | 1069|  14.9k|#define SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG 1
  ------------------
  687|  14.9k|		attr_out->attribute_length = 4;
  688|  14.9k|		attr_out->attribute_value = coolkey_static_cka_class[cka_class].class_value;
  689|  14.9k|		return SC_SUCCESS;
  ------------------
  |  |   28|  14.9k|#define SC_SUCCESS				0
  ------------------
  690|  14.9k|	}
  691|       |	/* If it matched, it must be one of the booleans */
  692|  28.4k|	mask = coolkey_static_cka_class[cka_class].boolean_mask;
  693|  28.4k|	bit = coolkey_get_fixed_boolean_bit(attr_type);
  694|       |	/* attribute isn't in the list */
  695|  28.4k|	if ((bit & mask) == 0) {
  ------------------
  |  Branch (695:6): [True: 11.0k, False: 17.4k]
  ------------------
  696|  11.0k|		return SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|  11.0k|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  697|  11.0k|	}
  698|  17.4k|	attr_out->attribute_length = 1;
  699|  17.4k|	attr_out->attribute_value = bit & fixed_attributes ? &coolkey_static_true : &coolkey_static_false;
  ------------------
  |  Branch (699:30): [True: 3.97k, False: 13.4k]
  ------------------
  700|  17.4k|	return SC_SUCCESS;
  ------------------
  |  |   28|  17.4k|#define SC_SUCCESS				0
  ------------------
  701|  28.4k|}
card-coolkey.c:coolkey_get_fixed_boolean_bit:
  621|  28.4k|{
  622|  28.4k|	switch(type) {
  623|      0|	case CKA_TOKEN:               return 0x00000080;
  ------------------
  |  |  138|      0|#define CKA_TOKEN 0x00000001UL
  ------------------
  |  Branch (623:2): [True: 0, False: 28.4k]
  ------------------
  624|  2.04k|	case CKA_PRIVATE:             return 0x00000100;
  ------------------
  |  |  139|  2.04k|#define CKA_PRIVATE 0x00000002UL
  ------------------
  |  Branch (624:2): [True: 2.04k, False: 26.4k]
  ------------------
  625|  2.13k|	case CKA_MODIFIABLE:          return 0x00000200;
  ------------------
  |  |  197|  2.13k|#define CKA_MODIFIABLE 0x00000170UL
  ------------------
  |  Branch (625:2): [True: 2.13k, False: 26.3k]
  ------------------
  626|  1.35k|	case CKA_DERIVE:              return 0x00000400;
  ------------------
  |  |  171|  1.35k|#define CKA_DERIVE 0x0000010CUL
  ------------------
  |  Branch (626:2): [True: 1.35k, False: 27.0k]
  ------------------
  627|  1.35k|	case CKA_LOCAL:               return 0x00000800;
  ------------------
  |  |  193|  1.35k|#define CKA_LOCAL 0x00000163UL
  ------------------
  |  Branch (627:2): [True: 1.35k, False: 27.0k]
  ------------------
  628|  1.35k|	case CKA_ENCRYPT:             return 0x00001000;
  ------------------
  |  |  163|  1.35k|#define CKA_ENCRYPT 0x00000104UL
  ------------------
  |  Branch (628:2): [True: 1.35k, False: 27.0k]
  ------------------
  629|  1.35k|	case CKA_DECRYPT:             return 0x00002000;
  ------------------
  |  |  164|  1.35k|#define CKA_DECRYPT 0x00000105UL
  ------------------
  |  Branch (629:2): [True: 1.35k, False: 27.0k]
  ------------------
  630|  1.35k|	case CKA_WRAP:                return 0x00004000;
  ------------------
  |  |  165|  1.35k|#define CKA_WRAP 0x00000106UL
  ------------------
  |  Branch (630:2): [True: 1.35k, False: 27.0k]
  ------------------
  631|  1.35k|	case CKA_UNWRAP:              return 0x00008000;
  ------------------
  |  |  166|  1.35k|#define CKA_UNWRAP 0x00000107UL
  ------------------
  |  Branch (631:2): [True: 1.35k, False: 27.0k]
  ------------------
  632|  1.35k|	case CKA_SIGN:                return 0x00010000;
  ------------------
  |  |  167|  1.35k|#define CKA_SIGN 0x00000108UL
  ------------------
  |  Branch (632:2): [True: 1.35k, False: 27.0k]
  ------------------
  633|  1.35k|	case CKA_SIGN_RECOVER:        return 0x00020000;
  ------------------
  |  |  168|  1.35k|#define CKA_SIGN_RECOVER 0x00000109UL
  ------------------
  |  Branch (633:2): [True: 1.35k, False: 27.0k]
  ------------------
  634|  1.35k|	case CKA_VERIFY:              return 0x00040000;
  ------------------
  |  |  169|  1.35k|#define CKA_VERIFY 0x0000010AUL
  ------------------
  |  Branch (634:2): [True: 1.35k, False: 27.0k]
  ------------------
  635|  1.35k|	case CKA_VERIFY_RECOVER:      return 0x00080000;
  ------------------
  |  |  170|  1.35k|#define CKA_VERIFY_RECOVER 0x0000010BUL
  ------------------
  |  Branch (635:2): [True: 1.35k, False: 27.0k]
  ------------------
  636|  1.35k|	case CKA_SENSITIVE:           return 0x00100000;
  ------------------
  |  |  162|  1.35k|#define CKA_SENSITIVE 0x00000103UL
  ------------------
  |  Branch (636:2): [True: 1.35k, False: 27.0k]
  ------------------
  637|  1.35k|	case CKA_ALWAYS_SENSITIVE:    return 0x00200000;
  ------------------
  |  |  195|  1.35k|#define CKA_ALWAYS_SENSITIVE 0x00000165UL
  ------------------
  |  Branch (637:2): [True: 1.35k, False: 27.0k]
  ------------------
  638|  1.35k|	case CKA_EXTRACTABLE:         return 0x00400000;
  ------------------
  |  |  192|  1.35k|#define CKA_EXTRACTABLE 0x00000162UL
  ------------------
  |  Branch (638:2): [True: 1.35k, False: 27.0k]
  ------------------
  639|  1.35k|	case CKA_NEVER_EXTRACTABLE:   return 0x00800000;
  ------------------
  |  |  194|  1.35k|#define CKA_NEVER_EXTRACTABLE 0x00000164UL
  ------------------
  |  Branch (639:2): [True: 1.35k, False: 27.0k]
  ------------------
  640|  5.31k|	default: break;
  ------------------
  |  Branch (640:2): [True: 5.31k, False: 23.1k]
  ------------------
  641|  28.4k|	}
  642|  5.31k|	return 0; /* return no bits */
  643|  28.4k|}
card-coolkey.c:sc_get_driver:
 2442|  17.0k|{
 2443|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2444|       |
 2445|  17.0k|	coolkey_ops = *iso_drv->ops;
 2446|  17.0k|	coolkey_ops.match_card = coolkey_match_card;
 2447|  17.0k|	coolkey_ops.init = coolkey_init;
 2448|  17.0k|	coolkey_ops.finish = coolkey_finish;
 2449|       |
 2450|  17.0k|	coolkey_ops.select_file =  coolkey_select_file; /* need to record object type */
 2451|  17.0k|	coolkey_ops.get_challenge = coolkey_get_challenge;
 2452|  17.0k|	coolkey_ops.read_binary = coolkey_read_binary;
 2453|  17.0k|	coolkey_ops.write_binary = coolkey_write_binary;
 2454|  17.0k|	coolkey_ops.set_security_env = coolkey_set_security_env;
 2455|  17.0k|	coolkey_ops.restore_security_env = coolkey_restore_security_env;
 2456|  17.0k|	coolkey_ops.compute_signature = coolkey_compute_crypt;
 2457|  17.0k|	coolkey_ops.decipher =  coolkey_compute_crypt;
 2458|  17.0k|	coolkey_ops.card_ctl = coolkey_card_ctl;
 2459|  17.0k|	coolkey_ops.check_sw = coolkey_check_sw;
 2460|  17.0k|	coolkey_ops.pin_cmd = coolkey_pin_cmd;
 2461|  17.0k|	coolkey_ops.logout = coolkey_logout;
 2462|  17.0k|	coolkey_ops.card_reader_lock_obtained = coolkey_card_reader_lock_obtained;
 2463|       |
 2464|  17.0k|	return &coolkey_drv;
 2465|  17.0k|}
card-coolkey.c:coolkey_match_card:
 2281|  8.25k|{
 2282|  8.25k|	int r;
 2283|       |
 2284|  8.25k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  8.25k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  8.25k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  8.25k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 8.25k]
  |  |  ------------------
  ------------------
 2285|       |
 2286|  8.25k|	r = coolkey_select_applet(card);
 2287|  8.25k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  8.25k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2287:6): [True: 1.04k, False: 7.21k]
  ------------------
 2288|  1.04k|		sc_apdu_t apdu;
 2289|       |
 2290|       |		/* The GET STATUS INS with P1 = 1 returns invalid instruction (0x6D00)
 2291|       |		 * on Coolkey applet (reserved for GetMemory function),
 2292|       |		 * while incorrect P1 (0x9C10) on Muscle applets
 2293|       |		 */
 2294|  1.04k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, COOLKEY_INS_GET_STATUS, 0x01, 0x00);
  ------------------
  |  |  291|  1.04k|#define SC_APDU_CASE_1			0x01
  ------------------
              		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, COOLKEY_INS_GET_STATUS, 0x01, 0x00);
  ------------------
  |  |   80|  1.04k|#define COOLKEY_INS_GET_STATUS                 0x3c
  ------------------
 2295|  1.04k|		apdu.cla = COOLKEY_CLASS;
  ------------------
  |  |   73|  1.04k|#define COOLKEY_CLASS           0xb0
  ------------------
 2296|  1.04k|		apdu.le = 0x00;
 2297|  1.04k|		apdu.resplen = 0;
 2298|  1.04k|		apdu.resp = NULL;
 2299|  1.04k|		r = sc_transmit_apdu(card, &apdu);
 2300|  1.04k|		if (r == SC_SUCCESS && apdu.sw1 == 0x6d && apdu.sw2 == 0x00) {
  ------------------
  |  |   28|  2.08k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2300:7): [True: 1.03k, False: 1]
  |  Branch (2300:26): [True: 1.01k, False: 21]
  |  Branch (2300:46): [True: 1.01k, False: 5]
  ------------------
 2301|  1.01k|			return 1;
 2302|  1.01k|		}
 2303|     27|		return 0;
 2304|  1.04k|	}
 2305|  7.21k|	return 0;
 2306|  8.25k|}
card-coolkey.c:coolkey_select_applet:
 1071|  11.3k|{
 1072|  11.3k|	u8 aid[] = { 0x62, 0x76, 0x01, 0xff, 0x00, 0x00, 0x00 };
 1073|  11.3k|	return coolkey_apdu_io(card, ISO7816_CLASS, ISO7816_INS_SELECT_FILE, 4, 0,
  ------------------
  |  |   72|  11.3k|#define ISO7816_CLASS           0x00
  ------------------
              	return coolkey_apdu_io(card, ISO7816_CLASS, ISO7816_INS_SELECT_FILE, 4, 0,
  ------------------
  |  |   76|  11.3k|#define ISO7816_INS_SELECT_FILE 0xa4
  ------------------
 1074|  11.3k|			&aid[0], sizeof(aid), NULL, NULL,  NULL, 0);
 1075|  11.3k|}
card-coolkey.c:coolkey_init:
 2310|  1.01k|{
 2311|  1.01k|	int r;
 2312|  1.01k|	unsigned long flags;
 2313|  1.01k|	unsigned long ext_flags;
 2314|  1.01k|	coolkey_private_data_t * priv;
 2315|       |
 2316|  1.01k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.01k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.01k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.01k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.01k]
  |  |  ------------------
  ------------------
 2317|       |
 2318|  1.01k|	r = coolkey_initialize(card);
 2319|  1.01k|	if (r < 0) {
  ------------------
  |  Branch (2319:6): [True: 306, False: 707]
  ------------------
 2320|    306|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|    306|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    306|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    306|	int _ret = r; \
  |  |  |  |  155|    306|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 306, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    306|		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|    306|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 306, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    306|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    306|	} 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|    306|	return _ret; \
  |  |  |  |  163|    306|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2321|    306|	}
 2322|       |
 2323|    707|	card->type = SC_CARD_TYPE_COOLKEY_GENERIC;
 2324|       |
 2325|       |	/* set Token Major/minor version */
 2326|    707|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|    707|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
 2327|       |
 2328|    707|	_sc_card_add_rsa_alg(card, 1024, flags, 0); /* mandatory */
 2329|    707|	_sc_card_add_rsa_alg(card, 2048, flags, 0); /* optional */
 2330|    707|	_sc_card_add_rsa_alg(card, 3072, flags, 0); /* optional */
 2331|       |
 2332|    707|	flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  174|    707|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              	flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  173|    707|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              	flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|    707|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|    707|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
 2333|    707|	ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  201|    707|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              	ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  202|    707|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
 2334|       |
 2335|    707|	_sc_card_add_ec_alg(card, 256, flags, ext_flags, NULL);
 2336|    707|	_sc_card_add_ec_alg(card, 384, flags, ext_flags, NULL);
 2337|    707|	_sc_card_add_ec_alg(card, 521, flags, ext_flags, NULL);
 2338|       |
 2339|       |
 2340|    707|	priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|    707|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 2341|    707|	if (priv->pin_count != 0) {
  ------------------
  |  Branch (2341:6): [True: 142, False: 565]
  ------------------
 2342|    142|		card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    142|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
 2343|    142|	}
 2344|       |
 2345|    707|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    707|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    707|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    707|	int _ret = r; \
  |  |  |  |  155|    707|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 707, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    707|		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: 707]
  |  |  |  |  ------------------
  |  |  |  |  157|    707|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    707|	} 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|    707|	return _ret; \
  |  |  |  |  163|    707|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2346|    707|}
card-coolkey.c:coolkey_initialize:
 2150|  1.01k|{
 2151|  1.01k|	int r;
 2152|  1.01k|	coolkey_private_data_t *priv = NULL;
 2153|  1.01k|	coolkey_life_cycle_t life_cycle;
 2154|  1.01k|	coolkey_object_info_t object_info;
 2155|  1.01k|	int combined_processed = 0;
 2156|       |
 2157|       |	/* already found? */
 2158|  1.01k|	if (card->drv_data) {
  ------------------
  |  Branch (2158:6): [True: 0, False: 1.01k]
  ------------------
 2159|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2160|      0|	}
 2161|  1.01k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"Coolkey Applet found");
  ------------------
  |  |   70|  1.01k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2162|       |
 2163|  1.01k|	priv = coolkey_new_private_data();
 2164|  1.01k|	if (priv == NULL) {
  ------------------
  |  Branch (2164:6): [True: 0, False: 1.01k]
  ------------------
 2165|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2166|      0|		goto cleanup;
 2167|      0|	}
 2168|  1.01k|	r = coolkey_get_life_cycle(card, &life_cycle);
 2169|  1.01k|	if (r < 0) {
  ------------------
  |  Branch (2169:6): [True: 64, False: 949]
  ------------------
 2170|     64|		goto cleanup;
 2171|     64|	}
 2172|       |
 2173|       |	/* Select a coolkey read the coolkey objects out */
 2174|    949|	r = coolkey_select_applet(card);
 2175|    949|	if (r < 0) {
  ------------------
  |  Branch (2175:6): [True: 10, False: 939]
  ------------------
 2176|     10|		goto cleanup;
 2177|     10|	}
 2178|       |
 2179|    939|	priv->protocol_version_major = life_cycle.protocol_version_major;
 2180|    939|	priv->protocol_version_minor = life_cycle.protocol_version_minor;
 2181|    939|	priv->pin_count = life_cycle.pin_count;
 2182|    939|	priv->life_cycle = life_cycle.life_cycle;
 2183|       |
 2184|       |	/* walk down the list of objects and read them off the token */
 2185|    939|	r = coolkey_list_object(card, COOLKEY_LIST_RESET, &object_info);
  ------------------
  |  |  105|    939|#define COOLKEY_LIST_RESET 0x00
  ------------------
 2186|  10.4k|	while (r >= 0) {
  ------------------
  |  Branch (2186:9): [True: 9.62k, False: 866]
  ------------------
 2187|  9.62k|		unsigned long object_id;
 2188|  9.62k|		unsigned long object_len;
 2189|       |
 2190|       |		/* The card did not return what we expected: Lets try other objects */
 2191|  9.62k|		if ((size_t)r < (sizeof(object_info)))
  ------------------
  |  Branch (2191:7): [True: 11, False: 9.61k]
  ------------------
 2192|     11|			break;
 2193|       |
 2194|       |		/* TODO also look at the ACL... */
 2195|       |
 2196|  9.61k|		object_id = bebytes2ulong(object_info.object_id);
 2197|  9.61k|		object_len = bebytes2ulong(object_info.object_length);
 2198|       |		/* Avoid insanely large data */
 2199|  9.61k|		if (object_len > MAX_FILE_SIZE) {
  ------------------
  |  |  220|  9.61k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (2199:7): [True: 9, False: 9.60k]
  ------------------
 2200|      9|			r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      9|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2201|      9|			goto cleanup;
 2202|      9|		}
 2203|       |
 2204|       |		/* the combined object is a single object that can store the other objects.
 2205|       |		 * most coolkeys provisioned by TPS has a single combined object that is
 2206|       |		 * compressed greatly increasing the effectiveness of compress (since lots
 2207|       |		 * of certs on the token share the same Subject and Issuer DN's). We now
 2208|       |		 * process it separately so that we can have both combined objects managed
 2209|       |		 * by TPS and user managed certs on the same token */
 2210|  9.60k|		if (object_id == COOLKEY_COMBINED_OBJECT_ID) {
  ------------------
  |  |  110|  9.60k|#define COOLKEY_COMBINED_OBJECT_ID 0x7a300000 /* 'z0\0\0' */
  ------------------
  |  Branch (2210:7): [True: 55, False: 9.55k]
  ------------------
 2211|     55|			u8 *object = malloc(object_len);
 2212|     55|			if (object == NULL) {
  ------------------
  |  Branch (2212:8): [True: 0, False: 55]
  ------------------
 2213|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2214|      0|				break;
 2215|      0|			}
 2216|     55|			r = coolkey_read_object(card, COOLKEY_COMBINED_OBJECT_ID, 0, object, object_len,
  ------------------
  |  |  110|     55|#define COOLKEY_COMBINED_OBJECT_ID 0x7a300000 /* 'z0\0\0' */
  ------------------
 2217|     55|				priv->nonce, sizeof(priv->nonce));
 2218|     55|			if (r < 0) {
  ------------------
  |  Branch (2218:8): [True: 20, False: 35]
  ------------------
 2219|     20|				free(object);
 2220|     20|				break;
 2221|     20|			}
 2222|     35|			r = coolkey_process_combined_object(card, priv, object, r);
 2223|     35|			free(object);
 2224|     35|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     35|#define SC_SUCCESS				0
  ------------------
  |  Branch (2224:8): [True: 33, False: 2]
  ------------------
 2225|     33|				break;
 2226|     33|			}
 2227|      2|			combined_processed = 1;
 2228|  9.55k|		} else {
 2229|  9.55k|			sc_log(card->ctx, "Add new object id=%ld, len=%lu", object_id, object_len);
  ------------------
  |  |   71|  9.55k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2230|  9.55k|			r = coolkey_add_object(priv, object_id, NULL, object_len, 0);
 2231|  9.55k|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|  9.55k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2231:8): [True: 3.89k, False: 5.65k]
  ------------------
 2232|  3.89k|				sc_log(card->ctx, "coolkey_add_object() returned %d", r);
  ------------------
  |  |   71|  3.89k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2233|  9.55k|		}
 2234|       |
 2235|       |		/* Read next object: error is handled on the cycle condition and below after cycle */
 2236|  9.55k|		r = coolkey_list_object(card, COOLKEY_LIST_NEXT, &object_info);
  ------------------
  |  |  106|  9.55k|#define COOLKEY_LIST_NEXT  0x01
  ------------------
 2237|  9.55k|	}
 2238|    930|	if (r != SC_ERROR_FILE_END_REACHED) {
  ------------------
  |  |   69|    930|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (2238:6): [True: 205, False: 725]
  ------------------
 2239|       |		/* This means the card does not cooperate at all: bail out */
 2240|    205|		if (r >= 0) {
  ------------------
  |  Branch (2240:7): [True: 11, False: 194]
  ------------------
 2241|     11|			r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     11|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 2242|     11|		}
 2243|    205|		goto cleanup;
 2244|    205|	}
 2245|       |	/* if we didn't pull the cuid from the combined object, then grab it now */
 2246|    725|	if (!combined_processed) {
  ------------------
  |  Branch (2246:6): [True: 725, False: 0]
  ------------------
 2247|    725|		global_platform_cplc_data_t cplc_data;
 2248|       |		/* select the card manager, because a card with applet only will have
 2249|       |		   already selected the coolkey applet */
 2250|       |
 2251|    725|		r = gp_select_card_manager(card);
 2252|    725|		if (r < 0) {
  ------------------
  |  Branch (2252:7): [True: 3, False: 722]
  ------------------
 2253|      3|			goto cleanup;
 2254|      3|		}
 2255|       |
 2256|    722|		r = gp_get_cplc_data(card, &cplc_data);
 2257|    722|		if (r < 0) {
  ------------------
  |  Branch (2257:7): [True: 15, False: 707]
  ------------------
 2258|     15|			goto cleanup;
 2259|     15|		}
 2260|    707|		coolkey_make_cuid_from_cplc(&priv->cuid, &cplc_data);
 2261|    707|		priv->token_name = (u8 *)strdup("COOLKEY");
 2262|    707|		if (priv->token_name == NULL) {
  ------------------
  |  Branch (2262:7): [True: 0, False: 707]
  ------------------
 2263|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2264|      0|			goto cleanup;
 2265|      0|		}
 2266|    707|		priv->token_name_length = sizeof("COOLKEY")-1;
 2267|    707|	}
 2268|    707|	card->drv_data = priv;
 2269|    707|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    707|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    707|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    707|	int _ret = r; \
  |  |  |  |  155|    707|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 707, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    707|		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: 707]
  |  |  |  |  ------------------
  |  |  |  |  157|    707|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    707|	} 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|    707|	return _ret; \
  |  |  |  |  163|    707|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2270|       |
 2271|    306|cleanup:
 2272|    306|	if (priv) {
  ------------------
  |  Branch (2272:6): [True: 306, False: 0]
  ------------------
 2273|    306|		coolkey_free_private_data(priv);
 2274|    306|	}
 2275|    306|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    306|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    306|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    306|	int _ret = r; \
  |  |  |  |  155|    306|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 306, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    306|		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|    306|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 306, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    306|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    306|	} 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|    306|	return _ret; \
  |  |  |  |  163|    306|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2276|    306|}
card-coolkey.c:coolkey_new_private_data:
  773|  1.01k|{
  774|  1.01k|	coolkey_private_data_t *priv;
  775|       |
  776|       |	/* allocate priv and zero all the fields */
  777|  1.01k|	priv = calloc(1, sizeof(coolkey_private_data_t));
  778|  1.01k|	if (!priv)
  ------------------
  |  Branch (778:6): [True: 0, False: 1.01k]
  ------------------
  779|      0|		return NULL;
  780|       |
  781|       |	/* set other fields as appropriate */
  782|  1.01k|	priv->key_id = COOLKEY_INVALID_KEY;
  ------------------
  |  |  111|  1.01k|#define COOLKEY_INVALID_KEY        0xff00
  ------------------
  783|  1.01k|	if (list_init(&priv->objects_list) != 0 ||
  ------------------
  |  Branch (783:6): [True: 0, False: 1.01k]
  ------------------
  784|  1.01k|	    list_attributes_comparator(&priv->objects_list, coolkey_compare_id) != 0 ||
  ------------------
  |  Branch (784:6): [True: 0, False: 1.01k]
  ------------------
  785|  1.01k|	    list_attributes_copy(&priv->objects_list, coolkey_list_meter, 1) != 0) {
  ------------------
  |  Branch (785:6): [True: 0, False: 1.01k]
  ------------------
  786|      0|		coolkey_free_private_data(priv);
  787|      0|		return NULL;
  788|      0|	}
  789|       |
  790|  1.01k|	return priv;
  791|  1.01k|}
card-coolkey.c:coolkey_get_life_cycle:
 1029|  1.01k|{
 1030|  1.01k|	coolkey_status_t status;
 1031|  1.01k|	u8 *receive_buf;
 1032|  1.01k|	size_t receive_len;
 1033|  1.01k|	int len;
 1034|       |
 1035|  1.01k|	receive_len = sizeof(*life_cycle);
 1036|  1.01k|	receive_buf = (u8 *)life_cycle;
 1037|  1.01k|	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_LIFE_CYCLE, 0, 0,
  ------------------
  |  |   73|  1.01k|#define COOLKEY_CLASS           0xb0
  ------------------
              	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_LIFE_CYCLE, 0, 0,
  ------------------
  |  |   79|  1.01k|#define COOLKEY_INS_GET_LIFE_CYCLE             0xf2
  ------------------
 1038|  1.01k|			NULL, 0, &receive_buf, &receive_len, NULL, 0);
 1039|  1.01k|	if (len == sizeof(*life_cycle)) {
  ------------------
  |  Branch (1039:6): [True: 944, False: 69]
  ------------------
 1040|    944|		return SC_SUCCESS;
  ------------------
  |  |   28|    944|#define SC_SUCCESS				0
  ------------------
 1041|    944|	}
 1042|       |
 1043|     69|	receive_len = 1;
 1044|     69|	receive_buf = &life_cycle->life_cycle;
 1045|     69|	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_LIFE_CYCLE, 0, 0,
  ------------------
  |  |   73|     69|#define COOLKEY_CLASS           0xb0
  ------------------
              	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_LIFE_CYCLE, 0, 0,
  ------------------
  |  |   79|     69|#define COOLKEY_INS_GET_LIFE_CYCLE             0xf2
  ------------------
 1046|     69|			NULL, 0, &receive_buf, &receive_len, NULL, 0);
 1047|     69|	if (len < 0) { /* Error from the trasmittion */
  ------------------
  |  Branch (1047:6): [True: 44, False: 25]
  ------------------
 1048|     44|		return len;
 1049|     44|	}
 1050|     25|	if (len != 1) { /* The returned data is invalid */
  ------------------
  |  Branch (1050:6): [True: 2, False: 23]
  ------------------
 1051|      2|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      2|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1052|      2|	}
 1053|     23|	receive_len = sizeof(status);
 1054|     23|	receive_buf = (u8 *)&status;
 1055|     23|	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_STATUS, 0, 0,
  ------------------
  |  |   73|     23|#define COOLKEY_CLASS           0xb0
  ------------------
              	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_STATUS, 0, 0,
  ------------------
  |  |   80|     23|#define COOLKEY_INS_GET_STATUS                 0x3c
  ------------------
 1056|     23|			NULL, 0, &receive_buf, &receive_len, NULL, 0);
 1057|     23|	if (len < 0) { /* Error from the trasmittion */
  ------------------
  |  Branch (1057:6): [True: 10, False: 13]
  ------------------
 1058|     10|		return len;
 1059|     10|	}
 1060|     13|	if (len != sizeof(status)) { /* The returned data is invalid */
  ------------------
  |  Branch (1060:6): [True: 8, False: 5]
  ------------------
 1061|      8|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      8|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1062|      8|	}
 1063|      5|	life_cycle->protocol_version_major = status.protocol_version_major;
 1064|      5|	life_cycle->protocol_version_minor = status.protocol_version_minor;
 1065|      5|	life_cycle->pin_count = status.pin_count;
 1066|      5|	return SC_SUCCESS;
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
 1067|     13|}
card-coolkey.c:coolkey_list_object:
 2137|  10.4k|{
 2138|  10.4k|	u8 *rbuf = (u8 *) object_info;
 2139|  10.4k|	size_t rbuflen = sizeof(*object_info);
 2140|       |
 2141|  10.4k|	return coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_LIST_OBJECTS, seq, 0,
  ------------------
  |  |   73|  10.4k|#define COOLKEY_CLASS           0xb0
  ------------------
              	return coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_LIST_OBJECTS, seq, 0,
  ------------------
  |  |   82|  10.4k|#define COOLKEY_INS_LIST_OBJECTS               0x58
  ------------------
 2142|  10.4k|			NULL, 0, &rbuf, &rbuflen, NULL, 0);
 2143|       |
 2144|  10.4k|}
card-coolkey.c:coolkey_process_combined_object:
 2001|     35|{
 2002|     35|	coolkey_combined_header_t *header = (coolkey_combined_header_t *)object;
 2003|     35|	unsigned short compressed_offset;
 2004|     35|	unsigned short compressed_length;
 2005|     35|	unsigned short compressed_type;
 2006|     35|	size_t object_offset;
 2007|     35|	unsigned short object_count;
 2008|     35|	coolkey_decompressed_header_t *decompressed_header;
 2009|     35|	u8 *decompressed_object = NULL;
 2010|     35|	size_t decompressed_object_len = 0;
 2011|     35|	int free_decompressed = 0;
 2012|     35|	int i, r;
 2013|       |
 2014|     35|	if (object_length < sizeof(coolkey_combined_header_t)) {
  ------------------
  |  Branch (2014:6): [True: 1, False: 34]
  ------------------
 2015|      1|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      1|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2016|      1|	}
 2017|     34|	compressed_offset = bebytes2ushort(header->compression_offset);
 2018|     34|	compressed_length = bebytes2ushort(header->compression_length);
 2019|     34|	compressed_type   = bebytes2ushort(header->compression_type);
 2020|       |
 2021|     34|	if ((((size_t)compressed_offset) + (size_t)compressed_length) >  object_length) {
  ------------------
  |  Branch (2021:6): [True: 7, False: 27]
  ------------------
 2022|      7|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      7|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2023|      7|	}
 2024|       |
 2025|       |	/* store the CUID */
 2026|     27|	memcpy(&priv->cuid, &header->cuid, sizeof(priv->cuid));
 2027|       |
 2028|     27|	if (compressed_type == COOLKEY_COMPRESSION_ZLIB) {
  ------------------
  |  |  181|     27|#define COOLKEY_COMPRESSION_ZLIB 1
  ------------------
  |  Branch (2028:6): [True: 1, False: 26]
  ------------------
 2029|      1|#ifdef ENABLE_ZLIB
 2030|      1|		r = sc_decompress_alloc(&decompressed_object, &decompressed_object_len, &object[compressed_offset], compressed_length, COMPRESSION_AUTO);
  ------------------
  |  |   26|      1|#define COMPRESSION_AUTO	0
  ------------------
 2031|      1|		if (r)
  ------------------
  |  Branch (2031:7): [True: 1, False: 0]
  ------------------
 2032|      1|			goto done;
 2033|      0|		free_decompressed = 1;
 2034|       |#else
 2035|       |		sc_log(card->ctx, "Coolkey compression not supported, no zlib");
 2036|       |		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
 2037|       |#endif
 2038|     26|	}  else {
 2039|     26|		decompressed_object =&object[compressed_offset];
 2040|     26|		decompressed_object_len = (size_t) compressed_length;
 2041|     26|	}
 2042|       |
 2043|     26|	decompressed_header = (coolkey_decompressed_header_t *)decompressed_object;
 2044|       |
 2045|     26|	if (decompressed_object_len < sizeof(coolkey_decompressed_header_t)) {
  ------------------
  |  Branch (2045:6): [True: 1, False: 25]
  ------------------
 2046|      1|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      1|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2047|      1|		goto done;
 2048|      1|	}
 2049|     25|	object_offset = bebytes2ushort(decompressed_header->object_offset);
 2050|     25|	object_count = bebytes2ushort(decompressed_header->object_count);
 2051|       |
 2052|       |
 2053|       |	/*
 2054|       |	 * using 2 different tests here so we can log different errors if logging is
 2055|       |	 * turned on.
 2056|       |	 */
 2057|       |	/* make sure token_name doesn't overrun the buffer */
 2058|     25|	if (decompressed_header->token_name_length +
  ------------------
  |  Branch (2058:6): [True: 0, False: 25]
  ------------------
 2059|     25|		offsetof(coolkey_decompressed_header_t, token_name) > decompressed_object_len) {
 2060|      0|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      0|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2061|      0|		goto done;
 2062|      0|	}
 2063|       |	/* make sure it doesn't overlap the object space */
 2064|     25|	if (decompressed_header->token_name_length +
  ------------------
  |  Branch (2064:6): [True: 2, False: 23]
  ------------------
 2065|     25|		offsetof(coolkey_decompressed_header_t, token_name) > object_offset) {
 2066|      2|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      2|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2067|      2|		goto done;
 2068|      2|	}
 2069|       |
 2070|       |	/* store the token name in the priv structure so the emulator can set it */
 2071|     23|	free(priv->token_name);
 2072|     23|	priv->token_name = malloc(decompressed_header->token_name_length+1);
 2073|     23|	if (priv->token_name == NULL) {
  ------------------
  |  Branch (2073:6): [True: 0, False: 23]
  ------------------
 2074|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2075|      0|		goto done;
 2076|      0|	}
 2077|     23|	memcpy(priv->token_name, &decompressed_header->token_name[0],
 2078|     23|							decompressed_header->token_name_length);
 2079|     23|	priv->token_name[decompressed_header->token_name_length] = '\0';
 2080|     23|	priv->token_name_length = decompressed_header->token_name_length;
 2081|       |
 2082|     23|	if (object_count > decompressed_object_len / sizeof(coolkey_combined_object_header_t)) {
  ------------------
  |  Branch (2082:6): [True: 8, False: 15]
  ------------------
 2083|      8|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      8|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2084|      8|		goto done;
 2085|      8|	}
 2086|       |
 2087|     34|	for (i=0; i < object_count; i++) {
  ------------------
  |  Branch (2087:12): [True: 32, False: 2]
  ------------------
 2088|     32|		u8 *current_object = NULL;
 2089|     32|		coolkey_combined_object_header_t *object_header = NULL;
 2090|     32|		unsigned long object_id;
 2091|     32|		int current_object_len;
 2092|       |
 2093|       |		/* Can we read the object header at all? */
 2094|     32|		if (decompressed_object_len < sizeof(coolkey_combined_object_header_t) ||
  ------------------
  |  Branch (2094:7): [True: 0, False: 32]
  ------------------
 2095|     32|		    object_offset > decompressed_object_len - sizeof(coolkey_combined_object_header_t)) {
  ------------------
  |  Branch (2095:7): [True: 12, False: 20]
  ------------------
 2096|     12|			r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|     12|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2097|     12|			goto done;
 2098|     12|		}
 2099|       |
 2100|     20|		current_object = &decompressed_object[object_offset];
 2101|     20|		object_header = (coolkey_combined_object_header_t *)current_object;
 2102|       |
 2103|       |		/* Parse object ID */
 2104|     20|		object_id = bebytes2ulong(object_header->object_id);
 2105|       |
 2106|       |		/* figure out how big it is */
 2107|     20|		r = coolkey_v1_get_object_length(current_object, decompressed_object_len-object_offset);
 2108|     20|		if (r < 0) {
  ------------------
  |  Branch (2108:7): [True: 0, False: 20]
  ------------------
 2109|      0|			goto done;
 2110|      0|		}
 2111|     20|		if ((size_t)r > decompressed_object_len - object_offset) {
  ------------------
  |  Branch (2111:7): [True: 0, False: 20]
  ------------------
 2112|      0|			r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      0|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2113|      0|			goto done;
 2114|      0|		}
 2115|     20|		current_object_len = r;
 2116|     20|		object_offset += current_object_len;
 2117|       |
 2118|       |		/* record this object */
 2119|     20|		sc_log(card->ctx, "Add new object id=%ld", object_id);
  ------------------
  |  |   71|     20|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2120|     20|		r = coolkey_add_object(priv, object_id, current_object, current_object_len, 1);
 2121|     20|		if (r) {
  ------------------
  |  Branch (2121:7): [True: 1, False: 19]
  ------------------
 2122|      1|			goto done;
 2123|      1|		}
 2124|       |
 2125|     20|	}
 2126|      2|	r = SC_SUCCESS;
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
 2127|       |
 2128|     27|done:
 2129|     27|	if (free_decompressed) {
  ------------------
  |  Branch (2129:6): [True: 0, False: 27]
  ------------------
 2130|      0|		free(decompressed_object);
 2131|      0|	}
 2132|     27|	return r;
 2133|      2|}
card-coolkey.c:coolkey_v1_get_object_length:
  707|     20|{
  708|     20|	coolkey_combined_object_header_t *object_head = (coolkey_combined_object_header_t *) obj;
  709|     20|	int attribute_count;
  710|     20|	u8 *current_attribute;
  711|     20|	int j;
  712|     20|	size_t len;
  713|       |
  714|     20|	len = sizeof(coolkey_combined_object_header_t);
  715|     20|	if (buf_len <= len) {
  ------------------
  |  Branch (715:6): [True: 1, False: 19]
  ------------------
  716|      1|		return (int)buf_len;
  717|      1|	}
  718|     19|	attribute_count = bebytes2ushort(object_head->attribute_count);
  719|     19|	buf_len -= len;
  720|       |
  721|   111k|	for (current_attribute = obj + len, j = 0; j < attribute_count; j++) {
  ------------------
  |  Branch (721:45): [True: 111k, False: 19]
  ------------------
  722|   111k|		size_t attribute_len = coolkey_v1_get_attribute_record_len(current_attribute, buf_len);
  723|       |
  724|   111k|		len += attribute_len;
  725|   111k|		current_attribute += attribute_len;
  726|   111k|		buf_len -= attribute_len;
  727|   111k|	}
  728|     19|	return (int)len;
  729|     20|}
card-coolkey.c:coolkey_add_object:
 1960|  9.57k|{
 1961|  9.57k|	sc_cardctl_coolkey_object_t new_object;
 1962|  9.57k|	int r;
 1963|       |
 1964|  9.57k|	memset(&new_object, 0, sizeof(new_object));
 1965|  9.57k|	new_object.path = coolkey_template_path;
 1966|  9.57k|	new_object.path.len = 4;
 1967|  9.57k|	ulong2bebytes(new_object.path.value, object_id);
 1968|  9.57k|	new_object.id = object_id;
 1969|  9.57k|	new_object.length = object_length;
 1970|       |
 1971|       |	/* The object ID needs to be unique */
 1972|  9.57k|	if (coolkey_find_object_by_id(&priv->objects_list, object_id) != NULL) {
  ------------------
  |  Branch (1972:6): [True: 3.90k, False: 5.67k]
  ------------------
 1973|  3.90k|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  3.90k|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1974|  3.90k|	}
 1975|       |
 1976|  5.67k|	if (object_data) {
  ------------------
  |  Branch (1976:6): [True: 19, False: 5.65k]
  ------------------
 1977|     19|		new_object.data = malloc(object_length + add_v1_record);
 1978|     19|		if (new_object.data == NULL) {
  ------------------
  |  Branch (1978:7): [True: 0, False: 19]
  ------------------
 1979|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1980|      0|		}
 1981|     19|		if (add_v1_record) {
  ------------------
  |  Branch (1981:7): [True: 19, False: 0]
  ------------------
 1982|     19|			new_object.data[0] = COOLKEY_V1_OBJECT;
  ------------------
  |  |  230|     19|#define COOLKEY_V1_OBJECT 1
  ------------------
 1983|     19|			new_object.length++;
 1984|     19|		}
 1985|     19|		memcpy(&new_object.data[add_v1_record], object_data, object_length);
 1986|     19|	}
 1987|       |
 1988|  5.67k|	r = coolkey_add_object_to_list(&priv->objects_list, &new_object);
 1989|  5.67k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  5.67k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1989:6): [True: 0, False: 5.67k]
  ------------------
 1990|       |		/* if we didn't successfully put the object on the list,
 1991|       |		 * the data space didn't get adopted. free it before we return */
 1992|      0|		free(new_object.data);
 1993|       |		new_object.data = NULL;
 1994|      0|	}
 1995|  5.67k|	return r;
 1996|  5.67k|}
card-coolkey.c:coolkey_add_object_to_list:
  817|  5.67k|{
  818|  5.67k|	if (list_append(list, object) < 0)
  ------------------
  |  Branch (818:6): [True: 0, False: 5.67k]
  ------------------
  819|      0|		return SC_ERROR_UNKNOWN;
  ------------------
  |  |  130|      0|#define SC_ERROR_UNKNOWN			-1900
  ------------------
  820|  5.67k|	return SC_SUCCESS;
  ------------------
  |  |   28|  5.67k|#define SC_SUCCESS				0
  ------------------
  821|  5.67k|}
card-coolkey.c:coolkey_make_cuid_from_cplc:
 1079|    707|{
 1080|    707|	cuid->ic_fabricator[0]    = cplc_data->ic_fabricator[0];
 1081|    707|	cuid->ic_fabricator[1]    = cplc_data->ic_fabricator[1];
 1082|    707|	cuid->ic_type[0]          = cplc_data->ic_type[0];
 1083|    707|	cuid->ic_type[1]          = cplc_data->ic_type[1];
 1084|    707|	cuid->ic_batch[0]         = cplc_data->ic_batch[0];
 1085|    707|	cuid->ic_batch[1]         = cplc_data->ic_batch[1];
 1086|    707|	cuid->ic_serial_number[0] = cplc_data->ic_serial_number[0];
 1087|    707|	cuid->ic_serial_number[1] = cplc_data->ic_serial_number[1];
 1088|    707|	cuid->ic_serial_number[2] = cplc_data->ic_serial_number[2];
 1089|    707|	cuid->ic_serial_number[3] = cplc_data->ic_serial_number[3];
 1090|    707|}
card-coolkey.c:coolkey_free_private_data:
  794|  1.01k|{
  795|  1.01k|	list_t *l = &priv->objects_list;
  796|  1.01k|	sc_cardctl_coolkey_object_t *o;
  797|       |
  798|       |	/* Clean up the allocated memory in the items */
  799|  1.01k|	list_iterator_start(l);
  800|  6.68k|	while (list_iterator_hasnext(l)) {
  ------------------
  |  Branch (800:9): [True: 5.67k, False: 1.01k]
  ------------------
  801|  5.67k|		o = (sc_cardctl_coolkey_object_t *)list_iterator_next(l);
  802|  5.67k|		free(o->data);
  803|  5.67k|		o->data = NULL;
  804|  5.67k|	}
  805|  1.01k|	list_iterator_stop(l);
  806|       |
  807|  1.01k|	list_destroy(&priv->objects_list);
  808|  1.01k|	free(priv->token_name);
  809|  1.01k|	free(priv);
  810|  1.01k|	return;
  811|  1.01k|}
card-coolkey.c:coolkey_finish:
 1948|    707|{
 1949|    707|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|    707|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1950|       |
 1951|    707|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    707|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    707|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    707|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 707]
  |  |  ------------------
  ------------------
 1952|    707|	if (priv) {
  ------------------
  |  Branch (1952:6): [True: 707, False: 0]
  ------------------
 1953|    707|		coolkey_free_private_data(priv);
 1954|    707|	}
 1955|    707|	return SC_SUCCESS;
  ------------------
  |  |   28|    707|#define SC_SUCCESS				0
  ------------------
 1956|    707|}
card-coolkey.c:coolkey_select_file:
 1901|  2.12k|{
 1902|  2.12k|	int r;
 1903|  2.12k|	struct sc_file *file = NULL;
 1904|  2.12k|	coolkey_private_data_t *priv;
 1905|  2.12k|	unsigned long object_id;
 1906|       |
 1907|  2.12k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (1907:6): [True: 0, False: 2.12k]
  |  Branch (1907:22): [True: 0, False: 2.12k]
  ------------------
 1908|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1909|       |
 1910|  2.12k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  2.12k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.12k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.12k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.12k]
  |  |  ------------------
  ------------------
 1911|       |
 1912|  2.12k|	priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|  2.12k|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1913|       |
 1914|  2.12k|	if (in_path->len != 4) {
  ------------------
  |  Branch (1914:6): [True: 1, False: 2.12k]
  ------------------
 1915|      1|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      1|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1916|      1|	}
 1917|  2.12k|	r = coolkey_select_applet(card);
 1918|  2.12k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  2.12k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1918:6): [True: 1.52k, False: 600]
  ------------------
 1919|  1.52k|		return r;
 1920|  1.52k|	}
 1921|    600|	object_id = bebytes2ulong(in_path->value);
 1922|    600|	priv->obj = coolkey_find_object_by_id(&priv->objects_list, object_id);
 1923|    600|	if (priv->obj == NULL) {
  ------------------
  |  Branch (1923:6): [True: 567, False: 33]
  ------------------
 1924|    567|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    567|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1925|    567|	}
 1926|       |
 1927|     33|	priv->key_id = COOLKEY_INVALID_KEY;
  ------------------
  |  |  111|     33|#define COOLKEY_INVALID_KEY        0xff00
  ------------------
 1928|     33|	if (coolkey_class(object_id) == COOLKEY_KEY_CLASS) {
  ------------------
  |  |  112|     33|#define COOLKEY_KEY_CLASS			'k'
  ------------------
  |  Branch (1928:6): [True: 0, False: 33]
  ------------------
 1929|      0|		priv->key_id = coolkey_get_key_id(object_id);
 1930|      0|	}
 1931|     33|	if (file_out) {
  ------------------
  |  Branch (1931:6): [True: 32, False: 1]
  ------------------
 1932|     32|		file = sc_file_new();
 1933|     32|		if (file == NULL)
  ------------------
  |  Branch (1933:7): [True: 0, False: 32]
  ------------------
 1934|     32|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1935|     32|		file->path = *in_path;
 1936|       |		/* this could be like the FCI */
 1937|     32|		file->type =  SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     32|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1938|     32|		file->shareable = 0;
 1939|     32|		file->ef_structure = 0;
 1940|     32|		file->size = priv->obj->length;
 1941|     32|		*file_out = file;
 1942|     32|	}
 1943|       |
 1944|     33|	return SC_SUCCESS;
  ------------------
  |  |   28|     33|#define SC_SUCCESS				0
  ------------------
 1945|     33|}
card-coolkey.c:coolkey_class:
 1874|     33|static u8 coolkey_class(unsigned long object_id) {
 1875|     33|	return (object_id >> 24) & 0xff;
 1876|     33|}
card-coolkey.c:coolkey_get_challenge:
 1612|    694|{
 1613|    694|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    694|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    694|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    694|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    694|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 694]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1614|       |
 1615|    694|	if (len > COOLKEY_MAX_CHUNK_SIZE)
  ------------------
  |  |   69|    694|#define COOLKEY_MAX_CHUNK_SIZE 240 /* must be less than 255-8 */
  ------------------
  |  Branch (1615:6): [True: 70, False: 624]
  ------------------
 1616|     70|		len = COOLKEY_MAX_CHUNK_SIZE;
  ------------------
  |  |   69|     70|#define COOLKEY_MAX_CHUNK_SIZE 240 /* must be less than 255-8 */
  ------------------
 1617|       |
 1618|    694|	LOG_TEST_RET(card->ctx,
  ------------------
  |  |  174|    694|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    694|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    694|	int _ret = (r); \
  |  |  |  |  168|    694|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 272, False: 422]
  |  |  |  |  ------------------
  |  |  |  |  169|    272|		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|    272|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    272|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    272|		return _ret; \
  |  |  |  |  172|    272|	} \
  |  |  |  |  173|    694|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 422]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1619|    422|			coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_RANDOM, 0, 0,
 1620|    422|				NULL, 0, &rnd, &len,  NULL, 0),
 1621|    422|			"Could not get challenge");
 1622|       |
 1623|    422|	LOG_FUNC_RETURN(card->ctx, (int) len);
  ------------------
  |  |  164|    422|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    422|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    422|	int _ret = r; \
  |  |  |  |  155|    422|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 421]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    421|	} else { \
  |  |  |  |  159|    421|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    421|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    421|	} \
  |  |  |  |  162|    422|	return _ret; \
  |  |  |  |  163|    422|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1624|    422|}
card-coolkey.c:coolkey_read_binary:
 1181|    480|{
 1182|    480|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|    480|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1183|    480|	int r = 0;
 1184|    480|	size_t len;
 1185|    480|	u8 *data = NULL;
 1186|       |
 1187|    480|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    480|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    480|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    480|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 480]
  |  |  ------------------
  ------------------
 1188|    480|	if (idx > priv->obj->length) {
  ------------------
  |  Branch (1188:6): [True: 0, False: 480]
  ------------------
 1189|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_END_REACHED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1190|      0|	}
 1191|       |
 1192|       |	/* if we've already read the data, just return it */
 1193|    480|	if (priv->obj->data) {
  ------------------
  |  Branch (1193:6): [True: 450, False: 30]
  ------------------
 1194|    450|		sc_log(card->ctx, "returning cached value idx=%u count=%zu", idx, count);
  ------------------
  |  |   71|    450|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1195|    450|		len = MIN(count, priv->obj->length-idx);
  ------------------
  |  |   69|    450|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 431, False: 19]
  |  |  ------------------
  ------------------
 1196|    450|		memcpy(buf, &priv->obj->data[idx], len);
 1197|    450|		LOG_FUNC_RETURN(card->ctx, (int)len);
  ------------------
  |  |  164|    450|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    450|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    450|	int _ret = r; \
  |  |  |  |  155|    450|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 450]
  |  |  |  |  ------------------
  |  |  |  |  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|    450|	} else { \
  |  |  |  |  159|    450|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    450|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    450|	} \
  |  |  |  |  162|    450|	return _ret; \
  |  |  |  |  163|    450|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1198|    450|	}
 1199|       |
 1200|     30|	sc_log(card->ctx, "clearing cache idx=%u count=%zu", idx, count);
  ------------------
  |  |   71|     30|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1201|       |
 1202|     30|	data = malloc(priv->obj->length);
 1203|     30|	if (data == NULL) {
  ------------------
  |  Branch (1203:6): [True: 0, False: 30]
  ------------------
 1204|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1205|      0|		goto done;
 1206|      0|	}
 1207|       |
 1208|       |
 1209|     30|	r = coolkey_read_object(card, priv->obj->id, 0, data, priv->obj->length,
 1210|     30|		priv->nonce, sizeof(priv->nonce));
 1211|     30|	if (r < 0)
  ------------------
  |  Branch (1211:6): [True: 10, False: 20]
  ------------------
 1212|     10|		goto done;
 1213|       |
 1214|     20|	if ((size_t) r != priv->obj->length) {
  ------------------
  |  Branch (1214:6): [True: 0, False: 20]
  ------------------
 1215|      0|		priv->obj->length = r;
 1216|      0|	}
 1217|       |
 1218|       |
 1219|       |	/* OK we've read the data, now copy the required portion out to the callers buffer */
 1220|     20|	len = MIN(count, priv->obj->length-idx);
  ------------------
  |  |   69|     20|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 19, False: 1]
  |  |  ------------------
  ------------------
 1221|     20|	memcpy(buf, &data[idx], len);
 1222|     20|	r = (int)len;
 1223|       |	/* cache the data in the object */
 1224|     20|	priv->obj->data=data;
 1225|     20|	data = NULL;
 1226|       |
 1227|     30|done:
 1228|     30|	if (data)
  ------------------
  |  Branch (1228:6): [True: 10, False: 20]
  ------------------
 1229|     10|		free(data);
 1230|     30|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     30|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     30|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     30|	int _ret = r; \
  |  |  |  |  155|     30|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  156|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     10|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     20|	} else { \
  |  |  |  |  159|     20|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     20|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     20|	} \
  |  |  |  |  162|     30|	return _ret; \
  |  |  |  |  163|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1231|     30|}
card-coolkey.c:coolkey_card_ctl:
 1582|  58.2k|{
 1583|  58.2k|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|  58.2k|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1584|       |
 1585|  58.2k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  58.2k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  58.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  58.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  58.2k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 58.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1586|  58.2k|	sc_log(card->ctx, "cmd=%ld ptr=%p", cmd, ptr);
  ------------------
  |  |   71|  58.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1587|       |
 1588|  58.2k|	if (priv == NULL) {
  ------------------
  |  Branch (1588:6): [True: 0, False: 58.2k]
  ------------------
 1589|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1590|      0|	}
 1591|  58.2k|	switch(cmd) {
  ------------------
  |  Branch (1591:9): [True: 57.5k, False: 713]
  ------------------
 1592|      1|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1592:3): [True: 1, False: 58.2k]
  ------------------
 1593|      1|			return coolkey_get_serial_nr_from_CUID(card, (sc_serial_number_t *) ptr);
 1594|    706|		case SC_CARDCTL_COOLKEY_GET_TOKEN_INFO:
  ------------------
  |  Branch (1594:3): [True: 706, False: 57.5k]
  ------------------
 1595|    706|			return coolkey_get_token_info(card, (sc_pkcs15_tokeninfo_t *) ptr);
 1596|  2.54k|		case SC_CARDCTL_COOLKEY_FIND_OBJECT:
  ------------------
  |  Branch (1596:3): [True: 2.54k, False: 55.6k]
  ------------------
 1597|  2.54k|			return coolkey_find_object(card, (sc_cardctl_coolkey_find_object_t *)ptr);
 1598|    706|		case SC_CARDCTL_COOLKEY_INIT_GET_OBJECTS:
  ------------------
  |  Branch (1598:3): [True: 706, False: 57.5k]
  ------------------
 1599|    706|			return coolkey_get_init_and_get_count(&priv->objects_list, (int *)ptr);
 1600|  5.20k|		case SC_CARDCTL_COOLKEY_GET_NEXT_OBJECT:
  ------------------
  |  Branch (1600:3): [True: 5.20k, False: 53.0k]
  ------------------
 1601|  5.20k|			return coolkey_fetch_object(&priv->objects_list, (sc_cardctl_coolkey_object_t *)ptr);
 1602|    706|		case SC_CARDCTL_COOLKEY_FINAL_GET_OBJECTS:
  ------------------
  |  Branch (1602:3): [True: 706, False: 57.5k]
  ------------------
 1603|    706|			return coolkey_final_iterator(&priv->objects_list);
 1604|  47.6k|		case SC_CARDCTL_COOLKEY_GET_ATTRIBUTE:
  ------------------
  |  Branch (1604:3): [True: 47.6k, False: 10.5k]
  ------------------
 1605|  47.6k|			return coolkey_find_attribute(card,(sc_cardctl_coolkey_attribute_t *)ptr);
 1606|  58.2k|	}
 1607|       |
 1608|    713|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    713|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    713|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    713|	int _ret = r; \
  |  |  |  |  155|    713|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 713, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    713|		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|    713|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 713, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    713|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    713|	} 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|    713|	return _ret; \
  |  |  |  |  163|    713|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1609|    713|}
card-coolkey.c:coolkey_get_serial_nr_from_CUID:
 1354|      1|{
 1355|      1|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|      1|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1356|       |
 1357|      1|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      1|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      1|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      1|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      1|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1358|      1|	memcpy(serial->value, &priv->cuid, sizeof(priv->cuid));
 1359|      1|	serial->len = sizeof(priv->cuid);
 1360|      1|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1361|      1|}
card-coolkey.c:coolkey_get_token_info:
 1327|    706|{
 1328|    706|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|    706|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1329|    706|	char *label = NULL;
 1330|    706|	char *manufacturer_id = NULL;
 1331|    706|	char *serial_number = NULL;
 1332|       |
 1333|    706|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    706|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    706|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    706|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    706|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 706]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1334|    706|	label = strdup((char *)priv->token_name);
 1335|    706|	manufacturer_id = coolkey_get_manufacturer(&priv->cuid);
 1336|    706|	serial_number = coolkey_cuid_to_string(&priv->cuid);
 1337|       |
 1338|    706|	if (label && manufacturer_id && serial_number) {
  ------------------
  |  Branch (1338:6): [True: 706, False: 0]
  |  Branch (1338:15): [True: 706, False: 0]
  |  Branch (1338:34): [True: 706, False: 0]
  ------------------
 1339|    706|		free(token_info->label);
 1340|    706|		token_info->label = label;
 1341|    706|		free(token_info->manufacturer_id);
 1342|    706|		token_info->manufacturer_id = manufacturer_id;
 1343|    706|		free(token_info->serial_number);
 1344|    706|		token_info->serial_number = serial_number;
 1345|    706|		return SC_SUCCESS;
  ------------------
  |  |   28|    706|#define SC_SUCCESS				0
  ------------------
 1346|    706|	}
 1347|      0|	free(label);
 1348|      0|	free(manufacturer_id);
 1349|      0|	free(serial_number);
 1350|      0|	return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1351|    706|}
card-coolkey.c:coolkey_get_manufacturer:
 1298|    706|{
 1299|    706|	unsigned short fabricator = bebytes2ushort(cuid->ic_fabricator);
 1300|    706|	int i;
 1301|    706|	char *buf;
 1302|    706|	const char *manufacturer_string = "%04x Unknown";
 1303|    706|	size_t len;
 1304|    706|	int r;
 1305|       |
 1306|  4.22k|	for (i=0; i < manufacturer_list_count; i++) {
  ------------------
  |  Branch (1306:12): [True: 3.52k, False: 704]
  ------------------
 1307|  3.52k|		if (manufacturer_list[i].id == fabricator) {
  ------------------
  |  Branch (1307:7): [True: 2, False: 3.52k]
  ------------------
 1308|      2|			manufacturer_string = manufacturer_list[i].string;
 1309|      2|			break;
 1310|      2|		}
 1311|  3.52k|	}
 1312|    706|	len = strlen(manufacturer_string)+1;
 1313|    706|	buf= malloc(len);
 1314|    706|	if (buf == NULL) {
  ------------------
  |  Branch (1314:6): [True: 0, False: 706]
  ------------------
 1315|      0|		return NULL;
 1316|      0|	}
 1317|    706|	r = snprintf(buf, len, manufacturer_string, fabricator);
 1318|    706|	if (r < 0) {
  ------------------
  |  Branch (1318:6): [True: 0, False: 706]
  ------------------
 1319|      0|		free(buf);
 1320|      0|		return NULL;
 1321|      0|	}
 1322|    706|	return buf;
 1323|    706|}
card-coolkey.c:coolkey_cuid_to_string:
 1273|    706|{
 1274|    706|	char *buf;
 1275|    706|	size_t len = sizeof(coolkey_cuid_t)*2 + 1;
 1276|    706|	buf = malloc(len);
 1277|    706|	if (buf == NULL) {
  ------------------
  |  Branch (1277:6): [True: 0, False: 706]
  ------------------
 1278|      0|		return NULL;
 1279|      0|	}
 1280|    706|	sc_bin_to_hex((u8 *)cuid, sizeof(*cuid), buf, len, 0);
 1281|    706|	return buf;
 1282|    706|}
card-coolkey.c:coolkey_find_object:
 1553|  2.54k|{
 1554|  2.54k|	sc_cardctl_coolkey_object_t *obj = NULL;
 1555|  2.54k|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|  2.54k|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1556|  2.54k|	int r;
 1557|       |
 1558|  2.54k|	switch (fobj->type) {
 1559|    667|	case SC_CARDCTL_COOLKEY_FIND_BY_ID:
  ------------------
  |  | 1079|    667|#define SC_CARDCTL_COOLKEY_FIND_BY_ID       0
  ------------------
  |  Branch (1559:2): [True: 667, False: 1.87k]
  ------------------
 1560|    667|		obj = coolkey_find_object_by_id(&priv->objects_list, fobj->find_id);
 1561|    667|		break;
 1562|  1.87k|	case SC_CARDCTL_COOLKEY_FIND_BY_TEMPLATE:
  ------------------
  |  | 1080|  1.87k|#define SC_CARDCTL_COOLKEY_FIND_BY_TEMPLATE 1
  ------------------
  |  Branch (1562:2): [True: 1.87k, False: 667]
  ------------------
 1563|  1.87k|		obj = coolkey_find_object_by_template(card, fobj->coolkey_template, fobj->template_count);
 1564|  1.87k|		break;
 1565|      0|	default:
  ------------------
  |  Branch (1565:2): [True: 0, False: 2.54k]
  ------------------
 1566|      0|		break;
 1567|  2.54k|	}
 1568|  2.54k|	if (obj == NULL) {
  ------------------
  |  Branch (1568:6): [True: 1.38k, False: 1.16k]
  ------------------
 1569|  1.38k|		return SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|  1.38k|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
 1570|  1.38k|	}
 1571|  1.16k|	if (obj->data == NULL) {
  ------------------
  |  Branch (1571:6): [True: 41, False: 1.12k]
  ------------------
 1572|     41|		r = coolkey_fill_object(card, obj);
 1573|     41|		if (r < 0) {
  ------------------
  |  Branch (1573:7): [True: 22, False: 19]
  ------------------
 1574|     22|			return r;
 1575|     22|		}
 1576|     41|	}
 1577|  1.13k|	fobj->obj = obj;
 1578|  1.13k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.13k|#define SC_SUCCESS				0
  ------------------
 1579|  1.16k|}
card-coolkey.c:coolkey_get_init_and_get_count:
 1246|    706|{
 1247|    706|	*countp = list_size(list);
 1248|    706|	list_iterator_start(list);
 1249|    706|	return SC_SUCCESS;
  ------------------
  |  |   28|    706|#define SC_SUCCESS				0
  ------------------
 1250|    706|}
card-coolkey.c:coolkey_fetch_object:
 1254|  5.20k|{
 1255|  5.20k|	sc_cardctl_coolkey_object_t *ptr;
 1256|  5.20k|	if (!list_iterator_hasnext(list)) {
  ------------------
  |  Branch (1256:6): [True: 0, False: 5.20k]
  ------------------
 1257|      0|		return SC_ERROR_FILE_END_REACHED;
  ------------------
  |  |   69|      0|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
 1258|      0|	}
 1259|       |
 1260|  5.20k|	ptr = list_iterator_next(list);
 1261|  5.20k|	*coolkey_obj = *ptr;
 1262|  5.20k|	return SC_SUCCESS;
  ------------------
  |  |   28|  5.20k|#define SC_SUCCESS				0
  ------------------
 1263|  5.20k|}
card-coolkey.c:coolkey_final_iterator:
 1267|    706|{
 1268|    706|	list_iterator_stop(list);
 1269|    706|	return SC_SUCCESS;
  ------------------
  |  |   28|    706|#define SC_SUCCESS				0
  ------------------
 1270|    706|}
card-coolkey.c:coolkey_check_sw:
  877|  53.7k|{
  878|  53.7k|	sc_log(card->ctx,
  ------------------
  |  |   71|  53.7k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  879|  53.7k|		"sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
  880|       |
  881|  53.7k|	if (sw1 == 0x90 && sw2 == 0x00)
  ------------------
  |  Branch (881:6): [True: 21.5k, False: 32.2k]
  |  Branch (881:21): [True: 20.4k, False: 1.02k]
  ------------------
  882|  20.4k|		return SC_SUCCESS;
  ------------------
  |  |   28|  20.4k|#define SC_SUCCESS				0
  ------------------
  883|       |
  884|  33.2k|	if (sw1 == 0x9c) {
  ------------------
  |  Branch (884:6): [True: 80, False: 33.1k]
  ------------------
  885|     80|		if (sw2 == 0xff) {
  ------------------
  |  Branch (885:7): [True: 13, False: 67]
  ------------------
  886|       |			/* shouldn't happen on a production applet, 0x9cff is a debugging error code */
  887|     13|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     13|#define SC_ERROR_INTERNAL			-1400
  ------------------
  888|     13|		}
  889|     67|		if (sw2 >= coolkey_number_of_error_codes) {
  ------------------
  |  Branch (889:7): [True: 30, False: 37]
  ------------------
  890|     30|			return SC_ERROR_UNKNOWN;
  ------------------
  |  |  130|     30|#define SC_ERROR_UNKNOWN			-1900
  ------------------
  891|     30|		}
  892|     37|		return coolkey_error_codes[sw2].sc_error;
  893|     67|	}
  894|       |
  895|       |	/* iso error */
  896|  33.1k|        return sc_get_iso7816_driver()->ops->check_sw(card, sw1, sw2);
  897|  33.2k|}
card-coolkey.c:coolkey_pin_cmd:
 2351|    201|{
 2352|    201|	int r;
 2353|    201|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  754|    201|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 2354|    201|	size_t rbuflen;
 2355|    201|	u8 *rbuf;
 2356|       |
 2357|       |	/* COOLKEY uses a separate pin from the card pin, managed by the applet.
 2358|       |	 * if we successfully log into coolkey, we will get a nonce, which we append
 2359|       |	 * to our APDUs to authenticate the apdu to the card. This allows coolkey to
 2360|       |	 * maintain separate per application login states without the application
 2361|       |	 * having to cache the pin */
 2362|    201|	switch (data->cmd) {
 2363|    193|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  418|    193|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (2363:2): [True: 193, False: 8]
  ------------------
 2364|    193|		if (priv->nonce_valid) {
  ------------------
  |  Branch (2364:7): [True: 0, False: 193]
  ------------------
 2365|      0|			data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  432|      0|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
 2366|    193|		} else {
 2367|    193|			data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  431|    193|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 2368|       |			/* coolkey retries is 100. It's unlikely the pin is block.
 2369|       |			 * instead, coolkey slows down the login command exponentially
 2370|       |			 */
 2371|    193|			data->pin1.tries_left = 0xf;
 2372|    193|		}
 2373|    193|		r = SC_SUCCESS;
  ------------------
  |  |   28|    193|#define SC_SUCCESS				0
  ------------------
 2374|    193|		break;
 2375|       |
 2376|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2376:2): [True: 0, False: 201]
  ------------------
 2377|      3|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      3|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (2377:2): [True: 3, False: 198]
  ------------------
 2378|       |		/* these 2 commands are currently reserved for TPS */
 2379|      3|	default:
  ------------------
  |  Branch (2379:2): [True: 0, False: 201]
  ------------------
 2380|      3|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      3|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2381|      3|		break;
 2382|      5|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|      5|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (2382:2): [True: 5, False: 196]
  ------------------
 2383|       |		/* coolkey applet supports multiple pins, but TPS currently only uses one.
 2384|       |		 * just support the one pin for now (we need an array of nonces to handle
 2385|       |		 * multiple pins) */
 2386|       |		/* coolkey only supports unpadded ascii pins, so no need to format the pin */
 2387|      5|		rbuflen = sizeof(priv->nonce);
 2388|      5|		rbuf = &priv->nonce[0];
 2389|      5|		r = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_VERIFY_PIN,
  ------------------
  |  |   73|      5|#define COOLKEY_CLASS           0xb0
  ------------------
              		r = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_VERIFY_PIN,
  ------------------
  |  |   81|      5|#define COOLKEY_INS_VERIFY_PIN                 0x42
  ------------------
 2390|      5|			data->pin_reference, 0, data->pin1.data, data->pin1.len,
 2391|      5|			&rbuf, &rbuflen, NULL, 0);
 2392|      5|		if (r < 0) {
  ------------------
  |  Branch (2392:7): [True: 4, False: 1]
  ------------------
 2393|      4|			break;
 2394|      4|		}
 2395|      1|		priv->nonce_valid = 1;
 2396|      1|		r = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 2397|    201|	}
 2398|    201|	return r;
 2399|    201|}
card-coolkey.c:coolkey_card_reader_lock_obtained:
 2420|  25.2k|{
 2421|  25.2k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  25.2k|#define SC_SUCCESS				0
  ------------------
 2422|       |
 2423|  25.2k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  25.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  25.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  25.2k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 25.2k]
  |  |  ------------------
  ------------------
 2424|       |
 2425|  25.2k|	if (was_reset > 0) {
  ------------------
  |  Branch (2425:6): [True: 0, False: 25.2k]
  ------------------
 2426|      0|		r = coolkey_select_applet(card);
 2427|      0|	}
 2428|       |
 2429|  25.2k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  25.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  25.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  25.2k|	int _ret = r; \
  |  |  |  |  155|  25.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 25.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  25.2k|		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: 25.2k]
  |  |  |  |  ------------------
  |  |  |  |  157|  25.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  25.2k|	} 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|  25.2k|	return _ret; \
  |  |  |  |  163|  25.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2430|  25.2k|}

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

dnie_match_card:
  738|  23.5k|{
  739|  23.5k|	int result = 0;
  740|  23.5k|	int matched = -1;
  741|  23.5k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  23.5k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  23.5k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  23.5k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  23.5k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 23.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|  23.5k|	matched = _sc_match_atr(card, dnie_atrs, &card->type);
  743|  23.5k|	result = (matched >= 0) ? 1 : 0;
  ------------------
  |  Branch (743:11): [True: 2.11k, False: 21.4k]
  ------------------
  744|  23.5k|	LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  164|  23.5k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  23.5k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  23.5k|	int _ret = r; \
  |  |  |  |  155|  23.5k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21.4k, False: 2.11k]
  |  |  |  |  ------------------
  |  |  |  |  156|  21.4k|		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: 21.4k]
  |  |  |  |  ------------------
  |  |  |  |  157|  21.4k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  21.4k|	} else { \
  |  |  |  |  159|  2.11k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  2.11k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  2.11k|	} \
  |  |  |  |  162|  23.5k|	return _ret; \
  |  |  |  |  163|  23.5k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  745|  23.5k|}
sc_get_dnie_driver:
 2301|  17.0k|{
 2302|  17.0k|	return get_dnie_driver();
 2303|  17.0k|}
card-dnie.c:get_dnie_driver:
 2238|  17.0k|{
 2239|  17.0k|	sc_card_driver_t *iso_drv = sc_get_iso7816_driver();
 2240|       |
 2241|       |	/* memcpy() from standard iso7816 declared operations */
 2242|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2242:6): [True: 1, False: 17.0k]
  ------------------
 2243|      1|		iso_ops = iso_drv->ops;
 2244|  17.0k|	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|  17.0k|	dnie_ops.match_card	= dnie_match_card;
 2252|  17.0k|	dnie_ops.init		= dnie_init;
 2253|  17.0k|	dnie_ops.finish		= dnie_finish;
 2254|       |
 2255|       |	/* iso7816-4 functions */
 2256|  17.0k|	dnie_ops.read_binary	= dnie_read_binary;
 2257|  17.0k|	dnie_ops.write_binary	= NULL;
 2258|  17.0k|	dnie_ops.update_binary	= NULL;
 2259|  17.0k|	dnie_ops.erase_binary	= NULL;
 2260|  17.0k|	dnie_ops.read_record	= NULL;
 2261|  17.0k|	dnie_ops.write_record	= NULL;
 2262|  17.0k|	dnie_ops.append_record	= NULL;
 2263|  17.0k|	dnie_ops.update_record	= NULL;
 2264|  17.0k|	dnie_ops.select_file	= dnie_select_file;
 2265|  17.0k|	dnie_ops.get_challenge	= dnie_get_challenge;
 2266|       |
 2267|       |	/* iso7816-8 functions */
 2268|  17.0k|	dnie_ops.verify		= NULL;
 2269|  17.0k|	dnie_ops.logout		= dnie_logout;
 2270|       |	/* dnie_ops.restore_security_env */
 2271|  17.0k|	dnie_ops.set_security_env = dnie_set_security_env;
 2272|  17.0k|	dnie_ops.decipher	= dnie_decipher;
 2273|  17.0k|	dnie_ops.compute_signature = dnie_compute_signature;
 2274|  17.0k|	dnie_ops.change_reference_data = NULL;
 2275|  17.0k|	dnie_ops.reset_retry_counter = NULL;
 2276|       |
 2277|       |	/* iso7816-9 functions */
 2278|  17.0k|	dnie_ops.create_file	= NULL;
 2279|  17.0k|	dnie_ops.delete_file	= NULL;
 2280|  17.0k|	dnie_ops.list_files	= dnie_list_files;
 2281|  17.0k|	dnie_ops.check_sw	= dnie_check_sw;
 2282|  17.0k|	dnie_ops.card_ctl	= dnie_card_ctl;
 2283|  17.0k|	dnie_ops.process_fci	= dnie_process_fci;
 2284|       |	/* dnie_ops.construct_fci */
 2285|  17.0k|	dnie_ops.pin_cmd	= dnie_pin_cmd;
 2286|  17.0k|	dnie_ops.get_data	= NULL;
 2287|  17.0k|	dnie_ops.put_data	= NULL;
 2288|  17.0k|	dnie_ops.delete_record	= NULL;
 2289|       |
 2290|  17.0k|	return &dnie_driver;
 2291|  17.0k|}
card-dnie.c:dnie_init:
  829|    627|{
  830|    627|	int res = SC_SUCCESS;
  ------------------
  |  |   28|    627|#define SC_SUCCESS				0
  ------------------
  831|    627|	sc_context_t *ctx = card->ctx;
  832|    627|	cwa_provider_t *provider = NULL;
  833|       |
  834|    627|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    627|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    627|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    627|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    627|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 627]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  835|       |
  836|       |	/* if recognized as terminated DNIe card, return error */
  837|    627|	if (card->type == SC_CARD_TYPE_DNIE_TERMINATED)
  ------------------
  |  Branch (837:6): [True: 5, False: 622]
  ------------------
  838|    627|	    LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_CARD, "DNIe card is terminated.");
  ------------------
  |  |  174|      5|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      5|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      5|	int _ret = (r); \
  |  |  |  |  168|      5|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      5|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      5|		return _ret; \
  |  |  |  |  172|      5|	} \
  |  |  |  |  173|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  839|       |
  840|       |	/* create and initialize cwa-dnie provider*/
  841|    622|	provider = dnie_get_cwa_provider(card);
  842|    622|	if (!provider)
  ------------------
  |  Branch (842:6): [True: 0, False: 622]
  ------------------
  843|    622|	    LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "Error initializing cwa-dnie provider");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  844|       |
  845|       |	/** Secure messaging initialization section **/
  846|    622|	memset(&(card->sm_ctx), 0, sizeof(sm_context_t));
  847|    622|	card->sm_ctx.ops.get_sm_apdu = dnie_sm_get_wrapped_apdu;
  848|    622|	card->sm_ctx.ops.free_sm_apdu = dnie_sm_free_wrapped_apdu;
  849|    622|	card->sm_ctx.sm_mode = SM_MODE_NONE;
  ------------------
  |  |   43|    622|#define SM_MODE_NONE		0x0
  ------------------
  850|       |
  851|    622|	res = cwa_create_secure_channel(card, provider, CWA_SM_OFF);
  ------------------
  |  |   31|    622|#define CWA_SM_OFF        0x00	/** Disable SM channel */
  ------------------
  852|    622|	if (res < 0)
  ------------------
  |  Branch (852:6): [True: 27, False: 595]
  ------------------
  853|     27|		free(provider);
  854|    622|	LOG_TEST_RET(card->ctx, res, "Failure resetting CWA secure channel.");
  ------------------
  |  |  174|    622|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    622|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    622|	int _ret = (r); \
  |  |  |  |  168|    622|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 27, False: 595]
  |  |  |  |  ------------------
  |  |  |  |  169|     27|		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|     27|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     27|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     27|		return _ret; \
  |  |  |  |  172|     27|	} \
  |  |  |  |  173|    622|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 595]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  855|       |
  856|       |	/* initialize private data */
  857|    595|	card->drv_data = calloc(1, sizeof(dnie_private_data_t));
  858|    595|	if (card->drv_data == NULL) {
  ------------------
  |  Branch (858:6): [True: 0, False: 595]
  ------------------
  859|      0|		free(provider);
  860|      0|	    LOG_TEST_RET(card->ctx, SC_ERROR_OUT_OF_MEMORY, "Could not allocate DNIe private data.");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  861|      0|	}
  862|       |
  863|       |#ifdef ENABLE_DNIE_UI
  864|       |	/* read environment from configuration file */
  865|       |	res = dnie_get_environment(card, &(GET_DNIE_UI_CTX(card)));
  866|       |	if (res != SC_SUCCESS) {
  867|       |		free(card->drv_data);
  868|       |		free(provider);
  869|       |		LOG_TEST_RET(card->ctx, res, "Failure reading DNIe environment.");
  870|       |	}
  871|       |#endif
  872|       |
  873|    595|	init_flags(card);
  874|       |
  875|    595|	GET_DNIE_PRIV_DATA(card)->cwa_provider = provider;
  ------------------
  |  |   97|    595|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
  876|       |
  877|    595|	LOG_FUNC_RETURN(card->ctx, res);
  ------------------
  |  |  164|    595|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    595|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    595|	int _ret = r; \
  |  |  |  |  155|    595|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 595, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    595|		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: 595]
  |  |  |  |  ------------------
  |  |  |  |  157|    595|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    595|	} 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|    595|	return _ret; \
  |  |  |  |  163|    595|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  878|    595|}
card-dnie.c:init_flags:
  705|    595|{
  706|    595|	unsigned long algoflags;
  707|       |	/* set up flags according documentation */
  708|    595|	card->name = DNIE_CHIP_SHORTNAME;
  ------------------
  |  |   68|    595|#define DNIE_CHIP_SHORTNAME "dnie"
  ------------------
  709|    595|	card->cla = 0x00;	/* default APDU class (interindustry) */
  710|    595|	card->caps |= SC_CARD_CAP_RNG;	/* we have a random number generator */
  ------------------
  |  |  550|    595|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  711|    595|	card->max_send_size = (255 - 12);	/* manual says 255, but we need 12 extra bytes when encoding */
  712|    595|	card->max_recv_size = 255;
  713|       |
  714|       |	/* RSA Support with PKCS1.5 padding */
  715|    595|	algoflags = SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  133|    595|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              	algoflags = SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|    595|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    595|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    595|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  716|    595|	_sc_card_add_rsa_alg(card, 1024, algoflags, 0);
  717|    595|	_sc_card_add_rsa_alg(card, 1920, algoflags, 0);
  718|    595|	_sc_card_add_rsa_alg(card, 2048, algoflags, 0);
  719|    595|}
card-dnie.c:dnie_finish:
  890|    595|{
  891|    595|	int result = SC_SUCCESS;
  ------------------
  |  |   28|    595|#define SC_SUCCESS				0
  ------------------
  892|    595|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    595|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    595|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    595|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    595|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 595]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  893|    595|	dnie_clear_cache(GET_DNIE_PRIV_DATA(card));
  ------------------
  |  |   97|    595|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
  894|       |	/* disable sm channel if established */
  895|    595|	result = cwa_create_secure_channel(card, GET_DNIE_PRIV_DATA(card)->cwa_provider, CWA_SM_OFF);
  ------------------
  |  |   97|    595|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
              	result = cwa_create_secure_channel(card, GET_DNIE_PRIV_DATA(card)->cwa_provider, CWA_SM_OFF);
  ------------------
  |  |   31|    595|#define CWA_SM_OFF        0x00	/** Disable SM channel */
  ------------------
  896|    595|	free(GET_DNIE_PRIV_DATA(card)->cwa_provider);
  ------------------
  |  |   97|    595|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
  897|    595|	free(card->drv_data);
  898|    595|	LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  164|    595|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    595|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    595|	int _ret = r; \
  |  |  |  |  155|    595|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 595, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    595|		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|    585|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 585, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  157|    595|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    595|	} 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|    595|	return _ret; \
  |  |  |  |  163|    595|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  899|    595|}
card-dnie.c:dnie_clear_cache:
  689|  6.15k|{
  690|  6.15k|	if (data == NULL) return;
  ------------------
  |  Branch (690:6): [True: 565, False: 5.59k]
  ------------------
  691|  5.59k|	if (data->cache != NULL)
  ------------------
  |  Branch (691:6): [True: 322, False: 5.27k]
  ------------------
  692|    322|		free(data->cache);
  693|       |	data->cache = NULL;
  694|  5.59k|	data->cachelen = 0;
  695|  5.59k|}
card-dnie.c:dnie_read_binary:
 1091|  5.18k|{
 1092|  5.18k|	size_t res = 0;
 1093|  5.18k|	int rc;
 1094|  5.18k|	sc_context_t *ctx = NULL;
 1095|       |	/* preliminary checks */
 1096|  5.18k|	if (!card || !card->ctx || !buf || (count <= 0))
  ------------------
  |  Branch (1096:6): [True: 0, False: 5.18k]
  |  Branch (1096:15): [True: 0, False: 5.18k]
  |  Branch (1096:29): [True: 0, False: 5.18k]
  |  Branch (1096:37): [True: 0, False: 5.18k]
  ------------------
 1097|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1098|  5.18k|	ctx = card->ctx;
 1099|       |
 1100|  5.18k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  5.18k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.18k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.18k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.18k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.18k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1101|  5.18k|	if (idx == 0 || GET_DNIE_PRIV_DATA(card)->cache == NULL) {
  ------------------
  |  |   97|  4.78k|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
  |  Branch (1101:6): [True: 392, False: 4.78k]
  |  Branch (1101:18): [True: 2.85k, False: 1.93k]
  ------------------
 1102|       |		/* on first block or no cache, try to fill */
 1103|  3.25k|		rc = dnie_fill_cache(card, flags);
 1104|  3.25k|		if (rc < 0) {
  ------------------
  |  Branch (1104:7): [True: 2.92k, False: 328]
  ------------------
 1105|  2.92k|			sc_log(ctx, "Cannot fill cache. using iso_read_binary()");
  ------------------
  |  |   71|  2.92k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1106|  2.92k|			return iso_ops->read_binary(card, idx, buf, count, flags);
 1107|  2.92k|		}
 1108|  3.25k|	}
 1109|  2.25k|	if (idx >= GET_DNIE_PRIV_DATA(card)->cachelen)
  ------------------
  |  |   97|  2.25k|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
  |  Branch (1109:6): [True: 295, False: 1.96k]
  ------------------
 1110|    295|		return 0;	/* at eof */
 1111|  1.96k|	res = MIN(count, GET_DNIE_PRIV_DATA(card)->cachelen - idx);	/* eval how many bytes to read */
  ------------------
  |  |   69|  1.96k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 1.69k, False: 270]
  |  |  ------------------
  ------------------
 1112|  1.96k|	memcpy(buf, GET_DNIE_PRIV_DATA(card)->cache + idx, res);	/* copy data from buffer */
  ------------------
  |  |   97|  1.96k|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
 1113|  1.96k|	sc_log(ctx, "dnie_read_binary() '%zu' bytes", res);
  ------------------
  |  |   71|  1.96k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1114|  1.96k|	LOG_FUNC_RETURN(ctx, (int)res);
  ------------------
  |  |  164|  1.96k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.96k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.96k|	int _ret = r; \
  |  |  |  |  155|  1.96k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 1.96k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.96k|	} else { \
  |  |  |  |  159|  1.96k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.96k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.96k|	} \
  |  |  |  |  162|  1.96k|	return _ret; \
  |  |  |  |  163|  1.96k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1115|  1.96k|}
card-dnie.c:dnie_fill_cache:
  966|  3.25k|{
  967|  3.25k|	u8 tmp[MAX_RESP_BUFFER_SIZE];
  968|  3.25k|	sc_apdu_t apdu;
  969|  3.25k|	size_t count = 0;
  970|  3.25k|	size_t len = 0;
  971|  3.25k|	u8 *buffer = NULL;
  972|  3.25k|	u8 *p;
  973|  3.25k|	sc_context_t *ctx = NULL;
  974|       |
  975|  3.25k|	if (!card || !card->ctx)
  ------------------
  |  Branch (975:6): [True: 0, False: 3.25k]
  |  Branch (975:15): [True: 0, False: 3.25k]
  ------------------
  976|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  977|  3.25k|	ctx = card->ctx;
  978|       |
  979|  3.25k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.25k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.25k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.25k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.25k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  980|       |
  981|       |	/* mark cache empty */
  982|  3.25k|	dnie_clear_cache(GET_DNIE_PRIV_DATA(card));
  ------------------
  |  |   97|  3.25k|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
  983|       |
  984|       |	/* initialize apdu */
  985|  3.25k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, 0x00, 0x00);
  ------------------
  |  |  292|  3.25k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  986|       |
  987|       |	/* try to read_binary while data available but never long than 32767 */
  988|  3.25k|	count = card->max_recv_size;
  989|  4.98k|	for (len = 0; len < 0x7fff;) {
  ------------------
  |  Branch (989:16): [True: 4.98k, False: 1]
  ------------------
  990|  4.98k|		int r = SC_SUCCESS;
  ------------------
  |  |   28|  4.98k|#define SC_SUCCESS				0
  ------------------
  991|       |		/* fill apdu */
  992|  4.98k|		apdu.p1 = 0xff & (len >> 8);
  993|  4.98k|		apdu.p2 = 0xff & len;
  994|  4.98k|		apdu.le = count;
  995|  4.98k|		apdu.resplen = MAX_RESP_BUFFER_SIZE;
  ------------------
  |  |   56|  4.98k|#define MAX_RESP_BUFFER_SIZE 2048
  ------------------
  996|  4.98k|		apdu.resp = tmp;
  997|       |		/* transmit apdu */
  998|  4.98k|		r = sc_transmit_apdu(card, &apdu);
  999|  4.98k|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  4.98k|#define SC_SUCCESS				0
  ------------------
  |  Branch (999:7): [True: 899, False: 4.08k]
  ------------------
 1000|    899|			free(buffer);
 1001|    899|			if (apdu.resp != tmp)
  ------------------
  |  Branch (1001:8): [True: 0, False: 899]
  ------------------
 1002|      0|				free(apdu.resp);
 1003|    899|			sc_log(ctx, "read_binary() APDU transmit failed");
  ------------------
  |  |   71|    899|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1004|    899|			LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    899|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    899|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    899|	int _ret = r; \
  |  |  |  |  155|    899|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 899, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    899|		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|    899|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 899, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    899|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    899|	} 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|    899|	return _ret; \
  |  |  |  |  163|    899|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1005|    899|		}
 1006|  4.08k|		if (apdu.resplen == 0) {
  ------------------
  |  Branch (1006:7): [True: 2.09k, False: 1.98k]
  ------------------
 1007|       |			/* on no data received, check if requested len is longer than
 1008|       |			   available data in card. If so, ask just for remaining data */
 1009|  2.09k|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1010|  2.09k|			if (r == SC_ERROR_WRONG_LENGTH) {
  ------------------
  |  |   56|  2.09k|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  |  Branch (1010:8): [True: 74, False: 2.02k]
  ------------------
 1011|     74|				count = 0xff & apdu.sw2;
 1012|     74|				if (count != 0) {
  ------------------
  |  Branch (1012:9): [True: 70, False: 4]
  ------------------
 1013|     70|					if (apdu.resp != tmp)
  ------------------
  |  Branch (1013:10): [True: 0, False: 70]
  ------------------
 1014|      0|						free(apdu.resp);
 1015|     70|					continue;	/* read again with correct size */
 1016|     70|				}
 1017|      4|				goto read_done;	/* no more data to read */
 1018|     74|			}
 1019|  2.02k|			if (r == SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   55|  2.02k|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (1019:8): [True: 1, False: 2.02k]
  ------------------
 1020|      1|				goto read_done;
 1021|  2.02k|			free(buffer);
 1022|  2.02k|			if (apdu.resp != tmp)
  ------------------
  |  Branch (1022:8): [True: 0, False: 2.02k]
  ------------------
 1023|      0|				free(apdu.resp);
 1024|  2.02k|			LOG_FUNC_RETURN(ctx, r);	/* arriving here means response error */
  ------------------
  |  |  164|  2.02k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.02k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.02k|	int _ret = r; \
  |  |  |  |  155|  2.02k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.02k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.02k|		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|  2.02k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.02k, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.02k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.02k|	} 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|  2.02k|	return _ret; \
  |  |  |  |  163|  2.02k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1025|  2.02k|		}
 1026|       |		/* copy received data into buffer. realloc() if not enough space */
 1027|  1.98k|		count = apdu.resplen;
 1028|  1.98k|		p = realloc(buffer, len + count);
 1029|  1.98k|		if (!p) {
  ------------------
  |  Branch (1029:7): [True: 0, False: 1.98k]
  ------------------
 1030|      0|			free(buffer);
 1031|      0|			free((void *)apdu.data);
 1032|      0|			if (apdu.resp != tmp)
  ------------------
  |  Branch (1032:8): [True: 0, False: 0]
  ------------------
 1033|      0|				free(apdu.resp);
 1034|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1035|      0|		}
 1036|  1.98k|		buffer = p;
 1037|  1.98k|		memcpy(buffer + len, apdu.resp, count);
 1038|  1.98k|		if (apdu.resp != tmp) {
  ------------------
  |  Branch (1038:7): [True: 0, False: 1.98k]
  ------------------
 1039|      0|			free(apdu.resp);
 1040|      0|			apdu.resp = tmp;
 1041|      0|		}
 1042|  1.98k|		len += count;
 1043|  1.98k|		if (count != card->max_recv_size)
  ------------------
  |  Branch (1043:7): [True: 321, False: 1.66k]
  ------------------
 1044|    321|			goto read_done;
 1045|  1.98k|	}
 1046|       |
 1047|    327| read_done:
 1048|    327| 	free((void *)apdu.data);
 1049|    327|	if (apdu.resp != tmp)
  ------------------
  |  Branch (1049:6): [True: 0, False: 327]
  ------------------
 1050|      0|		free(apdu.resp);
 1051|       |
 1052|    327|	if (dnie_is_compressed(card, buffer, len)) {
  ------------------
  |  Branch (1052:6): [True: 20, False: 307]
  ------------------
 1053|     20|		if (flags)
  ------------------
  |  Branch (1053:7): [True: 0, False: 20]
  ------------------
 1054|      0|			*flags |= SC_FILE_FLAG_COMPRESSED_ZLIB;
  ------------------
  |  |  231|      0|#define SC_FILE_FLAG_COMPRESSED_ZLIB		0x02
  ------------------
 1055|       |		/* Remove first 8 bytes with compression info*/
 1056|     20|		len -= 8;
 1057|     20|		p = malloc(len);
 1058|     20|		if (!p) {
  ------------------
  |  Branch (1058:7): [True: 0, False: 20]
  ------------------
 1059|      0|			free(buffer);
 1060|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1061|      0|		}
 1062|     20|		memcpy(p, buffer + 8, len);
 1063|     20|		free(buffer);
 1064|     20|		buffer = p;
 1065|     20|	}
 1066|       |
 1067|       |
 1068|       |	/* ok: as final step, set correct cache data into dnie_priv structures */
 1069|    327|	GET_DNIE_PRIV_DATA(card)->cache = buffer;
  ------------------
  |  |   97|    327|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
 1070|    327|	GET_DNIE_PRIV_DATA(card)->cachelen = len;
  ------------------
  |  |   97|    327|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
 1071|    327|	sc_log(ctx, "fill_cache() done. length '%zu' bytes", len);
  ------------------
  |  |   71|    327|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1072|    327|	LOG_FUNC_RETURN(ctx, (int)len);
  ------------------
  |  |  164|    327|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    327|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    327|	int _ret = r; \
  |  |  |  |  155|    327|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 25, False: 302]
  |  |  |  |  ------------------
  |  |  |  |  156|     25|		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: 25]
  |  |  |  |  ------------------
  |  |  |  |  157|     25|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    302|	} else { \
  |  |  |  |  159|    302|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    302|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    302|	} \
  |  |  |  |  162|    327|	return _ret; \
  |  |  |  |  163|    327|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1073|    327|}
card-dnie.c:dnie_is_compressed:
  913|    327|{
  914|    327|#ifdef ENABLE_ZLIB
  915|    327|	size_t uncompressed = 0L;
  916|    327|	size_t compressed = 0L;
  917|       |
  918|    327|	if (!card || !card->ctx || !from || !len)
  ------------------
  |  Branch (918:6): [True: 0, False: 327]
  |  Branch (918:15): [True: 0, False: 327]
  |  Branch (918:29): [True: 5, False: 322]
  |  Branch (918:38): [True: 0, False: 322]
  ------------------
  919|      5|		return 0;
  920|    322|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    322|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    322|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    322|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    322|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 322]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  921|       |
  922|       |	/* if data size not enough for compression header assume uncompressed */
  923|    322|	if (len < 8)
  ------------------
  |  Branch (923:6): [True: 18, False: 304]
  ------------------
  924|     18|		goto compress_exit;
  925|       |	/* evaluate compressed an uncompressed sizes (little endian format) */
  926|    304|	uncompressed = lebytes2ulong(from);
  927|    304|	compressed = lebytes2ulong(from + 4);
  928|       |	/* if compressed size doesn't match data length assume not compressed */
  929|    304|	if (compressed != len - 8)
  ------------------
  |  Branch (929:6): [True: 252, False: 52]
  ------------------
  930|    252|		goto compress_exit;
  931|       |	/* if compressed size greater than uncompressed, assume uncompressed data */
  932|     52|	if (uncompressed < compressed)
  ------------------
  |  Branch (932:6): [True: 1, False: 51]
  ------------------
  933|      1|		goto compress_exit;
  934|       |	/* Do not try to allocate insane size if we receive bogus data */
  935|     51|	if (uncompressed > MAX_FILE_SIZE)
  ------------------
  |  |  220|     51|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (935:6): [True: 31, False: 20]
  ------------------
  936|     31|		goto compress_exit;
  937|       |
  938|     20|	sc_log(card->ctx, "Data seems to be compressed.");
  ------------------
  |  |   71|     20|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  939|     20|	return 1;
  940|    302|compress_exit:
  941|    302|#endif
  942|       |
  943|    302|	sc_log(card->ctx, "Data not compressed.");
  ------------------
  |  |   71|    302|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  944|    302|	return 0;
  945|     51|}
card-dnie.c:dnie_select_file:
 1215|  5.06k|{
 1216|  5.06k|	int res = SC_SUCCESS;
  ------------------
  |  |   28|  5.06k|#define SC_SUCCESS				0
  ------------------
 1217|  5.06k|	sc_context_t *ctx = NULL;
 1218|  5.06k|	unsigned char tmp_path[sizeof(DNIE_MF_NAME)];
 1219|  5.06k|	size_t reminder = 0;
 1220|       |
 1221|  5.06k|	if (!card || !card->ctx || !in_path)
  ------------------
  |  Branch (1221:6): [True: 0, False: 5.06k]
  |  Branch (1221:15): [True: 0, False: 5.06k]
  |  Branch (1221:29): [True: 0, False: 5.06k]
  ------------------
 1222|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1223|  5.06k|	ctx = card->ctx;
 1224|       |
 1225|  5.06k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  5.06k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.06k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.06k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.06k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1226|       |
 1227|  5.06k|	switch (in_path->type) {
 1228|      9|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      9|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1228:2): [True: 9, False: 5.05k]
  ------------------
 1229|       |		/* pathlen must be of len=2 */
 1230|       |		/*
 1231|       |		 * gscriptor shows that DNIe also handles
 1232|       |		 * Select child DF (p1=1) and Select EF (p1=2),
 1233|       |		 * but we'll use P1=0 as general solution for all cases
 1234|       |		 *
 1235|       |		 * According iso7816-4 sect 7.1.1  pathlen==0 implies
 1236|       |		 * select MF, but this case is not supported by DNIe
 1237|       |		 */
 1238|      9|		if (in_path->len != 2)
  ------------------
  |  Branch (1238:7): [True: 0, False: 9]
  ------------------
 1239|      9|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1240|      9|		sc_log_hex(ctx, "select_file(ID)", in_path->value, in_path->len);
  ------------------
  |  |  129|      9|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|      9|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1241|      9|		res = dnie_compose_and_send_apdu(card, in_path->value, in_path->len, 0, file_out);
 1242|      9|		break;
 1243|  1.08k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  1.08k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1243:2): [True: 1.08k, False: 3.97k]
  ------------------
 1244|  1.08k|		sc_log_hex(ctx, "select_file(NAME)", in_path->value, in_path->len);
  ------------------
  |  |  129|  1.08k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  1.08k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1245|  1.08k|		res = dnie_compose_and_send_apdu(card, in_path->value, in_path->len, 4, file_out);
 1246|  1.08k|		break;
 1247|  3.96k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  3.96k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (1247:2): [True: 3.96k, False: 1.09k]
  ------------------
 1248|  3.96k|		if ((in_path->len == 0) || ((in_path->len & 1) != 0)) /* not divisible by 2 */
  ------------------
  |  Branch (1248:7): [True: 16, False: 3.94k]
  |  Branch (1248:30): [True: 0, False: 3.94k]
  ------------------
 1249|  3.96k|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     16|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     16|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     16|	int _ret = r; \
  |  |  |  |  155|     16|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     16|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     16|	} 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|     16|	return _ret; \
  |  |  |  |  163|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1250|       |
 1251|  3.94k|		sc_log_hex(ctx, "select_file(PATH): requested", in_path->value, in_path->len);
  ------------------
  |  |  129|  3.94k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  3.94k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1252|       |
 1253|       |		/* convert to SC_PATH_TYPE_FILE_ID */
 1254|  3.94k|		res = sc_lock(card); /* lock to ensure path traversal */
 1255|  3.94k|		LOG_TEST_RET(ctx, res, "sc_lock() failed");
  ------------------
  |  |  174|  3.94k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.94k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.94k|	int _ret = (r); \
  |  |  |  |  168|  3.94k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.94k]
  |  |  |  |  ------------------
  |  |  |  |  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|  3.94k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.94k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1256|  3.94k|		if (memcmp(in_path->value, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (1256:7): [True: 3.51k, False: 431]
  ------------------
 1257|       |			/* if MF, use the name as path */
 1258|  3.51k|			strcpy((char *)tmp_path, DNIE_MF_NAME);
  ------------------
  |  |   69|  3.51k|#define DNIE_MF_NAME "Master.File"
  ------------------
 1259|  3.51k|			sc_log_hex(ctx, "select_file(NAME): requested", tmp_path, sizeof(DNIE_MF_NAME) - 1);
  ------------------
  |  |  129|  3.51k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  3.51k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1260|  3.51k|			res = dnie_compose_and_send_apdu(card, tmp_path, sizeof(DNIE_MF_NAME) - 1, 4, file_out);
  ------------------
  |  |   69|  3.51k|#define DNIE_MF_NAME "Master.File"
  ------------------
 1261|  3.51k|			if (res != SC_SUCCESS) {
  ------------------
  |  |   28|  3.51k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1261:8): [True: 2.45k, False: 1.05k]
  ------------------
 1262|  2.45k|				sc_unlock(card);
 1263|  2.45k|				LOG_TEST_RET(ctx, res, "select_file(NAME) failed");
  ------------------
  |  |  174|  2.45k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.45k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.45k|	int _ret = (r); \
  |  |  |  |  168|  2.45k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.45k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.45k|		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.45k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.45k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.45k|		return _ret; \
  |  |  |  |  172|  2.45k|	} \
  |  |  |  |  173|  2.45k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1264|  2.45k|			}
 1265|  1.05k|			tmp_path[2] = 0;
 1266|  1.05k|			reminder = in_path->len - 2;
 1267|  1.05k|		} else {
 1268|    431|			tmp_path[2] = 0;
 1269|    431|			reminder = in_path->len;
 1270|    431|		}
 1271|  2.43k|		while (reminder > 0) {
  ------------------
  |  Branch (1271:10): [True: 1.21k, False: 1.21k]
  ------------------
 1272|  1.21k|			tmp_path[0] = in_path->value[in_path->len - reminder];
 1273|  1.21k|			tmp_path[1] = in_path->value[1 + in_path->len - reminder];
 1274|  1.21k|			sc_log(ctx, "select_file(PATH): requested:%s ", sc_dump_hex(tmp_path, 2));
  ------------------
  |  |   71|  1.21k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1275|  1.21k|			res = dnie_compose_and_send_apdu(card, tmp_path, 2, 0, file_out);
 1276|  1.21k|			if (res != SC_SUCCESS) {
  ------------------
  |  |   28|  1.21k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1276:8): [True: 275, False: 943]
  ------------------
 1277|    275|				sc_unlock(card);
 1278|    275|				LOG_TEST_RET(ctx, res, "select_file(PATH) failed");
  ------------------
  |  |  174|    275|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    275|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    275|	int _ret = (r); \
  |  |  |  |  168|    275|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 275, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    275|		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|    275|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    275|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    275|		return _ret; \
  |  |  |  |  172|    275|	} \
  |  |  |  |  173|    275|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1279|    275|			}
 1280|    943|			reminder -= 2;
 1281|    943|		}
 1282|  1.21k|		sc_unlock(card);
 1283|  1.21k|		break;
 1284|      0|	case SC_PATH_TYPE_FROM_CURRENT:
  ------------------
  |  |  122|      0|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (1284:2): [True: 0, False: 5.06k]
  ------------------
 1285|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_NO_CARD_SUPPORT);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1286|      0|		break;
 1287|      0|	case SC_PATH_TYPE_PARENT:
  ------------------
  |  |  123|      0|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (1287:2): [True: 0, False: 5.06k]
  ------------------
 1288|       |		/* Hey!! Manual doesn't says anything on this, but
 1289|       |		 * gscriptor shows that this type is supported
 1290|       |		 */
 1291|      0|		sc_log(ctx, "select_file(PARENT)");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1292|       |		/* according iso7816-4 sect 7.1.1 shouldn't have any parameters */
 1293|      0|		if (in_path->len != 0)
  ------------------
  |  Branch (1293:7): [True: 0, False: 0]
  ------------------
 1294|      0|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1295|      0|		res = dnie_compose_and_send_apdu(card, NULL, 0, 3, file_out);
 1296|      0|		break;
 1297|      0|	default:
  ------------------
  |  Branch (1297:2): [True: 0, False: 5.06k]
  ------------------
 1298|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1299|      0|		break;
 1300|  5.06k|	}
 1301|       |
 1302|       |	/* as last step clear data cache and return */
 1303|  2.31k|	dnie_clear_cache(GET_DNIE_PRIV_DATA(card));
  ------------------
  |  |   97|  2.31k|#define GET_DNIE_PRIV_DATA(card) ((dnie_private_data_t *) ((card)->drv_data))
  ------------------
 1304|  2.31k|	LOG_FUNC_RETURN(ctx, res);
  ------------------
  |  |  164|  2.31k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.31k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.31k|	int _ret = r; \
  |  |  |  |  155|  2.31k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.31k|		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|    715|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 715, False: 1.59k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.31k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.31k|	} 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|  2.31k|	return _ret; \
  |  |  |  |  163|  2.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1305|  2.31k|}
card-dnie.c:dnie_compose_and_send_apdu:
 1129|  5.83k|{
 1130|  5.83k|	int res = 0;
 1131|  5.83k|	sc_apdu_t apdu;
 1132|  5.83k|	u8 rbuf[MAX_RESP_BUFFER_SIZE];
 1133|  5.83k|	sc_context_t *ctx = NULL;
 1134|       |
 1135|  5.83k|	if (!card || !card->ctx)
  ------------------
  |  Branch (1135:6): [True: 0, False: 5.83k]
  |  Branch (1135:15): [True: 0, False: 5.83k]
  ------------------
 1136|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1137|  5.83k|	ctx = card->ctx;
 1138|       |
 1139|  5.83k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  5.83k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.83k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.83k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.83k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1140|       |
 1141|  5.83k|	dnie_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, p1, 0,
  ------------------
  |  |  294|  5.83k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1142|  5.83k|					sc_get_max_recv_size(card), pathlen,
 1143|  5.83k|					rbuf, sizeof(rbuf), path, pathlen);
 1144|  5.83k|	if (p1 == 3)
  ------------------
  |  Branch (1144:6): [True: 0, False: 5.83k]
  ------------------
 1145|      0|		apdu.cse= SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 1146|       |
 1147|  5.83k|	if (file_out == NULL)
  ------------------
  |  Branch (1147:6): [True: 2.97k, False: 2.85k]
  ------------------
 1148|  2.97k|		apdu.cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|  2.97k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1149|       |
 1150|  5.83k|	res = sc_transmit_apdu(card, &apdu);
 1151|  5.83k|	if ((res != SC_SUCCESS) || (file_out == NULL))
  ------------------
  |  |   28|  5.83k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1151:6): [True: 88, False: 5.74k]
  |  Branch (1151:29): [True: 2.92k, False: 2.81k]
  ------------------
 1152|  5.83k|		LOG_TEST_RET(ctx, res, "SelectFile() APDU transmit failed");
  ------------------
  |  |  174|  3.01k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.01k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.01k|	int _ret = (r); \
  |  |  |  |  168|  3.01k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 88, False: 2.92k]
  |  |  |  |  ------------------
  |  |  |  |  169|     88|		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|     88|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     88|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     88|		return _ret; \
  |  |  |  |  172|     88|	} \
  |  |  |  |  173|  3.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.92k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1153|  5.74k|	if (file_out == NULL) {
  ------------------
  |  Branch (1153:6): [True: 2.92k, False: 2.81k]
  ------------------
 1154|  2.92k|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (1154:7): [True: 0, False: 2.92k]
  ------------------
 1155|      0|			SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, 0);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1156|  2.92k|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  153|  2.92k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  2.92k|	int _ret = r; \
  |  |  155|  2.92k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 2.92k, False: 0]
  |  |  ------------------
  |  |  156|  2.92k|		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|  1.82k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1.82k, False: 1.10k]
  |  |  ------------------
  |  |  157|  2.92k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  2.92k|	} 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|  2.92k|	return _ret; \
  |  |  163|  2.92k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1157|  2.92k|			       sc_check_sw(card, apdu.sw1, apdu.sw2));
 1158|  2.92k|	}
 1159|       |
 1160|       |	/* analyze response. if FCI, try to parse */
 1161|  2.81k|	res = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1162|  2.81k|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|  2.81k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1162:6): [True: 1.31k, False: 1.50k]
  ------------------
 1163|  1.31k|		LOG_TEST_RET(ctx, res, "SelectFile() check_sw failed");
  ------------------
  |  |  174|  1.31k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.31k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.31k|	int _ret = (r); \
  |  |  |  |  168|  1.31k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.31k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.31k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.31k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.31k|		return _ret; \
  |  |  |  |  172|  1.31k|	} \
  |  |  |  |  173|  1.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1164|  1.31k|	}
 1165|  1.50k|	if ((apdu.resplen < 2) || (apdu.resp[0] == 0x00)) {
  ------------------
  |  Branch (1165:6): [True: 108, False: 1.39k]
  |  Branch (1165:28): [True: 17, False: 1.38k]
  ------------------
 1166|    125|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    125|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    125|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    125|	int _ret = r; \
  |  |  |  |  155|    125|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 125, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    125|		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|    125|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 125, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    125|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    125|	} 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|    125|	return _ret; \
  |  |  |  |  163|    125|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1167|    125|	}
 1168|       |
 1169|  1.38k|	if (file_out) {
  ------------------
  |  Branch (1169:6): [True: 1.38k, False: 0]
  ------------------
 1170|       |		/* finally process FCI response */
 1171|  1.38k|		size_t len = apdu.resp[1];
 1172|  1.38k|		sc_file_free(*file_out);
 1173|  1.38k|		*file_out = sc_file_new();
 1174|  1.38k|		if (*file_out == NULL) {
  ------------------
  |  Branch (1174:7): [True: 0, False: 1.38k]
  ------------------
 1175|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1176|      0|		}
 1177|  1.38k|		if (apdu.resplen - 2 < len || len < 1) {
  ------------------
  |  Branch (1177:7): [True: 35, False: 1.34k]
  |  Branch (1177:33): [True: 30, False: 1.31k]
  ------------------
 1178|     65|			LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     65|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     65|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     65|	int _ret = r; \
  |  |  |  |  155|     65|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 65, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     65|		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|     65|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 65, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     65|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     65|	} 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|     65|	return _ret; \
  |  |  |  |  163|     65|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1179|     65|		}
 1180|  1.31k|		res = card->ops->process_fci(card, *file_out, apdu.resp + 2, len);
 1181|  1.31k|	}
 1182|  1.31k|	LOG_FUNC_RETURN(ctx, res);
  ------------------
  |  |  164|  1.31k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.31k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.31k|	int _ret = r; \
  |  |  |  |  155|  1.31k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.31k|		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|     34|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 34, False: 1.28k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.31k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.31k|	} 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|  1.31k|	return _ret; \
  |  |  |  |  163|  1.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1183|  1.31k|}
card-dnie.c:dnie_get_challenge:
 1327|    440|{
 1328|       |	/* As DNIe cannot handle other data length than 0x08 and 0x14 */
 1329|    440|	u8 rbuf[8];
 1330|    440|	size_t out_len;
 1331|    440|	int r;
 1332|       |
 1333|    440|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    440|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    440|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    440|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    440|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 440]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1334|       |
 1335|    440|	r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
 1336|    440|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE cmd failed");
  ------------------
  |  |  174|    440|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    440|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    440|	int _ret = (r); \
  |  |  |  |  168|    440|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 62, False: 378]
  |  |  |  |  ------------------
  |  |  |  |  169|     62|		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|     62|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     62|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     62|		return _ret; \
  |  |  |  |  172|     62|	} \
  |  |  |  |  173|    440|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 378]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1337|       |
 1338|    378|	if (len < (size_t) r) {
  ------------------
  |  Branch (1338:6): [True: 1, False: 377]
  ------------------
 1339|      1|		out_len = len;
 1340|    377|	} else {
 1341|    377|		out_len = (size_t) r;
 1342|    377|	}
 1343|    378|	memcpy(rnd, rbuf, out_len);
 1344|       |
 1345|    378|	LOG_FUNC_RETURN(card->ctx, (int) out_len);
  ------------------
  |  |  164|    378|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    378|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    378|	int _ret = r; \
  |  |  |  |  155|    378|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 375]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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: 3]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    375|	} else { \
  |  |  |  |  159|    375|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    375|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    375|	} \
  |  |  |  |  162|    378|	return _ret; \
  |  |  |  |  163|    378|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1346|    378|}
card-dnie.c:dnie_check_sw:
 1750|  12.1k|{
 1751|  12.1k|	int res = SC_SUCCESS;
  ------------------
  |  |   28|  12.1k|#define SC_SUCCESS				0
  ------------------
 1752|  12.1k|	int n = 0;
 1753|  12.1k|	if (!card || !card->ctx)
  ------------------
  |  Branch (1753:6): [True: 0, False: 12.1k]
  |  Branch (1753:15): [True: 0, False: 12.1k]
  ------------------
 1754|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1755|  12.1k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  12.1k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  12.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  12.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  12.1k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 12.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1756|       |
 1757|       |	/* check specific dnie errors */
 1758|  48.5k|	for (n = 0; dnie_errors[n].SWs != 0; n++) {
  ------------------
  |  Branch (1758:14): [True: 36.4k, False: 12.1k]
  ------------------
 1759|  36.4k|		if (dnie_errors[n].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (1759:7): [True: 69, False: 36.3k]
  ------------------
 1760|     69|			sc_log(card->ctx, "%s", dnie_errors[n].errorstr);
  ------------------
  |  |   71|     69|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1761|     69|			return dnie_errors[n].errorno;
 1762|     69|		}
 1763|  36.4k|	}
 1764|       |
 1765|       |	/* arriving here means check for supported iso error codes */
 1766|  12.1k|	res = iso_ops->check_sw(card, sw1, sw2);
 1767|  12.1k|	LOG_FUNC_RETURN(card->ctx, res);
  ------------------
  |  |  164|  12.1k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  12.1k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  12.1k|	int _ret = r; \
  |  |  |  |  155|  12.1k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  12.1k|		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|  6.27k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6.27k, False: 5.85k]
  |  |  |  |  ------------------
  |  |  |  |  157|  12.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  12.1k|	} 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|  12.1k|	return _ret; \
  |  |  |  |  163|  12.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1768|  12.1k|}
card-dnie.c:dnie_card_ctl:
 1787|    182|{
 1788|    182|	int result = SC_SUCCESS;
  ------------------
  |  |   28|    182|#define SC_SUCCESS				0
  ------------------
 1789|    182|	if ((card == NULL) || (card->ctx == NULL))
  ------------------
  |  Branch (1789:6): [True: 0, False: 182]
  |  Branch (1789:24): [True: 0, False: 182]
  ------------------
 1790|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1791|    182|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    182|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    182|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    182|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    182|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 182]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1792|    182|	if (data == NULL) {
  ------------------
  |  Branch (1792:6): [True: 0, False: 182]
  ------------------
 1793|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1794|      0|	}
 1795|    182|	switch (request) {
 1796|       |		/* obtain lifecycle status by reading card->type */
 1797|     54|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1797:2): [True: 54, False: 128]
  ------------------
 1798|     54|		switch (card->type) {
  ------------------
  |  Branch (1798:11): [True: 54, False: 0]
  ------------------
 1799|      0|		case SC_CARD_TYPE_DNIE_ADMIN:
  ------------------
  |  Branch (1799:3): [True: 0, False: 54]
  ------------------
 1800|      0|			result = SC_CARDCTRL_LIFECYCLE_ADMIN;
 1801|      0|			break;
 1802|     54|		case SC_CARD_TYPE_DNIE_USER:
  ------------------
  |  Branch (1802:3): [True: 54, False: 0]
  ------------------
 1803|     54|			result = SC_CARDCTRL_LIFECYCLE_USER;
 1804|     54|			break;
 1805|      0|		case SC_CARD_TYPE_DNIE_BLANK:
  ------------------
  |  Branch (1805:3): [True: 0, False: 54]
  ------------------
 1806|      0|		case SC_CARD_TYPE_DNIE_TERMINATED:
  ------------------
  |  Branch (1806:3): [True: 0, False: 54]
  ------------------
 1807|      0|			result = SC_CARDCTRL_LIFECYCLE_OTHER;
 1808|      0|			break;
 1809|     54|		}
 1810|     54|		*(int *)data = result;
 1811|     54|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     54|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     54|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     54|	int _ret = r; \
  |  |  |  |  155|     54|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 54, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     54|		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: 54]
  |  |  |  |  ------------------
  |  |  |  |  157|     54|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     54|	} 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|     54|	return _ret; \
  |  |  |  |  163|     54|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1812|       |		/* call card to obtain serial number */
 1813|     56|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1813:2): [True: 56, False: 126]
  ------------------
 1814|     56|		result = dnie_get_serialnr(card, (sc_serial_number_t *) data);
 1815|     56|		LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  164|     56|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     56|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     56|	int _ret = r; \
  |  |  |  |  155|     56|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 56, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     56|		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|     37|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 37, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  157|     56|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     56|	} 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|     56|	return _ret; \
  |  |  |  |  163|     56|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1816|      0|	case SC_CARDCTL_DNIE_GENERATE_KEY:
  ------------------
  |  Branch (1816:2): [True: 0, False: 182]
  ------------------
 1817|       |		/* some reports says that this card supports genkey */
 1818|      0|		result = dnie_generate_key(card, data);
 1819|      0|		LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1820|      0|	case SC_CARDCTL_DNIE_GET_INFO:
  ------------------
  |  Branch (1820:2): [True: 0, False: 182]
  ------------------
 1821|       |		/* retrieve name, surname and eid number */
 1822|      0|		result = dnie_get_info(card, data);
 1823|      0|		LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1824|     72|	default:
  ------------------
  |  Branch (1824:2): [True: 72, False: 110]
  ------------------
 1825|       |		/* default: unsupported function */
 1826|     72|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     72|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     72|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     72|	int _ret = r; \
  |  |  |  |  155|     72|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 72, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     72|		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|     72|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 72, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     72|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     72|	} 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|     72|	return _ret; \
  |  |  |  |  163|     72|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1827|    182|	}
 1828|    182|}
card-dnie.c:dnie_get_serialnr:
  637|     56|{
  638|     56|	int result;
  639|     56|	sc_apdu_t apdu;
  640|     56|	u8 rbuf[MAX_RESP_BUFFER_SIZE];
  641|     56|	if ((card == NULL) || (card->ctx == NULL) || (serial == NULL))
  ------------------
  |  Branch (641:6): [True: 0, False: 56]
  |  Branch (641:24): [True: 0, False: 56]
  |  Branch (641:47): [True: 0, False: 56]
  ------------------
  642|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  643|       |
  644|     56|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     56|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     56|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     56|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     56|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  645|     56|	if (card->type != SC_CARD_TYPE_DNIE_USER)
  ------------------
  |  Branch (645:6): [True: 0, False: 56]
  ------------------
  646|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  647|       |	/* if serial number is cached, use it */
  648|     56|	if (card->serialnr.len) {
  ------------------
  |  Branch (648:6): [True: 6, False: 50]
  ------------------
  649|      6|		memcpy(serial, &card->serialnr, sizeof(*serial));
  650|      6|		sc_log_hex(card->ctx, "Serial Number (cached)", serial->value, serial->len);
  ------------------
  |  |  129|      6|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|      6|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  651|      6|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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: 6]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|      6|	}
  653|       |	/* not cached, retrieve it by mean of an APDU */
  654|       |	/* official driver read 0x11 bytes, but only uses 7. Manual says just 7 (for le) */
  655|     50|	dnie_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xb8, 0x00, 0x00, 0x07, 0,
  ------------------
  |  |  292|     50|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  656|     50|					rbuf, sizeof(rbuf), NULL, 0);
  657|     50|	apdu.cla = 0x90;	/* proprietary cmd */
  658|       |	/* send apdu */
  659|     50|	result = sc_transmit_apdu(card, &apdu);
  660|     50|	if (result != SC_SUCCESS) {
  ------------------
  |  |   28|     50|#define SC_SUCCESS				0
  ------------------
  |  Branch (660:6): [True: 6, False: 44]
  ------------------
  661|      6|		LOG_TEST_RET(card->ctx, result, "APDU transmit failed");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|      6|	}
  663|     44|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (663:6): [True: 22, False: 22]
  |  Branch (663:26): [True: 9, False: 13]
  ------------------
  664|     31|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     31|#define SC_ERROR_INTERNAL			-1400
  ------------------
  665|       |	/* cache serial number */
  666|     13|	memcpy(card->serialnr.value, apdu.resp, 7 * sizeof(u8));
  667|     13|	card->serialnr.len = 7 * sizeof(u8);
  668|       |	/* TODO: fill Issuer Identification Number data with proper (ATR?) info */
  669|       |	/*
  670|       |	   card->serialnr.iin.mii=;
  671|       |	   card->serialnr.iin.country=;
  672|       |	   card->serialnr.iin.issuer_id=;
  673|       |	 */
  674|       |	/* copy and return serial number */
  675|     13|	memcpy(serial, &card->serialnr, sizeof(*serial));
  676|     13|	sc_log_hex(card->ctx, "Serial Number (apdu)", serial->value, serial->len);
  ------------------
  |  |  129|     13|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     13|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  677|     13|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     13|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     13|	int _ret = r; \
  |  |  |  |  155|     13|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     13|		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: 13]
  |  |  |  |  ------------------
  |  |  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     13|	} 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|     13|	return _ret; \
  |  |  |  |  163|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  678|     13|}
card-dnie.c:dnie_process_fci:
 1925|  1.31k|{
 1926|  1.31k|	int res = SC_SUCCESS;
  ------------------
  |  |   28|  1.31k|#define SC_SUCCESS				0
  ------------------
 1927|  1.31k|	int *op = df_acl;
 1928|  1.31k|	int n = 0;
 1929|  1.31k|	sc_context_t *ctx = NULL;
 1930|  1.31k|	if ((card == NULL) || (card->ctx == NULL) || (file == NULL) || buflen == 0)
  ------------------
  |  Branch (1930:6): [True: 0, False: 1.31k]
  |  Branch (1930:24): [True: 0, False: 1.31k]
  |  Branch (1930:47): [True: 0, False: 1.31k]
  |  Branch (1930:65): [True: 0, False: 1.31k]
  ------------------
 1931|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1932|  1.31k|	ctx = card->ctx;
 1933|  1.31k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.31k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.31k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.31k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.31k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1934|       |	/* first of all, let iso do the hard work */
 1935|  1.31k|	res = iso_ops->process_fci(card, file, buf, buflen);
 1936|  1.31k|	LOG_TEST_RET(ctx, res, "iso7816_process_fci() failed");
  ------------------
  |  |  174|  1.31k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.31k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.31k|	int _ret = (r); \
  |  |  |  |  168|  1.31k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 1.31k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1937|       |	/* if tag 0x85 is received, then file->prop_attr_len should be filled
 1938|       |	 * by sc_file_set_prop_attr() code. So check and set data according manual
 1939|       |	 * Note errata at pg 35 of Manual  about DF identifier (should be 0x38) */
 1940|  1.31k|	if (file->prop_attr_len == 0) {	/* no proprietary tag (0x85) received */
  ------------------
  |  Branch (1940:6): [True: 930, False: 386]
  ------------------
 1941|    930|		res = SC_SUCCESS;
  ------------------
  |  |   28|    930|#define SC_SUCCESS				0
  ------------------
 1942|    930|		goto dnie_process_fci_end;
 1943|    930|	}
 1944|       |	/* at least 10 bytes should be received */
 1945|    386|	if (file->prop_attr_len < 10) {
  ------------------
  |  Branch (1945:6): [True: 12, False: 374]
  ------------------
 1946|     12|		res = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|     12|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 1947|     12|		goto dnie_process_fci_end;
 1948|     12|	}
 1949|       |	/* byte 0 denotes file type */
 1950|    374|	switch (file->prop_attr[0]) {
 1951|     31|	case 0x01:		/* EF for plain files */
  ------------------
  |  Branch (1951:2): [True: 31, False: 343]
  ------------------
 1952|     31|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     31|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 1953|     31|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     31|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 1954|     31|		break;
 1955|    106|	case 0x15:		/* EF for keys: linear variable simple TLV */
  ------------------
  |  Branch (1955:2): [True: 106, False: 268]
  ------------------
 1956|    106|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    106|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 1957|       |		/* pin file 3F000000 has also this EF type */
 1958|    106|		if ( ( file->prop_attr[2] == 0x00 ) && (file->prop_attr[3] == 0x00 ) ) {
  ------------------
  |  Branch (1958:8): [True: 61, False: 45]
  |  Branch (1958:42): [True: 28, False: 33]
  ------------------
 1959|     28|			sc_log(ctx,"Processing pin EF");
  ------------------
  |  |   71|     28|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1960|     28|			break;
 1961|     28|		}
 1962|       |		/* FCI response for Keys EF returns 3 additional bytes */
 1963|     78|		if (file->prop_attr_len < 13) {
  ------------------
  |  Branch (1963:7): [True: 10, False: 68]
  ------------------
 1964|     10|			sc_log(ctx, "FCI response len for Keys EF should be 13 bytes");
  ------------------
  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1965|     10|			res = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|     10|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 1966|     10|			goto dnie_process_fci_end;
 1967|     10|		}
 1968|     68|		break;
 1969|    191|	case 0x24:		/* EF for compressed certificates */
  ------------------
  |  Branch (1969:2): [True: 191, False: 183]
  ------------------
 1970|    191|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    191|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 1971|    191|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|    191|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 1972|       |		/* evaluate real length by reading first 8 bytes from file */
 1973|    191|		res = dnie_read_header(card);
 1974|       |		/* Hey!, we need pin to read certificates... */
 1975|    191|		if (res == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)
  ------------------
  |  |   61|    191|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (1975:7): [True: 1, False: 190]
  ------------------
 1976|      1|			goto dnie_process_fci_end;
 1977|    190|		if (res <= 0) {
  ------------------
  |  Branch (1977:7): [True: 156, False: 34]
  ------------------
 1978|    156|			sc_log(ctx,
  ------------------
  |  |   71|    156|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1979|    156|			       "Cannot evaluate uncompressed size. use fci length");
 1980|    156|		} else {
 1981|     34|			sc_log(ctx, "Storing uncompressed size '%d' into fci",
  ------------------
  |  |   71|     34|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1982|     34|			       res);
 1983|     34|			file->prop_attr[3] = (u8) ((res >> 8) & 0xff);
 1984|     34|			file->prop_attr[4] = (u8) (res & 0xff);
 1985|     34|		}
 1986|    190|		break;
 1987|     35|	case 0x38:		/* Errata: manual page 35 says wrong 0x34 */
  ------------------
  |  Branch (1987:2): [True: 35, False: 339]
  ------------------
 1988|     35|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     35|#define SC_FILE_TYPE_DF			0x04
  ------------------
 1989|     35|		break;
 1990|     11|	default:
  ------------------
  |  Branch (1990:2): [True: 11, False: 363]
  ------------------
 1991|     11|		res = SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     11|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
 1992|     11|		goto dnie_process_fci_end;
 1993|    374|	}
 1994|       |
 1995|       |	/* bytes 1 and 2 stores file ID */
 1996|    352|	file->id = ( ( 0xff & (int)file->prop_attr[1] ) << 8 ) |
 1997|    352|			( 0xff & (int)file->prop_attr[2] ) ;
 1998|       |
 1999|       |	/* bytes 3 and 4 states file length */
 2000|    352|	file->size = ( ( 0xff & (int)file->prop_attr[3] ) << 8 ) |
 2001|    352|			( 0xff & (int)file->prop_attr[4] ) ;
 2002|       |
 2003|       |	/* bytes 5 to 9 states security attributes */
 2004|       |	/* NOTE:
 2005|       |	 * seems that these 5 bytes are handled according iso7816-9 sect 8.
 2006|       |	 * but sadly that each card uses their own bits :-(
 2007|       |	 * Moreover: Manual talks on 5 bytes, but official driver only uses 4
 2008|       |	 * No info available (yet), so copy code from card-jcos.c / card-flex.c
 2009|       |	 * card drivers and pray... */
 2010|    352|	op = (file->type == SC_FILE_TYPE_DF) ? df_acl : ef_acl;
  ------------------
  |  |  214|    352|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (2010:7): [True: 35, False: 317]
  ------------------
 2011|  2.11k|	for (n = 0; n < 5; n++) {
  ------------------
  |  Branch (2011:14): [True: 1.76k, False: 352]
  ------------------
 2012|  1.76k|		int key_ref = 0;
 2013|  1.76k|		if (*(op + n) == -1)
  ------------------
  |  Branch (2013:7): [True: 352, False: 1.40k]
  ------------------
 2014|    352|			continue;	/* unused entry: skip */
 2015|  1.40k|		key_ref = file->prop_attr[5 + n] & 0x0F;
 2016|  1.40k|		switch (0xF0 & file->prop_attr[5 + n]) {
 2017|    455|		case 0x00:
  ------------------
  |  Branch (2017:3): [True: 455, False: 953]
  ------------------
 2018|    455|			sc_file_add_acl_entry(file, *(op + n), SC_AC_NONE,
  ------------------
  |  |  150|    455|#define SC_AC_NONE			0x00000000
  ------------------
 2019|    455|					      SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    455|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 2020|    455|			break;
 2021|    103|		case 0x10:
  ------------------
  |  Branch (2021:3): [True: 103, False: 1.30k]
  ------------------
 2022|       |			/* this tag is omitted in official code
 2023|       |			   case 0x20:
 2024|       |			 */
 2025|    242|		case 0x30:
  ------------------
  |  Branch (2025:3): [True: 139, False: 1.26k]
  ------------------
 2026|    242|			sc_file_add_acl_entry(file, *(op + n), SC_AC_CHV,
  ------------------
  |  |  151|    242|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 2027|    242|					      key_ref);
 2028|    242|			break;
 2029|     90|		case 0x40:
  ------------------
  |  Branch (2029:3): [True: 90, False: 1.31k]
  ------------------
 2030|     90|			sc_file_add_acl_entry(file, *(op + n), SC_AC_TERM,
  ------------------
  |  |  152|     90|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
 2031|     90|					      key_ref);
 2032|     90|			break;
 2033|    252|		case 0xF0:
  ------------------
  |  Branch (2033:3): [True: 252, False: 1.15k]
  ------------------
 2034|    252|			sc_file_add_acl_entry(file, *(op + n), SC_AC_NEVER,
  ------------------
  |  |  163|    252|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 2035|    252|					      SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    252|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 2036|    252|			break;
 2037|    369|		default:
  ------------------
  |  Branch (2037:3): [True: 369, False: 1.03k]
  ------------------
 2038|    369|			sc_file_add_acl_entry(file, *(op + n), SC_AC_UNKNOWN,
  ------------------
  |  |  162|    369|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
 2039|    369|					      SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    369|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 2040|    369|			break;
 2041|  1.40k|		}
 2042|  1.40k|	}
 2043|       |	/* NOTE: Following bytes are described at DNIe manual pg 36, but No
 2044|       |	   documentation about what to do with following data is provided...
 2045|       |	   logs suggest that they are neither generated nor handled.
 2046|       |
 2047|       |	   UPDATE: these additional bytes are received when FileDescriptor tag
 2048|       |	   is 0x15 (EF for keys)
 2049|       |	 */
 2050|    352|	if (file->prop_attr[0] == 0x15) {
  ------------------
  |  Branch (2050:6): [True: 96, False: 256]
  ------------------
 2051|     96|		sc_log(card->ctx,
  ------------------
  |  |   71|     96|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2052|     96|		       "Processing flags for Cryptographic key files");
 2053|       |		/* byte 10 (if present) shows Control Flags for security files */
 2054|       |		/* bytes 11 and 12 (if present) states Control bytes for
 2055|       |		   RSA crypto files */
 2056|       |		/* TODO: write when know what to do */
 2057|     96|	}
 2058|    352|	res = SC_SUCCESS;	/* arriving here means success */
  ------------------
  |  |   28|    352|#define SC_SUCCESS				0
  ------------------
 2059|  1.31k| dnie_process_fci_end:
 2060|  1.31k|	LOG_FUNC_RETURN(card->ctx, res);
  ------------------
  |  |  164|  1.31k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.31k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.31k|	int _ret = r; \
  |  |  |  |  155|  1.31k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.31k|		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|     34|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 34, False: 1.28k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.31k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.31k|	} 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|  1.31k|	return _ret; \
  |  |  |  |  163|  1.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2061|  1.31k|}
card-dnie.c:dnie_read_header:
 1848|    191|{
 1849|    191|	sc_apdu_t apdu;
 1850|    191|	int r;
 1851|    191|	u8 buf[MAX_RESP_BUFFER_SIZE];
 1852|    191|	unsigned long uncompressed = 0L;
 1853|    191|	unsigned long compressed = 0L;
 1854|    191|	sc_context_t *ctx = NULL;
 1855|       |
 1856|    191|	if (!card || !card->ctx)
  ------------------
  |  Branch (1856:6): [True: 0, False: 191]
  |  Branch (1856:15): [True: 0, False: 191]
  ------------------
 1857|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1858|    191|	ctx = card->ctx;
 1859|    191|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    191|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    191|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    191|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    191|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 191]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1860|       |
 1861|       |	/* initialize apdu */
 1862|    191|	dnie_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, 0x00, 0x00, 8, 0,
  ------------------
  |  |  292|    191|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1863|    191|					buf, MAX_RESP_BUFFER_SIZE, NULL, 0);
  ------------------
  |  |   56|    191|#define MAX_RESP_BUFFER_SIZE 2048
  ------------------
 1864|       |	/* transmit apdu */
 1865|    191|	r = sc_transmit_apdu(card, &apdu);
 1866|    191|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    191|#define SC_SUCCESS				0
  ------------------
  |  Branch (1866:6): [True: 15, False: 176]
  ------------------
 1867|     15|		sc_log(ctx, "read_header() APDU transmit failed");
  ------------------
  |  |   71|     15|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1868|     15|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     15|	} 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|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1869|     15|	}
 1870|       |	/* check response */
 1871|    176|	if (apdu.resplen != 8)
  ------------------
  |  Branch (1871:6): [True: 47, False: 129]
  ------------------
 1872|     47|		goto header_notcompressed;
 1873|    129|	uncompressed = lebytes2ulong(apdu.resp);
 1874|    129|	compressed = lebytes2ulong(apdu.resp + 4);
 1875|    129|	if (uncompressed < compressed)
  ------------------
  |  Branch (1875:6): [True: 39, False: 90]
  ------------------
 1876|     39|		goto header_notcompressed;
 1877|     90|	if (uncompressed > 32767)
  ------------------
  |  Branch (1877:6): [True: 56, False: 34]
  ------------------
 1878|     56|		goto header_notcompressed;
 1879|       |	/* ok: assume data is correct */
 1880|     34|	sc_log(ctx, "read_header: uncompressed file size is %lu", uncompressed);
  ------------------
  |  |   71|     34|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1881|     34|	return (int)(0x7FFF & uncompressed);
 1882|       |
 1883|    142| header_notcompressed:
 1884|    142|	sc_log(ctx, "response doesn't match compressed file header");
  ------------------
  |  |   71|    142|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1885|    142|	return 0;
 1886|     90|}
card-dnie.c:dnie_pin_cmd:
 2174|     54|{
 2175|     54|	int res = SC_SUCCESS;
  ------------------
  |  |   28|     54|#define SC_SUCCESS				0
  ------------------
 2176|     54|	int lc = SC_CARDCTRL_LIFECYCLE_USER;
 2177|       |
 2178|     54|	if ((card == NULL) || (card->ctx == NULL) || (data == NULL))
  ------------------
  |  Branch (2178:6): [True: 0, False: 54]
  |  Branch (2178:24): [True: 0, False: 54]
  |  Branch (2178:47): [True: 0, False: 54]
  ------------------
 2179|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2180|     54|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     54|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     54|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     54|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     54|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2181|       |
 2182|       |	/*
 2183|       |	* some flags and settings from documentation
 2184|       |	* No (easy) way to handle pinpad through SM, so disable it
 2185|       |	*/
 2186|     54|	data->flags &= ~SC_PIN_CMD_NEED_PADDING; /* no pin padding */
  ------------------
  |  |  422|     54|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 2187|     54|	data->flags &= ~SC_PIN_CMD_USE_PINPAD;	 /* cannot handle pinpad */
  ------------------
  |  |  421|     54|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
 2188|       |
 2189|       |	/* ensure that card is in USER Lifecycle */
 2190|     54|	res = dnie_card_ctl(card, SC_CARDCTL_LIFECYCLE_GET, &lc);
 2191|     54|	LOG_TEST_RET(card->ctx, res, "Cannot get card LC status");
  ------------------
  |  |  174|     54|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     54|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     54|	int _ret = (r); \
  |  |  |  |  168|     54|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 54]
  |  |  |  |  ------------------
  |  |  |  |  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|     54|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2192|     54|	if (lc != SC_CARDCTRL_LIFECYCLE_USER) {
  ------------------
  |  Branch (2192:6): [True: 0, False: 54]
  ------------------
 2193|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2194|      0|	}
 2195|       |
 2196|       |	/* only allow changes on CHV pin ) */
 2197|     54|	switch (data->pin_type) {
 2198|     54|	case SC_AC_CHV:	/* Card Holder Verifier */
  ------------------
  |  |  151|     54|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (2198:2): [True: 54, False: 0]
  ------------------
 2199|     54|		break;
 2200|      0|	case SC_AC_TERM:	/* Terminal auth */
  ------------------
  |  |  152|      0|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (2200:2): [True: 0, False: 54]
  ------------------
 2201|      0|	case SC_AC_PRO:	/* SM auth */
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (2201:2): [True: 0, False: 54]
  ------------------
 2202|      0|	case SC_AC_AUT:	/* Key auth */
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (2202:2): [True: 0, False: 54]
  ------------------
 2203|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2204|      0|	default:
  ------------------
  |  Branch (2204:2): [True: 0, False: 54]
  ------------------
 2205|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2206|     54|	}
 2207|       |	/* This DNIe driver only supports VERIFY operation */
 2208|     54|	switch (data->cmd) {
 2209|      0|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (2209:2): [True: 0, False: 54]
  ------------------
 2210|      0|		res =  dnie_pin_verify(card,data);
 2211|      0|		break;
 2212|      0|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (2212:2): [True: 0, False: 54]
  ------------------
 2213|      0|		res =  dnie_pin_change(card,data);
 2214|      0|		break;
 2215|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2215:2): [True: 0, False: 54]
  ------------------
 2216|     54|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  418|     54|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (2216:2): [True: 54, False: 0]
  ------------------
 2217|     54|		res= SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     54|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2218|     54|		break;
 2219|      0|	default:
  ------------------
  |  Branch (2219:2): [True: 0, False: 54]
  ------------------
 2220|      0|		res= SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2221|      0|		break;
 2222|     54|	}
 2223|       |	/* return result */
 2224|     54|	LOG_FUNC_RETURN(card->ctx, res);
  ------------------
  |  |  164|     54|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     54|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     54|	int _ret = r; \
  |  |  |  |  155|     54|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 54, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     54|		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|     54|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 54, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     54|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     54|	} 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|     54|	return _ret; \
  |  |  |  |  163|     54|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2225|     54|}

sc_get_dtrust_driver:
 1056|  17.0k|{
 1057|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1057:6): [True: 1, False: 17.0k]
  ------------------
 1058|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1059|       |
 1060|  17.0k|	dtrust_ops = *iso_ops;
 1061|  17.0k|	dtrust_ops.match_card = dtrust_match_card;
 1062|  17.0k|	dtrust_ops.init = dtrust_init;
 1063|  17.0k|	dtrust_ops.finish = dtrust_finish;
 1064|  17.0k|	dtrust_ops.pin_cmd = dtrust_pin_cmd;
 1065|  17.0k|	dtrust_ops.set_security_env = dtrust_set_security_env;
 1066|  17.0k|	dtrust_ops.compute_signature = dtrust_compute_signature;
 1067|  17.0k|	dtrust_ops.decipher = dtrust_decipher;
 1068|  17.0k|	dtrust_ops.logout = dtrust_logout;
 1069|       |
 1070|  17.0k|	return &dtrust_drv;
 1071|  17.0k|}
card-dtrust.c:dtrust_match_card:
  234|  16.3k|{
  235|  16.3k|	if (_sc_match_atr(card, dtrust_atrs, &card->type) < 0)
  ------------------
  |  Branch (235:6): [True: 16.2k, False: 67]
  ------------------
  236|  16.2k|		return 0;
  237|       |
  238|     67|	if (_dtrust_match_cardos(card) != SC_SUCCESS)
  ------------------
  |  |   28|     67|#define SC_SUCCESS				0
  ------------------
  |  Branch (238:6): [True: 67, False: 0]
  ------------------
  239|     67|		return 0;
  240|       |
  241|      0|	if (_dtrust_match_profile(card) != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (241:6): [True: 0, False: 0]
  ------------------
  242|      0|		return 0;
  243|       |
  244|      0|	sc_log(card->ctx, "D-Trust Signature Card");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  245|       |
  246|      0|	return 1;
  247|      0|}
card-dtrust.c:_dtrust_match_cardos:
  114|     67|{
  115|     67|	int r;
  116|     67|	size_t prodlen;
  117|     67|	u8 buf[32];
  118|       |
  119|       |	/* check OS version */
  120|     67|	r = sc_get_data(card, 0x0182, buf, 32);
  121|     67|	LOG_TEST_RET(card->ctx, r, "OS version check failed");
  ------------------
  |  |  174|     67|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     67|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     67|	int _ret = (r); \
  |  |  |  |  168|     67|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 48, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  169|     48|		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|     48|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     48|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     48|		return _ret; \
  |  |  |  |  172|     48|	} \
  |  |  |  |  173|     67|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|       |
  123|     19|	if (card->type == SC_CARD_TYPE_DTRUST_V4_1_STD) {
  ------------------
  |  Branch (123:6): [True: 9, False: 10]
  ------------------
  124|      9|		if (r != 2 || buf[0] != 0xc9 || buf[1] != 0x04)
  ------------------
  |  Branch (124:7): [True: 6, False: 3]
  |  Branch (124:17): [True: 1, False: 2]
  |  Branch (124:35): [True: 1, False: 1]
  ------------------
  125|      8|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      8|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  126|     10|	} else if (card->type == SC_CARD_TYPE_DTRUST_V5_1_STD) {
  ------------------
  |  Branch (126:13): [True: 10, False: 0]
  ------------------
  127|     10|		if (r != 2 || buf[0] != 0xcb || buf[1] != 0x01)
  ------------------
  |  Branch (127:7): [True: 3, False: 7]
  |  Branch (127:17): [True: 5, False: 2]
  |  Branch (127:35): [True: 1, False: 1]
  ------------------
  128|      9|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      9|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  129|     10|	}
  130|       |
  131|       |	/* check product name */
  132|      2|	r = sc_get_data(card, 0x0180, buf, 32);
  133|      2|	LOG_TEST_RET(card->ctx, r, "Product name check failed");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  134|       |
  135|      0|	prodlen = (size_t)r;
  136|      0|	if (card->type == SC_CARD_TYPE_DTRUST_V4_1_STD) {
  ------------------
  |  Branch (136:6): [True: 0, False: 0]
  ------------------
  137|      0|		if (prodlen != strlen("CardOS V5.4     2019") + 1 || memcmp(buf, "CardOS V5.4     2019", prodlen))
  ------------------
  |  Branch (137:7): [True: 0, False: 0]
  |  Branch (137:56): [True: 0, False: 0]
  ------------------
  138|      0|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  139|      0|	} else if (card->type == SC_CARD_TYPE_DTRUST_V5_1_STD) {
  ------------------
  |  Branch (139:13): [True: 0, False: 0]
  ------------------
  140|      0|		if (prodlen != strlen("CardOS V6.0 2021") + 1 || memcmp(buf, "CardOS V6.0 2021", prodlen))
  ------------------
  |  Branch (140:7): [True: 0, False: 0]
  |  Branch (140:52): [True: 0, False: 0]
  ------------------
  141|      0|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  142|      0|	}
  143|       |
  144|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  145|      0|}

sc_get_edo_driver:
  306|  17.0k|struct sc_card_driver* sc_get_edo_driver(void) {
  307|  17.0k|	edo_ops = *sc_get_iso7816_driver()->ops;
  308|  17.0k|	edo_ops.match_card = edo_match_card;
  309|  17.0k|	edo_ops.init = edo_init;
  310|  17.0k|	edo_ops.select_file = edo_select_file;
  311|  17.0k|	edo_ops.set_security_env = edo_set_security_env;
  312|  17.0k|	edo_ops.compute_signature = edo_compute_signature;
  313|  17.0k|	edo_ops.logout = edo_logout;
  314|       |
  315|  17.0k|	return &edo_drv;
  316|  17.0k|}
card-edo.c:edo_match_card:
   62|  8.63k|static int edo_match_card(sc_card_t* card) {
   63|  8.63k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  8.63k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  8.63k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  8.63k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 8.63k]
  |  |  ------------------
  ------------------
   64|  8.63k|	if (_sc_match_atr(card, edo_atrs, &card->type) >= 0) {
  ------------------
  |  Branch (64:6): [True: 0, False: 8.63k]
  ------------------
   65|      0|		sc_log(card->ctx, "ATR recognized as Polish eID card.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   66|      0|		LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   67|      0|	}
   68|  8.63k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  8.63k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  8.63k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  8.63k|	int _ret = r; \
  |  |  |  |  155|  8.63k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8.63k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  8.63k|		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: 8.63k]
  |  |  |  |  ------------------
  |  |  |  |  157|  8.63k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  8.63k|	} 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|  8.63k|	return _ret; \
  |  |  |  |  163|  8.63k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   69|  8.63k|}

sc_get_entersafe_driver:
 1579|  17.0k|{
 1580|  17.0k|	return sc_get_driver();
 1581|  17.0k|}
card-entersafe.c:sc_get_driver:
 1553|  17.0k|{
 1554|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1555|       |
 1556|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1556:6): [True: 1, False: 17.0k]
  ------------------
 1557|      1|		iso_ops = iso_drv->ops;
 1558|       |
 1559|  17.0k|	entersafe_ops = *iso_drv->ops;
 1560|  17.0k|	entersafe_ops.match_card = entersafe_match_card;
 1561|  17.0k|	entersafe_ops.init = entersafe_init;
 1562|  17.0k|	entersafe_ops.read_binary = entersafe_read_binary;
 1563|  17.0k|	entersafe_ops.write_binary = NULL;
 1564|  17.0k|	entersafe_ops.update_binary = entersafe_update_binary;
 1565|  17.0k|	entersafe_ops.select_file = entersafe_select_file;
 1566|  17.0k|	entersafe_ops.restore_security_env = entersafe_restore_security_env;
 1567|  17.0k|	entersafe_ops.set_security_env = entersafe_set_security_env;
 1568|  17.0k|	entersafe_ops.decipher = entersafe_decipher;
 1569|  17.0k|	entersafe_ops.compute_signature = entersafe_compute_signature;
 1570|  17.0k|	entersafe_ops.create_file = entersafe_create_file;
 1571|       |	entersafe_ops.delete_file = NULL;
 1572|  17.0k|	entersafe_ops.pin_cmd = entersafe_pin_cmd;
 1573|  17.0k|	entersafe_ops.card_ctl = entersafe_card_ctl_2048;
 1574|  17.0k|	entersafe_ops.process_fci = entersafe_process_fci;
 1575|  17.0k|	return &entersafe_drv;
 1576|  17.0k|}
card-entersafe.c:entersafe_match_card:
  135|  11.2k|{
  136|  11.2k|	int i;
  137|  11.2k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  11.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  11.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  11.2k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 11.2k]
  |  |  ------------------
  ------------------
  138|       |
  139|  11.2k|	i = _sc_match_atr(card, entersafe_atrs, &card->type);
  140|  11.2k|	if (i < 0)
  ------------------
  |  Branch (140:6): [True: 11.1k, False: 176]
  ------------------
  141|  11.1k|		return 0;
  142|       |
  143|    176|	return 1;
  144|  11.2k|}
card-entersafe.c:entersafe_init:
  147|    176|{
  148|    176|	unsigned int flags;
  149|       |
  150|    176|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    176|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    176|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    176|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 176]
  |  |  ------------------
  ------------------
  151|       |
  152|    176|	card->name = "entersafe";
  153|    176|	card->cla  = 0x00;
  154|    176|	card->drv_data = NULL;
  155|       |
  156|    176|	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |   93|    176|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  102|    176|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    176|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  157|       |
  158|    176|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  159|    176|	_sc_card_add_rsa_alg(card, 768, flags, 0);
  160|    176|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  161|    176|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  162|       |
  163|    176|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    176|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  164|       |
  165|       |	/* we need read_binary&friends with max 224 bytes per read */
  166|    176|	card->max_send_size = 224;
  167|    176|	card->max_recv_size = 224;
  168|    176|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|    176|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    176|	int _ret = r; \
  |  |  155|    176|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 176, False: 0]
  |  |  ------------------
  |  |  156|    176|		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: 176]
  |  |  ------------------
  |  |  157|    176|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    176|	} 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|    176|	return _ret; \
  |  |  163|    176|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  169|    176|}
card-entersafe.c:entersafe_read_binary:
  427|  4.15k|{
  428|  4.15k|	sc_apdu_t apdu;
  429|  4.15k|	u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
  430|  4.15k|	int r;
  431|       |
  432|  4.15k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  4.15k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  4.15k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  4.15k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 4.15k]
  |  |  ------------------
  ------------------
  433|       |
  434|  4.15k|	if (count > card->max_recv_size)
  ------------------
  |  Branch (434:6): [True: 0, False: 4.15k]
  ------------------
  435|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  436|  4.15k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, (idx >> 8) & 0xFF, idx & 0xFF);
  ------------------
  |  |  292|  4.15k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  437|       |
  438|  4.15k|	apdu.cla = idx > 0x7fff ? 0x80 : 0x00;
  ------------------
  |  Branch (438:13): [True: 79, False: 4.07k]
  ------------------
  439|  4.15k|	apdu.le = count;
  440|  4.15k|	apdu.resplen = count;
  441|  4.15k|	apdu.resp = recvbuf;
  442|       |
  443|  4.15k|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
  444|  4.15k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  4.15k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.15k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.15k|	int _ret = (r); \
  |  |  |  |  168|  4.15k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 22, False: 4.12k]
  |  |  |  |  ------------------
  |  |  |  |  169|     22|		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|     22|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     22|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     22|		return _ret; \
  |  |  |  |  172|     22|	} \
  |  |  |  |  173|  4.15k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.12k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|  4.12k|	if (apdu.resplen == 0)
  ------------------
  |  Branch (445:6): [True: 115, False: 4.01k]
  ------------------
  446|    115|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|    115|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    115|	int _ret = r; \
  |  |  155|    115|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 115, False: 0]
  |  |  ------------------
  |  |  156|    115|		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|    101|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 101, False: 14]
  |  |  ------------------
  |  |  157|    115|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    115|	} 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|    115|	return _ret; \
  |  |  163|    115|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  447|  4.01k|	memcpy(buf, recvbuf, apdu.resplen);
  448|       |
  449|  4.01k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)apdu.resplen);
  ------------------
  |  |  153|  4.01k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  4.01k|	int _ret = r; \
  |  |  155|  4.01k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 4.01k]
  |  |  ------------------
  |  |  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|  4.01k|	} else { \
  |  |  159|  4.01k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|  4.01k|			"returning with: %d\n", _ret); \
  |  |  161|  4.01k|	} \
  |  |  162|  4.01k|	return _ret; \
  |  |  163|  4.01k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  450|  4.01k|}
card-entersafe.c:entersafe_transmit_apdu:
  370|  4.47k|{
  371|  4.47k|	u8 *cipher_data = NULL, *mac_data = NULL;
  372|  4.47k|	size_t cipher_data_size, mac_data_size, blocks;
  373|  4.47k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  4.47k|#define SC_SUCCESS				0
  ------------------
  374|  4.47k|	u8 *sbuf = NULL;
  375|  4.47k|	size_t ssize = 0;
  376|       |
  377|  4.47k|	if (card == NULL || apdu == NULL)
  ------------------
  |  Branch (377:6): [True: 0, False: 4.47k]
  |  Branch (377:22): [True: 0, False: 4.47k]
  ------------------
  378|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  379|       |
  380|  4.47k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  4.47k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  4.47k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  4.47k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 4.47k]
  |  |  ------------------
  ------------------
  381|       |
  382|  4.47k|	if ((cipher || mac) && (!key || (keylen != 8 && keylen != 16)))
  ------------------
  |  Branch (382:7): [True: 0, False: 4.47k]
  |  Branch (382:17): [True: 0, False: 4.47k]
  |  Branch (382:26): [True: 0, False: 0]
  |  Branch (382:35): [True: 0, False: 0]
  |  Branch (382:50): [True: 0, False: 0]
  ------------------
  383|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  384|       |
  385|  4.47k|	r = sc_apdu_get_octets(card->ctx, apdu, &sbuf, &ssize, SC_PROTO_RAW);
  ------------------
  |  |  354|  4.47k|#define SC_PROTO_RAW		0x00001000
  ------------------
  386|  4.47k|	if (r == SC_SUCCESS)
  ------------------
  |  |   28|  4.47k|#define SC_SUCCESS				0
  ------------------
  |  Branch (386:6): [True: 4.47k, False: 0]
  ------------------
  387|  4.47k|		sc_apdu_log(card->ctx, sbuf, ssize, 1);
  ------------------
  |  |  291|  4.47k|	sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, is_outgoing != 0 ? "Outgoing APDU" : "Incoming APDU", data, len)
  |  |  ------------------
  |  |  |  |  127|  8.94k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:65): [True: 4.47k, Folded]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  388|  4.47k|	if (sbuf)
  ------------------
  |  Branch (388:6): [True: 4.47k, False: 0]
  ------------------
  389|  4.47k|		free(sbuf);
  390|       |
  391|  4.47k|	if (cipher) {
  ------------------
  |  Branch (391:6): [True: 0, False: 4.47k]
  ------------------
  392|      0|		blocks = (apdu->lc + 2) / 8 + 1;
  393|      0|		cipher_data_size = blocks * 8;
  394|      0|		cipher_data = malloc(cipher_data_size);
  395|      0|		if (!cipher_data) {
  ------------------
  |  Branch (395:7): [True: 0, False: 0]
  ------------------
  396|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  397|      0|			goto out;
  398|      0|		}
  399|       |
  400|      0|		if ((r = entersafe_cipher_apdu(card, apdu, key, keylen, cipher_data, cipher_data_size)) < 0)
  ------------------
  |  Branch (400:7): [True: 0, False: 0]
  ------------------
  401|      0|			goto out;
  402|      0|	}
  403|  4.47k|	if (mac) {
  ------------------
  |  Branch (403:6): [True: 0, False: 4.47k]
  ------------------
  404|      0|		mac_data_size = apdu->lc + 4;
  405|      0|		mac_data = malloc(mac_data_size);
  406|      0|		if (!mac_data) {
  ------------------
  |  Branch (406:7): [True: 0, False: 0]
  ------------------
  407|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  408|      0|			goto out;
  409|      0|		}
  410|      0|		r = entersafe_mac_apdu(card, apdu, key, keylen, mac_data, mac_data_size);
  411|      0|		if (r < 0)
  ------------------
  |  Branch (411:7): [True: 0, False: 0]
  ------------------
  412|      0|			goto out;
  413|      0|	}
  414|       |
  415|  4.47k|	r = sc_transmit_apdu(card, apdu);
  416|       |
  417|  4.47k|out:
  418|  4.47k|	free(cipher_data);
  419|  4.47k|	free(mac_data);
  420|       |
  421|  4.47k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  4.47k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  4.47k|	int _ret = r; \
  |  |  155|  4.47k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 4.47k, False: 0]
  |  |  ------------------
  |  |  156|  4.47k|		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|     38|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 38, False: 4.43k]
  |  |  ------------------
  |  |  157|  4.47k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  4.47k|	} 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|  4.47k|	return _ret; \
  |  |  163|  4.47k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  422|  4.47k|}
card-entersafe.c:entersafe_select_file:
  590|    976|{
  591|    976|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (591:6): [True: 0, False: 976]
  |  Branch (591:22): [True: 0, False: 976]
  ------------------
  592|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  593|    976|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    976|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    976|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    976|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 976]
  |  |  ------------------
  ------------------
  594|       |
  595|    976|	switch (in_path->type) {
  596|      0|		case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (596:3): [True: 0, False: 976]
  ------------------
  597|      0|			if (in_path->len != 2)
  ------------------
  |  Branch (597:8): [True: 0, False: 0]
  ------------------
  598|      0|				SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  599|      0|			return entersafe_select_fid(card,in_path->value[0], in_path->value[1], file_out);
  600|    397|		case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|    397|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (600:3): [True: 397, False: 579]
  ------------------
  601|    397|			return entersafe_select_aid(card, in_path, file_out);
  602|    579|		case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|    579|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (602:3): [True: 579, False: 397]
  ------------------
  603|    579|			return entersafe_select_path(card, in_path->value, in_path->len, file_out);
  604|      0|		default:
  ------------------
  |  Branch (604:3): [True: 0, False: 976]
  ------------------
  605|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  606|    976|	}
  607|    976|}
card-entersafe.c:entersafe_select_fid:
  503|    821|{
  504|    821|	int r;
  505|    821|	sc_file_t *file = NULL;
  506|    821|	sc_path_t path;
  507|       |
  508|    821|	memset(&path, 0, sizeof(sc_path_t));
  509|       |
  510|    821|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    821|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  511|    821|	path.value[0] = id_hi;
  512|    821|	path.value[1] = id_lo;
  513|    821|	path.len = 2;
  514|       |
  515|    821|	r = iso_ops->select_file(card, &path, &file);
  516|    821|	if (r < 0)
  ------------------
  |  Branch (516:6): [True: 320, False: 501]
  ------------------
  517|    320|		sc_file_free(file);
  518|    821|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    821|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    821|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    821|	int _ret = (r); \
  |  |  |  |  168|    821|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 320, False: 501]
  |  |  |  |  ------------------
  |  |  |  |  169|    320|		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|    320|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    320|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    320|		return _ret; \
  |  |  |  |  172|    320|	} \
  |  |  |  |  173|    821|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 501]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  519|       |
  520|    501|	if (file_out)
  ------------------
  |  Branch (520:6): [True: 188, False: 313]
  ------------------
  521|    188|		*file_out = file;
  522|    313|	else
  523|    313|		sc_file_free(file);
  524|       |
  525|    501|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 501]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  526|    501|}
card-entersafe.c:entersafe_select_aid:
  531|    397|{
  532|    397|	int r;
  533|       |
  534|    397|	r = iso_ops->select_file(card, in_path, file_out);
  535|    397|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    397|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    397|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    397|	int _ret = (r); \
  |  |  |  |  168|    397|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 316, False: 81]
  |  |  |  |  ------------------
  |  |  |  |  169|    316|		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|    316|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    316|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    316|		return _ret; \
  |  |  |  |  172|    316|	} \
  |  |  |  |  173|    397|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  536|       |
  537|     81|	if (file_out) {
  ------------------
  |  Branch (537:6): [True: 0, False: 81]
  ------------------
  538|      0|		sc_file_t *file = *file_out;
  539|      0|		if (file == NULL)
  ------------------
  |  Branch (539:7): [True: 0, False: 0]
  ------------------
  540|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  541|       |
  542|      0|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  543|      0|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      0|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  544|      0|		file->path.len = 0;
  545|      0|		file->size = 0;
  546|       |		/* AID */
  547|      0|		memcpy(file->name, in_path->value, in_path->len);
  548|      0|		file->namelen = in_path->len;
  549|      0|		file->id = 0x0000;
  550|      0|	}
  551|     81|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|     81|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     81|	int _ret = r; \
  |  |  155|     81|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 81, False: 0]
  |  |  ------------------
  |  |  156|     81|		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: 81]
  |  |  ------------------
  |  |  157|     81|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     81|	} 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|     81|	return _ret; \
  |  |  163|     81|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  552|     81|}
card-entersafe.c:entersafe_select_path:
  557|    579|{
  558|    579|	u8 n_pathbuf[SC_MAX_PATH_SIZE];
  559|    579|	const u8 *path = pathbuf;
  560|    579|	size_t pathlen = len;
  561|    579|	unsigned int i;
  562|    579|	int r;
  563|       |
  564|    579|	if (pathlen % 2 != 0 || pathlen > 6 || pathlen <= 0)
  ------------------
  |  Branch (564:6): [True: 0, False: 579]
  |  Branch (564:26): [True: 10, False: 569]
  |  Branch (564:41): [True: 3, False: 566]
  ------------------
  565|     13|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     13|	int _ret = r; \
  |  |  155|     13|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  ------------------
  |  |  156|     13|		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|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 13, False: 0]
  |  |  ------------------
  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     13|	} 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|     13|	return _ret; \
  |  |  163|     13|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  566|       |
  567|       |	/* if pathlen == 6 then the first FID must be MF (== 3F00) */
  568|    566|	if (pathlen == 6 && (path[0] != 0x3f || path[1] != 0x00))
  ------------------
  |  Branch (568:6): [True: 82, False: 484]
  |  Branch (568:23): [True: 16, False: 66]
  |  Branch (568:42): [True: 10, False: 56]
  ------------------
  569|     26|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  153|     26|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     26|	int _ret = r; \
  |  |  155|     26|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 26, False: 0]
  |  |  ------------------
  |  |  156|     26|		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|     26|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 26, False: 0]
  |  |  ------------------
  |  |  157|     26|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     26|	} 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|     26|	return _ret; \
  |  |  163|     26|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  570|       |
  571|       |	/* unify path (the first FID should be MF) */
  572|    540|	if (path[0] != 0x3f || path[1] != 0x00) {
  ------------------
  |  Branch (572:6): [True: 72, False: 468]
  |  Branch (572:25): [True: 10, False: 458]
  ------------------
  573|     82|		n_pathbuf[0] = 0x3f;
  574|     82|		n_pathbuf[1] = 0x00;
  575|     82|		memcpy(n_pathbuf + 2, path, pathlen);
  576|     82|		path = n_pathbuf;
  577|     82|		pathlen += 2;
  578|     82|	}
  579|       |
  580|    821|	for (i = 0; i < pathlen - 2; i += 2) {
  ------------------
  |  Branch (580:14): [True: 576, False: 245]
  ------------------
  581|    576|		r = entersafe_select_fid(card, path[i], path[i + 1], NULL);
  582|    576|		LOG_TEST_RET(card->ctx, r, "SELECT FILE (DF-ID) failed");
  ------------------
  |  |  174|    576|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    576|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    576|	int _ret = (r); \
  |  |  |  |  168|    576|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 295, False: 281]
  |  |  |  |  ------------------
  |  |  |  |  169|    295|		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|    295|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    295|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    295|		return _ret; \
  |  |  |  |  172|    295|	} \
  |  |  |  |  173|    576|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 281]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|    576|	}
  584|    245|	return entersafe_select_fid(card, path[pathlen - 2], path[pathlen - 1], file_out);
  585|    540|}
card-entersafe.c:entersafe_pin_cmd:
  880|     12|{
  881|     12|	int r;
  882|     12|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     12|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     12|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     12|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 12]
  |  |  ------------------
  ------------------
  883|     12|	entersafe_init_pin_info(&data->pin1, 0);
  884|     12|	entersafe_init_pin_info(&data->pin2, 1);
  885|     12|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|     12|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  886|       |
  887|     12|	if (data->cmd != SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  417|     12|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (887:6): [True: 12, False: 0]
  ------------------
  888|     12|		r = iso_ops->pin_cmd(card, data);
  889|     12|		sc_log(card->ctx, "Verify rv:%i", r);
  ------------------
  |  |   71|     12|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  890|     12|	} else {
  891|      0|		{ /*verify*/
  892|      0|			sc_apdu_t apdu;
  893|      0|			u8 sbuf[0x10] = {0};
  894|       |
  895|      0|			if (data->pin1.len > sizeof(sbuf)) {
  ------------------
  |  Branch (895:8): [True: 0, False: 0]
  ------------------
  896|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  897|      0|			}
  898|       |
  899|      0|			memcpy(sbuf, data->pin1.data, data->pin1.len);
  900|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x20, 0x00, data->pin_reference + 1);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  901|      0|			apdu.lc = apdu.datalen = sizeof(sbuf);
  902|      0|			apdu.data = sbuf;
  903|       |
  904|      0|			r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
  905|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  906|      0|		}
  907|       |
  908|      0|		{ /*change*/
  909|      0|			sc_apdu_t apdu;
  910|      0|			u8 sbuf[0x12] = {0};
  911|       |
  912|      0|			if (data->pin2.len + 2 > sizeof(sbuf)) {
  ------------------
  |  Branch (912:8): [True: 0, False: 0]
  ------------------
  913|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  914|      0|			}
  915|       |
  916|      0|			sbuf[0] = 0x33;
  917|      0|			sbuf[1] = 0x00;
  918|      0|			memcpy(sbuf + 2, data->pin2.data, data->pin2.len);
  919|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xF4, 0x0B, data->pin_reference);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  920|      0|			apdu.cla = 0x84;
  921|      0|			apdu.lc = apdu.datalen = sizeof(sbuf);
  922|      0|			apdu.data = sbuf;
  923|       |
  924|      0|			r = entersafe_transmit_apdu(card, &apdu, key_maintain, sizeof(key_maintain), 1, 1);
  925|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  926|      0|		}
  927|      0|	}
  928|     12|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|     12|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     12|	int _ret = r; \
  |  |  155|     12|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 12, False: 0]
  |  |  ------------------
  |  |  156|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 12, False: 0]
  |  |  ------------------
  |  |  157|     12|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     12|	} 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|     12|	return _ret; \
  |  |  163|     12|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  929|     12|}
card-entersafe.c:entersafe_init_pin_info:
  870|     24|{
  871|     24|	pin->encoding   = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|     24|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  872|     24|	pin->min_length = 4;
  873|     24|	pin->max_length = 16;
  874|     24|	pin->pad_length = 16;
  875|     24|	pin->offset     = 5 + num * 16;
  876|     24|	pin->pad_char   = 0x00;
  877|     24|}
card-entersafe.c:entersafe_card_ctl_2048:
 1522|    345|{
 1523|    345|	sc_entersafe_create_data *tmp = (sc_entersafe_create_data *)ptr;
 1524|       |
 1525|    345|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    345|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    345|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    345|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 345]
  |  |  ------------------
  ------------------
 1526|       |
 1527|    345|	switch (cmd) {
 1528|      0|		case SC_CARDCTL_ENTERSAFE_CREATE_FILE:
  ------------------
  |  Branch (1528:3): [True: 0, False: 345]
  ------------------
 1529|      0|			if (tmp->type == SC_ENTERSAFE_MF_DATA)
  ------------------
  |  |  666|      0|#define	SC_ENTERSAFE_MF_DATA	0x01
  ------------------
  |  Branch (1529:8): [True: 0, False: 0]
  ------------------
 1530|      0|				return entersafe_create_mf(card, tmp);
 1531|      0|			else if (tmp->type == SC_ENTERSAFE_DF_DATA)
  ------------------
  |  |  667|      0|#define SC_ENTERSAFE_DF_DATA	0x02
  ------------------
  |  Branch (1531:13): [True: 0, False: 0]
  ------------------
 1532|      0|				return entersafe_create_df(card, tmp);
 1533|      0|			else if (tmp->type == SC_ENTERSAFE_EF_DATA)
  ------------------
  |  |  668|      0|#define SC_ENTERSAFE_EF_DATA	0x04
  ------------------
  |  Branch (1533:13): [True: 0, False: 0]
  ------------------
 1534|      0|				return entersafe_create_ef(card, tmp);
 1535|      0|			else
 1536|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1537|      0|		case SC_CARDCTL_ENTERSAFE_WRITE_KEY:
  ------------------
  |  Branch (1537:3): [True: 0, False: 345]
  ------------------
 1538|      0|			return entersafe_write_key(card, (sc_entersafe_wkey_data *)ptr);
 1539|      0|		case SC_CARDCTL_ENTERSAFE_GENERATE_KEY:
  ------------------
  |  Branch (1539:3): [True: 0, False: 345]
  ------------------
 1540|      0|			return entersafe_gen_key(card, (sc_entersafe_gen_key_data *)ptr);
 1541|      0|		case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (1541:3): [True: 0, False: 345]
  ------------------
 1542|      0|			return entersafe_erase_card(card);
 1543|    322|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1543:3): [True: 322, False: 23]
  ------------------
 1544|    322|			return entersafe_get_serialnr(card, (sc_serial_number_t *)ptr);
 1545|      0|		case SC_CARDCTL_ENTERSAFE_PREINSTALL_KEYS:
  ------------------
  |  Branch (1545:3): [True: 0, False: 345]
  ------------------
 1546|      0|			return entersafe_preinstall_keys(card, entersafe_preinstall_rsa_2048);
 1547|     23|		default:
  ------------------
  |  Branch (1547:3): [True: 23, False: 322]
  ------------------
 1548|     23|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     23|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1549|    345|	}
 1550|    345|}
card-entersafe.c:entersafe_get_serialnr:
 1347|    322|{
 1348|    322|	int	r;
 1349|    322|	sc_apdu_t apdu;
 1350|    322|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1351|       |
 1352|    322|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    322|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    322|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    322|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 322]
  |  |  ------------------
  ------------------
 1353|    322|	if (serial == NULL)
  ------------------
  |  Branch (1353:6): [True: 0, False: 322]
  ------------------
 1354|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1355|       |
 1356|    322|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xEA, 0x00, 0x00);
  ------------------
  |  |  292|    322|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1357|    322|	apdu.cla = 0x80;
 1358|    322|	apdu.resp = rbuf;
 1359|    322|	apdu.resplen = sizeof(rbuf);
 1360|    322|	apdu.le = 0x08;
 1361|       |
 1362|    322|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
 1363|    322|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    322|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    322|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    322|	int _ret = (r); \
  |  |  |  |  168|    322|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 16, False: 306]
  |  |  |  |  ------------------
  |  |  |  |  169|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     16|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     16|		return _ret; \
  |  |  |  |  172|     16|	} \
  |  |  |  |  173|    322|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 306]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1364|    306|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "EnterSafe get SN failed");
  ------------------
  |  |  174|    306|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    306|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    306|	int _ret = (r); \
  |  |  |  |  168|    306|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 257, False: 49]
  |  |  |  |  ------------------
  |  |  |  |  169|    257|		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|    257|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    257|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    257|		return _ret; \
  |  |  |  |  172|    257|	} \
  |  |  |  |  173|    306|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 49]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1365|     49|	if (apdu.resplen != 8)
  ------------------
  |  Branch (1365:6): [True: 33, False: 16]
  ------------------
 1366|     49|		LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid length of SN");
  ------------------
  |  |  174|     33|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     33|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     33|	int _ret = (r); \
  |  |  |  |  168|     33|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 33, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     33|		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|     33|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     33|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     33|		return _ret; \
  |  |  |  |  172|     33|	} \
  |  |  |  |  173|     33|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1367|       |
 1368|     16|	card->serialnr.len = serial->len = 8;
 1369|     16|	memcpy(card->serialnr.value, rbuf, 8);
 1370|     16|	memcpy(serial->value, rbuf, 8);
 1371|       |
 1372|     16|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|     16|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     16|	int _ret = r; \
  |  |  155|     16|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 16, False: 0]
  |  |  ------------------
  |  |  156|     16|		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: 16]
  |  |  ------------------
  |  |  157|     16|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     16|	} 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|     16|	return _ret; \
  |  |  163|     16|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1373|     16|}
card-entersafe.c:entersafe_process_fci:
  479|    377|{
  480|    377|	int r;
  481|       |
  482|    377|	if (file == NULL)
  ------------------
  |  Branch (482:6): [True: 0, False: 377]
  ------------------
  483|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  484|    377|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    377|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    377|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    377|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 377]
  |  |  ------------------
  ------------------
  485|       |
  486|    377|	r = iso_ops->process_fci(card, file, buf, buflen);
  487|    377|	LOG_TEST_RET(card->ctx, r, "Process fci failed");
  ------------------
  |  |  174|    377|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    377|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    377|	int _ret = (r); \
  |  |  |  |  168|    377|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 377]
  |  |  |  |  ------------------
  |  |  |  |  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|    377|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 377]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|       |
  489|    377|	if (file->namelen) {
  ------------------
  |  Branch (489:6): [True: 10, False: 367]
  ------------------
  490|     10|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     10|#define SC_FILE_TYPE_DF			0x04
  ------------------
  491|     10|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|     10|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  492|    367|	} else {
  493|    367|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    367|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  494|    367|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|    367|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  495|    367|	}
  496|       |
  497|    377|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    377|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    377|	int _ret = r; \
  |  |  155|    377|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 377, False: 0]
  |  |  ------------------
  |  |  156|    377|		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: 377]
  |  |  ------------------
  |  |  157|    377|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    377|	} 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|    377|	return _ret; \
  |  |  163|    377|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  498|    377|}

sc_get_eoi_driver:
  580|  17.0k|{
  581|  17.0k|	eoi_ops = *sc_get_iso7816_driver()->ops;
  582|       |
  583|  17.0k|	eoi_ops.match_card = eoi_match_card;
  584|  17.0k|	eoi_ops.init = eoi_init;
  585|  17.0k|	eoi_ops.finish = eoi_finish;
  586|  17.0k|	eoi_ops.select_file = eoi_select_file;
  587|  17.0k|	eoi_ops.logout = eoi_logout;
  588|  17.0k|	eoi_ops.pin_cmd = eoi_pin_cmd;
  589|  17.0k|	eoi_ops.card_ctl = eoi_card_ctl;
  590|  17.0k|	eoi_ops.set_security_env = eoi_set_security_env;
  591|  17.0k|	eoi_ops.compute_signature = eoi_compute_signature;
  592|       |
  593|  17.0k|	return &eoi_drv;
  594|  17.0k|}
card-eoi.c:eoi_match_card:
  250|  2.45k|static int eoi_match_card(sc_card_t* card) {
  251|  2.45k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.45k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.45k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.45k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.45k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.45k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  252|  2.45k|	if (_sc_match_atr(card, eoi_atrs, &card->type) >= 0) {
  ------------------
  |  Branch (252:6): [True: 70, False: 2.38k]
  ------------------
  253|     70|		sc_log(card->ctx, "ATR recognized as Slovenian eID card");
  ------------------
  |  |   71|     70|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  254|     70|		LOG_FUNC_RETURN(card->ctx, ATR_MATCH);
  ------------------
  |  |  164|     70|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     70|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     70|	int _ret = r; \
  |  |  |  |  155|     70|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 70]
  |  |  |  |  ------------------
  |  |  |  |  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|     70|	} else { \
  |  |  |  |  159|     70|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     70|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     70|	} \
  |  |  |  |  162|     70|	return _ret; \
  |  |  |  |  163|     70|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  255|     70|	}
  256|  2.38k|	LOG_FUNC_RETURN(card->ctx, !ATR_MATCH);
  ------------------
  |  |  164|  2.38k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.38k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.38k|	int _ret = r; \
  |  |  |  |  155|  2.38k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.38k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.38k|		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: 2.38k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.38k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.38k|	} 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|  2.38k|	return _ret; \
  |  |  |  |  163|  2.38k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|  2.38k|}
card-eoi.c:eoi_init:
  259|     70|static int eoi_init(sc_card_t* card) {
  260|     70|	struct eoi_privdata *privdata = (struct eoi_privdata *)card->drv_data;
  261|     70|	u8 version[6];
  262|     70|	size_t i, j;
  263|     70|	scconf_block **found_blocks, *block;
  264|     70|	int r;
  265|     70|	char *can;
  266|       |
  267|     70|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     70|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     70|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     70|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     70|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 70]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  268|       |
  269|     70|	if (eoi_get_data(card, 0x16, version, sizeof(version)) != SC_SUCCESS)
  ------------------
  |  |   28|     70|#define SC_SUCCESS				0
  ------------------
  |  Branch (269:6): [True: 54, False: 16]
  ------------------
  270|     70|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|     54|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     54|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     54|	int _ret = r; \
  |  |  |  |  155|     54|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 54, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     54|		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|     54|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 54, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     54|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     54|	} 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|     54|	return _ret; \
  |  |  |  |  163|     54|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|       |
  272|     16|	if (privdata)
  ------------------
  |  Branch (272:6): [True: 0, False: 16]
  ------------------
  273|     16|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  274|     16|	privdata = sc_mem_secure_alloc(sizeof(struct eoi_privdata));
  275|     16|	if (!privdata)
  ------------------
  |  Branch (275:6): [True: 0, False: 16]
  ------------------
  276|     16|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  277|       |	/* sc_mem_secure_alloc()-ed memory may not be zeroized */
  278|     16|	memset(privdata, 0, sizeof(struct eoi_privdata));
  279|     16|	card->drv_data = privdata;
  280|       |
  281|     16|	sprintf(privdata->version, "%X%02X.%02X%02X", version[0], version[1], version[2], version[3]);
  282|     16|	sc_log(card->ctx, "App version: %s", privdata->version);
  ------------------
  |  |   71|     16|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  283|       |
  284|     16|	memset(&card->sm_ctx, 0, sizeof card->sm_ctx);
  285|     16|	card->sm_ctx.ops.open = eoi_sm_open;
  286|       |
  287|     16|	card->max_send_size = SC_MAX_APDU_DATA_SIZE;
  ------------------
  |  |   35|     16|#define SC_MAX_APDU_DATA_SIZE		0xFF
  ------------------
  288|     16|	card->max_recv_size = SC_MAX_APDU_RESP_SIZE;
  ------------------
  |  |   36|     16|#define SC_MAX_APDU_RESP_SIZE		(0xFF+1)
  ------------------
  289|       |
  290|     32|	for (i = 0; i < sizeof eoi_curves / sizeof * eoi_curves; ++i) {
  ------------------
  |  Branch (290:14): [True: 16, False: 16]
  ------------------
  291|     16|		r = _sc_card_add_ec_alg(card, eoi_curves[i].len, SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDSA_HASH_NONE, 0, &eoi_curves[i].oid);
  ------------------
  |  |  174|     16|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              		r = _sc_card_add_ec_alg(card, eoi_curves[i].len, SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDSA_HASH_NONE, 0, &eoi_curves[i].oid);
  ------------------
  |  |  175|     16|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|     16|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  292|     16|		LOG_TEST_GOTO_ERR(card->ctx, r, "Add EC alg failed");
  ------------------
  |  |  184|     16|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     16|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     16|	int _ret = (r); \
  |  |  |  |  178|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|     16|	}
  294|       |
  295|     16|	can = getenv("EOI_CAN");
  296|     16|	if (can)
  ------------------
  |  Branch (296:6): [True: 0, False: 16]
  ------------------
  297|      0|		strlcpy(privdata->can, can, sizeof(privdata->can));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  298|     32|	for (i = 0; card->ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (298:14): [True: 16, False: 16]
  ------------------
  299|     16|		found_blocks = scconf_find_blocks(card->ctx->conf, card->ctx->conf_blocks[i],
  300|     16|					"card_driver", "eoi");
  301|     16|		if (!found_blocks)
  ------------------
  |  Branch (301:7): [True: 0, False: 16]
  ------------------
  302|      0|			continue;
  303|       |
  304|     16|		for (j = 0, block = found_blocks[j]; block; j++, block = found_blocks[j]) {
  ------------------
  |  Branch (304:40): [True: 0, False: 16]
  ------------------
  305|      0|			if (!privdata->can[0]) {
  ------------------
  |  Branch (305:8): [True: 0, False: 0]
  ------------------
  306|      0|				const char *can = scconf_get_str(block, "can", NULL);
  307|      0|				if (can)
  ------------------
  |  Branch (307:9): [True: 0, False: 0]
  ------------------
  308|      0|					strlcpy(privdata->can, can, sizeof(privdata->can));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  309|      0|			}
  310|      0|		}
  311|     16|		free(found_blocks);
  312|     16|	}
  313|       |
  314|     16|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     16|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     16|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     16|	int _ret = r; \
  |  |  |  |  155|     16|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     16|		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: 16]
  |  |  |  |  ------------------
  |  |  |  |  157|     16|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     16|	} 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|     16|	return _ret; \
  |  |  |  |  163|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|       |
  316|      0|err:
  317|      0|	if (privdata) {
  ------------------
  |  Branch (317:6): [True: 0, False: 0]
  ------------------
  318|      0|		sc_mem_clear(privdata, sizeof(struct eoi_privdata));
  319|      0|		sc_mem_secure_free(privdata, sizeof(struct eoi_privdata));
  320|      0|	}
  321|      0|	card->drv_data = NULL;
  322|       |
  323|      0|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  324|      0|}
card-eoi.c:eoi_get_data:
  233|     70|{
  234|     70|	int r;
  235|     70|	sc_apdu_t apdu;
  236|       |
  237|     70|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, data_id);
  ------------------
  |  |  292|     70|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  238|     70|	apdu.resp = buf;
  239|     70|	apdu.resplen = len;
  240|     70|	apdu.le = len;
  241|       |
  242|     70|	r = sc_transmit_apdu(card, &apdu);
  243|     70|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     70|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     70|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     70|	int _ret = (r); \
  |  |  |  |  168|     70|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 68]
  |  |  |  |  ------------------
  |  |  |  |  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|     70|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 68]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  244|     68|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  245|     68|	return r;
  246|     70|}
card-eoi.c:eoi_finish:
  327|     16|{
  328|     16|	struct eoi_privdata *privdata = (struct eoi_privdata *)card->drv_data;
  329|       |
  330|     16|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     16|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     16|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     16|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     16|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  331|       |
  332|     16|	if (privdata) {
  ------------------
  |  Branch (332:6): [True: 16, False: 0]
  ------------------
  333|     16|		sc_mem_clear(privdata, sizeof(struct eoi_privdata));
  334|     16|		sc_mem_secure_free(privdata, sizeof(struct eoi_privdata));
  335|     16|	}
  336|       |
  337|     16|	card->drv_data = NULL;
  338|       |
  339|     16|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     16|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     16|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     16|	int _ret = r; \
  |  |  |  |  155|     16|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     16|		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: 16]
  |  |  |  |  ------------------
  |  |  |  |  157|     16|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     16|	} 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|     16|	return _ret; \
  |  |  |  |  163|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  340|     16|}
card-eoi.c:eoi_select_file:
  343|    105|{
  344|    105|	struct eoi_privdata *privdata = (struct eoi_privdata *)card->drv_data;
  345|    105|	int i;
  346|       |
  347|    105|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    105|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    105|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    105|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    105|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 105]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  348|       |
  349|    105|	if (!privdata)
  ------------------
  |  Branch (349:6): [True: 0, False: 105]
  ------------------
  350|    105|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|       |
  352|    105|	for (i = 0; i < MAX_OBJECTS && privdata->pin_paths[i]; i++) {
  ------------------
  |  |   24|    210|#define MAX_OBJECTS 8
  ------------------
  |  Branch (352:14): [True: 105, False: 0]
  |  Branch (352:33): [True: 0, False: 105]
  ------------------
  353|      0|		if (privdata->pin_paths[i] && sc_compare_path(privdata->pin_paths[i], in_path)) {
  ------------------
  |  Branch (353:7): [True: 0, False: 0]
  |  Branch (353:33): [True: 0, False: 0]
  ------------------
  354|      0|			LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|      0|		}
  356|      0|	}
  357|       |
  358|    105|	LOG_FUNC_RETURN(card->ctx, sc_get_iso7816_driver()->ops->select_file(card, in_path, file_out));
  ------------------
  |  |  164|    105|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    105|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    105|	int _ret = r; \
  |  |  |  |  155|    105|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 105, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    105|		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|     79|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 79, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  157|    105|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    105|	} 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|    105|	return _ret; \
  |  |  |  |  163|    105|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  359|    105|}
card-eoi.c:eoi_pin_cmd:
  395|      3|{
  396|      3|	int r;
  397|       |
  398|      3|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      3|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      3|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      3|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      3|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  399|       |
  400|      3|	if (data->cmd == SC_PIN_CMD_VERIFY && card->sm_ctx.sm_mode == SM_MODE_NONE) {
  ------------------
  |  |  415|      6|#define SC_PIN_CMD_VERIFY	0
  ------------------
              	if (data->cmd == SC_PIN_CMD_VERIFY && card->sm_ctx.sm_mode == SM_MODE_NONE) {
  ------------------
  |  |   43|      0|#define SM_MODE_NONE		0x0
  ------------------
  |  Branch (400:6): [True: 0, False: 3]
  |  Branch (400:40): [True: 0, False: 0]
  ------------------
  401|       |		/* Establish SM before any PIN VERIFY command */
  402|      0|		r = eoi_sm_open(card);
  403|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (403:7): [True: 0, False: 0]
  ------------------
  404|      0|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  405|      0|	}
  406|       |
  407|      3|	if (data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  417|      3|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (407:6): [True: 0, False: 3]
  ------------------
  408|      0|		int pin_reference = data->pin_reference;
  409|      0|		size_t pin2_len = data->pin2.len;
  410|       |		/* Verify PUK, establish SM if necessary */
  411|      0|		data->cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  412|      0|		data->pin_reference = data->puk_reference;
  413|      0|		r = eoi_pin_cmd(card, data);
  414|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (414:7): [True: 0, False: 0]
  ------------------
  415|      0|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|       |		/* RESET RETRY COUNTER */
  417|      0|		data->cmd = SC_PIN_CMD_UNBLOCK;
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  418|      0|		data->pin_reference = 0x80|pin_reference;
  419|      0|		data->pin1.len = 0;
  420|      0|		data->pin2.len = 0;
  421|      0|		r = sc_get_iso7816_driver()->ops->pin_cmd(card, data);
  422|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (422:7): [True: 0, False: 0]
  ------------------
  423|      0|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  424|       |		/* Continue as CHANGE PIN */
  425|      0|		data->cmd = SC_PIN_CMD_CHANGE;
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  426|      0|		data->pin2.len = pin2_len;
  427|      0|	}
  428|       |
  429|       |	/* CHANGE PIN command does not send the old PIN as it should already be verified */
  430|      3|	if (data->cmd == SC_PIN_CMD_CHANGE)
  ------------------
  |  |  416|      3|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (430:6): [True: 0, False: 3]
  ------------------
  431|      0|		data->pin1.len = 0;
  432|       |
  433|      3|	LOG_FUNC_RETURN(card->ctx, sc_get_iso7816_driver()->ops->pin_cmd(card, data));
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} 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|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|      3|}
card-eoi.c:eoi_card_ctl:
  438|     10|{
  439|     10|	struct sc_card_driver *iso_driver = NULL;
  440|     10|	int r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     10|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  441|       |
  442|     10|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     10|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     10|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     10|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     10|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  443|     10|	switch (cmd) {
  444|      4|	case SC_CARDCTL_GET_MODEL:
  ------------------
  |  Branch (444:2): [True: 4, False: 6]
  ------------------
  445|      4|		if (!ptr) {
  ------------------
  |  Branch (445:7): [True: 0, False: 4]
  ------------------
  446|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  447|      4|		} else {
  448|      4|			*(char **)ptr = eoi_model;
  449|      4|			r = SC_SUCCESS;
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  450|      4|		}
  451|      4|		break;
  452|      6|	default:
  ------------------
  |  Branch (452:2): [True: 6, False: 4]
  ------------------
  453|      6|		iso_driver = sc_get_iso7816_driver();
  454|      6|		if (iso_driver->ops->card_ctl != NULL) {
  ------------------
  |  Branch (454:7): [True: 0, False: 6]
  ------------------
  455|      0|			r = sc_get_iso7816_driver()->ops->card_ctl(card, cmd, ptr);
  456|      0|		}
  457|     10|	}
  458|     10|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     10|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     10|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     10|	int _ret = r; \
  |  |  |  |  155|     10|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     10|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|     10|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     10|	} 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|     10|	return _ret; \
  |  |  |  |  163|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  459|     10|}

epass2003_refresh:
  926|    755|{
  927|    755|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    755|#define SC_SUCCESS				0
  ------------------
  928|    755|	epass2003_exdata *exdata = NULL;
  929|       |
  930|    755|	if (!card->drv_data)
  ------------------
  |  Branch (930:6): [True: 0, False: 755]
  ------------------
  931|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  932|       |
  933|    755|	exdata = (epass2003_exdata *)card->drv_data;
  934|       |
  935|    755|	if (exdata->sm) {
  ------------------
  |  Branch (935:6): [True: 567, False: 188]
  ------------------
  936|    567|		card->sm_ctx.sm_mode = 0;
  937|    567|		r = mutual_auth(card, g_init_key_enc, g_init_key_mac);
  938|    567|		card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|    567|#define SM_MODE_TRANSMIT	0x200
  ------------------
  939|    567|		LOG_TEST_RET(card->ctx, r, "mutual_auth failed");
  ------------------
  |  |  174|    567|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    567|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    567|	int _ret = (r); \
  |  |  |  |  168|    567|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 567, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    567|		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|    567|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    567|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    567|		return _ret; \
  |  |  |  |  172|    567|	} \
  |  |  |  |  173|    567|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  940|    567|	}
  941|       |
  942|    188|	return r;
  943|    755|}
sec_attr_to_entry:
 2253|  2.36k|{
 2254|  2.36k|	int i;
 2255|  2.36k|	int found = 0;
 2256|       |
 2257|  2.36k|	unsigned int method;
 2258|  2.36k|	unsigned long  keyref;
 2259|       |
 2260|  2.36k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  2.36k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.36k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.36k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.36k]
  |  |  ------------------
  ------------------
 2261|       |
 2262|  2.36k|	switch (file->sec_attr[index]) {
 2263|    867|	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE):
  ------------------
  |  |  739|    867|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE):
  ------------------
  |  |  734|    867|#define EPASS2003_AC_EVERYONE		0x00
  ------------------
  |  Branch (2263:2): [True: 867, False: 1.49k]
  ------------------
 2264|    867|		method = SC_AC_NONE;
  ------------------
  |  |  150|    867|#define SC_AC_NONE			0x00000000
  ------------------
 2265|    867|		keyref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|    867|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 2266|    867|		break;
 2267|    360|	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER):
  ------------------
  |  |  739|    360|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER):
  ------------------
  |  |  735|    360|#define EPASS2003_AC_USER		0x06
  ------------------
  |  Branch (2267:2): [True: 360, False: 2.00k]
  ------------------
 2268|    360|		method = SC_AC_CHV;
  ------------------
  |  |  151|    360|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 2269|    360|		keyref = 1;
 2270|    360|		break;
 2271|  1.13k|	default:
  ------------------
  |  Branch (2271:2): [True: 1.13k, False: 1.22k]
  ------------------
 2272|  1.13k|		sc_log(card->ctx, "Unknown value 0x%2.2x in file->sec_attr[%d]", file->sec_attr[index], index);
  ------------------
  |  |   71|  1.13k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2273|  1.13k|		method = SC_AC_NEVER;
  ------------------
  |  |  163|  1.13k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 2274|  1.13k|		keyref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  1.13k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 2275|  1.13k|		break;
 2276|  2.36k|	}
 2277|       |
 2278|  80.3k|	for (i = 0; i < (int)(sizeof(sec_attr_to_acl_entry) / sizeof(sec_attr_to_acl_entries_t)); i++) {
  ------------------
  |  Branch (2278:14): [True: 77.9k, False: 2.36k]
  ------------------
 2279|  77.9k|		const sec_attr_to_acl_entries_t *e = &sec_attr_to_acl_entry[i];
 2280|       |
 2281|  77.9k|		if (index == e->index && file->type == e->file_type
  ------------------
  |  Branch (2281:7): [True: 6.28k, False: 71.6k]
  |  Branch (2281:28): [True: 2.36k, False: 3.91k]
  ------------------
 2282|  2.36k|				&& file->ef_structure == e->file_ef_structure) {
  ------------------
  |  Branch (2282:8): [True: 103, False: 2.26k]
  ------------------
 2283|       |				/* may add multiple entries */
 2284|    103|			sc_file_add_acl_entry(file, e->op, method, keyref);
 2285|    103|			found++;
 2286|    103|		}
 2287|  77.9k|	}
 2288|  2.36k|	if (found != 1) {
  ------------------
  |  Branch (2288:6): [True: 2.26k, False: 103]
  ------------------
 2289|  2.26k|		sc_log(card->ctx,"found %d entries ", found);
  ------------------
  |  |   71|  2.26k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2290|  2.26k|	}
 2291|       |
 2292|  2.36k|	return 0;
 2293|  2.36k|}
sc_get_epass2003_driver:
 3322|  17.0k|{
 3323|  17.0k|	return sc_get_driver();
 3324|  17.0k|}
card-epass2003.c:mutual_auth:
  896|    567|{
  897|    567|	struct sc_context *ctx = card->ctx;
  898|    567|	int r;
  899|    567|	unsigned char result[256] = {0};
  900|    567|	unsigned char ran_key[8] = {0};
  901|    567|	epass2003_exdata *exdata = NULL;
  902|       |
  903|    567|	if (!card->drv_data)
  ------------------
  |  Branch (903:6): [True: 0, False: 567]
  ------------------
  904|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  905|    567|	exdata = (epass2003_exdata *)card->drv_data;
  906|       |
  907|    567|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    567|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    567|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    567|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    567|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 567]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  908|       |
  909|    567|	r = gen_init_key(card, key_enc, key_mac, result, exdata->smtype);
  910|    567|	LOG_TEST_RET(ctx, r, "gen_init_key failed");
  ------------------
  |  |  174|    567|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    567|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    567|	int _ret = (r); \
  |  |  |  |  168|    567|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 567, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    567|		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|    567|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    567|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    567|		return _ret; \
  |  |  |  |  172|    567|	} \
  |  |  |  |  173|    567|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  911|      0|	if (exdata->bFipsCertification) {
  ------------------
  |  Branch (911:6): [True: 0, False: 0]
  ------------------
  912|      0|		memcpy(ran_key, &result[12+1], 8);
  913|      0|	} else {
  914|      0|		memcpy(ran_key, &result[12], 8);
  915|      0|	}
  916|       |
  917|      0|	r = verify_init_key(card, ran_key, exdata->smtype);
  918|      0|	LOG_TEST_RET(ctx, r, "verify_init_key failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  919|       |
  920|      0|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  921|      0|}
card-epass2003.c:gen_init_key:
  679|    567|{
  680|    567|	int r;
  681|    567|	struct sc_apdu apdu;
  682|    567|	unsigned char data[256] = {0};
  683|    567|	unsigned char tmp_sm;
  684|    567|	unsigned char isFips;
  685|    567|	unsigned long blocksize = 0;
  686|    567|	unsigned char cryptogram[256] = {0}; /* host cryptogram */
  687|    567|	unsigned char iv[16] = {0};
  688|    567|	epass2003_exdata *exdata = NULL;
  689|       |
  690|    567|	if (!card->drv_data)
  ------------------
  |  Branch (690:6): [True: 0, False: 567]
  ------------------
  691|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  692|       |
  693|    567|	exdata = (epass2003_exdata *)card->drv_data;
  694|    567|	isFips = exdata->bFipsCertification;
  695|       |
  696|    567|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    567|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    567|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    567|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    567|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 567]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  697|       |
  698|    567|	if (1 != RAND_bytes(g_random, sizeof(g_random)))
  ------------------
  |  Branch (698:6): [True: 0, False: 567]
  ------------------
  699|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  700|       |
  701|    567|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x50, 0x00, 0x00);
  ------------------
  |  |  294|    567|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  702|    567|	apdu.cla = 0x80;
  703|    567|	apdu.lc = apdu.datalen = sizeof(g_random);
  704|    567|	apdu.data = g_random;	/* host random */
  705|    567|	if (isFips)
  ------------------
  |  Branch (705:6): [True: 9, False: 558]
  ------------------
  706|      9|		apdu.le = apdu.resplen = 29;
  707|    558|	else
  708|    558|		apdu.le = apdu.resplen = 28;
  709|       |
  710|    567|	apdu.resp = result;	/* card random is result[12~19] */
  711|       |
  712|    567|	tmp_sm = exdata->sm;
  713|    567|	exdata->sm = SM_PLAIN;
  ------------------
  |  |   91|    567|#define SM_PLAIN				0x00
  ------------------
  714|    567|	r = epass2003_transmit_apdu(card, &apdu);
  715|    567|	exdata->sm = tmp_sm;
  716|    567|	LOG_TEST_RET(card->ctx, r, "APDU gen_init_key failed");
  ------------------
  |  |  174|    567|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    567|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    567|	int _ret = (r); \
  |  |  |  |  168|    567|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 553]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|    567|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 553]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  717|       |
  718|    553|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  719|    553|	LOG_TEST_RET(card->ctx, r, "gen_init_key failed");
  ------------------
  |  |  174|    553|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    553|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    553|	int _ret = (r); \
  |  |  |  |  168|    553|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 526, False: 27]
  |  |  |  |  ------------------
  |  |  |  |  169|    526|		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|    526|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    526|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    526|		return _ret; \
  |  |  |  |  172|    526|	} \
  |  |  |  |  173|    553|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|       |
  721|       |	/* Step 1 - Generate Derivation data */
  722|     27|	if (isFips) {
  ------------------
  |  Branch (722:6): [True: 2, False: 25]
  ------------------
  723|      2|		memset(data, 0x00, 15);
  724|      2|		data[11] = 0x04;
  725|      2|		data[14] = 0x80;
  726|      2|		data[15] = 0x01;
  727|      2|		memcpy(&data[16], g_random, 8);
  728|      2|		memcpy(&data[24], &result[12 + 1], 8);
  729|     25|	} else {
  730|     25|		memcpy(data, &result[16], 4);
  731|     25|		memcpy(&data[4], g_random, 4);
  732|     25|		memcpy(&data[8], &result[12], 4);
  733|     25|		memcpy(&data[12], &g_random[4], 4);
  734|     25|	}
  735|       |
  736|       |	/* Step 2,3 - Create S-ENC/S-MAC Session Key */
  737|     27|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|     27|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (737:6): [True: 13, False: 14]
  ------------------
  738|     13|		if (isFips) {
  ------------------
  |  Branch (738:7): [True: 2, False: 11]
  ------------------
  739|      2|			r = aes128_encrypt_cmac(card, key_enc, 128, data, 32, exdata->sk_enc);
  740|      2|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cmac enc failed");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  741|      2|			memset(&data[11], 0x06, 1);
  742|      2|			r = aes128_encrypt_cmac(card, key_mac, 128, data, 32, exdata->sk_mac);
  743|      2|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cmac mac  failed");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  744|     11|		} else {
  745|     11|			r = aes128_encrypt_ecb(card, key_enc, 16, data, 16, exdata->sk_enc);
  746|     11|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_ecb enc  failed");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  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|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|     11|			r = aes128_encrypt_ecb(card, key_mac, 16, data, 16, exdata->sk_mac);
  748|     11|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_ecb mac  failed");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  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|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  749|     11|		}
  750|     14|	} else {
  751|     14|		r = des3_encrypt_ecb(card, key_enc, 16, data, 16, exdata->sk_enc);
  752|     14|		LOG_TEST_RET(card->ctx, r, "des3_encrypt_ecb failed");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  753|     14|		r = des3_encrypt_ecb(card, key_mac, 16, data, 16, exdata->sk_mac);
  754|     14|		LOG_TEST_RET(card->ctx, r, "des3_encrypt_ecb failed");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  755|     14|	}
  756|       |
  757|     27|	if (isFips) {
  ------------------
  |  Branch (757:6): [True: 2, False: 25]
  ------------------
  758|      2|		data[11] = 0x00;
  759|      2|		data[14] = 0x40;
  760|     25|	} else {
  761|     25|		memcpy(data, g_random, 8);
  762|     25|		memcpy(&data[8], &result[12], 8);
  763|     25|		data[16] = 0x80;
  764|     25|		blocksize = (key_type == KEY_TYPE_AES ? 16 : 8);
  ------------------
  |  |   80|     25|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (764:16): [True: 11, False: 14]
  ------------------
  765|     25|		memset(&data[17], 0x00, blocksize - 1);
  766|     25|	}
  767|       |
  768|       |	/* calculate host cryptogram */
  769|     27|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|     27|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (769:6): [True: 13, False: 14]
  ------------------
  770|     13|		if (isFips) {
  ------------------
  |  Branch (770:7): [True: 2, False: 11]
  ------------------
  771|      2|			r = aes128_encrypt_cmac(card, exdata->sk_enc, 128, data, 32, cryptogram);
  772|     11|		} else {
  773|     11|			r = aes128_encrypt_cbc(card, exdata->sk_enc, 16, iv, data, 16 + blocksize, cryptogram);
  774|     11|		}
  775|     14|	} else {
  776|     14|		r = des3_encrypt_cbc(card, exdata->sk_enc, 16, iv, data, 16 + blocksize, cryptogram);
  777|     14|	}
  778|       |
  779|     27|	LOG_TEST_RET(card->ctx, r, "calculate host cryptogram failed");
  ------------------
  |  |  174|     27|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     27|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     27|	int _ret = (r); \
  |  |  |  |  168|     27|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 27]
  |  |  |  |  ------------------
  |  |  |  |  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|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  780|       |
  781|       |	/* verify card cryptogram */
  782|     27|	if (isFips) {
  ------------------
  |  Branch (782:6): [True: 2, False: 25]
  ------------------
  783|      2|		if (0 != memcmp(&cryptogram[0], &result[20+1], 8))
  ------------------
  |  Branch (783:7): [True: 2, False: 0]
  ------------------
  784|      2|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  785|     25|	} else {
  786|     25|		if (0 != memcmp(&cryptogram[16], &result[20], 8))
  ------------------
  |  Branch (786:7): [True: 25, False: 0]
  ------------------
  787|     25|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  164|     25|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     25|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     25|	int _ret = r; \
  |  |  |  |  155|     25|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 25, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     25|		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|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 25, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     25|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     25|	} 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|     25|	return _ret; \
  |  |  |  |  163|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  788|     25|	}
  789|      0|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  790|      0|}
card-epass2003.c:epass2003_transmit_apdu:
 1635|    567|{
 1636|    567|	int r;
 1637|       |
 1638|    567|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    567|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    567|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    567|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    567|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 567]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1639|       |
 1640|    567|	r = sc_transmit_apdu_t(card, apdu);
 1641|    567|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    567|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    567|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    567|	int _ret = (r); \
  |  |  |  |  168|    567|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 553]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|    567|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 553]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1642|       |
 1643|    553|	return r;
 1644|    567|}
card-epass2003.c:sc_transmit_apdu_t:
  268|  3.81k|{
  269|  3.81k|	size_t resplen = apdu->resplen;
  270|  3.81k|	int r = sc_transmit_apdu(card, apdu);
  271|  3.81k|	if ((0x69 == apdu->sw1 && 0x85 == apdu->sw2) || (0x69 == apdu->sw1 && 0x88 == apdu->sw2)) {
  ------------------
  |  Branch (271:7): [True: 115, False: 3.70k]
  |  Branch (271:28): [True: 64, False: 51]
  |  Branch (271:51): [True: 51, False: 3.70k]
  |  Branch (271:72): [True: 17, False: 34]
  ------------------
  272|     81|		epass2003_refresh(card);
  273|       |		/* renew old resplen */
  274|     81|		apdu->resplen = resplen;
  275|     81|		r = sc_transmit_apdu(card, apdu);
  276|     81|	}
  277|  3.81k|	return r;
  278|  3.81k|}
card-epass2003.c:aes128_encrypt_cmac:
  415|     15|{
  416|     15|	size_t mactlen = 0;
  417|     15|	int r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     15|#define SC_ERROR_INTERNAL			-1400
  ------------------
  418|     15|#if OPENSSL_VERSION_NUMBER < 0x30000000L
  419|     15|	CMAC_CTX *ctx = CMAC_CTX_new();
  420|     15|	if (ctx == NULL) {
  ------------------
  |  Branch (420:6): [True: 0, False: 15]
  ------------------
  421|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  422|      0|	}
  423|       |
  424|     15|	if (!CMAC_Init(ctx, key, keysize / 8, EVP_aes_128_cbc(), NULL)) {
  ------------------
  |  Branch (424:6): [True: 0, False: 15]
  ------------------
  425|      0|		goto err;
  426|      0|	}
  427|     15|	if (!CMAC_Update(ctx, input, length)) {
  ------------------
  |  Branch (427:6): [True: 0, False: 15]
  ------------------
  428|      0|		goto err;
  429|      0|	}
  430|     15|	if (!CMAC_Final(ctx, output, &mactlen)) {
  ------------------
  |  Branch (430:6): [True: 0, False: 15]
  ------------------
  431|      0|		goto err;
  432|      0|	}
  433|     15|	r = SC_SUCCESS;
  ------------------
  |  |   28|     15|#define SC_SUCCESS				0
  ------------------
  434|     15|err:
  435|     15|	CMAC_CTX_free(ctx);
  436|       |#else
  437|       |	EVP_MAC *mac = EVP_MAC_fetch(card->ctx->ossl3ctx->libctx, "cmac", NULL);
  438|       |	if (mac == NULL) {
  439|       |		return r;
  440|       |	}
  441|       |
  442|       |	OSSL_PARAM params[2] = {0};
  443|       |	params[0] = OSSL_PARAM_construct_utf8_string("cipher","aes-128-cbc", 0);
  444|       |	params[1] = OSSL_PARAM_construct_end();
  445|       |
  446|       |	EVP_MAC_CTX *ctx = EVP_MAC_CTX_new(mac);
  447|       |	if (ctx == NULL) {
  448|       |		EVP_MAC_CTX_free(ctx);
  449|       |		sc_log_openssl(card->ctx);
  450|       |		return r;
  451|       |	}
  452|       |	if (!EVP_MAC_init(ctx, (const unsigned char *)key, keysize / 8, params)) {
  453|       |		sc_log_openssl(card->ctx);
  454|       |		goto err;
  455|       |	}
  456|       |	if (!EVP_MAC_update(ctx, input, length)) {
  457|       |		sc_log_openssl(card->ctx);
  458|       |		goto err;
  459|       |	}
  460|       |	if (!EVP_MAC_final(ctx, output, &mactlen, 16)) {
  461|       |		sc_log_openssl(card->ctx);
  462|       |		goto err;
  463|       |	}
  464|       |	r = SC_SUCCESS;
  465|       |err:
  466|       |	EVP_MAC_CTX_free(ctx);
  467|       |	EVP_MAC_free(mac);
  468|       |#endif
  469|     15|	return r;
  470|     15|}
card-epass2003.c:aes128_encrypt_ecb:
  475|     22|{
  476|     22|	unsigned char iv[EVP_MAX_IV_LENGTH] = {0};
  477|     22|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "AES-128-ECB");
  478|     22|	int r;
  479|     22|	r = openssl_enc(alg, key, iv, input, length, output);
  480|     22|	sc_evp_cipher_free(alg);
  481|     22|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     22|#define SC_SUCCESS				0
  ------------------
  |  Branch (481:6): [True: 0, False: 22]
  ------------------
  482|      0|		sc_log_openssl(card->ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  483|     22|	return r;
  484|     22|}
card-epass2003.c:openssl_enc:
  283|  1.76k|{
  284|  1.76k|	int r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  1.76k|#define SC_ERROR_INTERNAL			-1400
  ------------------
  285|  1.76k|	EVP_CIPHER_CTX * ctx = NULL;
  286|  1.76k|	int outl = 0;
  287|  1.76k|	int outl_tmp = 0;
  288|  1.76k|	unsigned char iv_tmp[EVP_MAX_IV_LENGTH] = {0};
  289|       |
  290|  1.76k|	memcpy(iv_tmp, iv, EVP_MAX_IV_LENGTH);
  291|  1.76k|	ctx = EVP_CIPHER_CTX_new();
  292|  1.76k|	if (ctx == NULL)
  ------------------
  |  Branch (292:6): [True: 0, False: 1.76k]
  ------------------
  293|      0|		goto out;
  294|       |
  295|  1.76k|	if (!EVP_EncryptInit_ex(ctx, cipher, NULL, key, iv_tmp) || !EVP_CIPHER_CTX_set_padding(ctx, 0))
  ------------------
  |  Branch (295:6): [True: 0, False: 1.76k]
  |  Branch (295:61): [True: 0, False: 1.76k]
  ------------------
  296|      0|		goto out;
  297|       |
  298|  1.76k|	if (!EVP_EncryptUpdate(ctx, output, &outl, input, (int)length))
  ------------------
  |  Branch (298:6): [True: 0, False: 1.76k]
  ------------------
  299|      0|		goto out;
  300|       |
  301|  1.76k|	if (!EVP_EncryptFinal_ex(ctx, output + outl, &outl_tmp))
  ------------------
  |  Branch (301:6): [True: 0, False: 1.76k]
  ------------------
  302|      0|		goto out;
  303|       |
  304|  1.76k|	r = SC_SUCCESS;
  ------------------
  |  |   28|  1.76k|#define SC_SUCCESS				0
  ------------------
  305|  1.76k|out:
  306|  1.76k|	EVP_CIPHER_CTX_free(ctx);
  307|  1.76k|	return r;
  308|  1.76k|}
card-epass2003.c:des3_encrypt_ecb:
  518|     28|{
  519|     28|	unsigned char iv[EVP_MAX_IV_LENGTH] = {0};
  520|     28|	unsigned char bKey[24] = {0};
  521|     28|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-EDE3");
  522|     28|	int r;
  523|       |
  524|     28|	if (keysize == 16) {
  ------------------
  |  Branch (524:6): [True: 28, False: 0]
  ------------------
  525|     28|		memcpy(&bKey[0], key, 16);
  526|     28|		memcpy(&bKey[16], key, 8);
  527|     28|	} else {
  528|      0|		memcpy(&bKey[0], key, 24);
  529|      0|	}
  530|       |
  531|     28|	r = openssl_enc(alg, bKey, iv, input, length, output);
  532|     28|	sc_evp_cipher_free(alg);
  533|     28|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     28|#define SC_SUCCESS				0
  ------------------
  |  Branch (533:6): [True: 0, False: 28]
  ------------------
  534|      0|		sc_log_openssl(card->ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  535|     28|	return r;
  536|     28|}
card-epass2003.c:aes128_encrypt_cbc:
  490|     64|{
  491|     64|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "AES-128-CBC");
  492|     64|	int r;
  493|     64|	r = openssl_enc(alg, key, iv, input, length, output);
  494|     64|	sc_evp_cipher_free(alg);
  495|     64|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     64|#define SC_SUCCESS				0
  ------------------
  |  Branch (495:6): [True: 0, False: 64]
  ------------------
  496|      0|		sc_log_openssl(card->ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  497|     64|	return r;
  498|     64|}
card-epass2003.c:des3_encrypt_cbc:
  542|    550|{
  543|    550|	unsigned char bKey[24] = {0};
  544|    550|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-EDE3-CBC");
  545|    550|	int r;
  546|       |
  547|    550|	if (keysize == 16) {
  ------------------
  |  Branch (547:6): [True: 550, False: 0]
  ------------------
  548|    550|		memcpy(&bKey[0], key, 16);
  549|    550|		memcpy(&bKey[16], key, 8);
  550|    550|	} else {
  551|      0|		memcpy(&bKey[0], key, 24);
  552|      0|	}
  553|       |
  554|    550|	r = openssl_enc(EVP_des_ede3_cbc(), bKey, iv, input, length, output);
  555|    550|	sc_evp_cipher_free(alg);
  556|    550|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    550|#define SC_SUCCESS				0
  ------------------
  |  Branch (556:6): [True: 0, False: 550]
  ------------------
  557|      0|		sc_log_openssl(card->ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  558|    550|	return r;
  559|    550|}
card-epass2003.c:sc_get_driver:
 3289|  17.0k|{
 3290|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3291|       |
 3292|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (3292:6): [True: 1, False: 17.0k]
  ------------------
 3293|      1|		iso_ops = iso_drv->ops;
 3294|       |
 3295|  17.0k|	epass2003_ops = *iso_ops;
 3296|       |
 3297|  17.0k|	epass2003_ops.match_card = epass2003_match_card;
 3298|  17.0k|	epass2003_ops.init = epass2003_init;
 3299|  17.0k|	epass2003_ops.finish = epass2003_finish;
 3300|  17.0k|	epass2003_ops.write_binary = NULL;
 3301|  17.0k|	epass2003_ops.write_record = NULL;
 3302|  17.0k|	epass2003_ops.select_file = epass2003_select_file;
 3303|       |	epass2003_ops.get_response = NULL;
 3304|  17.0k|	epass2003_ops.restore_security_env = epass2003_restore_security_env;
 3305|  17.0k|	epass2003_ops.set_security_env = epass2003_set_security_env;
 3306|  17.0k|	epass2003_ops.decipher = epass2003_decipher;
 3307|  17.0k|	epass2003_ops.compute_signature = epass2003_decipher;
 3308|  17.0k|	epass2003_ops.create_file = epass2003_create_file;
 3309|  17.0k|	epass2003_ops.delete_file = epass2003_delete_file;
 3310|  17.0k|	epass2003_ops.list_files = epass2003_list_files;
 3311|  17.0k|	epass2003_ops.card_ctl = epass2003_card_ctl;
 3312|  17.0k|	epass2003_ops.process_fci = epass2003_process_fci;
 3313|  17.0k|	epass2003_ops.construct_fci = epass2003_construct_fci;
 3314|  17.0k|	epass2003_ops.pin_cmd = epass2003_pin_cmd;
 3315|  17.0k|	epass2003_ops.check_sw = epass2003_check_sw;
 3316|  17.0k|	epass2003_ops.get_challenge = epass2003_get_challenge;
 3317|  17.0k|	epass2003_ops.logout = epass2003_logout;
 3318|  17.0k|	return &epass2003_drv;
 3319|  17.0k|}
card-epass2003.c:epass2003_match_card:
 1687|  11.1k|{
 1688|  11.1k|	int r;
 1689|       |
 1690|  11.1k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  11.1k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  11.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  11.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  11.1k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 11.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1691|  11.1k|	r = _sc_match_atr(card, epass2003_atrs, &card->type);
 1692|  11.1k|	if (r < 0)
  ------------------
  |  Branch (1692:6): [True: 10.4k, False: 694]
  ------------------
 1693|  10.4k|		return 0;
 1694|       |
 1695|    694|	return 1;
 1696|  11.1k|}
card-epass2003.c:epass2003_init:
 1701|    694|{
 1702|    694|	unsigned int flags;
 1703|    694|	unsigned int ext_flags;
 1704|    694|	unsigned char data[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1705|    694|	size_t datalen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|    694|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 1706|    694|	epass2003_exdata *exdata = NULL;
 1707|    694|	void *old_drv_data = card->drv_data;
 1708|       |
 1709|    694|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    694|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    694|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    694|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    694|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 694]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1710|       |
 1711|    694|	card->name = "epass2003";
 1712|    694|	card->cla = 0x00;
 1713|    694|	exdata = (epass2003_exdata *)calloc(1, sizeof(epass2003_exdata));
 1714|    694|	if (!exdata)
  ------------------
  |  Branch (1714:6): [True: 0, False: 694]
  ------------------
 1715|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1716|       |
 1717|    694|	card->drv_data = exdata;
 1718|       |
 1719|    694|	exdata->sm = SM_SCP01;
  ------------------
  |  |   92|    694|#define SM_SCP01				0x01
  ------------------
 1720|       |
 1721|       |	/* decide FIPS/Non-FIPS mode */
 1722|    694|	if (SC_SUCCESS != get_data(card, 0x86, data, datalen)) {
  ------------------
  |  |   28|    694|#define SC_SUCCESS				0
  ------------------
  |  Branch (1722:6): [True: 20, False: 674]
  ------------------
 1723|     20|		free(exdata);
 1724|     20|		card->drv_data = old_drv_data;
 1725|     20|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     20|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1726|     20|	}
 1727|       |
 1728|    674|	if (memcmp(&data[32], "\x87\x01\x01", 3) == 0 && memcmp(&data[0], "\x80\x01\x01", 3) == 0) {
  ------------------
  |  Branch (1728:6): [True: 28, False: 646]
  |  Branch (1728:51): [True: 5, False: 23]
  ------------------
 1729|      5|		exdata->bFipsCertification = 0x01;
 1730|    669|	} else {
 1731|    669|		exdata->bFipsCertification = 0x00;
 1732|    669|	}
 1733|       |
 1734|    674|	if (0x01 == data[2])
  ------------------
  |  Branch (1734:6): [True: 19, False: 655]
  ------------------
 1735|     19|		exdata->smtype = KEY_TYPE_AES;
  ------------------
  |  |   80|     19|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
 1736|    655|	else
 1737|    655|		exdata->smtype = KEY_TYPE_DES;
  ------------------
  |  |   81|    655|#define KEY_TYPE_DES	0x02	/* Non-FIPS mode */
  ------------------
 1738|       |
 1739|    674|	if (0x84 == data[14]) {
  ------------------
  |  Branch (1739:6): [True: 173, False: 501]
  ------------------
 1740|    173|		if (0x00 == data[16]) {
  ------------------
  |  Branch (1740:7): [True: 171, False: 2]
  ------------------
 1741|    171|			exdata->sm = SM_PLAIN;
  ------------------
  |  |   91|    171|#define SM_PLAIN				0x00
  ------------------
 1742|    171|		}
 1743|    173|	}
 1744|       |
 1745|       |	/* mutual authentication */
 1746|    674|	card->max_recv_size = 0xD8;
 1747|    674|	card->max_send_size = 0xE8;
 1748|       |
 1749|    674|	card->sm_ctx.ops.open = epass2003_refresh;
 1750|    674|	card->sm_ctx.ops.get_sm_apdu = epass2003_sm_get_wrapped_apdu;
 1751|    674|	card->sm_ctx.ops.free_sm_apdu = epass2003_sm_free_wrapped_apdu;
 1752|       |
 1753|       |	/* FIXME (VT): rather then set/unset 'g_sm', better to implement filter for APDUs to be wrapped */
 1754|    674|	epass2003_refresh(card);
 1755|       |
 1756|    674|	card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|    674|#define SM_MODE_TRANSMIT	0x200
  ------------------
 1757|       |
 1758|    674|	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |   93|    674|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  102|    674|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    674|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
 1759|       |
 1760|    674|	_sc_card_add_rsa_alg(card, 512, flags, 0);
 1761|    674|	_sc_card_add_rsa_alg(card, 768, flags, 0);
 1762|    674|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
 1763|    674|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
 1764|       |
 1765|       |	//set EC Alg Flags
 1766|    674|	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |   93|    674|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  176|    674|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|    674|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  178|    674|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  138|    674|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  175|    674|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|    674|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN|SC_ALGORITHM_ECDSA_HASH_SHA1|SC_ALGORITHM_ECDSA_HASH_SHA256|SC_ALGORITHM_ECDSA_HASH_NONE|SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|    674|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
 1767|    674|	ext_flags = 0;
 1768|    674|	_sc_card_add_ec_alg(card, 256, flags, ext_flags, NULL);
 1769|       |
 1770|    674|	card->caps = SC_CARD_CAP_RNG | SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  550|    674|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps = SC_CARD_CAP_RNG | SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|    674|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
 1771|       |
 1772|    674|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    674|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    674|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    674|	int _ret = r; \
  |  |  |  |  155|    674|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 674, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    674|		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: 674]
  |  |  |  |  ------------------
  |  |  |  |  157|    674|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    674|	} 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|    674|	return _ret; \
  |  |  |  |  163|    674|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1773|    674|}
card-epass2003.c:get_data:
 1649|    743|{
 1650|    743|	int r;
 1651|    743|	struct sc_apdu apdu;
 1652|    743|	unsigned char resp[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1653|    743|	size_t resplen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|    743|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 1654|    743|	epass2003_exdata *exdata = NULL;
 1655|       |
 1656|    743|	if (!card->drv_data)
  ------------------
  |  Branch (1656:6): [True: 0, False: 743]
  ------------------
 1657|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1658|       |
 1659|    743|	exdata = (epass2003_exdata *)card->drv_data;
 1660|       |
 1661|    743|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    743|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    743|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    743|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    743|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 743]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1662|       |
 1663|    743|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, type);
  ------------------
  |  |  292|    743|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1664|    743|	apdu.resp = resp;
 1665|    743|	apdu.le = 0;
 1666|    743|	apdu.resplen = resplen;
 1667|    743|	if (0x86 == type) {
  ------------------
  |  Branch (1667:6): [True: 694, False: 49]
  ------------------
 1668|       |		/* No SM temporarily */
 1669|    694|		unsigned char tmp_sm = exdata->sm;
 1670|    694|		exdata->sm = SM_PLAIN;
  ------------------
  |  |   91|    694|#define SM_PLAIN				0x00
  ------------------
 1671|    694|		r = sc_transmit_apdu(card, &apdu);
 1672|    694|		exdata->sm = tmp_sm;
 1673|    694|	} else {
 1674|     49|		r = sc_transmit_apdu_t(card, &apdu);
 1675|     49|	}
 1676|    743|	LOG_TEST_RET(card->ctx, r, "APDU get_data failed");
  ------------------
  |  |  174|    743|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    743|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    743|	int _ret = (r); \
  |  |  |  |  168|    743|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 740]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|    743|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 740]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1677|    740|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1678|    740|	LOG_TEST_RET(card->ctx, r, "get_data failed");
  ------------------
  |  |  174|    740|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    740|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    740|	int _ret = (r); \
  |  |  |  |  168|    740|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 41, False: 699]
  |  |  |  |  ------------------
  |  |  |  |  169|     41|		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|     41|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     41|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     41|		return _ret; \
  |  |  |  |  172|     41|	} \
  |  |  |  |  173|    740|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 699]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1679|       |
 1680|    699|	memcpy(data, resp, datalen);
 1681|    699|	return r;
 1682|    740|}
card-epass2003.c:epass2003_sm_get_wrapped_apdu:
 1584|  3.85k|{
 1585|  3.85k|	struct sc_context *ctx = card->ctx;
 1586|  3.85k|	struct sc_apdu *apdu = NULL;
 1587|  3.85k|	int rv;
 1588|       |
 1589|  3.85k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.85k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.85k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.85k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.85k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1590|  3.85k|	if (!plain || !sm_apdu)
  ------------------
  |  Branch (1590:6): [True: 0, False: 3.85k]
  |  Branch (1590:16): [True: 0, False: 3.85k]
  ------------------
 1591|  3.85k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1592|       |
 1593|  3.85k|	*sm_apdu = NULL;
 1594|       |	//construct new SM apdu from original apdu
 1595|  3.85k|	apdu = calloc(1, sizeof(struct sc_apdu));
 1596|  3.85k|	if (!apdu) {
  ------------------
  |  Branch (1596:6): [True: 0, False: 3.85k]
  ------------------
 1597|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1598|      0|		goto err;
 1599|      0|	}
 1600|  3.85k|	apdu->data = calloc (1, SC_MAX_EXT_APDU_BUFFER_SIZE);
  ------------------
  |  |   37|  3.85k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1601|  3.85k|	if (!apdu->data) {
  ------------------
  |  Branch (1601:6): [True: 0, False: 3.85k]
  ------------------
 1602|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1603|      0|		goto err;
 1604|      0|	}
 1605|  3.85k|	apdu->resp = calloc (1, SC_MAX_EXT_APDU_BUFFER_SIZE);
  ------------------
  |  |   37|  3.85k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1606|  3.85k|	if (!apdu->resp) {
  ------------------
  |  Branch (1606:6): [True: 0, False: 3.85k]
  ------------------
 1607|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1608|      0|		goto err;
 1609|      0|	}
 1610|  3.85k|	apdu->datalen = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|  3.85k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1611|  3.85k|	apdu->resplen = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|  3.85k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1612|       |
 1613|  3.85k|	rv = epass2003_sm_wrap_apdu(card, plain, apdu);
 1614|  3.85k|	if (rv) {
  ------------------
  |  Branch (1614:6): [True: 0, False: 3.85k]
  ------------------
 1615|      0|		rv = epass2003_sm_free_wrapped_apdu(card, NULL, &apdu);
 1616|      0|		if (rv < 0)
  ------------------
  |  Branch (1616:7): [True: 0, False: 0]
  ------------------
 1617|      0|			goto err;
 1618|      0|	}
 1619|       |
 1620|  3.85k|	*sm_apdu = apdu;
 1621|  3.85k|	apdu = NULL;
 1622|  3.85k|err:
 1623|  3.85k|	if (apdu) {
  ------------------
  |  Branch (1623:6): [True: 0, False: 3.85k]
  ------------------
 1624|      0|		free((unsigned char *) apdu->data);
 1625|      0|		free(apdu->resp);
 1626|      0|		free(apdu);
 1627|      0|		apdu = NULL;
 1628|      0|	}
 1629|  3.85k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  3.85k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.85k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.85k|	int _ret = r; \
  |  |  |  |  155|  3.85k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.85k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.85k|		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: 3.85k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.85k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.85k|	} 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|  3.85k|	return _ret; \
  |  |  |  |  163|  3.85k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1630|  3.85k|}
card-epass2003.c:epass2003_sm_wrap_apdu:
 1299|  3.85k|{
 1300|  3.85k|	unsigned char buf[4096] = {0}; /* APDU buffer */
 1301|  3.85k|	size_t buf_len = sizeof(buf);
 1302|  3.85k|	epass2003_exdata *exdata = NULL;
 1303|       |
 1304|  3.85k|	if (!card->drv_data)
  ------------------
  |  Branch (1304:6): [True: 0, False: 3.85k]
  ------------------
 1305|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1306|       |
 1307|  3.85k|	exdata = (epass2003_exdata *)card->drv_data;
 1308|       |
 1309|  3.85k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.85k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.85k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.85k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.85k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1310|       |
 1311|  3.85k|	if (exdata->sm)
  ------------------
  |  Branch (1311:6): [True: 568, False: 3.28k]
  ------------------
 1312|    568|		plain->cla |= 0x0C;
 1313|       |
 1314|  3.85k|	sm->cse = plain->cse;
 1315|  3.85k|	sm->cla = plain->cla;
 1316|  3.85k|	sm->ins = plain->ins;
 1317|  3.85k|	sm->p1 = plain->p1;
 1318|  3.85k|	sm->p2 = plain->p2;
 1319|  3.85k|	sm->lc = plain->lc;
 1320|  3.85k|	sm->le = plain->le;
 1321|  3.85k|	sm->control = plain->control;
 1322|  3.85k|	sm->flags = plain->flags;
 1323|       |
 1324|  3.85k|	switch (sm->cla & 0x0C) {
 1325|  3.28k|	case 0x00:
  ------------------
  |  Branch (1325:2): [True: 3.28k, False: 568]
  ------------------
 1326|  3.28k|	case 0x04:
  ------------------
  |  Branch (1326:2): [True: 0, False: 3.85k]
  ------------------
 1327|  3.28k|		sm->datalen = plain->datalen;
 1328|  3.28k|		memcpy((void *)sm->data, plain->data, plain->datalen);
 1329|  3.28k|		sm->resplen = plain->resplen;
 1330|  3.28k|		memcpy(sm->resp, plain->resp, plain->resplen);
 1331|  3.28k|		break;
 1332|    568|	case 0x0C:
  ------------------
  |  Branch (1332:2): [True: 568, False: 3.28k]
  ------------------
 1333|    568|		memset(buf, 0, sizeof(buf));
 1334|    568|		if (0 != encode_apdu(card, plain, sm, buf, &buf_len))
  ------------------
  |  Branch (1334:7): [True: 0, False: 568]
  ------------------
 1335|      0|			return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|      0|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 1336|    568|		break;
 1337|    568|	default:
  ------------------
  |  Branch (1337:2): [True: 0, False: 3.85k]
  ------------------
 1338|      0|		return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
 1339|  3.85k|	}
 1340|       |
 1341|  3.85k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.85k|#define SC_SUCCESS				0
  ------------------
 1342|  3.85k|}
card-epass2003.c:encode_apdu:
 1202|    568|{
 1203|    568|	size_t block_size = 0;
 1204|    568|	unsigned char dataTLV[4096] = {0};
 1205|    568|	size_t data_tlv_len = 0;
 1206|    568|	unsigned char le_tlv[256] = {0};
 1207|    568|	size_t le_tlv_len = 0;
 1208|    568|	size_t mac_tlv_len = 10;
 1209|    568|	size_t tmp_lc = 0;
 1210|    568|	size_t tmp_le = 0;
 1211|    568|	size_t expected_total_len;
 1212|    568|	unsigned char mac_tlv[256] = {0};
 1213|    568|	epass2003_exdata *exdata = NULL;
 1214|       |
 1215|    568|	mac_tlv[0] = 0x8E;
 1216|    568|	mac_tlv[1] = 8;
 1217|       |	/* size_t plain_le = 0; */
 1218|    568|	if (!card->drv_data)
  ------------------
  |  Branch (1218:6): [True: 0, False: 568]
  ------------------
 1219|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1220|    568|	exdata = (epass2003_exdata*)card->drv_data;
 1221|    568|	block_size = (KEY_TYPE_DES == exdata->smtype ? 16 : 8);
  ------------------
  |  |   81|    568|#define KEY_TYPE_DES	0x02	/* Non-FIPS mode */
  ------------------
  |  Branch (1221:16): [True: 537, False: 31]
  ------------------
 1222|       |
 1223|    568|	sm->cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|    568|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1224|    568|	apdu_buf[0] = (unsigned char)plain->cla;
 1225|    568|	apdu_buf[1] = (unsigned char)plain->ins;
 1226|    568|	apdu_buf[2] = (unsigned char)plain->p1;
 1227|    568|	apdu_buf[3] = (unsigned char)plain->p2;
 1228|       |	/* plain_le = plain->le; */
 1229|       |	/* padding */
 1230|    568|	if (exdata->bFipsCertification && plain->lc == 0 && apdu_buf[1] == 0x82 && apdu_buf[2] == 0x01) {
  ------------------
  |  Branch (1230:6): [True: 9, False: 559]
  |  Branch (1230:36): [True: 1, False: 8]
  |  Branch (1230:54): [True: 0, False: 1]
  |  Branch (1230:77): [True: 0, False: 0]
  ------------------
 1231|      0|		apdu_buf[4] = 0x00;
 1232|    568|	} else {
 1233|    568|		apdu_buf[4] = 0x80;
 1234|    568|	}
 1235|    568|	memset(&apdu_buf[5], 0x00, block_size - 5);
 1236|       |
 1237|       |	/* Data -> Data' */
 1238|    568|	if (plain->lc != 0)
  ------------------
  |  Branch (1238:6): [True: 566, False: 2]
  ------------------
 1239|    566|		if (0 != construct_data_tlv(card, plain, apdu_buf, dataTLV, &data_tlv_len, exdata->smtype))
  ------------------
  |  Branch (1239:7): [True: 0, False: 566]
  ------------------
 1240|      0|			return -1;
 1241|       |
 1242|    568|	if (plain->le != 0 || (plain->le == 0 && plain->resplen != 0))
  ------------------
  |  Branch (1242:6): [True: 12, False: 556]
  |  Branch (1242:25): [True: 556, False: 0]
  |  Branch (1242:43): [True: 556, False: 0]
  ------------------
 1243|    568|		if (0 != construct_le_tlv(plain, apdu_buf, data_tlv_len, le_tlv,
  ------------------
  |  Branch (1243:7): [True: 0, False: 568]
  ------------------
 1244|    568|				     &le_tlv_len, exdata->smtype))
 1245|      0|			return -1;
 1246|       |
 1247|    568|	if (exdata->bFipsCertification && plain->lc == 0 && apdu_buf[1] == 0x82 && apdu_buf[2] == 0x01) {
  ------------------
  |  Branch (1247:6): [True: 9, False: 559]
  |  Branch (1247:36): [True: 1, False: 8]
  |  Branch (1247:54): [True: 0, False: 1]
  |  Branch (1247:77): [True: 0, False: 0]
  ------------------
 1248|      0|		if (0 != construct_mac_tlv_case1(card, apdu_buf, data_tlv_len, le_tlv_len, mac_tlv, &mac_tlv_len, exdata->smtype))
  ------------------
  |  Branch (1248:7): [True: 0, False: 0]
  ------------------
 1249|      0|			return -1;
 1250|    568|	} else {
 1251|    568|		if (0 != construct_mac_tlv(card, apdu_buf, data_tlv_len, le_tlv_len, mac_tlv, &mac_tlv_len, exdata->smtype))
  ------------------
  |  Branch (1251:7): [True: 0, False: 568]
  ------------------
 1252|      0|			return -1;
 1253|    568|	}
 1254|       |
 1255|    568|	memset(apdu_buf + 4, 0, *apdu_buf_len - 4);
 1256|    568|	sm->lc = sm->datalen = data_tlv_len + le_tlv_len + mac_tlv_len;
 1257|    568|	if (sm->lc > 0xFF) {
  ------------------
  |  Branch (1257:6): [True: 0, False: 568]
  ------------------
 1258|      0|		sm->cse = SC_APDU_CASE_4_EXT;
  ------------------
  |  |  299|      0|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
 1259|      0|		apdu_buf[4] = (unsigned char)((sm->lc) / 0x10000);
 1260|      0|		apdu_buf[5] = (unsigned char)(((sm->lc) / 0x100) % 0x100);
 1261|      0|		apdu_buf[6] = (unsigned char)((sm->lc) % 0x100);
 1262|      0|		tmp_lc = 3;
 1263|    568|	} else {
 1264|    568|		apdu_buf[4] = (unsigned char)sm->lc;
 1265|    568|		tmp_lc = 1;
 1266|    568|	}
 1267|       |
 1268|       |	/* 2 is for Le extension in the worst case */
 1269|    568|	expected_total_len = 4 + tmp_lc + data_tlv_len + le_tlv_len + mac_tlv_len + 2;
 1270|       |
 1271|    568|	if (expected_total_len > *apdu_buf_len) {
  ------------------
  |  Branch (1271:6): [True: 0, False: 568]
  ------------------
 1272|      0|	    return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 1273|      0|	}
 1274|       |
 1275|    568|	memcpy(apdu_buf + 4 + tmp_lc, dataTLV, data_tlv_len);
 1276|    568|	memcpy(apdu_buf + 4 + tmp_lc + data_tlv_len, le_tlv, le_tlv_len);
 1277|    568|	memcpy(apdu_buf + 4 + tmp_lc + data_tlv_len + le_tlv_len, mac_tlv, mac_tlv_len);
 1278|    568|	memcpy((unsigned char *)sm->data, apdu_buf + 4 + tmp_lc, sm->datalen);
 1279|    568|	*apdu_buf_len = 0;
 1280|       |
 1281|    568|	if (4 == le_tlv_len) {
  ------------------
  |  Branch (1281:6): [True: 9, False: 559]
  ------------------
 1282|      9|		sm->cse = SC_APDU_CASE_4_EXT;
  ------------------
  |  |  299|      9|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|      9|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      9|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
 1283|      9|		*(apdu_buf + 4 + tmp_lc + sm->lc) = (unsigned char)(plain->le / 0x100);
 1284|      9|		*(apdu_buf + 4 + tmp_lc + sm->lc + 1) = (unsigned char)(plain->le % 0x100);
 1285|      9|		tmp_le = 2;
 1286|    559|	} else if (3 == le_tlv_len) {
  ------------------
  |  Branch (1286:13): [True: 559, False: 0]
  ------------------
 1287|    559|		*(apdu_buf + 4 + tmp_lc + sm->lc) = (unsigned char)plain->le;
 1288|    559|		tmp_le = 1;
 1289|    559|	}
 1290|       |
 1291|    568|	*apdu_buf_len += 4 + tmp_lc + data_tlv_len + le_tlv_len + mac_tlv_len + tmp_le;
 1292|       |	/* sm->le = calc_le(plain_le); */
 1293|    568|	return 0;
 1294|    568|}
card-epass2003.c:construct_data_tlv:
  950|    566|{
  951|    566|	size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
  ------------------
  |  |   80|    566|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (951:23): [True: 30, False: 536]
  ------------------
  952|    566|	unsigned char pad[4096] = {0};
  953|    566|	size_t pad_len;
  954|    566|	size_t tlv_more;	/* increased tlv length */
  955|    566|	unsigned char iv[16] = {0};
  956|    566|	epass2003_exdata *exdata = NULL;
  957|    566|	int r = 0;
  958|       |
  959|    566|	if (!card->drv_data)
  ------------------
  |  Branch (959:6): [True: 0, False: 566]
  ------------------
  960|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  961|       |
  962|    566|	exdata = (epass2003_exdata *)card->drv_data;
  963|       |
  964|       |	/* we encrypt the pad buffer and then write it to the apdu_buf at offset block_size + tlv_more */
  965|    566|	if (apdu->lc >= sizeof(pad) - block_size - 5)
  ------------------
  |  Branch (965:6): [True: 0, False: 566]
  ------------------
  966|    566|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  967|    566|				"ePass2003 secure messaging APDU data too large");
  968|       |
  969|       |	/* padding */
  970|    566|	apdu_buf[block_size] = 0x87;
  971|    566|	memcpy(pad, apdu->data, apdu->lc);
  972|    566|	pad[apdu->lc] = 0x80;
  973|    566|	if ((apdu->lc + 1) % block_size)
  ------------------
  |  Branch (973:6): [True: 566, False: 0]
  ------------------
  974|    566|		pad_len = ((apdu->lc + 1) / block_size + 1) * block_size;
  975|      0|	else
  976|      0|		pad_len = apdu->lc + 1;
  977|       |
  978|       |	/* encode Lc' */
  979|    566|	if (pad_len > 0x7E) {
  ------------------
  |  Branch (979:6): [True: 0, False: 566]
  ------------------
  980|       |		/* Lc' > 0x7E, use extended APDU */
  981|      0|		apdu_buf[block_size + 1] = 0x82;
  982|      0|		apdu_buf[block_size + 2] = (unsigned char)((pad_len + 1) / 0x100);
  983|      0|		apdu_buf[block_size + 3] = (unsigned char)((pad_len + 1) % 0x100);
  984|      0|		apdu_buf[block_size + 4] = 0x01;
  985|      0|		tlv_more = 5;
  986|    566|	} else {
  987|    566|		apdu_buf[block_size + 1] = (unsigned char)pad_len + 1;
  988|    566|		apdu_buf[block_size + 2] = 0x01;
  989|    566|		tlv_more = 3;
  990|    566|	}
  991|    566|	memcpy(data_tlv, &apdu_buf[block_size], tlv_more);
  992|       |
  993|       |	/* encrypt Data */
  994|    566|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|    566|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (994:6): [True: 30, False: 536]
  ------------------
  995|     30|		r = aes128_encrypt_cbc(card, exdata->sk_enc, 16, iv, pad, pad_len, apdu_buf + block_size + tlv_more);
  996|     30|		LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cbc failed");
  ------------------
  |  |  174|     30|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     30|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     30|	int _ret = (r); \
  |  |  |  |  168|     30|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  997|    536|	} else {
  998|    536|		r = des3_encrypt_cbc(card, exdata->sk_enc, 16, iv, pad, pad_len, apdu_buf + block_size + tlv_more);
  999|    536|		LOG_TEST_RET(card->ctx, r, "des3_encrypt_cbc failed");
  ------------------
  |  |  174|    536|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    536|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    536|	int _ret = (r); \
  |  |  |  |  168|    536|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 536]
  |  |  |  |  ------------------
  |  |  |  |  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|    536|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 536]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1000|    536|	}
 1001|       |
 1002|    566|	memcpy(data_tlv + tlv_more, apdu_buf + block_size + tlv_more, pad_len);
 1003|    566|	*data_tlv_len = tlv_more + pad_len;
 1004|    566|	return 0;
 1005|    566|}
card-epass2003.c:construct_le_tlv:
 1012|    568|{
 1013|    568|	size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
  ------------------
  |  |   80|    568|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1013:23): [True: 31, False: 537]
  ------------------
 1014|       |
 1015|    568|	*(apdu_buf + block_size + data_tlv_len) = 0x97;
 1016|    568|	if (apdu->le > 0x7F) {
  ------------------
  |  Branch (1016:6): [True: 9, False: 559]
  ------------------
 1017|       |		/* Le' > 0x7E, use extended APDU */
 1018|      9|		*(apdu_buf + block_size + data_tlv_len + 1) = 2;
 1019|      9|		*(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)(apdu->le / 0x100);
 1020|      9|		*(apdu_buf + block_size + data_tlv_len + 3) = (unsigned char)(apdu->le % 0x100);
 1021|      9|		memcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 4);
 1022|      9|		*le_tlv_len = 4;
 1023|    559|	} else {
 1024|    559|		*(apdu_buf + block_size + data_tlv_len + 1) = 1;
 1025|    559|		*(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)apdu->le;
 1026|    559|		memcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 3);
 1027|    559|		*le_tlv_len = 3;
 1028|    559|	}
 1029|    568|	return 0;
 1030|    568|}
card-epass2003.c:des_encrypt_cbc:
  588|  1.10k|{
  589|  1.10k|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-CBC");
  590|  1.10k|	int r;
  591|       |
  592|  1.10k|	r = openssl_enc(alg, key, iv, input, length, output);
  593|  1.10k|	sc_evp_cipher_free(alg);
  594|  1.10k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|  1.10k|#define SC_SUCCESS				0
  ------------------
  |  Branch (594:6): [True: 0, False: 1.10k]
  ------------------
  595|      0|		sc_log_openssl(card->ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  596|  1.10k|	return r;
  597|  1.10k|}
card-epass2003.c:des_decrypt_cbc:
  603|    552|{
  604|    552|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-CBC");
  605|    552|	int r;
  606|       |
  607|    552|	r = openssl_dec(alg, key, iv, input, length, output);
  608|    552|	sc_evp_cipher_free(alg);
  609|    552|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    552|#define SC_SUCCESS				0
  ------------------
  |  Branch (609:6): [True: 0, False: 552]
  ------------------
  610|      0|		sc_log_openssl(card->ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  611|    552|	return r;
  612|    552|}
card-epass2003.c:openssl_dec:
  313|    552|{
  314|    552|	int r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    552|#define SC_ERROR_INTERNAL			-1400
  ------------------
  315|    552|	EVP_CIPHER_CTX * ctx = NULL;
  316|    552|	int outl = 0;
  317|    552|	int outl_tmp = 0;
  318|    552|	unsigned char iv_tmp[EVP_MAX_IV_LENGTH] = {0};
  319|       |
  320|    552|	memcpy(iv_tmp, iv, EVP_MAX_IV_LENGTH);
  321|    552|	ctx = EVP_CIPHER_CTX_new();
  322|    552|	if (ctx == NULL)
  ------------------
  |  Branch (322:6): [True: 0, False: 552]
  ------------------
  323|      0|		goto out;
  324|       |
  325|    552|	if (!EVP_DecryptInit_ex(ctx, cipher, NULL, key, iv_tmp) ||
  ------------------
  |  Branch (325:6): [True: 0, False: 552]
  ------------------
  326|    552|			!EVP_CIPHER_CTX_set_padding(ctx, 0))
  ------------------
  |  Branch (326:4): [True: 0, False: 552]
  ------------------
  327|      0|		goto out;
  328|       |
  329|    552|	if (!EVP_DecryptUpdate(ctx, output, &outl, input, (int)length))
  ------------------
  |  Branch (329:6): [True: 0, False: 552]
  ------------------
  330|      0|		goto out;
  331|       |
  332|    552|	if (!EVP_DecryptFinal_ex(ctx, output + outl, &outl_tmp))
  ------------------
  |  Branch (332:6): [True: 0, False: 552]
  ------------------
  333|      0|		goto out;
  334|       |
  335|    552|	r = SC_SUCCESS;
  ------------------
  |  |   28|    552|#define SC_SUCCESS				0
  ------------------
  336|    552|out:
  337|    552|	EVP_CIPHER_CTX_free(ctx);
  338|    552|	return r;
  339|    552|}
card-epass2003.c:construct_mac_tlv:
 1037|    568|{
 1038|    568|	size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
  ------------------
  |  |   80|    568|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1038:23): [True: 31, False: 537]
  ------------------
 1039|    568|	unsigned char mac[4096] = {0};
 1040|    568|	size_t mac_len;
 1041|    568|	unsigned char icv[16] = {0};
 1042|    568|	int r ;
 1043|    568|	int i = (KEY_TYPE_AES == key_type ? 15 : 7);
  ------------------
  |  |   80|    568|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1043:11): [True: 31, False: 537]
  ------------------
 1044|    568|	epass2003_exdata *exdata = NULL;
 1045|       |
 1046|    568|	if (!card->drv_data)
  ------------------
  |  Branch (1046:6): [True: 0, False: 568]
  ------------------
 1047|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1048|       |
 1049|    568|	exdata = (epass2003_exdata *)card->drv_data;
 1050|       |
 1051|    568|	if (data_tlv_len + le_tlv_len + block_size + 1 > sizeof(mac)) {
  ------------------
  |  Branch (1051:6): [True: 0, False: 568]
  ------------------
 1052|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 1053|      0|	}
 1054|       |
 1055|    568|	if (0 == data_tlv_len && 0 == le_tlv_len) {
  ------------------
  |  Branch (1055:6): [True: 2, False: 566]
  |  Branch (1055:27): [True: 0, False: 2]
  ------------------
 1056|      0|		mac_len = block_size;
 1057|    568|	} else {
 1058|       |		/* padding */
 1059|    568|		*(apdu_buf + block_size + data_tlv_len + le_tlv_len) = 0x80;
 1060|    568|		if ((data_tlv_len + le_tlv_len + 1) % block_size) {
  ------------------
  |  Branch (1060:7): [True: 559, False: 9]
  ------------------
 1061|    559|			mac_len = (((data_tlv_len + le_tlv_len + 1) / block_size) +
 1062|    559|					1) * block_size + block_size;
 1063|    559|		} else {
 1064|      9|			mac_len = data_tlv_len + le_tlv_len + 1 + block_size;
 1065|      9|		}
 1066|    568|		memset((apdu_buf + block_size + data_tlv_len + le_tlv_len + 1),
 1067|    568|		       0, (mac_len - (data_tlv_len + le_tlv_len + 1)));
 1068|    568|	}
 1069|       |
 1070|       |	/* increase icv */
 1071|    568|	for (; i >= 0; i--) {
  ------------------
  |  Branch (1071:9): [True: 568, False: 0]
  ------------------
 1072|    568|		if (exdata->icv_mac[i] == 0xff) {
  ------------------
  |  Branch (1072:7): [True: 0, False: 568]
  ------------------
 1073|      0|			exdata->icv_mac[i] = 0;
 1074|    568|		} else {
 1075|    568|			exdata->icv_mac[i]++;
 1076|    568|			break;
 1077|    568|		}
 1078|    568|	}
 1079|       |
 1080|       |	/* calculate MAC */
 1081|    568|	memset(icv, 0, sizeof(icv));
 1082|    568|	memcpy(icv, exdata->icv_mac, 16);
 1083|    568|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|    568|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1083:6): [True: 31, False: 537]
  ------------------
 1084|     31|		if (exdata->bFipsCertification) {
  ------------------
  |  Branch (1084:7): [True: 9, False: 22]
  ------------------
 1085|    153|			for (int i = 0; i < 16; i++) {
  ------------------
  |  Branch (1085:20): [True: 144, False: 9]
  ------------------
 1086|    144|				apdu_buf[i] = apdu_buf[i] ^ icv[i];
 1087|    144|			}
 1088|      9|			r = aes128_encrypt_cmac(card, exdata->sk_mac, 128, apdu_buf, data_tlv_len + le_tlv_len + block_size, mac);
 1089|      9|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cmac failed");
  ------------------
  |  |  174|      9|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      9|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      9|	int _ret = (r); \
  |  |  |  |  168|      9|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  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|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1090|      9|			memcpy(mac_tlv + 2, &mac[0 /*ulmacLen-16*/], 8);
 1091|     45|			for (int j = 0; j < 4; j++) {
  ------------------
  |  Branch (1091:20): [True: 36, False: 9]
  ------------------
 1092|     36|				apdu_buf[j] = apdu_buf[j] ^ icv[j];
 1093|     36|			}
 1094|     22|		} else {
 1095|     22|			r = aes128_encrypt_cbc(card, exdata->sk_mac, 16, icv, apdu_buf, mac_len, mac);
 1096|     22|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cbc failed");
  ------------------
  |  |  174|     22|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     22|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     22|	int _ret = (r); \
  |  |  |  |  168|     22|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1097|     22|			memcpy(mac_tlv + 2, &mac[mac_len - 16], 8);
 1098|     22|		}
 1099|    537|	} else {
 1100|    537|		unsigned char iv[EVP_MAX_IV_LENGTH] = {0};
 1101|    537|		unsigned char tmp[8] = {0};
 1102|    537|		r = des_encrypt_cbc(card, exdata->sk_mac, 8, icv, apdu_buf, mac_len, mac);
 1103|    537|		LOG_TEST_RET(card->ctx, r, "des_encrypt_cbc 1 failed");
  ------------------
  |  |  174|    537|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    537|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    537|	int _ret = (r); \
  |  |  |  |  168|    537|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 537]
  |  |  |  |  ------------------
  |  |  |  |  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|    537|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 537]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|    537|		r = des_decrypt_cbc(card, &exdata->sk_mac[8], 8, iv, &mac[mac_len - 8], 8, tmp);
 1105|    537|		LOG_TEST_RET(card->ctx, r, "des_decrypt_cbc failed");
  ------------------
  |  |  174|    537|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    537|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    537|	int _ret = (r); \
  |  |  |  |  168|    537|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 537]
  |  |  |  |  ------------------
  |  |  |  |  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|    537|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 537]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1106|    537|		memset(iv, 0x00, sizeof iv);
 1107|    537|		r = des_encrypt_cbc(card, exdata->sk_mac, 8, iv, tmp, 8, mac_tlv + 2);
 1108|    537|		LOG_TEST_RET(card->ctx, r, "des_encrypt_cbc 2 failed");
  ------------------
  |  |  174|    537|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    537|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    537|	int _ret = (r); \
  |  |  |  |  168|    537|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 537]
  |  |  |  |  ------------------
  |  |  |  |  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|    537|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 537]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1109|    537|	}
 1110|       |
 1111|    568|	*mac_tlv_len = 2 + 8;
 1112|    568|	return 0;
 1113|    568|}
card-epass2003.c:epass2003_sm_free_wrapped_apdu:
 1552|  3.85k|{
 1553|  3.85k|	struct sc_context *ctx = card->ctx;
 1554|  3.85k|	int rv = SC_SUCCESS;
  ------------------
  |  |   28|  3.85k|#define SC_SUCCESS				0
  ------------------
 1555|       |
 1556|  3.85k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.85k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.85k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.85k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.85k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1557|  3.85k|	if (!sm_apdu)
  ------------------
  |  Branch (1557:6): [True: 0, False: 3.85k]
  ------------------
 1558|  3.85k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1559|  3.85k|	if (!(*sm_apdu))
  ------------------
  |  Branch (1559:6): [True: 0, False: 3.85k]
  ------------------
 1560|  3.85k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1561|       |
 1562|       |
 1563|  3.85k|	if (plain)
  ------------------
  |  Branch (1563:6): [True: 3.85k, False: 0]
  ------------------
 1564|  3.85k|		rv = epass2003_sm_unwrap_apdu(card, *sm_apdu, plain);
 1565|       |
 1566|  3.85k|	if ((*sm_apdu)->data) {
  ------------------
  |  Branch (1566:6): [True: 3.85k, False: 0]
  ------------------
 1567|  3.85k|		unsigned char * p = (unsigned char *)((*sm_apdu)->data);
 1568|  3.85k|		free(p);
 1569|  3.85k|	}
 1570|  3.85k|	if ((*sm_apdu)->resp) {
  ------------------
  |  Branch (1570:6): [True: 3.85k, False: 0]
  ------------------
 1571|  3.85k|		free((*sm_apdu)->resp);
 1572|  3.85k|	}
 1573|       |
 1574|  3.85k|	free(*sm_apdu);
 1575|  3.85k|	*sm_apdu = NULL;
 1576|       |
 1577|  3.85k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  3.85k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.85k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.85k|	int _ret = r; \
  |  |  |  |  155|  3.85k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.85k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.85k|		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|    567|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 567, False: 3.29k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.85k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.85k|	} 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|  3.85k|	return _ret; \
  |  |  |  |  163|  3.85k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1578|  3.85k|}
card-epass2003.c:epass2003_sm_unwrap_apdu:
 1509|  3.85k|{
 1510|  3.85k|	int r;
 1511|  3.85k|	size_t len = 0;
 1512|  3.85k|	epass2003_exdata *exdata = NULL;
 1513|       |
 1514|  3.85k|	if (!card->drv_data)
  ------------------
  |  Branch (1514:6): [True: 0, False: 3.85k]
  ------------------
 1515|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1516|       |
 1517|  3.85k|	exdata = (epass2003_exdata *)card->drv_data;
 1518|       |
 1519|  3.85k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.85k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.85k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.85k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.85k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1520|       |
 1521|       |	/* verify MAC, and check if SW1,2 match SW1,2 encapsulated in SM */
 1522|  3.85k|	if (exdata->sm) {
  ------------------
  |  Branch (1522:6): [True: 568, False: 3.28k]
  ------------------
 1523|    568|		if (epass2003_check_response_mac_and_sw(card, sm)) {
  ------------------
  |  Branch (1523:7): [True: 567, False: 1]
  ------------------
 1524|    567|			sc_log(card->ctx, "MAC or SW incorrect");
  ------------------
  |  |   71|    567|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1525|    567|			return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|    567|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 1526|    567|		}
 1527|    568|	}
 1528|  3.29k|	r = sc_check_sw(card, sm->sw1, sm->sw2);
 1529|  3.29k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  3.29k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1529:6): [True: 2.55k, False: 738]
  ------------------
 1530|  2.55k|		if (exdata->sm) {
  ------------------
  |  Branch (1530:7): [True: 0, False: 2.55k]
  ------------------
 1531|      0|			len = plain->resplen;
 1532|      0|			if (0 != decrypt_response(card, sm->resp, sm->resplen, plain->resp, &len))
  ------------------
  |  Branch (1532:8): [True: 0, False: 0]
  ------------------
 1533|      0|				return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|      0|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 1534|  2.55k|		} else {
 1535|  2.55k|			memcpy(plain->resp, sm->resp, sm->resplen);
 1536|  2.55k|			len = sm->resplen;
 1537|  2.55k|		}
 1538|  2.55k|	}
 1539|       |
 1540|  3.29k|	plain->resplen = len;
 1541|  3.29k|	plain->sw1 = sm->sw1;
 1542|  3.29k|	plain->sw2 = sm->sw2;
 1543|       |
 1544|  3.29k|	sc_log(card->ctx, "unwrapped APDU: resplen %zu, SW %02X%02X", plain->resplen, plain->sw1, plain->sw2);
  ------------------
  |  |   71|  3.29k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1545|  3.29k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.29k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.29k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.29k|	int _ret = r; \
  |  |  |  |  155|  3.29k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.29k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.29k|		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: 3.29k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.29k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.29k|	} 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|  3.29k|	return _ret; \
  |  |  |  |  163|  3.29k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1546|  3.29k|}
card-epass2003.c:epass2003_check_response_mac_and_sw:
 1346|    568|{
 1347|    568|	unsigned char iv[16];
 1348|    568|	unsigned char *data = NULL, *mac = NULL;
 1349|    568|	size_t blocksize, mac_len;
 1350|    568|	int ret = -1;
 1351|    568|	size_t taglen;
 1352|    568|	const u8 *tag;
 1353|    568|	epass2003_exdata *exdata;
 1354|    568|	unsigned char *in = sm->resp;
 1355|    568|	unsigned char *alt_in;
 1356|    568|	size_t inlen = sm->resplen;
 1357|    568|	size_t len_correction;
 1358|       |
 1359|       |	/* card/ctx/drv_data is already checked by caller */
 1360|    568|	exdata = (epass2003_exdata *)card->drv_data;
 1361|       |
 1362|       |	/* The SM must contain at least TLV encoded SW and MAC fields. */
 1363|    568|	if (inlen < 14 )
  ------------------
  |  Branch (1363:6): [True: 475, False: 93]
  ------------------
 1364|    475|		return ret;
 1365|       |
 1366|       |	/* compare BER-TLV encoded SW (TAG 0x99) and raw SW */
 1367|     93|	alt_in = in;
 1368|     93|	tag = sc_asn1_find_tag(card->ctx, alt_in, inlen, 0x99, &taglen);
 1369|     93|	if (tag == NULL || taglen != 2) {
  ------------------
  |  Branch (1369:6): [True: 54, False: 39]
  |  Branch (1369:21): [True: 4, False: 35]
  ------------------
 1370|       |		/*
 1371|       |		 * It seems that the EPASS2003 firmware has some problem with BER-TLV encoding.
 1372|       |		 * Instead of (correct) TLV 87 81 81 [01 .. ..] incorrect TLV 87 81 [01 .. ..]
 1373|       |		 * is returned. There seems to be some proprietary fix for the faulty encoding
 1374|       |		 * in the decrypt_response() function, similar fix here:
 1375|       |		 */
 1376|     58|		if (0x01 == in[2] && 0x82 != in[1]) {
  ------------------
  |  Branch (1376:7): [True: 34, False: 24]
  |  Branch (1376:24): [True: 33, False: 1]
  ------------------
 1377|     33|			sc_log(card->ctx, "Workaround, wrong BER-TLV ?");
  ------------------
  |  |   71|     33|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1378|     33|			len_correction = in[1] + 2;
 1379|     33|			if (inlen < len_correction)
  ------------------
  |  Branch (1379:8): [True: 7, False: 26]
  ------------------
 1380|      7|				return ret;
 1381|     26|			inlen -= len_correction;
 1382|     26|			alt_in += len_correction;
 1383|     26|			tag = sc_asn1_find_tag(card->ctx, alt_in, inlen, 0x99, &taglen);
 1384|     26|			if (tag == NULL || taglen != 2)
  ------------------
  |  Branch (1384:8): [True: 24, False: 2]
  |  Branch (1384:23): [True: 1, False: 1]
  ------------------
 1385|     25|				return ret;
 1386|     26|		} else {
 1387|     25|			return ret;
 1388|     25|		}
 1389|     58|	}
 1390|     36|	if (sm->sw1 != tag[0] || sm->sw2 != tag[1])
  ------------------
  |  Branch (1390:6): [True: 5, False: 31]
  |  Branch (1390:27): [True: 11, False: 20]
  ------------------
 1391|     16|		return ret;
 1392|       |
 1393|       |	/* no documentation/real hardware to test, the response is accepted without MAC check */
 1394|     20|	if (exdata->bFipsCertification) {
  ------------------
  |  Branch (1394:6): [True: 0, False: 20]
  ------------------
 1395|      0|		sc_log(card->ctx, "Warning, MAC is not checked");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1396|      0|		return 0;
 1397|      0|	}
 1398|     20|	tag = sc_asn1_find_tag(card->ctx, alt_in, inlen, 0x8e, &taglen);
 1399|     20|	if (tag == NULL || taglen != 8)
  ------------------
  |  Branch (1399:6): [True: 1, False: 19]
  |  Branch (1399:21): [True: 3, False: 16]
  ------------------
 1400|      4|		return ret;
 1401|       |
 1402|     16|	if (KEY_TYPE_AES == exdata->smtype)
  ------------------
  |  |   80|     16|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1402:6): [True: 1, False: 15]
  ------------------
 1403|      1|		blocksize = 16;
 1404|     15|	else
 1405|     15|		blocksize = 8;
 1406|       |
 1407|     16|	mac_len = tag - in - 2;
 1408|     16|	if (NULL == (data = calloc(1, mac_len + blocksize)))
  ------------------
  |  Branch (1408:6): [True: 0, False: 16]
  ------------------
 1409|      0|		goto end;
 1410|     16|	if (NULL == (mac = malloc(mac_len + blocksize)))
  ------------------
  |  Branch (1410:6): [True: 0, False: 16]
  ------------------
 1411|      0|		goto end;
 1412|       |
 1413|       |	/* copy response to buffer and append padding */
 1414|     16|	memcpy(data, in, mac_len);
 1415|     16|	data[mac_len++] = 0x80;
 1416|       |
 1417|     16|	if (mac_len % blocksize)
  ------------------
  |  Branch (1417:6): [True: 15, False: 1]
  ------------------
 1418|     15|		mac_len += (blocksize - (mac_len % blocksize));
 1419|       |
 1420|       |	/* calculate MAC */
 1421|     16|	memcpy(iv, exdata->icv_mac, blocksize);
 1422|       |
 1423|     16|	if (KEY_TYPE_AES == exdata->smtype) {
  ------------------
  |  |   80|     16|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1423:6): [True: 1, False: 15]
  ------------------
 1424|      1|		if (aes128_encrypt_cbc(card, exdata->sk_mac, 16, iv, data, mac_len, mac))
  ------------------
  |  Branch (1424:7): [True: 0, False: 1]
  ------------------
 1425|      0|			goto end;
 1426|     15|	} else {
 1427|     15|		uint8_t tmp[8];
 1428|     15|		uint8_t iv0[EVP_MAX_IV_LENGTH];
 1429|     15|		if (des_encrypt_cbc(card, exdata->sk_mac, 8, iv, data, mac_len, mac))
  ------------------
  |  Branch (1429:7): [True: 0, False: 15]
  ------------------
 1430|      0|			goto end;
 1431|     15|		memset(iv0, 0, EVP_MAX_IV_LENGTH);
 1432|     15|		if (des_decrypt_cbc(card, &exdata->sk_mac[8], 8, iv0, &mac[mac_len - 8], 8, tmp))
  ------------------
  |  Branch (1432:7): [True: 0, False: 15]
  ------------------
 1433|      0|			goto end;
 1434|     15|		memset(iv0, 0, EVP_MAX_IV_LENGTH);
 1435|     15|		if (des_encrypt_cbc(card, exdata->sk_mac, 8, iv0, tmp, 8, &mac[mac_len - 8]))
  ------------------
  |  Branch (1435:7): [True: 0, False: 15]
  ------------------
 1436|      0|			goto end;
 1437|     15|	}
 1438|       |	/* compare MAC */
 1439|     16|	if (!memcmp(tag, mac + mac_len - blocksize, 8))
  ------------------
  |  Branch (1439:6): [True: 1, False: 15]
  ------------------
 1440|      1|		ret = 0;
 1441|     16|end:
 1442|     16|	if (data)
  ------------------
  |  Branch (1442:6): [True: 16, False: 0]
  ------------------
 1443|     16|		free(data);
 1444|     16|	if (mac)
  ------------------
  |  Branch (1444:6): [True: 16, False: 0]
  ------------------
 1445|     16|		free(mac);
 1446|     16|	return ret;
 1447|     16|}
card-epass2003.c:epass2003_finish:
 1777|    674|{
 1778|    674|	epass2003_exdata *exdata = (epass2003_exdata *)card->drv_data;
 1779|       |
 1780|    674|	if (exdata)
  ------------------
  |  Branch (1780:6): [True: 674, False: 0]
  ------------------
 1781|    674|		free(exdata);
 1782|    674|	return SC_SUCCESS;
  ------------------
  |  |   28|    674|#define SC_SUCCESS				0
  ------------------
 1783|    674|}
card-epass2003.c:epass2003_select_file:
 2023|  3.54k|{
 2024|  3.54k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.54k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.54k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.54k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.54k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.54k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2025|       |
 2026|  3.54k|	switch (in_path->type) {
 2027|      0|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (2027:2): [True: 0, False: 3.54k]
  ------------------
 2028|      0|		if (in_path->len != 2)
  ------------------
  |  Branch (2028:7): [True: 0, False: 0]
  ------------------
 2029|      0|			LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2030|      0|		return epass2003_select_fid(card, in_path->value[0], in_path->value[1], file_out);
 2031|  1.24k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  1.24k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (2031:2): [True: 1.24k, False: 2.30k]
  ------------------
 2032|  1.24k|		return epass2003_select_aid(card, in_path, file_out);
 2033|  2.30k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  2.30k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (2033:2): [True: 2.30k, False: 1.24k]
  ------------------
 2034|  2.30k|		return epass2003_select_path(card, in_path->value, in_path->len, file_out);
 2035|      0|	default:
  ------------------
  |  Branch (2035:2): [True: 0, False: 3.54k]
  ------------------
 2036|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2037|  3.54k|	}
 2038|  3.54k|}
card-epass2003.c:epass2003_select_fid:
 1936|  3.36k|{
 1937|  3.36k|	int r;
 1938|  3.36k|	sc_file_t *file = NULL;
 1939|  3.36k|	sc_path_t path;
 1940|       |
 1941|  3.36k|	memset(&path, 0, sizeof(path));
 1942|  3.36k|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  3.36k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1943|  3.36k|	path.value[0] = id_hi;
 1944|  3.36k|	path.value[1] = id_lo;
 1945|  3.36k|	path.len = 2;
 1946|       |
 1947|  3.36k|	r = epass2003_select_fid_(card, &path, &file);
 1948|  3.36k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  3.36k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.36k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.36k|	int _ret = (r); \
  |  |  |  |  168|  3.36k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.68k, False: 1.67k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.68k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.68k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.68k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.68k|		return _ret; \
  |  |  |  |  172|  1.68k|	} \
  |  |  |  |  173|  3.36k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.67k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1949|       |
 1950|  1.67k|	if (file_out) {
  ------------------
  |  Branch (1950:6): [True: 325, False: 1.35k]
  ------------------
 1951|    325|		*file_out = file;
 1952|  1.35k|	} else {
 1953|  1.35k|		sc_file_free(file);
 1954|  1.35k|	}
 1955|       |
 1956|  1.67k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.67k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.67k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.67k|	int _ret = r; \
  |  |  |  |  155|  1.67k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.67k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.67k|		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: 1.67k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.67k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.67k|	} 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|  1.67k|	return _ret; \
  |  |  |  |  163|  1.67k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1957|  1.67k|}
card-epass2003.c:epass2003_select_fid_:
 1841|  3.36k|{
 1842|  3.36k|	struct sc_apdu apdu;
 1843|  3.36k|	u8 buf[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1844|  3.36k|	u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
 1845|  3.36k|	int r;
 1846|  3.36k|	size_t pathlen;
 1847|  3.36k|	sc_file_t *file = NULL;
 1848|       |
 1849|  3.36k|	r = epass2003_hook_path(in_path, 1);
 1850|  3.36k|	LOG_TEST_RET(card->ctx, r, "Can not hook path");
  ------------------
  |  |  174|  3.36k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.36k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.36k|	int _ret = (r); \
  |  |  |  |  168|  3.36k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.36k]
  |  |  |  |  ------------------
  |  |  |  |  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|  3.36k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.36k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1851|       |
 1852|  3.36k|	memcpy(path, in_path->value, in_path->len);
 1853|  3.36k|	pathlen = in_path->len;
 1854|       |
 1855|  3.36k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  3.36k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1856|       |
 1857|  3.36k|	switch (in_path->type) {
 1858|  3.36k|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|  3.36k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1858:2): [True: 3.36k, False: 0]
  ------------------
 1859|  3.36k|		apdu.p1 = 0;
 1860|  3.36k|		if (pathlen != 2)
  ------------------
  |  Branch (1860:7): [True: 0, False: 3.36k]
  ------------------
 1861|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1862|  3.36k|		break;
 1863|  3.36k|	default:
  ------------------
  |  Branch (1863:2): [True: 0, False: 3.36k]
  ------------------
 1864|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1865|  3.36k|	}
 1866|  3.36k|	apdu.p2 = 0;		/* first record, return FCI */
 1867|  3.36k|	apdu.lc = pathlen;
 1868|  3.36k|	apdu.data = path;
 1869|  3.36k|	apdu.datalen = pathlen;
 1870|       |
 1871|  3.36k|	if (file_out != NULL) {
  ------------------
  |  Branch (1871:6): [True: 3.36k, False: 0]
  ------------------
 1872|  3.36k|		apdu.resp = buf;
 1873|  3.36k|		apdu.resplen = sizeof(buf);
 1874|  3.36k|		apdu.le = 0;
 1875|  3.36k|	} else {
 1876|      0|		apdu.cse = (apdu.lc == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
              		apdu.cse = (apdu.lc == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (1876:14): [True: 0, False: 0]
  ------------------
 1877|      0|	}
 1878|       |
 1879|  3.36k|	if (path[0] == 0x29) {	/* TODO:0x29 accords with FID prefix in profile  */
  ------------------
  |  Branch (1879:6): [True: 161, False: 3.20k]
  ------------------
 1880|       |		/* Not allowed to select private key file, so fake fci. */
 1881|       |		/* 62 16 82 02 11 00 83 02 29 00 85 02 08 00 86 08 FF 90 90 90 FF FF FF FF */
 1882|    161|		apdu.resplen = 0x18;
 1883|    161|		memcpy(apdu.resp,
 1884|    161|		       "\x6f\x16\x82\x02\x11\x00\x83\x02\x29\x00\x85\x02\x08\x00\x86\x08\xff\x90\x90\x90\xff\xff\xff\xff",
 1885|    161|		       apdu.resplen);
 1886|    161|		apdu.resp[9] = path[1];
 1887|    161|		apdu.sw1 = 0x90;
 1888|    161|		apdu.sw2 = 0x00;
 1889|    161|	}
 1890|  3.20k|	else {
 1891|  3.20k|		r = sc_transmit_apdu_t(card, &apdu);
 1892|  3.20k|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  3.20k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.20k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.20k|	int _ret = (r); \
  |  |  |  |  168|  3.20k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 569, False: 2.63k]
  |  |  |  |  ------------------
  |  |  |  |  169|    569|		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|    569|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    569|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    569|		return _ret; \
  |  |  |  |  172|    569|	} \
  |  |  |  |  173|  3.20k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.63k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1893|  3.20k|	}
 1894|       |
 1895|  2.79k|	if (file_out == NULL) {
  ------------------
  |  Branch (1895:6): [True: 0, False: 2.79k]
  ------------------
 1896|      0|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (1896:7): [True: 0, False: 0]
  ------------------
 1897|      0|			LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1898|      0|		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1899|      0|	}
 1900|       |
 1901|  2.79k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1902|  2.79k|	if (r)
  ------------------
  |  Branch (1902:6): [True: 999, False: 1.79k]
  ------------------
 1903|  2.79k|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    999|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    999|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    999|	int _ret = r; \
  |  |  |  |  155|    999|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 999, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    999|		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|    999|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 999, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    999|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    999|	} 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|    999|	return _ret; \
  |  |  |  |  163|    999|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1904|  1.79k|	if (apdu.resplen < 2)
  ------------------
  |  Branch (1904:6): [True: 64, False: 1.73k]
  ------------------
 1905|  1.79k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     64|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     64|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     64|	int _ret = r; \
  |  |  |  |  155|     64|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 64, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     64|		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|     64|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 64, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     64|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     64|	} 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|     64|	return _ret; \
  |  |  |  |  163|     64|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1906|       |
 1907|  1.73k|	switch (apdu.resp[0]) {
 1908|  1.67k|	case 0x6F:
  ------------------
  |  Branch (1908:2): [True: 1.67k, False: 53]
  ------------------
 1909|  1.67k|		file = sc_file_new();
 1910|  1.67k|		if (file == NULL)
  ------------------
  |  Branch (1910:7): [True: 0, False: 1.67k]
  ------------------
 1911|  1.67k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1912|  1.67k|		file->path = *in_path;
 1913|  1.67k|		if (card->ops->process_fci == NULL) {
  ------------------
  |  Branch (1913:7): [True: 0, False: 1.67k]
  ------------------
 1914|      0|			sc_file_free(file);
 1915|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1916|      0|		}
 1917|       |
 1918|  1.67k|		if ((size_t) apdu.resp[1] + 2 <= apdu.resplen)
  ------------------
  |  Branch (1918:7): [True: 1.17k, False: 501]
  ------------------
 1919|  1.17k|			card->ops->process_fci(card, file, apdu.resp + 2, apdu.resp[1]);
 1920|  1.67k|		epass2003_hook_file(file, 0);
 1921|  1.67k|		*file_out = file;
 1922|  1.67k|		break;
 1923|     21|	case 0x00:		/* proprietary coding */
  ------------------
  |  Branch (1923:2): [True: 21, False: 1.71k]
  ------------------
 1924|     21|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     21|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     21|	int _ret = r; \
  |  |  |  |  155|     21|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     21|	} 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|     21|	return _ret; \
  |  |  |  |  163|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1925|      0|		break;
 1926|     32|	default:
  ------------------
  |  Branch (1926:2): [True: 32, False: 1.69k]
  ------------------
 1927|     32|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     32|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     32|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     32|	int _ret = r; \
  |  |  |  |  155|     32|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     32|		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|     32|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     32|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     32|	} 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|     32|	return _ret; \
  |  |  |  |  163|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1928|  1.73k|	}
 1929|  1.67k|	return 0;
 1930|  1.73k|}
card-epass2003.c:epass2003_hook_path:
 1789|  5.04k|{
 1790|  5.04k|	u8 fid_h = 0;
 1791|  5.04k|	u8 fid_l = 0;
 1792|       |
 1793|  5.04k|	if (!path || path->len < 2)
  ------------------
  |  Branch (1793:6): [True: 0, False: 5.04k]
  |  Branch (1793:15): [True: 0, False: 5.04k]
  ------------------
 1794|      0|		return -1;
 1795|  5.04k|	fid_h = path->value[path->len - 2];
 1796|  5.04k|	fid_l = path->value[path->len - 1];
 1797|       |
 1798|  5.04k|	switch (fid_h) {
 1799|    322|	case 0x29:
  ------------------
  |  Branch (1799:2): [True: 322, False: 4.71k]
  ------------------
 1800|    365|	case 0x30:
  ------------------
  |  Branch (1800:2): [True: 43, False: 4.99k]
  ------------------
 1801|    408|	case 0x31:
  ------------------
  |  Branch (1801:2): [True: 43, False: 4.99k]
  ------------------
 1802|    442|	case 0x32:
  ------------------
  |  Branch (1802:2): [True: 34, False: 5.00k]
  ------------------
 1803|    483|	case 0x33:
  ------------------
  |  Branch (1803:2): [True: 41, False: 5.00k]
  ------------------
 1804|    517|	case 0x34:
  ------------------
  |  Branch (1804:2): [True: 34, False: 5.00k]
  ------------------
 1805|    517|		if (inc)
  ------------------
  |  Branch (1805:7): [True: 265, False: 252]
  ------------------
 1806|    265|			fid_l = fid_l * FID_STEP;
  ------------------
  |  |  743|    265|#define FID_STEP 0x20
  ------------------
 1807|    252|		else
 1808|    252|			fid_l = fid_l / FID_STEP;
  ------------------
  |  |  743|    252|#define FID_STEP 0x20
  ------------------
 1809|    517|		path->value[path->len - 1] = fid_l;
 1810|    517|		return 1;
 1811|  4.52k|	default:
  ------------------
  |  Branch (1811:2): [True: 4.52k, False: 517]
  ------------------
 1812|  4.52k|		break;
 1813|  5.04k|	}
 1814|  4.52k|	return 0;
 1815|  5.04k|}
card-epass2003.c:epass2003_hook_file:
 1820|  1.67k|{
 1821|  1.67k|	int fidl = file->id & 0xff;
 1822|  1.67k|	int fidh = file->id & 0xff00;
 1823|  1.67k|	int rv = 0;
 1824|       |
 1825|  1.67k|	rv = epass2003_hook_path(&file->path, inc);
 1826|       |
 1827|  1.67k|	if (rv > 0) {
  ------------------
  |  Branch (1827:6): [True: 252, False: 1.42k]
  ------------------
 1828|    252|		if (inc)
  ------------------
  |  Branch (1828:7): [True: 0, False: 252]
  ------------------
 1829|      0|			file->id = fidh + fidl * FID_STEP;
  ------------------
  |  |  743|      0|#define FID_STEP 0x20
  ------------------
 1830|    252|		else
 1831|    252|			file->id = fidh + fidl / FID_STEP;
  ------------------
  |  |  743|    252|#define FID_STEP 0x20
  ------------------
 1832|    252|	}
 1833|  1.67k|	if (rv < 0)
  ------------------
  |  Branch (1833:6): [True: 0, False: 1.67k]
  ------------------
 1834|      0|		return rv;
 1835|  1.67k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.67k|#define SC_SUCCESS				0
  ------------------
 1836|  1.67k|}
card-epass2003.c:epass2003_select_aid:
 1962|  1.24k|{
 1963|  1.24k|	int r = 0;
 1964|       |
 1965|  1.24k|	r = iso_ops->select_file(card, in_path, file_out);
 1966|  1.24k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.24k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.24k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.24k|	int _ret = (r); \
  |  |  |  |  168|  1.24k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.06k, False: 180]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.06k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.06k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.06k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.06k|		return _ret; \
  |  |  |  |  172|  1.06k|	} \
  |  |  |  |  173|  1.24k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 180]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1967|       |
 1968|    180|	if (file_out) {
  ------------------
  |  Branch (1968:6): [True: 0, False: 180]
  ------------------
 1969|      0|		sc_file_t *file = *file_out;
 1970|       |
 1971|      0|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
 1972|      0|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      0|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
 1973|      0|		file->path.len = 0;
 1974|      0|		file->size = 0;
 1975|       |		/* AID */
 1976|      0|		memcpy(file->name, in_path->value, in_path->len);
 1977|      0|		file->namelen = in_path->len;
 1978|      0|		file->id = 0x0000;
 1979|      0|	}
 1980|       |
 1981|    180|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    180|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    180|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    180|	int _ret = r; \
  |  |  |  |  155|    180|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 180, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    180|		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: 180]
  |  |  |  |  ------------------
  |  |  |  |  157|    180|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    180|	} 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|    180|	return _ret; \
  |  |  |  |  163|    180|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1982|    180|}
card-epass2003.c:epass2003_select_path:
 1988|  2.30k|{
 1989|  2.30k|	u8 n_pathbuf[SC_MAX_PATH_SIZE];
 1990|  2.30k|	const u8 *path = pathbuf;
 1991|  2.30k|	size_t pathlen = len;
 1992|  2.30k|	unsigned int i;
 1993|  2.30k|	int r;
 1994|       |
 1995|  2.30k|	if (pathlen % 2 != 0 || pathlen > 6 || pathlen <= 0)
  ------------------
  |  Branch (1995:6): [True: 0, False: 2.30k]
  |  Branch (1995:26): [True: 10, False: 2.29k]
  |  Branch (1995:41): [True: 1, False: 2.29k]
  ------------------
 1996|  2.30k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     11|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     11|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     11|	int _ret = r; \
  |  |  |  |  155|     11|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     11|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     11|	} 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|     11|	return _ret; \
  |  |  |  |  163|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1997|       |
 1998|       |	/* if pathlen == 6 then the first FID must be MF (== 3F00) */
 1999|  2.29k|	if (pathlen == 6 && (path[0] != 0x3f || path[1] != 0x00))
  ------------------
  |  Branch (1999:6): [True: 195, False: 2.09k]
  |  Branch (1999:23): [True: 18, False: 177]
  |  Branch (1999:42): [True: 10, False: 167]
  ------------------
 2000|  2.29k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     28|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     28|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     28|	int _ret = r; \
  |  |  |  |  155|     28|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 28, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     28|		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|     28|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 28, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     28|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     28|	} 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|     28|	return _ret; \
  |  |  |  |  163|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2001|       |
 2002|       |	/* unify path (the first FID should be MF) */
 2003|  2.26k|	if (path[0] != 0x3f || path[1] != 0x00) {
  ------------------
  |  Branch (2003:6): [True: 408, False: 1.85k]
  |  Branch (2003:25): [True: 18, False: 1.83k]
  ------------------
 2004|    426|		n_pathbuf[0] = 0x3f;
 2005|    426|		n_pathbuf[1] = 0x00;
 2006|    426|		memcpy(n_pathbuf + 2, path, pathlen);
 2007|    426|		path = n_pathbuf;
 2008|    426|		pathlen += 2;
 2009|    426|	}
 2010|       |
 2011|  3.36k|	for (i = 0; i < pathlen - 2; i += 2) {
  ------------------
  |  Branch (2011:14): [True: 2.56k, False: 803]
  ------------------
 2012|  2.56k|		r = epass2003_select_fid(card, path[i], path[i + 1], NULL);
 2013|  2.56k|		LOG_TEST_RET(card->ctx, r, "SELECT FILE (DF-ID) failed");
  ------------------
  |  |  174|  2.56k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.56k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.56k|	int _ret = (r); \
  |  |  |  |  168|  2.56k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.45k, False: 1.10k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.45k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.45k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.45k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.45k|		return _ret; \
  |  |  |  |  172|  1.45k|	} \
  |  |  |  |  173|  2.56k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.10k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2014|  2.56k|	}
 2015|       |
 2016|    803|	return epass2003_select_fid(card, path[pathlen - 2], path[pathlen - 1], file_out);
 2017|  2.26k|}
card-epass2003.c:epass2003_card_ctl:
 3038|    138|{
 3039|    138|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    138|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    138|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    138|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    138|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 138]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3040|       |
 3041|    138|	sc_log(card->ctx, "cmd is %0lx", cmd);
  ------------------
  |  |   71|    138|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3042|    138|	switch (cmd) {
 3043|      0|	case SC_CARDCTL_ENTERSAFE_WRITE_KEY:
  ------------------
  |  Branch (3043:2): [True: 0, False: 138]
  ------------------
 3044|      0|		return epass2003_write_key(card, (sc_epass2003_wkey_data *) ptr);
 3045|      0|	case SC_CARDCTL_ENTERSAFE_GENERATE_KEY:
  ------------------
  |  Branch (3045:2): [True: 0, False: 138]
  ------------------
 3046|      0|		return epass2003_gen_key(card, (sc_epass2003_gen_key_data *) ptr);
 3047|      0|	case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (3047:2): [True: 0, False: 138]
  ------------------
 3048|      0|		return epass2003_erase_card(card);
 3049|     49|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (3049:2): [True: 49, False: 89]
  ------------------
 3050|     49|		return epass2003_get_serialnr(card, (sc_serial_number_t *) ptr);
 3051|     89|	default:
  ------------------
  |  Branch (3051:2): [True: 89, False: 49]
  ------------------
 3052|     89|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     89|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 3053|    138|	}
 3054|    138|}
card-epass2003.c:epass2003_get_serialnr:
 3019|     49|{
 3020|     49|	u8 rbuf[8];
 3021|     49|	size_t rbuf_len = sizeof(rbuf);
 3022|       |
 3023|     49|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     49|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     49|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     49|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     49|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 49]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3024|       |
 3025|     49|	if (SC_SUCCESS != get_data(card, 0x80, rbuf, rbuf_len))
  ------------------
  |  |   28|     49|#define SC_SUCCESS				0
  ------------------
  |  Branch (3025:6): [True: 24, False: 25]
  ------------------
 3026|     24|		return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|     24|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 3027|       |
 3028|     25|	card->serialnr.len = serial->len = 8;
 3029|     25|	memcpy(card->serialnr.value, rbuf, 8);
 3030|     25|	memcpy(serial->value, rbuf, 8);
 3031|       |
 3032|     25|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     25|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     25|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     25|	int _ret = r; \
  |  |  |  |  155|     25|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 25, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     25|		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: 25]
  |  |  |  |  ------------------
  |  |  |  |  157|     25|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     25|	} 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|     25|	return _ret; \
  |  |  |  |  163|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3033|     25|}
card-epass2003.c:epass2003_process_fci:
 2297|  1.17k|{
 2298|  1.17k|	sc_context_t *ctx = card->ctx;
 2299|  1.17k|	size_t taglen, len = buflen;
 2300|  1.17k|	const u8 *tag = NULL, *p = buf;
 2301|       |
 2302|  1.17k|	sc_log(ctx, "processing FCI bytes");
  ------------------
  |  |   71|  1.17k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2303|  1.17k|	tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen);
 2304|  1.17k|	if (tag != NULL && taglen == 2) {
  ------------------
  |  Branch (2304:6): [True: 329, False: 848]
  |  Branch (2304:21): [True: 310, False: 19]
  ------------------
 2305|    310|		file->id = (tag[0] << 8) | tag[1];
 2306|    310|		sc_log(ctx, "  file identifier: 0x%02X%02X", tag[0], tag[1]);
  ------------------
  |  |   71|    310|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2307|    310|	}
 2308|       |
 2309|  1.17k|	tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
 2310|  1.17k|	if (tag != NULL && taglen > 0 && taglen < 3) {
  ------------------
  |  Branch (2310:6): [True: 171, False: 1.00k]
  |  Branch (2310:21): [True: 135, False: 36]
  |  Branch (2310:35): [True: 107, False: 28]
  ------------------
 2311|    107|		file->size = tag[0];
 2312|    107|		if (taglen == 2)
  ------------------
  |  Branch (2312:7): [True: 94, False: 13]
  ------------------
 2313|     94|			file->size = (file->size << 8) + tag[1];
 2314|    107|		sc_log(ctx, "  bytes in file: %zu", file->size);
  ------------------
  |  |   71|    107|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2315|    107|	}
 2316|       |
 2317|  1.17k|	if (tag == NULL) {
  ------------------
  |  Branch (2317:6): [True: 1.00k, False: 171]
  ------------------
 2318|  1.00k|		tag = sc_asn1_find_tag(ctx, p, len, 0x81, &taglen);
 2319|  1.00k|		if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (2319:7): [True: 34, False: 972]
  |  Branch (2319:22): [True: 21, False: 13]
  ------------------
 2320|     21|			int bytes = (tag[0] << 8) + tag[1];
 2321|       |
 2322|     21|			sc_log(ctx, "  bytes in file: %d", bytes);
  ------------------
  |  |   71|     21|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2323|     21|			file->size = bytes;
 2324|     21|		}
 2325|  1.00k|	}
 2326|       |
 2327|  1.17k|	tag = sc_asn1_find_tag(ctx, p, len, 0x82, &taglen);
 2328|  1.17k|	if (tag != NULL) {
  ------------------
  |  Branch (2328:6): [True: 587, False: 590]
  ------------------
 2329|    587|		if (taglen > 0) {
  ------------------
  |  Branch (2329:7): [True: 577, False: 10]
  ------------------
 2330|    577|			unsigned char byte = tag[0];
 2331|    577|			const char *type;
 2332|       |
 2333|    577|			if (byte == 0x38) {
  ------------------
  |  Branch (2333:8): [True: 51, False: 526]
  ------------------
 2334|     51|				type = "DF";
 2335|     51|				file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     51|#define SC_FILE_TYPE_DF			0x04
  ------------------
 2336|    526|			} else if (0x01 <= byte && byte <= 0x07) {
  ------------------
  |  Branch (2336:15): [True: 508, False: 18]
  |  Branch (2336:31): [True: 219, False: 289]
  ------------------
 2337|    219|				type = "working EF";
 2338|    219|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    219|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 2339|    219|				switch (byte) {
 2340|     11|				case 0x01:
  ------------------
  |  Branch (2340:5): [True: 11, False: 208]
  ------------------
 2341|     11|					file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     11|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 2342|     11|					break;
 2343|     42|				case 0x02:
  ------------------
  |  Branch (2343:5): [True: 42, False: 177]
  ------------------
 2344|     42|					file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|     42|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
 2345|     42|					break;
 2346|    122|				case 0x04:
  ------------------
  |  Branch (2346:5): [True: 122, False: 97]
  ------------------
 2347|    122|					file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|    122|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
 2348|    122|					break;
 2349|     44|				default:
  ------------------
  |  Branch (2349:5): [True: 44, False: 175]
  ------------------
 2350|     44|					break;
 2351|    219|				}
 2352|       |
 2353|    307|			} else if (0x10 == byte) {
  ------------------
  |  Branch (2353:15): [True: 14, False: 293]
  ------------------
 2354|     14|				type = "BSO";
 2355|     14|				file->type = SC_FILE_TYPE_BSO;
  ------------------
  |  |  217|     14|#define SC_FILE_TYPE_BSO		0x10
  ------------------
 2356|    293|			} else if (0x11 <= byte) {
  ------------------
  |  Branch (2356:15): [True: 274, False: 19]
  ------------------
 2357|    274|				type = "internal EF";
 2358|    274|				file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|    274|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
 2359|    274|				switch (byte) {
 2360|    171|				case 0x11:
  ------------------
  |  Branch (2360:5): [True: 171, False: 103]
  ------------------
 2361|    171|					break;
 2362|     20|				case 0x12:
  ------------------
  |  Branch (2362:5): [True: 20, False: 254]
  ------------------
 2363|     20|					break;
 2364|     83|				default:
  ------------------
  |  Branch (2364:5): [True: 83, False: 191]
  ------------------
 2365|     83|					break;
 2366|    274|				}
 2367|    274|			} else {
 2368|     19|				type = "unknown";
 2369|     19|				file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     19|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
 2370|     19|			}
 2371|    577|			sc_log(ctx, "type %s, EF structure %d", type, byte);
  ------------------
  |  |   71|    577|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2372|    577|		}
 2373|    587|	}
 2374|       |
 2375|  1.17k|	tag = sc_asn1_find_tag(ctx, p, len, 0x84, &taglen);
 2376|  1.17k|	if (tag != NULL && taglen > 0 && taglen <= 16) {
  ------------------
  |  Branch (2376:6): [True: 109, False: 1.06k]
  |  Branch (2376:21): [True: 88, False: 21]
  |  Branch (2376:35): [True: 70, False: 18]
  ------------------
 2377|     70|		memcpy(file->name, tag, taglen);
 2378|     70|		file->namelen = taglen;
 2379|       |
 2380|     70|		sc_log_hex(ctx, "File name", file->name, file->namelen);
  ------------------
  |  |  129|     70|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     70|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2381|     70|		if (!file->type)
  ------------------
  |  Branch (2381:7): [True: 29, False: 41]
  ------------------
 2382|     29|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     29|#define SC_FILE_TYPE_DF			0x04
  ------------------
 2383|     70|	}
 2384|       |
 2385|  1.17k|	tag = sc_asn1_find_tag(ctx, p, len, 0x85, &taglen);
 2386|  1.17k|	if (tag != NULL && taglen)
  ------------------
  |  Branch (2386:6): [True: 191, False: 986]
  |  Branch (2386:21): [True: 177, False: 14]
  ------------------
 2387|    177|		sc_file_set_prop_attr(file, tag, taglen);
 2388|  1.00k|	else
 2389|  1.00k|		file->prop_attr_len = 0;
 2390|       |
 2391|  1.17k|	tag = sc_asn1_find_tag(ctx, p, len, 0xA5, &taglen);
 2392|  1.17k|	if (tag != NULL && taglen)
  ------------------
  |  Branch (2392:6): [True: 34, False: 1.14k]
  |  Branch (2392:21): [True: 10, False: 24]
  ------------------
 2393|     10|		sc_file_set_prop_attr(file, tag, taglen);
 2394|       |
 2395|  1.17k|	tag = sc_asn1_find_tag(ctx, p, len, 0x86, &taglen);
 2396|  1.17k|	if (tag != NULL && taglen) {
  ------------------
  |  Branch (2396:6): [True: 297, False: 880]
  |  Branch (2396:21): [True: 277, False: 20]
  ------------------
 2397|    277|		unsigned int i;
 2398|    277|		sc_file_set_sec_attr(file, tag, taglen);
 2399|  3.91k|		for (i = 0; i< taglen; i++)
  ------------------
  |  Branch (2399:15): [True: 3.63k, False: 277]
  ------------------
 2400|  3.63k|			if (tag[i] != 0xff) /* skip unused entries */
  ------------------
  |  Branch (2400:8): [True: 2.36k, False: 1.27k]
  ------------------
 2401|  2.36k|				sec_attr_to_entry(card, file, i);
 2402|    277|	}
 2403|       |
 2404|  1.17k|	tag = sc_asn1_find_tag(ctx, p, len, 0x8A, &taglen);
 2405|  1.17k|	if (tag != NULL && taglen == 1) {
  ------------------
  |  Branch (2405:6): [True: 179, False: 998]
  |  Branch (2405:21): [True: 108, False: 71]
  ------------------
 2406|    108|		if (tag[0] == 0x01)
  ------------------
  |  Branch (2406:7): [True: 18, False: 90]
  ------------------
 2407|     18|			file->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|     18|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
 2408|     90|		else if (tag[0] == 0x07 || tag[0] == 0x05)
  ------------------
  |  Branch (2408:12): [True: 18, False: 72]
  |  Branch (2408:30): [True: 10, False: 62]
  ------------------
 2409|     28|			file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|     28|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
 2410|     62|		else if (tag[0] == 0x06 || tag[0] == 0x04)
  ------------------
  |  Branch (2410:12): [True: 18, False: 44]
  |  Branch (2410:30): [True: 21, False: 23]
  ------------------
 2411|     39|			file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|     39|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
 2412|    108|	}
 2413|  1.17k|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|  1.17k|#define SC_FILE_MAGIC			0x14426950
  ------------------
 2414|       |
 2415|  1.17k|	return 0;
 2416|  1.17k|}
card-epass2003.c:epass2003_pin_cmd:
 3211|     49|{
 3212|     49|	int r;
 3213|     49|	u8 kid;
 3214|     49|	u8 retries = 0;
 3215|     49|	u8 pin_low = 3;
 3216|     49|	unsigned char maxtries = 0;
 3217|       |
 3218|     49|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     49|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     49|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     49|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     49|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 49]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3219|       |
 3220|     49|	internal_sanitize_pin_info(&data->pin1, 0);
 3221|     49|	internal_sanitize_pin_info(&data->pin2, 1);
 3222|     49|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|     49|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 3223|     49|	kid = data->pin_reference;
 3224|       |
 3225|     49|	if (NULL == (unsigned char *)data->pin1.data || 0 == data->pin1.len)
  ------------------
  |  Branch (3225:6): [True: 49, False: 0]
  |  Branch (3225:50): [True: 0, False: 0]
  ------------------
 3226|     49|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT);
  ------------------
  |  |  164|     49|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     49|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     49|	int _ret = r; \
  |  |  |  |  155|     49|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     49|		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|     49|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     49|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     49|	} 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|     49|	return _ret; \
  |  |  |  |  163|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3227|       |
 3228|       |	/* get pin retries */
 3229|      0|	if (data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  418|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (3229:6): [True: 0, False: 0]
  ------------------
 3230|       |
 3231|      0|		r = get_external_key_retries(card, 0x80 | kid, &retries);
 3232|      0|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (3232:7): [True: 0, False: 0]
  ------------------
 3233|      0|			data->pin1.tries_left = retries;
 3234|       |
 3235|      0|			r = get_external_key_maxtries(card, &maxtries);
 3236|      0|			LOG_TEST_RET(card->ctx, r, "get max counter failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3237|       |
 3238|      0|			data->pin1.max_tries = maxtries;
 3239|      0|		}
 3240|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3241|      0|	} else if (data->cmd == SC_PIN_CMD_UNBLOCK) { /* verify */
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (3241:13): [True: 0, False: 0]
  ------------------
 3242|      0|		r = external_key_auth(card, (kid + 1), (unsigned char *)data->pin1.data,
 3243|      0|				data->pin1.len);
 3244|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3245|      0|	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) { /* change */
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
              	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) { /* change */
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (3245:13): [True: 0, False: 0]
  |  Branch (3245:47): [True: 0, False: 0]
  ------------------
 3246|      0|		r = external_key_auth(card, kid, (unsigned char *)data->pin1.data,
 3247|      0|				data->pin1.len);
 3248|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3249|       |
 3250|      0|		r = update_secret_key(card, 0x04, kid, data->pin2.data,
 3251|      0|				(unsigned long)data->pin2.len);
 3252|      0|		LOG_TEST_RET(card->ctx, r, "change pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3253|      0|	} else {
 3254|      0|		r = external_key_auth(card, kid, (unsigned char *)data->pin1.data,
 3255|      0|				data->pin1.len);
 3256|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3257|       |
 3258|      0|		r = get_external_key_retries(card, 0x80 | kid, &retries);
 3259|      0|		if (retries < pin_low)
  ------------------
  |  Branch (3259:7): [True: 0, False: 0]
  ------------------
 3260|      0|			sc_log(card->ctx, "Verification failed (remaining tries: %d)", retries);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3261|       |
 3262|      0|		LOG_TEST_RET(card->ctx, r, "verify pin failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3263|      0|	}
 3264|       |
 3265|      0|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (3265:6): [True: 0, False: 0]
  ------------------
 3266|      0|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  432|      0|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
 3267|      0|	}
 3268|      0|	return r;
 3269|      0|}
card-epass2003.c:internal_sanitize_pin_info:
 3059|     98|{
 3060|     98|	pin->encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|     98|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 3061|     98|	pin->min_length = 4;
 3062|     98|	pin->max_length = 16;
 3063|     98|	pin->pad_length = 16;
 3064|     98|	pin->offset = 5 + num * 16;
 3065|     98|	pin->pad_char = 0x00;
 3066|     98|}
card-epass2003.c:epass2003_check_sw:
  245|  10.8k|{
  246|  10.8k|	const int err_count = sizeof(epass2003_errors)/sizeof(epass2003_errors[0]);
  247|  10.8k|	int i;
  248|       |
  249|       |	/* Handle special cases here */
  250|  10.8k|	if (sw1 == 0x6C) {
  ------------------
  |  Branch (250:6): [True: 40, False: 10.7k]
  ------------------
  251|     40|		sc_log(card->ctx, "Wrong length; correct length is %d", sw2);
  ------------------
  |  |   71|     40|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  252|     40|		return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|     40|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  253|     40|	}
  254|       |
  255|   507k|	for (i = 0; i < err_count; i++) {
  ------------------
  |  Branch (255:14): [True: 506k, False: 891]
  ------------------
  256|   506k|		if (epass2003_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (256:7): [True: 9.88k, False: 496k]
  ------------------
  257|  9.88k|			sc_log(card->ctx, "%s", epass2003_errors[i].errorstr);
  ------------------
  |  |   71|  9.88k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  258|  9.88k|			return epass2003_errors[i].errorno;
  259|  9.88k|		}
  260|   506k|	}
  261|       |
  262|    891|	sc_log(card->ctx, "Unknown SWs; SW1=%02X, SW2=%02X", sw1, sw2);
  ------------------
  |  |   71|    891|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  263|    891|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|    891|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  264|  10.7k|}
card-epass2003.c:epass2003_get_challenge:
 3123|    466|{
 3124|    466|	u8 rbuf[16];
 3125|    466|	size_t out_len;
 3126|    466|	int r;
 3127|       |
 3128|    466|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    466|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    466|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    466|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    466|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 466]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3129|       |
 3130|    466|	r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
 3131|    466|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE cmd failed");
  ------------------
  |  |  174|    466|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    466|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    466|	int _ret = (r); \
  |  |  |  |  168|    466|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 63, False: 403]
  |  |  |  |  ------------------
  |  |  |  |  169|     63|		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|     63|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     63|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     63|		return _ret; \
  |  |  |  |  172|     63|	} \
  |  |  |  |  173|    466|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 403]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3132|       |
 3133|    403|	if (len < (size_t) r) {
  ------------------
  |  Branch (3133:6): [True: 1, False: 402]
  ------------------
 3134|      1|		out_len = len;
 3135|    402|	} else {
 3136|    402|		out_len = (size_t) r;
 3137|    402|	}
 3138|    403|	memcpy(rnd, rbuf, out_len);
 3139|       |
 3140|    403|	LOG_FUNC_RETURN(card->ctx, (int) out_len);
  ------------------
  |  |  164|    403|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    403|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    403|	int _ret = r; \
  |  |  |  |  155|    403|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7, False: 396]
  |  |  |  |  ------------------
  |  |  |  |  156|      7|		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: 7]
  |  |  |  |  ------------------
  |  |  |  |  157|      7|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    396|	} else { \
  |  |  |  |  159|    396|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    396|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    396|	} \
  |  |  |  |  162|    403|	return _ret; \
  |  |  |  |  163|    403|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3141|    403|}

sc_get_esteid2018_driver:
  303|  17.0k|struct sc_card_driver *sc_get_esteid2018_driver(void) {
  304|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  305|       |
  306|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (306:6): [True: 1, False: 17.0k]
  ------------------
  307|      1|		iso_ops = iso_drv->ops;
  308|       |
  309|  17.0k|	esteid_ops = *iso_drv->ops;
  310|  17.0k|	esteid_ops.match_card = esteid_match_card;
  311|  17.0k|	esteid_ops.init = esteid_init;
  312|  17.0k|	esteid_ops.finish = esteid_finish;
  313|       |
  314|  17.0k|	esteid_ops.select_file = esteid_select_file;
  315|       |
  316|  17.0k|	esteid_ops.set_security_env = esteid_set_security_env;
  317|  17.0k|	esteid_ops.compute_signature = esteid_compute_signature;
  318|  17.0k|	esteid_ops.pin_cmd = esteid_pin_cmd;
  319|  17.0k|	esteid_ops.logout = esteid_logout;
  320|       |
  321|  17.0k|	return &esteid2018_driver;
  322|  17.0k|}
card-esteid2018.c:esteid_match_card:
   83|  8.63k|static int esteid_match_card(sc_card_t *card) {
   84|  8.63k|	int i = _sc_match_atr(card, esteid_atrs, &card->type);
   85|       |
   86|  8.63k|	if (i >= 0 && gp_select_aid(card, &IASECC_AID) == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (86:6): [True: 0, False: 8.63k]
  |  Branch (86:16): [True: 0, False: 0]
  ------------------
   87|      0|		card->name = esteid_atrs[i].name;
   88|      0|		return 1;
   89|      0|	}
   90|  8.63k|	return 0;
   91|  8.63k|}

sc_get_esteid2025_driver:
  220|  17.0k|{
  221|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  222|       |
  223|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (223:6): [True: 1, False: 17.0k]
  ------------------
  224|      1|		iso_ops = iso_drv->ops;
  225|       |
  226|  17.0k|	esteid_ops = *iso_drv->ops;
  227|  17.0k|	esteid_ops.match_card = esteid_match_card;
  228|  17.0k|	esteid_ops.init = esteid_init;
  229|       |
  230|  17.0k|	esteid_ops.select_file = esteid_select_file;
  231|       |
  232|  17.0k|	esteid_ops.set_security_env = esteid_set_security_env;
  233|  17.0k|	esteid_ops.compute_signature = esteid_compute_signature;
  234|  17.0k|	esteid_ops.pin_cmd = esteid_pin_cmd;
  235|  17.0k|	esteid_ops.logout = esteid_logout;
  236|       |
  237|  17.0k|	return &esteid2025_driver;
  238|  17.0k|}
card-esteid2025.c:esteid_match_card:
   65|  8.63k|{
   66|  8.63k|	int i = _sc_match_atr(card, esteid_atrs, &card->type);
   67|       |
   68|  8.63k|	if (i >= 0 && gp_select_aid(card, &THALES_AID) == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (68:6): [True: 0, False: 8.63k]
  |  Branch (68:16): [True: 0, False: 0]
  ------------------
   69|      0|		card->name = esteid_atrs[i].name;
   70|      0|		return 1;
   71|      0|	}
   72|  8.63k|	return 0;
   73|  8.63k|}

sc_get_cryptoflex_driver:
 1203|  17.0k|{
 1204|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1204:6): [True: 0, False: 17.0k]
  ------------------
 1205|      0|		iso_ops = sc_get_iso7816_driver()->ops;
 1206|       |
 1207|  17.0k|	cryptoflex_ops = *iso_ops;
 1208|  17.0k|	cryptoflex_ops.match_card = cryptoflex_match_card;
 1209|  17.0k|	cryptoflex_ops.init = flex_init;
 1210|  17.0k|	cryptoflex_ops.finish = flex_finish;
 1211|  17.0k|	cryptoflex_ops.process_fci = cryptoflex_process_file_attrs;
 1212|  17.0k|	cryptoflex_ops.construct_fci = cryptoflex_construct_file_attrs;
 1213|  17.0k|	cryptoflex_ops.select_file = flex_select_file;
 1214|  17.0k|	cryptoflex_ops.list_files = cryptoflex_list_files;
 1215|  17.0k|	cryptoflex_ops.delete_file = flex_delete_file;
 1216|  17.0k|	cryptoflex_ops.create_file = flex_create_file;
 1217|  17.0k|	cryptoflex_ops.card_ctl = flex_card_ctl;
 1218|  17.0k|	cryptoflex_ops.set_security_env = flex_set_security_env;
 1219|  17.0k|	cryptoflex_ops.restore_security_env = flex_restore_security_env;
 1220|  17.0k|	cryptoflex_ops.compute_signature = cryptoflex_compute_signature;
 1221|  17.0k|	cryptoflex_ops.decipher = flex_decipher;
 1222|  17.0k|	cryptoflex_ops.pin_cmd = flex_pin_cmd;
 1223|  17.0k|	cryptoflex_ops.logout = flex_logout;
 1224|  17.0k|	return &cryptoflex_drv;
 1225|  17.0k|}
sc_get_cyberflex_driver:
 1228|  17.0k|{
 1229|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1229:6): [True: 1, False: 17.0k]
  ------------------
 1230|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1231|       |
 1232|  17.0k|	cyberflex_ops = *iso_ops;
 1233|  17.0k|	cyberflex_ops.match_card = cyberflex_match_card;
 1234|  17.0k|	cyberflex_ops.init = flex_init;
 1235|  17.0k|	cyberflex_ops.finish = flex_finish;
 1236|  17.0k|	cyberflex_ops.process_fci = cyberflex_process_file_attrs;
 1237|  17.0k|	cyberflex_ops.construct_fci = cyberflex_construct_file_attrs;
 1238|  17.0k|	cyberflex_ops.select_file = flex_select_file;
 1239|  17.0k|	cyberflex_ops.list_files = cyberflex_list_files;
 1240|  17.0k|	cyberflex_ops.delete_file = flex_delete_file;
 1241|  17.0k|	cyberflex_ops.create_file = flex_create_file;
 1242|  17.0k|	cyberflex_ops.card_ctl = flex_card_ctl;
 1243|  17.0k|	cyberflex_ops.set_security_env = flex_set_security_env;
 1244|  17.0k|	cyberflex_ops.restore_security_env = flex_restore_security_env;
 1245|  17.0k|	cyberflex_ops.compute_signature = cyberflex_compute_signature;
 1246|  17.0k|	cyberflex_ops.decipher = flex_decipher;
 1247|  17.0k|	cyberflex_ops.pin_cmd = flex_pin_cmd;
 1248|  17.0k|	cyberflex_ops.logout = flex_logout;
 1249|  17.0k|	return &cyberflex_drv;
 1250|  17.0k|}
card-flex.c:cryptoflex_match_card:
  134|  16.5k|{
  135|  16.5k|	int i;
  136|       |
  137|  16.5k|	i = _sc_match_atr(card, flex_atrs, NULL);
  138|  16.5k|	if (i < 0)
  ------------------
  |  Branch (138:6): [True: 16.3k, False: 163]
  ------------------
  139|  16.3k|		return 0;
  140|    163|	switch (flex_atrs[i].type) {
  ------------------
  |  Branch (140:10): [True: 163, False: 0]
  ------------------
  141|    163|	case SC_CARD_TYPE_FLEX_CRYPTO:
  ------------------
  |  Branch (141:2): [True: 163, False: 0]
  ------------------
  142|    163|	case SC_CARD_TYPE_FLEX_MULTI:
  ------------------
  |  Branch (142:2): [True: 0, False: 163]
  ------------------
  143|    163|		card->name = flex_atrs[i].name;
  144|    163|		card->type = flex_atrs[i].type;
  145|    163|		card->flags = flex_atrs[i].flags;
  146|    163|		return 1;
  147|    163|	}
  148|      0|	return 0;
  149|    163|}
card-flex.c:flex_init:
  169|    276|{
  170|    276|	struct flex_private_data *data;
  171|       |
  172|    276|	if (!(data = malloc(sizeof(*data))))
  ------------------
  |  Branch (172:6): [True: 0, False: 276]
  ------------------
  173|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  174|    276|	card->drv_data = data;
  175|       |
  176|    276|	card->cla = 0xC0;
  177|    276|	data->aak_key_ref = 1;
  178|       |
  179|       |	/* Override Cryptoflex defaults for specific card types */
  180|    276|	switch (card->type) {
  ------------------
  |  Branch (180:10): [True: 113, False: 163]
  ------------------
  181|    113|	case SC_CARD_TYPE_FLEX_CYBER:
  ------------------
  |  Branch (181:2): [True: 113, False: 163]
  ------------------
  182|    113|		card->cla = 0x00;
  183|    113|		data->aak_key_ref = 0;
  184|    113|		break;
  185|    276|	}
  186|       |
  187|       |	/* FIXME: Card type detection */
  188|    276|	if (1) {
  ------------------
  |  Branch (188:6): [True: 276, Folded]
  ------------------
  189|    276|		unsigned long flags;
  190|       |
  191|    276|		flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|    276|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  192|    276|		flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    276|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  193|    276|		if (card->flags & FLAG_KEYGEN)
  ------------------
  |  |   31|    276|#define FLAG_KEYGEN		0x80000000
  ------------------
  |  Branch (193:7): [True: 163, False: 113]
  ------------------
  194|    163|			flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    163|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  195|       |
  196|    276|		_sc_card_add_rsa_alg(card, 512, flags, 0);
  197|    276|		_sc_card_add_rsa_alg(card, 768, flags, 0);
  198|    276|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  199|    276|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  200|    276|	}
  201|       |
  202|       |	/* SCardTransmit failed: 8010002f
  203|       |	 * this can be solved with a small delay. */
  204|    276|	msleep(100);
  ------------------
  |  |   59|    276|#define msleep(t)	usleep((t) * 1000)
  ------------------
  205|       |
  206|       |	/* State that we have an RNG */
  207|    276|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    276|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  208|       |
  209|    276|	return 0;
  210|    276|}
card-flex.c:flex_finish:
  128|    276|{
  129|    276|	free(card->drv_data);
  130|    276|	return 0;
  131|    276|}
card-flex.c:cryptoflex_process_file_attrs:
  270|    190|{
  271|    190|	sc_context_t *ctx = card->ctx;
  272|    190|	const u8 *p = buf + 2;
  273|    190|	u8 b1, b2;
  274|    190|	int is_mf = 0;
  275|       |
  276|    190|	if (buflen < 14)
  ------------------
  |  Branch (276:6): [True: 0, False: 190]
  ------------------
  277|      0|		return -1;
  278|    190|	b1 = *p++;
  279|    190|	b2 = *p++;
  280|    190|	file->size = (b1 << 8) + b2;
  281|    190|	b1 = *p++;
  282|    190|	b2 = *p++;
  283|    190|	file->id = (b1 << 8) + b2;
  284|    190|	if (file->id == 0x3F00)
  ------------------
  |  Branch (284:6): [True: 4, False: 186]
  ------------------
  285|      4|		is_mf = 1;
  286|    190|	switch (*p) {
  287|     35|	case 0x01:
  ------------------
  |  Branch (287:2): [True: 35, False: 155]
  ------------------
  288|     35|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     35|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  289|     35|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     35|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  290|     35|		break;
  291|    103|	case 0x02:
  ------------------
  |  Branch (291:2): [True: 103, False: 87]
  ------------------
  292|    103|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    103|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  293|    103|		file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|    103|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  294|    103|		break;
  295|      4|	case 0x04:
  ------------------
  |  Branch (295:2): [True: 4, False: 186]
  ------------------
  296|      4|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      4|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  297|      4|		file->ef_structure = SC_FILE_EF_LINEAR_VARIABLE;
  ------------------
  |  |  224|      4|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  298|      4|		break;
  299|      5|	case 0x06:
  ------------------
  |  Branch (299:2): [True: 5, False: 185]
  ------------------
  300|      5|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      5|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  301|      5|		file->ef_structure = SC_FILE_EF_CYCLIC;
  ------------------
  |  |  226|      5|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  302|      5|		break;
  303|      6|	case 0x38:
  ------------------
  |  Branch (303:2): [True: 6, False: 184]
  ------------------
  304|      6|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      6|#define SC_FILE_TYPE_DF			0x04
  ------------------
  305|      6|		break;
  306|     37|	default:
  ------------------
  |  Branch (306:2): [True: 37, False: 153]
  ------------------
  307|     37|		sc_log(ctx,  "invalid file type: 0x%02X\n", *p);
  ------------------
  |  |   71|     37|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  308|     37|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     37|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  309|    190|	}
  310|    153|	p += 2;
  311|    153|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|    153|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (311:6): [True: 6, False: 147]
  ------------------
  312|      6|		add_acl_entry(card, file, SC_AC_OP_LIST_FILES, (u8)(p[0] >> 4));
  ------------------
  |  |  172|      6|#define SC_AC_OP_LIST_FILES		6
  ------------------
  313|      6|		add_acl_entry(card, file, SC_AC_OP_DELETE, (u8)(p[1] >> 4));
  ------------------
  |  |  168|      6|#define SC_AC_OP_DELETE			2
  ------------------
  314|      6|		add_acl_entry(card, file, SC_AC_OP_CREATE, (u8)(p[1] & 0x0F));
  ------------------
  |  |  169|      6|#define SC_AC_OP_CREATE			3
  ------------------
  315|    147|	} else { /* EF */
  316|    147|		add_acl_entry(card, file, SC_AC_OP_READ, (u8)(p[0] >> 4));
  ------------------
  |  |  188|    147|#define SC_AC_OP_READ			22
  ------------------
  317|    147|		switch (file->ef_structure) {
  ------------------
  |  Branch (317:11): [True: 147, False: 0]
  ------------------
  318|     35|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|     35|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (318:3): [True: 35, False: 112]
  ------------------
  319|     35|			add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(p[0] & 0x0F));
  ------------------
  |  |  189|     35|#define SC_AC_OP_UPDATE			23
  ------------------
  320|     35|			break;
  321|    103|		case SC_FILE_EF_LINEAR_FIXED:
  ------------------
  |  |  222|    103|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (321:3): [True: 103, False: 44]
  ------------------
  322|    107|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|    107|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (322:3): [True: 4, False: 143]
  ------------------
  323|    107|			add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(p[0] & 0x0F));
  ------------------
  |  |  189|    107|#define SC_AC_OP_UPDATE			23
  ------------------
  324|    107|			break;
  325|      5|		case SC_FILE_EF_CYCLIC:
  ------------------
  |  |  226|      5|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (325:3): [True: 5, False: 142]
  ------------------
  326|      5|			break;
  327|    147|		}
  328|    147|	}
  329|    153|	if (file->type != SC_FILE_TYPE_DF || is_mf) {
  ------------------
  |  |  214|    306|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (329:6): [True: 147, False: 6]
  |  Branch (329:39): [True: 2, False: 4]
  ------------------
  330|    149|		add_acl_entry(card, file, SC_AC_OP_REHABILITATE, (u8)(p[2] >> 4));
  ------------------
  |  |  170|    149|#define SC_AC_OP_REHABILITATE		4
  ------------------
  331|    149|		add_acl_entry(card, file, SC_AC_OP_INVALIDATE, (u8)(p[2] & 0x0F));
  ------------------
  |  |  171|    149|#define SC_AC_OP_INVALIDATE		5
  ------------------
  332|    149|	}
  333|    153|	p += 3;
  334|    153|	if (*p)
  ------------------
  |  Branch (334:6): [True: 89, False: 64]
  ------------------
  335|     89|		file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|     89|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  336|     64|	else
  337|     64|		file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|     64|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  338|       |
  339|    153|	return cryptoflex_get_ac_keys(card, file);
  340|    153|}
card-flex.c:add_acl_entry:
  214|    868|{
  215|    868|	struct flex_private_data *prv = DRV_DATA(card);
  ------------------
  |  |  109|    868|#define DRV_DATA(card)	((struct flex_private_data *) (card)->drv_data)
  ------------------
  216|       |
  217|    868|	switch (nibble) {
  218|    233|	case 0:
  ------------------
  |  Branch (218:2): [True: 233, False: 635]
  ------------------
  219|    233|		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|    233|#define SC_AC_NONE			0x00000000
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    233|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  220|    233|		break;
  221|     67|	case 1:
  ------------------
  |  Branch (221:2): [True: 67, False: 801]
  ------------------
  222|     67|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 1);
  ------------------
  |  |  151|     67|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  223|     67|		break;
  224|     62|	case 2:
  ------------------
  |  Branch (224:2): [True: 62, False: 806]
  ------------------
  225|     62|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 2);
  ------------------
  |  |  151|     62|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  226|     62|		break;
  227|     68|	case 3:
  ------------------
  |  Branch (227:2): [True: 68, False: 800]
  ------------------
  228|     68|		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  153|     68|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     68|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  229|     68|		break;
  230|     22|	case 4:
  ------------------
  |  Branch (230:2): [True: 22, False: 846]
  ------------------
  231|       |		/* Assume the key is the AAK */
  232|     22|		sc_file_add_acl_entry(file, op, SC_AC_AUT, prv->aak_key_ref);
  ------------------
  |  |  154|     22|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  233|     22|		break;
  234|     88|	case 6:
  ------------------
  |  Branch (234:2): [True: 88, False: 780]
  ------------------
  235|     88|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 1);
  ------------------
  |  |  151|     88|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  236|     88|		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  153|     88|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     88|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  237|     88|		break;
  238|     42|	case 7:
  ------------------
  |  Branch (238:2): [True: 42, False: 826]
  ------------------
  239|     42|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 2);
  ------------------
  |  |  151|     42|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  240|     42|		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  153|     42|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     42|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  241|     42|		break;
  242|     66|	case 8:
  ------------------
  |  Branch (242:2): [True: 66, False: 802]
  ------------------
  243|     66|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 1);
  ------------------
  |  |  151|     66|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  244|       |		/* Assume the key is the AAK */
  245|     66|		sc_file_add_acl_entry(file, op, SC_AC_AUT, prv->aak_key_ref);
  ------------------
  |  |  154|     66|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  246|     66|		break;
  247|     26|	case 9:
  ------------------
  |  Branch (247:2): [True: 26, False: 842]
  ------------------
  248|     26|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 2);
  ------------------
  |  |  151|     26|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  249|       |		/* Assume the key is the AAK */
  250|     26|		sc_file_add_acl_entry(file, op, SC_AC_AUT, prv->aak_key_ref);
  ------------------
  |  |  154|     26|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  251|     26|		break;
  252|    113|	case 15:
  ------------------
  |  Branch (252:2): [True: 113, False: 755]
  ------------------
  253|    113|		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  163|    113|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    113|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  254|    113|		break;
  255|     81|	default:
  ------------------
  |  Branch (255:2): [True: 81, False: 787]
  ------------------
  256|     81|		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  162|     81|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     81|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  257|     81|		break;
  258|    868|	}
  259|    868|}
card-flex.c:cryptoflex_get_ac_keys:
  263|    153|{
  264|    153|	return 0;
  265|    153|}
card-flex.c:flex_select_file:
  491|  1.52k|{
  492|  1.52k|	int r;
  493|  1.52k|	const u8 *pathptr = path->value;
  494|  1.52k|	size_t pathlen = path->len;
  495|  1.52k|	int locked = 0;
  496|  1.52k|	u8 p1 = 0;
  497|       |
  498|  1.52k|	switch (path->type) {
  ------------------
  |  Branch (498:10): [True: 1.52k, False: 0]
  ------------------
  499|    927|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|    927|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (499:2): [True: 927, False: 596]
  ------------------
  500|    927|		if ((pathlen & 1) != 0) /* not divisible by 2 */
  ------------------
  |  Branch (500:7): [True: 0, False: 927]
  ------------------
  501|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  502|    927|		if (pathlen == 0)
  ------------------
  |  Branch (502:7): [True: 10, False: 917]
  ------------------
  503|     10|			return 0;
  504|    917|		if (pathlen != 2 || memcmp(pathptr, "\x3F\x00", 2) != 0) {
  ------------------
  |  Branch (504:7): [True: 746, False: 171]
  |  Branch (504:23): [True: 161, False: 10]
  ------------------
  505|    907|			locked = 1;
  506|    907|			r = sc_lock(card);
  507|    907|			LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|    907|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    907|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    907|	int _ret = (r); \
  |  |  |  |  168|    907|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 907]
  |  |  |  |  ------------------
  |  |  |  |  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|    907|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 907]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  508|    907|			if (memcmp(pathptr, "\x3F\x00", 2) != 0) {
  ------------------
  |  Branch (508:8): [True: 161, False: 746]
  ------------------
  509|    161|				r = select_file_id(card, (const u8 *) "\x3F\x00", 2, 0, NULL);
  510|    161|				if (r)
  ------------------
  |  Branch (510:9): [True: 68, False: 93]
  ------------------
  511|     68|					sc_unlock(card);
  512|    161|				LOG_TEST_RET(card->ctx, r, "Unable to select Master File (MF)");
  ------------------
  |  |  174|    161|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    161|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    161|	int _ret = (r); \
  |  |  |  |  168|    161|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 68, False: 93]
  |  |  |  |  ------------------
  |  |  |  |  169|     68|		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|     68|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     68|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     68|		return _ret; \
  |  |  |  |  172|     68|	} \
  |  |  |  |  173|    161|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 93]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  513|    161|			}
  514|  1.18k|			while (pathlen > 2) {
  ------------------
  |  Branch (514:11): [True: 754, False: 432]
  ------------------
  515|    754|				r = select_file_id(card, pathptr, 2, 0, NULL);
  516|    754|				if (r)
  ------------------
  |  Branch (516:9): [True: 407, False: 347]
  ------------------
  517|    407|					sc_unlock(card);
  518|    754|				LOG_TEST_RET(card->ctx, r, "Unable to select DF");
  ------------------
  |  |  174|    754|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    754|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    754|	int _ret = (r); \
  |  |  |  |  168|    754|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 407, False: 347]
  |  |  |  |  ------------------
  |  |  |  |  169|    407|		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|    407|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    407|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    407|		return _ret; \
  |  |  |  |  172|    407|	} \
  |  |  |  |  173|    754|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 347]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  519|    347|				pathptr += 2;
  520|    347|				pathlen -= 2;
  521|    347|			}
  522|    839|		}
  523|    442|		break;
  524|    590|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|    590|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (524:2): [True: 590, False: 933]
  ------------------
  525|    590|		p1 = 0x04;
  526|    590|		break;
  527|      6|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      6|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (527:2): [True: 6, False: 1.51k]
  ------------------
  528|      6|		if (pathlen != 2)
  ------------------
  |  Branch (528:7): [True: 0, False: 6]
  ------------------
  529|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  530|      6|		break;
  531|  1.52k|	}
  532|  1.03k|	r = select_file_id(card, pathptr, pathlen, p1, file_out);
  533|  1.03k|	if (locked)
  ------------------
  |  Branch (533:6): [True: 432, False: 606]
  ------------------
  534|    432|		sc_unlock(card);
  535|  1.03k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  1.03k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  1.03k|	int _ret = r; \
  |  |  155|  1.03k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1.03k, False: 0]
  |  |  ------------------
  |  |  156|  1.03k|		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|    578|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 578, False: 460]
  |  |  ------------------
  |  |  157|  1.03k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  1.03k|	} 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|  1.03k|	return _ret; \
  |  |  163|  1.03k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  536|  1.03k|}
card-flex.c:select_file_id:
  438|  1.95k|{
  439|  1.95k|	int r;
  440|  1.95k|	sc_apdu_t apdu;
  441|  1.95k|        u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  442|  1.95k|        sc_file_t *file;
  443|       |
  444|  1.95k|	sc_log(card->ctx,  "called, p1=%u\n", p1);
  ------------------
  |  |   71|  1.95k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  445|  1.95k|	sc_log_hex(card->ctx, "path", buf, buflen);
  ------------------
  |  |  129|  1.95k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  1.95k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|       |
  447|  1.95k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, p1, 0);
  ------------------
  |  |  294|  1.95k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  448|  1.95k|	apdu.resp = rbuf;
  449|  1.95k|	apdu.resplen = sizeof(rbuf);
  450|  1.95k|	apdu.datalen = buflen;
  451|  1.95k|	apdu.data = buf;
  452|  1.95k|	apdu.lc = buflen;
  453|  1.95k|	apdu.le = 252;
  454|       |
  455|       |	/* No need to get file information, if file is NULL. */
  456|  1.95k|	if (file_out == NULL) {
  ------------------
  |  Branch (456:6): [True: 1.54k, False: 405]
  ------------------
  457|  1.54k|		apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  1.54k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  458|  1.54k|		apdu.le = 0;
  459|  1.54k|	}
  460|  1.95k|	r = sc_transmit_apdu(card, &apdu);
  461|  1.95k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.95k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.95k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.95k|	int _ret = (r); \
  |  |  |  |  168|  1.95k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 20, False: 1.93k]
  |  |  |  |  ------------------
  |  |  |  |  169|     20|		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|     20|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     20|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     20|		return _ret; \
  |  |  |  |  172|     20|	} \
  |  |  |  |  173|  1.95k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.93k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  462|  1.93k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  463|  1.93k|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|  1.93k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.93k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.93k|	int _ret = (r); \
  |  |  |  |  168|  1.93k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 900, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  169|    900|		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|    900|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    900|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    900|		return _ret; \
  |  |  |  |  172|    900|	} \
  |  |  |  |  173|  1.93k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|       |
  465|  1.03k|	if (file_out == NULL)
  ------------------
  |  Branch (465:6): [True: 675, False: 358]
  ------------------
  466|    675|		return 0;
  467|       |
  468|    358|	if (apdu.resplen < 14)
  ------------------
  |  Branch (468:6): [True: 60, False: 298]
  ------------------
  469|     60|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     60|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  470|    298|	if (apdu.resp[0] == 0x6F) {
  ------------------
  |  Branch (470:6): [True: 18, False: 280]
  ------------------
  471|     18|		sc_log(card->ctx,  "unsupported: card returned FCI\n");
  ------------------
  |  |   71|     18|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  472|     18|		return SC_ERROR_UNKNOWN_DATA_RECEIVED; /* FIXME */
  ------------------
  |  |   63|     18|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  473|     18|	}
  474|    280|	file = sc_file_new();
  475|    280|	if (file == NULL)
  ------------------
  |  Branch (475:6): [True: 0, False: 280]
  ------------------
  476|    280|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  477|       |
  478|       |	/* We abuse process_fci here even though it's not the real FCI. */
  479|    280|	r = card->ops->process_fci(card, file, apdu.resp, apdu.resplen);
  480|    280|	if (r) {
  ------------------
  |  Branch (480:6): [True: 55, False: 225]
  ------------------
  481|     55|		sc_file_free(file);
  482|     55|		return r;
  483|     55|	}
  484|       |
  485|    225|	*file_out = file;
  486|    225|	return 0;
  487|    280|}
card-flex.c:flex_card_ctl:
 1089|     76|{
 1090|     76|	switch (cmd) {
  ------------------
  |  Branch (1090:10): [True: 40, False: 36]
  ------------------
 1091|      0|	case SC_CARDCTL_GET_DEFAULT_KEY:
  ------------------
  |  Branch (1091:2): [True: 0, False: 76]
  ------------------
 1092|      0|		return flex_get_default_key(card,
 1093|      0|				(struct sc_cardctl_default_key *) ptr);
 1094|      0|	case SC_CARDCTL_CRYPTOFLEX_GENERATE_KEY:
  ------------------
  |  Branch (1094:2): [True: 0, False: 76]
  ------------------
 1095|      0|		return flex_generate_key(card,
 1096|      0|				(struct sc_cardctl_cryptoflex_genkey_info *) ptr);
 1097|     40|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1097:2): [True: 40, False: 36]
  ------------------
 1098|     40|		return flex_get_serialnr(card, (sc_serial_number_t *) ptr);
 1099|     76|	}
 1100|       |
 1101|     36|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     36|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1102|     76|}
card-flex.c:flex_get_serialnr:
 1051|     40|{
 1052|     40|	int       r;
 1053|     40|	u8        buf[16];
 1054|     40|	size_t    len;
 1055|     40|	sc_path_t tpath;
 1056|     40|	sc_file_t *tfile = NULL;
 1057|       |
 1058|     40|	if (!serial)
  ------------------
  |  Branch (1058:6): [True: 0, False: 40]
  ------------------
 1059|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1060|       |	/* see if we have cached serial number */
 1061|     40|	if (card->serialnr.len) {
  ------------------
  |  Branch (1061:6): [True: 0, False: 40]
  ------------------
 1062|      0|		memcpy(serial, &card->serialnr, sizeof(*serial));
 1063|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1064|      0|	}
 1065|       |	/* read EF_ICCSN */
 1066|     40|	sc_format_path("3F000002", &tpath);
 1067|     40|	r = sc_select_file(card, &tpath, &tfile);
 1068|     40|	if (r < 0)
  ------------------
  |  Branch (1068:6): [True: 27, False: 13]
  ------------------
 1069|     27|		return r;
 1070|     13|	len = tfile->size;
 1071|     13|	sc_file_free(tfile);
 1072|     13|	if (len != 8) {
  ------------------
  |  Branch (1072:6): [True: 11, False: 2]
  ------------------
 1073|     11|		sc_log(card->ctx,  "unexpected file length of EF_ICCSN (%lu)\n",
  ------------------
  |  |   71|     11|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1074|     11|			(unsigned long) len);
 1075|     11|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     11|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1076|     11|	}
 1077|      2|	r = sc_read_binary(card, 0, buf, len, 0);
 1078|      2|	if (r < 0)
  ------------------
  |  Branch (1078:6): [True: 1, False: 1]
  ------------------
 1079|      1|		return r;
 1080|      1|	card->serialnr.len = len;
 1081|      1|	memcpy(card->serialnr.value, buf, len);
 1082|       |
 1083|      1|	memcpy(serial, &card->serialnr, sizeof(*serial));
 1084|       |
 1085|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1086|      2|}
card-flex.c:flex_pin_cmd:
 1151|     40|{
 1152|     40|	sc_apdu_t apdu;
 1153|     40|	int r;
 1154|     40|	int old_cla = -1;
 1155|       |
 1156|       |	/* Fix pin data */
 1157|     40|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|     40|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1158|     40|	flex_init_pin_info(&data->pin1, 0);
 1159|     40|	flex_init_pin_info(&data->pin2, 1);
 1160|       |
 1161|     40|	if (data->cmd == SC_PIN_CMD_VERIFY) {
  ------------------
  |  |  415|     40|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1161:6): [True: 0, False: 40]
  ------------------
 1162|      0|		r = flex_build_verify_apdu(card, &apdu, data);
 1163|      0|		if (r < 0)
  ------------------
  |  Branch (1163:7): [True: 0, False: 0]
  ------------------
 1164|      0|			return r;
 1165|      0|		data->apdu = &apdu;
 1166|     40|	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  416|     80|#define SC_PIN_CMD_CHANGE	1
  ------------------
              	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  417|     40|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1166:13): [True: 0, False: 40]
  |  Branch (1166:47): [True: 0, False: 40]
  ------------------
 1167|      0|		if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1167:7): [True: 0, False: 0]
  ------------------
 1168|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1169|      0|		old_cla = card->cla;
 1170|      0|		if (!IS_CYBERFLEX(card))
  ------------------
  |  |   32|      0|#define IS_CYBERFLEX(card)	(card->type == SC_CARD_TYPE_FLEX_CYBER)
  ------------------
  |  Branch (1170:7): [True: 0, False: 0]
  ------------------
 1171|      0|			card->cla = 0xF0;
 1172|      0|	}
 1173|       |
 1174|       |	/* According to the Cryptoflex documentation, the card
 1175|       |	 * does not return the number of attempts left using
 1176|       |	 * the 63C0xx convention */
 1177|     40|	r = iso_ops->pin_cmd(card, data);
 1178|     40|	if (old_cla != -1)
  ------------------
  |  Branch (1178:6): [True: 0, False: 40]
  ------------------
 1179|      0|		card->cla = old_cla;
 1180|       |	data->apdu = NULL;
 1181|     40|	return r;
 1182|     40|}
card-flex.c:flex_init_pin_info:
 1142|     80|{
 1143|     80|	pin->encoding   = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|     80|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1144|     80|	pin->min_length = 4;
 1145|     80|	pin->max_length = 8;
 1146|     80|	pin->pad_length = 8;
 1147|     80|	pin->offset     = 5 + num * 8;
 1148|     80|}
card-flex.c:cyberflex_match_card:
  152|  16.6k|{
  153|  16.6k|	int i;
  154|       |
  155|  16.6k|	i = _sc_match_atr(card, flex_atrs, NULL);
  156|  16.6k|	if (i < 0)
  ------------------
  |  Branch (156:6): [True: 16.3k, False: 276]
  ------------------
  157|  16.3k|		return 0;
  158|    276|	switch (flex_atrs[i].type) {
  ------------------
  |  Branch (158:10): [True: 113, False: 163]
  ------------------
  159|    113|	case SC_CARD_TYPE_FLEX_CYBER:
  ------------------
  |  Branch (159:2): [True: 113, False: 163]
  ------------------
  160|    113|		card->name = flex_atrs[i].name;
  161|    113|		card->type = flex_atrs[i].type;
  162|    113|		card->flags = flex_atrs[i].flags;
  163|    113|		return 1;
  164|    276|	}
  165|    163|	return 0;
  166|    276|}
card-flex.c:cyberflex_process_file_attrs:
  345|     90|{
  346|     90|	sc_context_t *ctx = card->ctx;
  347|     90|	const u8 *p = buf + 2;
  348|     90|	const u8 *pos;
  349|     90|	u8 b1, b2;
  350|     90|	int is_mf = 0;
  351|       |
  352|     90|	if (buflen < 14)
  ------------------
  |  Branch (352:6): [True: 0, False: 90]
  ------------------
  353|      0|		return -1;
  354|     90|	b1 = *p++;
  355|     90|	b2 = *p++;
  356|     90|	file->size = (b1 << 8) + b2;
  357|     90|	b1 = *p++;
  358|     90|	b2 = *p++;
  359|     90|	file->id = (b1 << 8) + b2;
  360|     90|	switch (*p) {
  361|     20|	case 0x01:
  ------------------
  |  Branch (361:2): [True: 20, False: 70]
  ------------------
  362|     20|		is_mf = 1;
  363|     20|		break;
  364|     31|	case 0x02:
  ------------------
  |  Branch (364:2): [True: 31, False: 59]
  ------------------
  365|     31|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     31|#define SC_FILE_TYPE_DF			0x04
  ------------------
  366|     31|		break;
  367|     28|	case 0x04:
  ------------------
  |  Branch (367:2): [True: 28, False: 62]
  ------------------
  368|     28|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     28|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  369|     28|		break;
  370|     11|	default:
  ------------------
  |  Branch (370:2): [True: 11, False: 79]
  ------------------
  371|     11|		sc_log(ctx,  "invalid file type: 0x%02X\n", *p);
  ------------------
  |  |   71|     11|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  372|     11|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     11|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  373|     90|	}
  374|       |
  375|     79|	if (is_mf) {
  ------------------
  |  Branch (375:6): [True: 20, False: 59]
  ------------------
  376|     20|		sc_file_add_acl_entry(file, SC_AC_OP_LIST_FILES, SC_AC_AUT, 0);
  ------------------
  |  |  172|     20|#define SC_AC_OP_LIST_FILES		6
  ------------------
              		sc_file_add_acl_entry(file, SC_AC_OP_LIST_FILES, SC_AC_AUT, 0);
  ------------------
  |  |  154|     20|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  377|     20|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE, SC_AC_AUT, 0);
  ------------------
  |  |  168|     20|#define SC_AC_OP_DELETE			2
  ------------------
              		sc_file_add_acl_entry(file, SC_AC_OP_DELETE, SC_AC_AUT, 0);
  ------------------
  |  |  154|     20|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  378|     20|		sc_file_add_acl_entry(file, SC_AC_OP_CREATE, SC_AC_AUT, 0);
  ------------------
  |  |  169|     20|#define SC_AC_OP_CREATE			3
  ------------------
              		sc_file_add_acl_entry(file, SC_AC_OP_CREATE, SC_AC_AUT, 0);
  ------------------
  |  |  154|     20|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  379|     59|	} else {
  380|     59|		p += 2;
  381|     59|		if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     59|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (381:7): [True: 31, False: 28]
  ------------------
  382|     31|			add_acl_entry(card, file, SC_AC_OP_LIST_FILES, (u8)(p[0] >> 4));
  ------------------
  |  |  172|     31|#define SC_AC_OP_LIST_FILES		6
  ------------------
  383|     31|			add_acl_entry(card, file, SC_AC_OP_DELETE, (u8)(p[1] >> 4));
  ------------------
  |  |  168|     31|#define SC_AC_OP_DELETE			2
  ------------------
  384|     31|			add_acl_entry(card, file, SC_AC_OP_CREATE, (u8)(p[1] & 0x0F));
  ------------------
  |  |  169|     31|#define SC_AC_OP_CREATE			3
  ------------------
  385|     31|		} else { /* EF */
  386|     28|			add_acl_entry(card, file, SC_AC_OP_READ, (u8)(p[0] >> 4));
  ------------------
  |  |  188|     28|#define SC_AC_OP_READ			22
  ------------------
  387|     28|		}
  388|     59|	}
  389|     79|	if (file->type != SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     79|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (389:6): [True: 48, False: 31]
  ------------------
  390|     48|		add_acl_entry(card, file, SC_AC_OP_REHABILITATE, (u8)(p[2] >> 4));
  ------------------
  |  |  170|     48|#define SC_AC_OP_REHABILITATE		4
  ------------------
  391|     48|		add_acl_entry(card, file, SC_AC_OP_INVALIDATE, (u8)(p[2] & 0x0F));
  ------------------
  |  |  171|     48|#define SC_AC_OP_INVALIDATE		5
  ------------------
  392|     48|	}
  393|     79|	pos = p;
  394|     79|	p += 3;
  395|     79|	if (*p++)
  ------------------
  |  Branch (395:6): [True: 53, False: 26]
  ------------------
  396|     53|		file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|     53|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  397|     26|	else
  398|     26|		file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|     26|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  399|     79|	p++;
  400|     79|	if (0 == is_mf) {
  ------------------
  |  Branch (400:6): [True: 59, False: 20]
  ------------------
  401|     59|		p++;
  402|     59|		switch (*p) {
  403|     34|		case  0x00:
  ------------------
  |  Branch (403:3): [True: 34, False: 25]
  ------------------
  404|     34|			file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     34|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  405|     34|			break;
  406|      6|		case  0x01:
  ------------------
  |  Branch (406:3): [True: 6, False: 53]
  ------------------
  407|      6|			file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|      6|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  408|      6|			break;
  409|      6|		case  0x02:
  ------------------
  |  Branch (409:3): [True: 6, False: 53]
  ------------------
  410|      6|			file->ef_structure = SC_FILE_EF_LINEAR_VARIABLE;
  ------------------
  |  |  224|      6|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  411|      6|			break;
  412|      3|		case  0x03:
  ------------------
  |  Branch (412:3): [True: 3, False: 56]
  ------------------
  413|      3|			file->ef_structure = SC_FILE_EF_CYCLIC;
  ------------------
  |  |  226|      3|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  414|      3|			break;
  415|      3|		case  0x04:
  ------------------
  |  Branch (415:3): [True: 3, False: 56]
  ------------------
  416|      3|			break;
  417|      7|		default:
  ------------------
  |  Branch (417:3): [True: 7, False: 52]
  ------------------
  418|      7|			sc_log(ctx,  "invalid file type: 0x%02X\n", *p);
  ------------------
  |  |   71|      7|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  419|      7|			return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|      7|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  420|     59|		}
  421|     52|		switch (file->ef_structure) {
  ------------------
  |  Branch (421:11): [True: 49, False: 3]
  ------------------
  422|     34|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|     34|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (422:3): [True: 34, False: 18]
  ------------------
  423|     34|			add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(pos[0] & 0x0F));
  ------------------
  |  |  189|     34|#define SC_AC_OP_UPDATE			23
  ------------------
  424|     34|			break;
  425|      6|		case SC_FILE_EF_LINEAR_FIXED:
  ------------------
  |  |  222|      6|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (425:3): [True: 6, False: 46]
  ------------------
  426|     12|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|     12|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (426:3): [True: 6, False: 46]
  ------------------
  427|     12|			add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(pos[0] & 0x0F));
  ------------------
  |  |  189|     12|#define SC_AC_OP_UPDATE			23
  ------------------
  428|     12|			break;
  429|      3|		case SC_FILE_EF_CYCLIC:
  ------------------
  |  |  226|      3|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (429:3): [True: 3, False: 49]
  ------------------
  430|      3|			break;
  431|     52|		}
  432|     52|	}
  433|     72|	return 0;
  434|     79|}

sc_get_gemsafeV1_driver:
  591|  17.0k|{
  592|  17.0k|	return sc_get_driver();
  593|  17.0k|}
card-gemsafeV1.c:sc_get_driver:
  566|  17.0k|{
  567|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  568|  17.0k|	if (!iso_ops)
  ------------------
  |  Branch (568:6): [True: 1, False: 17.0k]
  ------------------
  569|      1|		iso_ops = iso_drv->ops;
  570|       |	/* use the standard iso operations as default */
  571|  17.0k|	gemsafe_ops = *iso_drv->ops;
  572|       |	/* gemsafe specific functions */
  573|  17.0k|	gemsafe_ops.match_card	= gemsafe_match_card;
  574|  17.0k|	gemsafe_ops.init	= gemsafe_init;
  575|  17.0k|	gemsafe_ops.finish	= gemsafe_finish;
  576|  17.0k|	gemsafe_ops.select_file	= gemsafe_select_file;
  577|  17.0k|	gemsafe_ops.restore_security_env = gemsafe_restore_security_env;
  578|  17.0k|	gemsafe_ops.set_security_env     = gemsafe_set_security_env;
  579|  17.0k|	gemsafe_ops.decipher             = gemsafe_decipher;
  580|  17.0k|	gemsafe_ops.compute_signature    = gemsafe_compute_signature;
  581|  17.0k|	gemsafe_ops.get_challenge 		 = gemsafe_get_challenge;
  582|  17.0k|	gemsafe_ops.process_fci	= gemsafe_process_fci;
  583|  17.0k|	gemsafe_ops.pin_cmd		 = iso_ops->pin_cmd;
  584|  17.0k|	gemsafe_ops.card_reader_lock_obtained = gemsafe_card_reader_lock_obtained;
  585|  17.0k|	gemsafe_ops.logout = gemsafe_logout;
  586|       |
  587|  17.0k|	return &gemsafe_drv;
  588|  17.0k|}
card-gemsafeV1.c:gemsafe_match_card:
  124|  15.6k|{
  125|  15.6k|	int i;
  126|       |
  127|  15.6k|	i = _sc_match_atr(card, gemsafe_atrs, &card->type);
  128|  15.6k|	if (i < 0)
  ------------------
  |  Branch (128:6): [True: 15.0k, False: 578]
  ------------------
  129|  15.0k|		return 0;
  130|       |
  131|    578|	return 1;
  132|  15.6k|}
card-gemsafeV1.c:gemsafe_init:
  135|    578|{
  136|    578|	int	r;
  137|    578|	gemsafe_exdata *exdata = NULL;
  138|       |
  139|    578|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    578|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    578|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    578|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 578]
  |  |  ------------------
  ------------------
  140|       |
  141|    578|	card->name = "GemSAFE V1";
  142|    578|	card->cla  = 0x00;
  143|       |
  144|    578|	exdata = (gemsafe_exdata *)calloc(1, sizeof(gemsafe_exdata));
  145|    578|	if (!exdata)
  ------------------
  |  Branch (145:6): [True: 0, False: 578]
  ------------------
  146|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  147|    578|	exdata->aid_len = sizeof(exdata->aid);
  148|    578|	if(card->type == SC_CARD_TYPE_GEMSAFEV1_GENERIC) {
  ------------------
  |  Branch (148:5): [True: 76, False: 502]
  ------------------
  149|       |		/* try to get a AID from the config file */
  150|     76|		r = get_conf_aid(card, exdata->aid, &exdata->aid_len);
  151|     76|		if (r < 0) {
  ------------------
  |  Branch (151:7): [True: 76, False: 0]
  ------------------
  152|       |			/* failed, use default value */
  153|     76|			memcpy(exdata->aid, gemsafe_def_aid, sizeof(gemsafe_def_aid));
  154|     76|			exdata->aid_len = sizeof(gemsafe_def_aid);
  155|     76|		}
  156|    502|	} else if (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID) {
  ------------------
  |  Branch (156:13): [True: 500, False: 2]
  ------------------
  157|    500|		memcpy(exdata->aid, gemsafe_pteid_aid, sizeof(gemsafe_pteid_aid));
  158|    500|		exdata->aid_len = sizeof(gemsafe_pteid_aid);
  159|    500|	} else if (card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID) {
  ------------------
  |  Branch (159:13): [True: 2, False: 0]
  ------------------
  160|      2|		memcpy(exdata->aid, gemsafe_seeid_aid, sizeof(gemsafe_seeid_aid));
  161|      2|		exdata->aid_len = sizeof(gemsafe_seeid_aid);
  162|      2|	}
  163|       |
  164|       |	/* increase lock_count here to prevent sc_unlock to select
  165|       |	 * applet twice in gp_select_applet */
  166|    578|	card->lock_count++;
  167|       |	/* SELECT applet */
  168|    578|	r = iso7816_select_aid(card, exdata->aid, exdata->aid_len, NULL, NULL);
  169|    578|	if (r < 0) {
  ------------------
  |  Branch (169:6): [True: 8, False: 570]
  ------------------
  170|      8|		free(exdata);
  171|      8|		sc_log(card->ctx,  "applet selection failed\n");
  ------------------
  |  |   71|      8|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  172|      8|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      8|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  173|      8|	}
  174|    570|	card->lock_count--;
  175|       |
  176|       |	/* set the supported algorithm */
  177|    570|	unsigned long flags;
  178|       |
  179|    570|	flags  = SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|    570|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    570|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    570|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  180|    570|	flags |= SC_ALGORITHM_RSA_PAD_ISO9796;
  ------------------
  |  |  106|    570|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  181|    570|	flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    570|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  182|    570|	flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    570|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  183|       |
  184|       |	/* GemSAFE V3 cards support SHA256 */
  185|    570|	if (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID ||
  ------------------
  |  Branch (185:6): [True: 496, False: 74]
  ------------------
  186|     74|	    card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID)
  ------------------
  |  Branch (186:6): [True: 1, False: 73]
  ------------------
  187|    497|		flags |= SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  138|    497|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  188|       |
  189|    570|	_sc_card_add_rsa_alg(card,  512, flags, 0);
  190|    570|	_sc_card_add_rsa_alg(card,  768, flags, 0);
  191|    570|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  192|    570|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  193|    570|	_sc_card_add_rsa_alg(card, 3072, flags, 0);
  194|    570|	_sc_card_add_rsa_alg(card, 4096, flags, 0);
  195|       |
  196|       |	/* fake algorithm to persuade register_mechanisms()
  197|       |	 * to register these hashes */
  198|    570|	if (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID ||
  ------------------
  |  Branch (198:6): [True: 496, False: 74]
  ------------------
  199|    497|	    card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID) {
  ------------------
  |  Branch (199:6): [True: 1, False: 73]
  ------------------
  200|    497|		flags  = SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|    497|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  201|    497|		flags |= SC_ALGORITHM_RSA_HASH_MD5;
  ------------------
  |  |  135|    497|#define SC_ALGORITHM_RSA_HASH_MD5	0x00000400
  ------------------
  202|    497|		flags |= SC_ALGORITHM_RSA_HASH_MD5_SHA1;
  ------------------
  |  |  136|    497|#define SC_ALGORITHM_RSA_HASH_MD5_SHA1	0x00000800
  ------------------
  203|    497|		flags |= SC_ALGORITHM_RSA_HASH_RIPEMD160;
  ------------------
  |  |  137|    497|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
  204|       |
  205|    497|		_sc_card_add_rsa_alg(card,  512, flags, 0);
  206|    497|	}
  207|       |
  208|    570|	card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    570|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  209|    570|	card->drv_data = exdata;
  210|       |
  211|    570|	return SC_SUCCESS;
  ------------------
  |  |   28|    570|#define SC_SUCCESS				0
  ------------------
  212|    578|}
card-gemsafeV1.c:get_conf_aid:
   93|     76|{
   94|     76|	sc_context_t		*ctx = card->ctx;
   95|     76|	scconf_block		*conf_block, **blocks;
   96|     76|	int			i;
   97|     76|	const char		*str_aid;
   98|       |
   99|     76|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     76|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     76|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     76|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 76]
  |  |  ------------------
  ------------------
  100|       |
  101|     76|	conf_block = NULL;
  102|    152|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (102:14): [True: 76, False: 76]
  ------------------
  103|     76|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i],
  104|     76|						"card", "gemsafeV1");
  105|     76|		if (blocks != NULL && blocks[0] != NULL)
  ------------------
  |  Branch (105:7): [True: 76, False: 0]
  |  Branch (105:25): [True: 0, False: 76]
  ------------------
  106|      0|			conf_block = blocks[0];
  107|     76|		free(blocks);
  108|     76|	}
  109|       |
  110|     76|	if (!conf_block) {
  ------------------
  |  Branch (110:6): [True: 76, False: 0]
  ------------------
  111|     76|		sc_log(ctx,  "no card specific options configured, trying default AID\n");
  ------------------
  |  |   71|     76|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  112|     76|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     76|#define SC_ERROR_INTERNAL			-1400
  ------------------
  113|     76|	}
  114|       |
  115|      0|	str_aid = scconf_get_str(conf_block, "aid", NULL);
  116|      0|	if (!str_aid) {
  ------------------
  |  Branch (116:6): [True: 0, False: 0]
  ------------------
  117|      0|		sc_log(ctx,  "no aid configured, trying default AID\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  118|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  119|      0|	}
  120|      0|	return sc_hex_to_bin(str_aid, aid, len);
  121|      0|}
card-gemsafeV1.c:gemsafe_finish:
  215|    570|{
  216|    570|	gemsafe_exdata *exdata = (gemsafe_exdata *)card->drv_data;
  217|       |
  218|    570|	if (exdata)
  ------------------
  |  Branch (218:6): [True: 570, False: 0]
  ------------------
  219|    570|		free(exdata);
  220|    570|	return SC_SUCCESS;
  ------------------
  |  |   28|    570|#define SC_SUCCESS				0
  ------------------
  221|    570|}
card-gemsafeV1.c:gemsafe_select_file:
  225|  4.81k|{
  226|       |	/* so far just call the iso select file (but this will change) */
  227|  4.81k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  4.81k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  4.81k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  4.81k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 4.81k]
  |  |  ------------------
  ------------------
  228|       |
  229|  4.81k|	return iso_ops->select_file(card, path, file_out);
  230|  4.81k|}
card-gemsafeV1.c:gemsafe_set_security_env:
  406|     60|{
  407|     60|	u8 alg_ref;
  408|     60|	struct sc_security_env se_env = *env;
  409|     60|	struct sc_context *ctx = card->ctx;
  410|       |
  411|     60|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     60|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     60|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     60|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 60]
  |  |  ------------------
  ------------------
  412|       |
  413|     60|	if (!(se_env.flags & SC_SEC_ENV_ALG_REF_PRESENT)) {
  ------------------
  |  |   56|     60|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
  |  Branch (413:6): [True: 60, False: 0]
  ------------------
  414|       |		/* set the algorithm reference */
  415|     60|		alg_ref = gemsafe_flags2algref(card, &se_env);
  416|     60|		if (alg_ref) {
  ------------------
  |  Branch (416:7): [True: 60, False: 0]
  ------------------
  417|     60|			se_env.algorithm_ref = alg_ref;
  418|     60|			se_env.flags |= SC_SEC_ENV_ALG_REF_PRESENT;
  ------------------
  |  |   56|     60|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
  419|     60|		}
  420|     60|	}
  421|     60|	if (!(se_env.flags & SC_SEC_ENV_ALG_REF_PRESENT))
  ------------------
  |  |   56|     60|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
  |  Branch (421:6): [True: 0, False: 60]
  ------------------
  422|      0|		sc_log(ctx, "unknown algorithm flags '%lx'\n", se_env.algorithm_flags);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  423|       |
  424|     60|	se_env.flags &= ~SC_SEC_ENV_FILE_REF_PRESENT;
  ------------------
  |  |   57|     60|#define SC_SEC_ENV_FILE_REF_PRESENT	0x0002
  ------------------
  425|     60|	return iso_ops->set_security_env(card, &se_env, se_num);
  426|     60|}
card-gemsafeV1.c:gemsafe_flags2algref:
  363|     60|{
  364|     60|	u8 ret = 0;
  365|       |
  366|     60|	if (env->operation == SC_SEC_OPERATION_SIGN) {
  ------------------
  |  |   48|     60|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (366:6): [True: 38, False: 22]
  ------------------
  367|     38|		if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA256)
  ------------------
  |  |  138|     38|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  |  Branch (367:7): [True: 3, False: 35]
  ------------------
  368|      3|			ret = GEMSAFEV3_ALG_REF_SHA256;
  ------------------
  |  |   34|      3|#define GEMSAFEV3_ALG_REF_SHA256	0x42
  ------------------
  369|     35|		else if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01)
  ------------------
  |  |  109|     35|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (369:12): [True: 35, False: 0]
  ------------------
  370|     35|			ret = (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID ||
  ------------------
  |  Branch (370:11): [True: 6, False: 29]
  ------------------
  371|     29|			       card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID) ?
  ------------------
  |  Branch (371:11): [True: 0, False: 29]
  ------------------
  372|      6|			      GEMSAFEV3_ALG_REF_FREEFORM :
  ------------------
  |  |   32|      6|#define GEMSAFEV3_ALG_REF_FREEFORM	0x02
  ------------------
  373|     35|			      GEMSAFEV1_ALG_REF_FREEFORM;
  ------------------
  |  |   31|     29|#define GEMSAFEV1_ALG_REF_FREEFORM	0x12
  ------------------
  374|      0|		else if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_ISO9796)
  ------------------
  |  |  106|      0|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  |  Branch (374:12): [True: 0, False: 0]
  ------------------
  375|      0|			ret = 0x11;
  376|     38|	} else if (env->operation == SC_SEC_OPERATION_DECIPHER) {
  ------------------
  |  |   47|     22|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
  |  Branch (376:13): [True: 22, False: 0]
  ------------------
  377|     22|		if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02)
  ------------------
  |  |  110|     22|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  |  Branch (377:7): [True: 22, False: 0]
  ------------------
  378|     22|			ret = (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID ||
  ------------------
  |  Branch (378:11): [True: 1, False: 21]
  ------------------
  379|     21|			       card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID) ?
  ------------------
  |  Branch (379:11): [True: 0, False: 21]
  ------------------
  380|      1|			      GEMSAFEV3_ALG_REF_FREEFORM :
  ------------------
  |  |   32|      1|#define GEMSAFEV3_ALG_REF_FREEFORM	0x02
  ------------------
  381|     22|			      GEMSAFEV1_ALG_REF_FREEFORM;
  ------------------
  |  |   31|     21|#define GEMSAFEV1_ALG_REF_FREEFORM	0x12
  ------------------
  382|     22|	}
  383|       |
  384|     60|	return ret;
  385|     60|}
card-gemsafeV1.c:gemsafe_decipher:
  495|     17|{
  496|     17|	int r;
  497|     17|	struct sc_apdu apdu;
  498|     17|	u8 rbuf[MAX_RESP_BUFFER_SIZE];
  499|     17|	sc_context_t *ctx = card->ctx;
  500|       |
  501|     17|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     17|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     17|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     17|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 17]
  |  |  ------------------
  ------------------
  502|     17|	if (crgram_len > 255)
  ------------------
  |  Branch (502:6): [True: 1, False: 16]
  ------------------
  503|      1|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      1|	int _ret = r; \
  |  |  155|      1|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  163|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  504|       |
  505|     16|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x80, 0x84);
  ------------------
  |  |  294|     16|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  506|     16|	apdu.cla |= 0x80;
  507|     16|	apdu.resp = rbuf;
  508|     16|	apdu.resplen = sizeof(rbuf);
  509|     16|	apdu.le      = crgram_len;
  510|       |
  511|     16|	apdu.data = crgram;
  512|     16|	apdu.lc   = crgram_len;
  513|     16|	apdu.datalen = crgram_len;
  514|     16|	r = sc_transmit_apdu(card, &apdu);
  515|     16|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     16|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     16|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     16|	int _ret = (r); \
  |  |  |  |  168|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  516|     14|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (516:6): [True: 10, False: 4]
  |  Branch (516:26): [True: 9, False: 1]
  ------------------
  517|      9|		size_t len = apdu.resplen > outlen ? outlen : apdu.resplen;
  ------------------
  |  Branch (517:16): [True: 2, False: 7]
  ------------------
  518|       |
  519|      9|		memcpy(out, apdu.resp, len);
  520|      9|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)len);
  ------------------
  |  |  153|      9|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      9|	int _ret = r; \
  |  |  155|      9|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 8]
  |  |  ------------------
  |  |  156|      1|		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: 1]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      8|	} else { \
  |  |  159|      8|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      8|			"returning with: %d\n", _ret); \
  |  |  161|      8|	} \
  |  |  162|      9|	return _ret; \
  |  |  163|      9|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  521|      9|	}
  522|      5|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|      5|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      5|	int _ret = r; \
  |  |  155|      5|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 5, False: 0]
  |  |  ------------------
  |  |  156|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 5, False: 0]
  |  |  ------------------
  |  |  157|      5|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      5|	} 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|      5|	return _ret; \
  |  |  163|      5|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  523|      5|}
card-gemsafeV1.c:gemsafe_compute_signature:
  430|     24|{
  431|     24|	int r;
  432|     24|	size_t len;
  433|     24|	struct sc_apdu apdu;
  434|     24|	u8 rbuf[MAX_RESP_BUFFER_SIZE];
  435|     24|	u8 sbuf[MAX_RESP_BUFFER_SIZE];
  436|     24|	sc_context_t *ctx = card->ctx;
  437|       |
  438|     24|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     24|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     24|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     24|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 24]
  |  |  ------------------
  ------------------
  439|       |
  440|       |	/* the card can sign 36 bytes of free form data */
  441|     24|	if (data_len > 36) {
  ------------------
  |  Branch (441:6): [True: 1, False: 23]
  ------------------
  442|      1|		sc_log(ctx, "error: input data too long: %zu bytes", data_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  443|      1|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  444|      1|	}
  445|       |
  446|       |	/* the Portuguese eID card requires a two-phase exchange */
  447|       |	/* and so does the Swedish one */
  448|     23|	if(card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID ||
  ------------------
  |  Branch (448:5): [True: 7, False: 16]
  ------------------
  449|     16|	   card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID) {
  ------------------
  |  Branch (449:5): [True: 0, False: 16]
  ------------------
  450|      7|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x2A, 0x90, 0xA0);
  ------------------
  |  |  293|      7|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  451|     16|	} else {
  452|     16|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x9E, 0xAC);
  ------------------
  |  |  294|     16|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  453|     16|		apdu.cla |= 0x80;
  454|     16|		apdu.resp = rbuf;
  455|     16|		apdu.resplen = sizeof(rbuf);
  456|     16|		apdu.le      = 256;
  457|     16|	}
  458|       |	/* we sign a digestInfo object => tag 0x90 */
  459|     23|	sbuf[0] = 0x90;
  460|     23|	sbuf[1] = (u8)data_len;
  461|     23|	memcpy(sbuf + 2, data, data_len);
  462|     23|	apdu.data = sbuf;
  463|     23|	apdu.lc   = data_len + 2;
  464|     23|	apdu.datalen = data_len + 2;
  465|       |
  466|     23|	r = sc_transmit_apdu(card, &apdu);
  467|     23|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     23|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     23|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     23|	int _ret = (r); \
  |  |  |  |  168|     23|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  468|     22|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (468:6): [True: 11, False: 11]
  |  Branch (468:26): [True: 10, False: 1]
  ------------------
  469|     10|		if(card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID ||
  ------------------
  |  Branch (469:6): [True: 3, False: 7]
  ------------------
  470|      7|		   card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID) {
  ------------------
  |  Branch (470:6): [True: 0, False: 7]
  ------------------
  471|       |			/* finalize the exchange */
  472|      3|			sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x2A, 0x9E, 0x9A);
  ------------------
  |  |  292|      3|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  473|      3|			apdu.le = 128; /* 1024 bit keys */
  474|      3|			apdu.resp = rbuf;
  475|      3|			apdu.resplen = sizeof(rbuf);
  476|      3|			if(card->type == SC_CARD_TYPE_GEMSAFEV1_SEEID) {
  ------------------
  |  Branch (476:7): [True: 0, False: 3]
  ------------------
  477|       |			  /* cla 0x80 not supported */
  478|      0|			  apdu.cla = 0x00;
  479|      0|			}
  480|      3|			r = sc_transmit_apdu(card, &apdu);
  481|      3|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  482|      2|			if(apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (482:7): [True: 1, False: 1]
  |  Branch (482:27): [True: 1, False: 0]
  ------------------
  483|      2|				SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      2|	int _ret = r; \
  |  |  155|      2|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  ------------------
  |  |  156|      2|		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|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 2, False: 0]
  |  |  ------------------
  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  163|      2|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  484|      2|		}
  485|      7|		len = apdu.resplen > outlen ? outlen : apdu.resplen;
  ------------------
  |  Branch (485:9): [True: 1, False: 6]
  ------------------
  486|       |
  487|      7|		memcpy(out, apdu.resp, len);
  488|      7|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)len);
  ------------------
  |  |  153|      7|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      7|	int _ret = r; \
  |  |  155|      7|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 6]
  |  |  ------------------
  |  |  156|      1|		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: 1]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      6|	} else { \
  |  |  159|      6|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      6|			"returning with: %d\n", _ret); \
  |  |  161|      6|	} \
  |  |  162|      7|	return _ret; \
  |  |  163|      7|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  489|      7|	}
  490|     12|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|     12|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     12|	int _ret = r; \
  |  |  155|     12|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 12, False: 0]
  |  |  ------------------
  |  |  156|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 12, False: 0]
  |  |  ------------------
  |  |  157|     12|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     12|	} 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|     12|	return _ret; \
  |  |  163|     12|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  491|     12|}
card-gemsafeV1.c:gemsafe_get_challenge:
  526|    653|{
  527|    653|	int prev_cla, r;
  528|       |
  529|    653|	prev_cla = card->cla;
  530|    653|	if(card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID) {
  ------------------
  |  Branch (530:5): [True: 330, False: 323]
  ------------------
  531|       |		/* Warning: this depends on iso7816_get_challenge not
  532|       |		 * changing the value of the card's CLA
  533|       |		 */
  534|    330|		card->cla = 0x80;
  535|    330|	}
  536|    653|	r = iso_ops->get_challenge(card, rnd, len);
  537|       |	/* Restore the CLA value if needed */
  538|    653|	if(card->cla != prev_cla)
  ------------------
  |  Branch (538:5): [True: 330, False: 323]
  ------------------
  539|    330|		card->cla = prev_cla;
  540|       |
  541|    653|	return r;
  542|    653|}
card-gemsafeV1.c:gemsafe_process_fci:
  321|    701|{
  322|    701|	int        r;
  323|    701|	size_t     tlen;
  324|    701|	const u8   *tag = NULL, *p = buf;
  325|    701|	const char *type;
  326|    701|	struct sc_context *ctx = card->ctx;
  327|       |
  328|    701|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    701|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    701|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    701|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 701]
  |  |  ------------------
  ------------------
  329|       |
  330|    701|	r = iso_ops->process_fci(card, file, buf, len);
  331|    701|	if (r < 0)
  ------------------
  |  Branch (331:6): [True: 0, False: 701]
  ------------------
  332|      0|		return r;
  333|    701|	sc_log(ctx,
  ------------------
  |  |   71|    701|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  334|    701|		"processing GemSAFE V1 specific FCI information\n");
  335|       |
  336|       |
  337|    701|	tag = sc_asn1_find_tag(ctx, p, len, 0x82, &tlen);
  338|    701|	if (!tag) {
  ------------------
  |  Branch (338:6): [True: 411, False: 290]
  ------------------
  339|       |		/* no FDB => we have a DF */
  340|    411|		type = "DF";
  341|    411|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    411|#define SC_FILE_TYPE_DF			0x04
  ------------------
  342|    411|	} else {
  343|    290|		type = "EF";
  344|    290|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    290|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  345|    290|	}
  346|       |
  347|    701|	sc_log(ctx,  "file type: %s\n", type);
  ------------------
  |  |   71|    701|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  348|       |
  349|    701|	tag = sc_asn1_find_tag(ctx, p, len, 0x8C, &tlen);
  350|    701|	if (tag && tlen > 1) {
  ------------------
  |  Branch (350:6): [True: 97, False: 604]
  |  Branch (350:13): [True: 81, False: 16]
  ------------------
  351|     81|		r = gemsafe_setacl(card, file, tag, strcmp(type, "DF") ? 0 : 1);
  ------------------
  |  Branch (351:39): [True: 52, False: 29]
  ------------------
  352|     81|		if (r < 0) {
  ------------------
  |  Branch (352:7): [True: 0, False: 81]
  ------------------
  353|      0|			sc_log(ctx,  "unable to set ACL\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  354|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  355|      0|		}
  356|     81|	} else
  357|    620|		sc_log(ctx,  "error: AM and SC bytes missing\n");
  ------------------
  |  |   71|    620|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  358|       |
  359|    701|	return SC_SUCCESS;
  ------------------
  |  |   28|    701|#define SC_SUCCESS				0
  ------------------
  360|    701|}
card-gemsafeV1.c:gemsafe_setacl:
  260|     81|{
  261|     81|	int       r;
  262|     81|	u8        cond;
  263|     81|	const u8 *p = data + 1;
  264|     81|	struct sc_context *ctx = card->ctx;
  265|       |
  266|     81|	if (is_df) {
  ------------------
  |  Branch (266:6): [True: 29, False: 52]
  ------------------
  267|     29|		if (*data & 0x04)	/* CREATE DF */
  ------------------
  |  Branch (267:7): [True: 18, False: 11]
  ------------------
  268|     18|			cond = *p++;
  269|     11|		else
  270|     11|			cond = 0xff;
  271|     29|		sc_log(ctx,
  ------------------
  |  |   71|     29|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  272|     29|			"DF security byte CREATE DF: %02x\n", cond);
  273|     29|		r = gemsafe_sc2acl(file, SC_AC_OP_CREATE, cond);
  ------------------
  |  |  169|     29|#define SC_AC_OP_CREATE			3
  ------------------
  274|     29|		if (r < 0)
  ------------------
  |  Branch (274:7): [True: 0, False: 29]
  ------------------
  275|      0|			return r;
  276|     29|		if (*data & 0x02)	/* CREATE EF */
  ------------------
  |  Branch (276:7): [True: 18, False: 11]
  ------------------
  277|     18|			cond = *p;
  278|     11|		else
  279|     11|			cond = 0xff;
  280|     29|		sc_log(ctx,
  ------------------
  |  |   71|     29|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  281|     29|			"DF security byte CREATE EF: %02x\n", cond);
  282|       |		/* XXX: opensc doesn't currently separate access conditions for
  283|       |		 * CREATE EF and CREATE DF, this should be changed */
  284|     29|		r = gemsafe_sc2acl(file, SC_AC_OP_CREATE, cond);
  ------------------
  |  |  169|     29|#define SC_AC_OP_CREATE			3
  ------------------
  285|     29|		if (r < 0)
  ------------------
  |  Branch (285:7): [True: 0, False: 29]
  ------------------
  286|      0|			return r;
  287|     52|	} else {
  288|       |		/* XXX: ACTIVATE FILE and DEACTIVATE FILE ac are currently not
  289|       |		 * supported => ignore them */
  290|     52|		if (*data & 0x02)	/* UPDATE BINARY, ERASE BINARY */
  ------------------
  |  Branch (290:7): [True: 32, False: 20]
  ------------------
  291|     32|			cond = *p++;
  292|     20|		else
  293|     20|			cond = 0xff;
  294|     52|		sc_log(ctx,
  ------------------
  |  |   71|     52|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  295|     52|			"EF security byte UPDATE/ERASE BINARY: %02x\n", cond);
  296|     52|		r = gemsafe_sc2acl(file, SC_AC_OP_UPDATE, cond);
  ------------------
  |  |  189|     52|#define SC_AC_OP_UPDATE			23
  ------------------
  297|     52|		if (r < 0)
  ------------------
  |  Branch (297:7): [True: 0, False: 52]
  ------------------
  298|      0|			return r;
  299|     52|		r = gemsafe_sc2acl(file, SC_AC_OP_WRITE, cond);
  ------------------
  |  |  190|     52|#define SC_AC_OP_WRITE			24
  ------------------
  300|     52|		if (r < 0)
  ------------------
  |  Branch (300:7): [True: 0, False: 52]
  ------------------
  301|      0|			return r;
  302|     52|		r = gemsafe_sc2acl(file, SC_AC_OP_ERASE, cond);
  ------------------
  |  |  202|     52|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     52|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  303|     52|		if (r < 0)
  ------------------
  |  Branch (303:7): [True: 0, False: 52]
  ------------------
  304|      0|			return r;
  305|     52|		if (*data & 0x01)	/* READ BINARY */
  ------------------
  |  Branch (305:7): [True: 34, False: 18]
  ------------------
  306|     34|			cond = *p;
  307|     18|		else
  308|     18|			cond = 0xff;
  309|     52|		sc_log(ctx,
  ------------------
  |  |   71|     52|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  310|     52|			"EF security byte READ BINARY: %02x\n", cond);
  311|     52|		r = gemsafe_sc2acl(file, SC_AC_OP_READ, cond);
  ------------------
  |  |  188|     52|#define SC_AC_OP_READ			22
  ------------------
  312|     52|		if (r < 0)
  ------------------
  |  Branch (312:7): [True: 0, False: 52]
  ------------------
  313|      0|			return r;
  314|     52|	}
  315|       |
  316|     81|	return SC_SUCCESS;
  ------------------
  |  |   28|     81|#define SC_SUCCESS				0
  ------------------
  317|     81|}
card-gemsafeV1.c:gemsafe_sc2acl:
  233|    266|{
  234|    266|	int r;
  235|    266|	unsigned int meth = 0;
  236|       |
  237|    266|	if (sc_byte == 0xff) {
  ------------------
  |  Branch (237:6): [True: 100, False: 166]
  ------------------
  238|    100|		r = sc_file_add_acl_entry(file, ops, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    100|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  239|    100|		return r;
  240|    100|	}
  241|    166|	if (sc_byte == 0x00) {
  ------------------
  |  Branch (241:6): [True: 23, False: 143]
  ------------------
  242|     23|		r = sc_file_add_acl_entry(file, ops, SC_AC_NONE, 0);
  ------------------
  |  |  150|     23|#define SC_AC_NONE			0x00000000
  ------------------
  243|     23|		return r;
  244|     23|	}
  245|       |
  246|       |	/* XXX: OR combination of access rights are currently not supported
  247|       |	 * hence ignored */
  248|    143|	if (sc_byte & 0x40)
  ------------------
  |  Branch (248:6): [True: 65, False: 78]
  ------------------
  249|     65|		meth |= SC_AC_PRO;
  ------------------
  |  |  153|     65|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  250|    143|	if (sc_byte & 0x20)
  ------------------
  |  Branch (250:6): [True: 54, False: 89]
  ------------------
  251|     54|		meth |= SC_AC_AUT | SC_AC_TERM;
  ------------------
  |  |  154|     54|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
              		meth |= SC_AC_AUT | SC_AC_TERM;
  ------------------
  |  |  152|     54|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  252|    143|	if (sc_byte & 0x10)
  ------------------
  |  Branch (252:6): [True: 58, False: 85]
  ------------------
  253|     58|		meth |= SC_AC_CHV;
  ------------------
  |  |  151|     58|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  254|       |
  255|    143|	return sc_file_add_acl_entry(file, ops, meth, sc_byte & 0x0f);
  256|    166|}
card-gemsafeV1.c:gemsafe_card_reader_lock_obtained:
  545|  2.46k|{
  546|  2.46k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  2.46k|#define SC_SUCCESS				0
  ------------------
  547|  2.46k|	gemsafe_exdata *exdata = (gemsafe_exdata *)card->drv_data;
  548|       |
  549|  2.46k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  2.46k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.46k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.46k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.46k]
  |  |  ------------------
  ------------------
  550|       |
  551|  2.46k|	if (was_reset > 0 && exdata) {
  ------------------
  |  Branch (551:6): [True: 0, False: 2.46k]
  |  Branch (551:23): [True: 0, False: 0]
  ------------------
  552|      0|		r = iso7816_select_aid(card, exdata->aid, exdata->aid_len, NULL, NULL);
  553|      0|	}
  554|       |
  555|  2.46k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  2.46k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.46k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.46k|	int _ret = r; \
  |  |  |  |  155|  2.46k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.46k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.46k|		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: 2.46k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.46k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.46k|	} 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|  2.46k|	return _ret; \
  |  |  |  |  163|  2.46k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|  2.46k|}

sc_get_gids_driver:
 2185|  17.0k|{
 2186|  17.0k|	return sc_get_driver();
 2187|  17.0k|}
card-gids.c:sc_get_driver:
 2140|  17.0k|{
 2141|       |
 2142|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2142:6): [True: 1, False: 17.0k]
  ------------------
 2143|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 2144|       |
 2145|  17.0k|	gids_ops.match_card = gids_match_card;
 2146|  17.0k|	gids_ops.init = gids_init;
 2147|  17.0k|	gids_ops.finish = gids_finish;
 2148|  17.0k|	gids_ops.read_binary = gids_read_binary;
 2149|  17.0k|	gids_ops.write_binary = NULL;
 2150|  17.0k|	gids_ops.update_binary = NULL;
 2151|  17.0k|	gids_ops.erase_binary = NULL;
 2152|  17.0k|	gids_ops.read_record = NULL;
 2153|  17.0k|	gids_ops.write_record = NULL;
 2154|  17.0k|	gids_ops.append_record = NULL;
 2155|  17.0k|	gids_ops.update_record = NULL;
 2156|  17.0k|	gids_ops.select_file = gids_select_file;
 2157|  17.0k|	gids_ops.get_response = iso_ops->get_response;
 2158|  17.0k|	gids_ops.get_challenge = NULL;
 2159|  17.0k|	gids_ops.verify = NULL; // see pin_cmd
 2160|  17.0k|	gids_ops.logout = gids_logout;
 2161|  17.0k|	gids_ops.restore_security_env = NULL;
 2162|  17.0k|	gids_ops.set_security_env = gids_set_security_env;
 2163|  17.0k|	gids_ops.decipher = gids_decipher;
 2164|  17.0k|	gids_ops.compute_signature = iso_ops->compute_signature;
 2165|  17.0k|	gids_ops.change_reference_data = NULL; // see pin_cmd
 2166|  17.0k|	gids_ops.reset_retry_counter = NULL; // see pin_cmd
 2167|  17.0k|	gids_ops.create_file = iso_ops->create_file;
 2168|  17.0k|	gids_ops.delete_file = NULL;
 2169|  17.0k|	gids_ops.list_files = NULL;
 2170|  17.0k|	gids_ops.check_sw = iso_ops->check_sw;
 2171|  17.0k|	gids_ops.card_ctl = gids_card_ctl;
 2172|  17.0k|	gids_ops.process_fci = iso_ops->process_fci;
 2173|  17.0k|	gids_ops.construct_fci = iso_ops->construct_fci;
 2174|  17.0k|	gids_ops.pin_cmd = gids_pin_cmd;
 2175|  17.0k|	gids_ops.get_data = NULL;
 2176|  17.0k|	gids_ops.put_data = NULL;
 2177|  17.0k|	gids_ops.delete_record = NULL;
 2178|  17.0k|	gids_ops.read_public_key = gids_read_public_key;
 2179|  17.0k|	gids_ops.card_reader_lock_obtained = gids_card_reader_lock_obtained;
 2180|       |
 2181|  17.0k|	return &gids_drv;
 2182|  17.0k|}
card-gids.c:gids_match_card:
  563|  3.61k|{
  564|  3.61k|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  565|  3.61k|	int r,i;
  566|  3.61k|	size_t resplen = sizeof(rbuf);
  567|  3.61k|	const u8 *tag;
  568|  3.61k|	size_t taglen;
  569|  3.61k|	const u8 *aid;
  570|  3.61k|	size_t aidlen;
  571|       |
  572|  3.61k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.61k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.61k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.61k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.61k]
  |  |  ------------------
  ------------------
  573|       |
  574|       |	/* Detect by selecting applet */
  575|  3.61k|	r = gids_select_aid(card, gids_aid.value, gids_aid.len, rbuf, &resplen);
  576|  3.61k|	if (r<0) return 0;
  ------------------
  |  Branch (576:6): [True: 3.51k, False: 104]
  ------------------
  577|       |
  578|    104|	card->type = SC_CARD_TYPE_GIDS_GENERIC;
  579|    104|	if (resplen > 2) {
  ------------------
  |  Branch (579:6): [True: 19, False: 85]
  ------------------
  580|     19|		tag = sc_asn1_find_tag(card->ctx, rbuf, resplen, GIDS_APPLICATION_TEMPLATE_TAG, &taglen);
  ------------------
  |  |  105|     19|#define GIDS_APPLICATION_TEMPLATE_TAG 0x61
  ------------------
  581|     19|		if (tag != NULL) {
  ------------------
  |  Branch (581:7): [True: 16, False: 3]
  ------------------
  582|     16|			aid = sc_asn1_find_tag(card->ctx, tag, taglen, GIDS_APPLICATION_AID_TAG, &aidlen);
  ------------------
  |  |  106|     16|#define GIDS_APPLICATION_AID_TAG 0x4F
  ------------------
  583|     16|			if (aid != NULL ) {
  ------------------
  |  Branch (583:8): [True: 14, False: 2]
  ------------------
  584|     14|				sc_log(card->ctx, "found AID");
  ------------------
  |  |   71|     14|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  585|     39|				for (i = 0; gids_aids[i].len_long != 0; i++) {
  ------------------
  |  Branch (585:17): [True: 27, False: 12]
  ------------------
  586|     27|					if ( aidlen > gids_aids[i].len_long && memcmp(aid, gids_aids[i].value,
  ------------------
  |  Branch (586:11): [True: 25, False: 2]
  |  Branch (586:45): [True: 2, False: 23]
  ------------------
  587|     25|									gids_aids[i].len_long) == 0) {
  588|      2|						card->type = gids_aids[i].enumtag;
  589|      2|						break;
  590|      2|					}
  591|     27|				}
  592|     14|			}
  593|     16|		}
  594|     19|	}
  595|       |
  596|    104|	return 1;
  597|  3.61k|}
card-gids.c:gids_select_aid:
  280|  3.61k|{
  281|  3.61k|	sc_apdu_t apdu;
  282|  3.61k|	int r;
  283|       |
  284|  3.61k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.61k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.61k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.61k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.61k]
  |  |  ------------------
  ------------------
  285|  3.61k|	sc_log(card->ctx, "Got args: aid=%p, aidlen=%zu, response=%p, responselen=%zu",
  ------------------
  |  |   71|  7.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 3.61k, False: 0]
  |  |  ------------------
  ------------------
  286|  3.61k|			aid, aidlen, response, responselen ? *responselen : 0);
  287|       |
  288|  3.61k|	sc_format_apdu(card, &apdu,
  289|  3.61k|		response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_SELECT, P1_SELECT_DF_BY_NAME, P2_SELECT_FIRST_OR_ONLY_OCCURENCE);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
              		response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_SELECT, P1_SELECT_DF_BY_NAME, P2_SELECT_FIRST_OR_ONLY_OCCURENCE);
  ------------------
  |  |  294|  3.61k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              		response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_SELECT, P1_SELECT_DF_BY_NAME, P2_SELECT_FIRST_OR_ONLY_OCCURENCE);
  ------------------
  |  |   68|  3.61k|#define INS_SELECT 0xA4
  ------------------
              		response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_SELECT, P1_SELECT_DF_BY_NAME, P2_SELECT_FIRST_OR_ONLY_OCCURENCE);
  ------------------
  |  |   72|  3.61k|#define P1_SELECT_DF_BY_NAME 0x04
  ------------------
              		response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_SELECT, P1_SELECT_DF_BY_NAME, P2_SELECT_FIRST_OR_ONLY_OCCURENCE);
  ------------------
  |  |   75|  3.61k|#define P2_SELECT_FIRST_OR_ONLY_OCCURENCE 0x00
  ------------------
  |  Branch (289:3): [True: 0, False: 3.61k]
  ------------------
  290|  3.61k|	apdu.lc = aidlen;
  291|  3.61k|	apdu.data = aid;
  292|  3.61k|	apdu.datalen = aidlen;
  293|  3.61k|	apdu.resp = response;
  294|  3.61k|	apdu.resplen = responselen ? *responselen : 0;
  ------------------
  |  Branch (294:17): [True: 3.61k, False: 0]
  ------------------
  295|  3.61k|	apdu.le = response == NULL ? 0 : 256; /* could be 21 for fci */
  ------------------
  |  Branch (295:12): [True: 0, False: 3.61k]
  ------------------
  296|       |
  297|  3.61k|	r = sc_transmit_apdu(card, &apdu);
  298|  3.61k|	if (responselen)
  ------------------
  |  Branch (298:6): [True: 3.61k, False: 0]
  ------------------
  299|  3.61k|		*responselen = apdu.resplen;
  300|  3.61k|	LOG_TEST_RET(card->ctx, r, "gids select failed");
  ------------------
  |  |  174|  3.61k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.61k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.61k|	int _ret = (r); \
  |  |  |  |  168|  3.61k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 3.61k]
  |  |  |  |  ------------------
  |  |  |  |  169|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      7|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      7|		return _ret; \
  |  |  |  |  172|      7|	} \
  |  |  |  |  173|  3.61k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.61k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|  3.61k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|  3.61k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  3.61k|	int _ret = r; \
  |  |  155|  3.61k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 3.61k, False: 0]
  |  |  ------------------
  |  |  156|  3.61k|		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|  3.50k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 3.50k, False: 104]
  |  |  ------------------
  |  |  157|  3.61k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  3.61k|	} 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|  3.61k|	return _ret; \
  |  |  163|  3.61k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  302|  3.61k|}
card-gids.c:gids_init:
  631|    104|{
  632|    104|	unsigned long flags;
  633|    104|	struct gids_private_data *data;
  634|    104|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    104|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    104|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    104|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 104]
  |  |  ------------------
  ------------------
  635|       |
  636|       |	// cache some data in memory
  637|    104|	data = (struct gids_private_data*) calloc(1, sizeof(struct gids_private_data));
  638|    104|	if (!data) {
  ------------------
  |  Branch (638:6): [True: 0, False: 104]
  ------------------
  639|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  640|      0|	}
  641|    104|	memset(data, 0, sizeof(struct gids_private_data));
  642|    104|	card->drv_data = data;
  643|       |	// invalidate the master file and cmap file cache
  644|    104|	data->cmapfilesize = sizeof(data->cmapfile);
  645|    104|	data->masterfilesize = sizeof(data->masterfile);
  646|       |
  647|       |	/* supported RSA keys and how padding is done */
  648|    104|	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  111|    104|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    104|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    104|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  133|    104|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    104|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  649|       |
  650|       |	/* fix me: add other algorithms when the gids specification will tell how to extract the algo id from the FCP */
  651|    104|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  652|    104|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  653|    104|	_sc_card_add_rsa_alg(card, 3072, flags, 0);
  654|    104|	_sc_card_add_rsa_alg(card, 4096, flags, 0);
  655|       |
  656|    104|	return SC_SUCCESS;
  ------------------
  |  |   28|    104|#define SC_SUCCESS				0
  ------------------
  657|    104|}
card-gids.c:gids_finish:
  661|    104|{
  662|    104|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    104|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    104|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    104|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 104]
  |  |  ------------------
  ------------------
  663|       |	/* free the private data */
  664|    104|	if (card->drv_data) {
  ------------------
  |  Branch (664:6): [True: 104, False: 0]
  ------------------
  665|    104|		free(card->drv_data);
  666|       |		card->drv_data = NULL;
  667|    104|	}
  668|    104|	return 0;
  669|    104|}
card-gids.c:gids_read_binary:
 1032|      6|		unsigned char *buf, size_t count, unsigned long *flags) {
 1033|      6|	struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
 1034|      6|	struct sc_context *ctx = card->ctx;
 1035|      6|	int r;
 1036|      6|	int size;
 1037|       |
 1038|      6|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      6|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      6|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      6|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      6|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1039|       |
 1040|      6|	if (! data->currentDO || ! data->currentEFID) {
  ------------------
  |  Branch (1040:6): [True: 6, False: 0]
  |  Branch (1040:27): [True: 0, False: 0]
  ------------------
 1041|      6|		LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1042|      6|	}
 1043|      0|	if (data->state != GIDS_STATE_READ_DATA_PRESENT) {
  ------------------
  |  |   58|      0|#define GIDS_STATE_READ_DATA_PRESENT 1
  ------------------
  |  Branch (1043:6): [True: 0, False: 0]
  ------------------
 1044|       |		// this function is called to read the certificate only
 1045|      0|		u8 buffer[SC_MAX_EXT_APDU_BUFFER_SIZE];
 1046|      0|		size_t buffersize = sizeof(buffer);
 1047|      0|		r = gids_get_DO(card, data->currentEFID, data->currentDO, buffer, &(buffersize));
 1048|      0|		if (r <0) return r;
  ------------------
  |  Branch (1048:7): [True: 0, False: 0]
  ------------------
 1049|      0|		if (buffersize < 4) {
  ------------------
  |  Branch (1049:7): [True: 0, False: 0]
  ------------------
 1050|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1051|      0|		}
 1052|      0|		if (buffer[0] == 1 && buffer[1] == 0) {
  ------------------
  |  Branch (1052:7): [True: 0, False: 0]
  |  Branch (1052:25): [True: 0, False: 0]
  ------------------
 1053|      0|			if (flags)
  ------------------
  |  Branch (1053:8): [True: 0, False: 0]
  ------------------
 1054|      0|				*flags |= SC_FILE_FLAG_COMPRESSED_ZLIB;
  ------------------
  |  |  231|      0|#define SC_FILE_FLAG_COMPRESSED_ZLIB		0x02
  ------------------
 1055|       |			/* compressed data are starting on position buffer + 4 */
 1056|      0|			data->buffersize = buffersize - 4;
 1057|      0|			memcpy(data->buffer, buffer + 4, buffersize - 4);
 1058|      0|		} else {
 1059|      0|			sc_log(card->ctx, "unknown compression method %d", buffer[0] + (buffer[1] << 8));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1060|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1061|      0|		}
 1062|      0|		data->state = GIDS_STATE_READ_DATA_PRESENT;
  ------------------
  |  |   58|      0|#define GIDS_STATE_READ_DATA_PRESENT 1
  ------------------
 1063|      0|	}
 1064|      0|	if (offset >= data->buffersize) {
  ------------------
  |  Branch (1064:6): [True: 0, False: 0]
  ------------------
 1065|      0|		return 0;
 1066|      0|	}
 1067|      0|	size = (int) MIN((data->buffersize - offset), count);
  ------------------
  |  |   69|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1068|      0|	memcpy(buf, data->buffer + offset, size);
 1069|      0|	return size;
 1070|      0|}
card-gids.c:gids_get_DO:
  210|    113|static int gids_get_DO(sc_card_t* card, int fileIdentifier, int dataObjectIdentifier, u8* response, size_t *responselen) {
  211|    113|	sc_apdu_t apdu;
  212|    113|	int r;
  213|    113|	u8 data[4] = {0x5C, 0x02, (dataObjectIdentifier&0xFF00)>>8, (dataObjectIdentifier&0xFF)};
  214|    113|	size_t datasize = 0;
  215|    113|	const u8* p;
  216|    113|	u8 buffer[MAX_GIDS_FILE_SIZE];
  217|    113|	size_t buffer_len = sizeof(buffer);
  218|       |
  219|    113|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    113|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    113|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    113|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 113]
  |  |  ------------------
  ------------------
  220|    113|	sc_log(card->ctx, "Got args: fileIdentifier=%x, dataObjectIdentifier=%x, response=%p, responselen=%zu",
  ------------------
  |  |   71|    226|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 113, False: 0]
  |  |  ------------------
  ------------------
  221|    113|			fileIdentifier, dataObjectIdentifier, response, responselen ? *responselen : 0);
  222|       |
  223|    113|	sc_format_apdu(card, &apdu,
  224|    113|		response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_GET_DATA, (fileIdentifier&0xFF00)>>8, (fileIdentifier&0xFF));
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
              		response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_GET_DATA, (fileIdentifier&0xFF00)>>8, (fileIdentifier&0xFF));
  ------------------
  |  |  294|    113|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              		response == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, INS_GET_DATA, (fileIdentifier&0xFF00)>>8, (fileIdentifier&0xFF));
  ------------------
  |  |   65|    113|#define INS_GET_DATA 0xCB
  ------------------
  |  Branch (224:3): [True: 0, False: 113]
  ------------------
  225|    113|	apdu.lc = 04;
  226|    113|	apdu.data = data;
  227|    113|	apdu.datalen = 04;
  228|    113|	apdu.resp = buffer;
  229|    113|	apdu.resplen = buffer_len;
  230|    113|	apdu.le = 256;
  231|       |
  232|    113|	r = sc_transmit_apdu(card, &apdu);
  233|    113|	LOG_TEST_RET(card->ctx, r, "gids get data failed");
  ------------------
  |  |  174|    113|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    113|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    113|	int _ret = (r); \
  |  |  |  |  168|    113|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 110]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|    113|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 110]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|    110|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "invalid return");
  ------------------
  |  |  174|    110|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    110|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    110|	int _ret = (r); \
  |  |  |  |  168|    110|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 38, False: 72]
  |  |  |  |  ------------------
  |  |  |  |  169|     38|		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|     38|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     38|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     38|		return _ret; \
  |  |  |  |  172|     38|	} \
  |  |  |  |  173|    110|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 72]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  235|     72|	buffer_len = apdu.resplen;
  236|       |
  237|     72|	p = sc_asn1_find_tag(card->ctx, buffer, buffer_len, dataObjectIdentifier, &datasize);
  238|     72|	if (!p) {
  ------------------
  |  Branch (238:6): [True: 5, False: 67]
  ------------------
  239|      5|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|      5|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      5|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      5|	int _ret = r; \
  |  |  |  |  155|      5|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      5|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      5|	} 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|      5|	return _ret; \
  |  |  |  |  163|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  240|      5|	}
  241|     67|	if (response && responselen) {
  ------------------
  |  Branch (241:6): [True: 67, False: 0]
  |  Branch (241:18): [True: 67, False: 0]
  ------------------
  242|     67|		if (datasize > *responselen) {
  ------------------
  |  Branch (242:7): [True: 0, False: 67]
  ------------------
  243|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_BUFFER_TOO_SMALL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  244|      0|		}
  245|     67|		memcpy(response, p, datasize);
  246|     67|		*responselen = datasize;
  247|     67|	}
  248|     67|	return SC_SUCCESS;
  ------------------
  |  |   28|     67|#define SC_SUCCESS				0
  ------------------
  249|     67|}
card-gids.c:gids_select_file:
  964|    539|			   struct sc_file **file_out) {
  965|    539|	struct sc_file *file = NULL;
  966|    539|	struct sc_context *ctx = card->ctx;
  967|    539|	struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
  968|       |
  969|    539|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    539|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    539|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    539|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    539|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 539]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  970|       |
  971|    539|	data->state = GIDS_STATE_NONE;
  ------------------
  |  |   57|    539|#define GIDS_STATE_NONE 0
  ------------------
  972|    539|	data->currentDO = 0;
  973|    539|	data->currentEFID = 0;
  974|    539|	if (in_path->len == 4 && in_path->value[0] == 0xA0) {
  ------------------
  |  Branch (974:6): [True: 303, False: 236]
  |  Branch (974:27): [True: 0, False: 303]
  ------------------
  975|       |		// is it a DO pseudo file ?
  976|       |		// yes, succeed
  977|      0|		data->currentEFID = in_path->value[1] + (in_path->value[0]<<8);
  978|      0|		data->currentDO = in_path->value[3] + (in_path->value[2]<<8);
  979|       |
  980|      0|		if (file_out) {
  ------------------
  |  Branch (980:7): [True: 0, False: 0]
  ------------------
  981|      0|			file = sc_file_new();
  982|      0|			if (file == NULL)
  ------------------
  |  Branch (982:8): [True: 0, False: 0]
  ------------------
  983|      0|				LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  984|      0|			file->path = *in_path;
  985|      0|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  986|      0|			file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|      0|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  987|      0|			file->size = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|      0|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
  988|      0|			*file_out = file;
  989|      0|		}
  990|      0|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  991|    539|	} else if (in_path->len == 4 && in_path->value[0] == 0x3F && in_path->value[1] == 0xFF &&  in_path->type == SC_PATH_TYPE_PATH) {
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (991:13): [True: 303, False: 236]
  |  Branch (991:34): [True: 303, False: 0]
  |  Branch (991:63): [True: 0, False: 303]
  |  Branch (991:93): [True: 0, False: 0]
  ------------------
  992|       |		// GIDS does not allow a select with a path containing a DF
  993|       |		// replace the file selection from SC_PATH_TYPE_PATH to SC_PATH_TYPE_FILE_ID
  994|      0|		struct sc_path key_path;
  995|      0|		memset(&key_path, 0, sizeof(key_path));
  996|      0|		key_path.len = 2;
  997|      0|		key_path.value[0] = in_path->value[2];
  998|      0|		key_path.value[1] = in_path->value[3];
  999|      0|		key_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1000|      0|		return iso_ops->select_file(card, &key_path, file_out);
 1001|    539|	} else {
 1002|    539|		return iso_ops->select_file(card, in_path, file_out);
 1003|    539|	}
 1004|    539|}
card-gids.c:gids_card_ctl:
 2089|    134|{
 2090|    134|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    134|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    134|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    134|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    134|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 134]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2091|    134|	switch (cmd) {
 2092|     12|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (2092:3): [True: 12, False: 122]
  ------------------
 2093|     12|			return gids_get_serialnr(card, (sc_serial_number_t *) ptr);
 2094|    103|		case SC_CARDCTL_GIDS_GET_ALL_CONTAINERS:
  ------------------
  |  Branch (2094:3): [True: 103, False: 31]
  ------------------
 2095|    103|			return gids_get_all_containers(card, (size_t*) ptr);
 2096|      0|		case SC_CARDCTL_GIDS_GET_CONTAINER_DETAIL:
  ------------------
  |  Branch (2096:3): [True: 0, False: 134]
  ------------------
 2097|      0|			return gids_get_container_detail(card, (sc_cardctl_gids_get_container_t*) ptr);
 2098|      0|		case SC_CARDCTL_GIDS_SELECT_KEY_REFERENCE:
  ------------------
  |  Branch (2098:3): [True: 0, False: 134]
  ------------------
 2099|      0|			return gids_select_key_reference(card, (sc_pkcs15_prkey_info_t*) ptr);
 2100|      0|		case SC_CARDCTL_GIDS_CREATE_KEY:
  ------------------
  |  Branch (2100:3): [True: 0, False: 134]
  ------------------
 2101|      0|			return gids_create_keyfile(card, (sc_pkcs15_object_t*) ptr);
 2102|      0|		case SC_CARDCTL_GIDS_GENERATE_KEY:
  ------------------
  |  Branch (2102:3): [True: 0, False: 134]
  ------------------
 2103|      0|			return gids_generate_key(card, ((struct sc_cardctl_gids_genkey*) ptr)->object, ((struct sc_cardctl_gids_genkey*) ptr)->pubkey);
 2104|      0|		case SC_CARDCTL_GIDS_IMPORT_KEY:
  ------------------
  |  Branch (2104:3): [True: 0, False: 134]
  ------------------
 2105|      0|			return gids_import_key(card, ((struct sc_cardctl_gids_importkey*) ptr)->object, ((struct sc_cardctl_gids_importkey*) ptr)->key);
 2106|      0|		case SC_CARDCTL_GIDS_SAVE_CERT:
  ------------------
  |  Branch (2106:3): [True: 0, False: 134]
  ------------------
 2107|      0|			return gids_save_certificate(card, ((struct sc_cardctl_gids_save_cert*) ptr)->certobject,
 2108|      0|										((struct sc_cardctl_gids_save_cert*) ptr)->privkeyobject, ((struct sc_cardctl_gids_save_cert*) ptr)->path);
 2109|      0|		case SC_CARDCTL_GIDS_DELETE_CERT:
  ------------------
  |  Branch (2109:3): [True: 0, False: 134]
  ------------------
 2110|      0|			return gids_delete_cert(card, (sc_pkcs15_object_t*) ptr);
 2111|      0|		case SC_CARDCTL_GIDS_DELETE_KEY:
  ------------------
  |  Branch (2111:3): [True: 0, False: 134]
  ------------------
 2112|      0|			return gids_delete_key(card, (sc_pkcs15_object_t*) ptr);
 2113|      0|		case SC_CARDCTL_GIDS_INITIALIZE:
  ------------------
  |  Branch (2113:3): [True: 0, False: 134]
  ------------------
 2114|      0|			return gids_initialize(card, (sc_cardctl_gids_init_param_t*) ptr);
 2115|      0|		case SC_CARDCTL_GIDS_SET_ADMIN_KEY:
  ------------------
  |  Branch (2115:3): [True: 0, False: 134]
  ------------------
 2116|      0|			return gids_set_administrator_key(card, (u8*) ptr);
 2117|      0|		case SC_CARDCTL_GIDS_AUTHENTICATE_ADMIN:
  ------------------
  |  Branch (2117:3): [True: 0, False: 134]
  ------------------
 2118|      0|			return gids_authenticate_admin(card, (u8*) ptr);
 2119|     19|		default:
  ------------------
  |  Branch (2119:3): [True: 19, False: 115]
  ------------------
 2120|     19|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     19|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2121|    134|	}
 2122|    134|}
card-gids.c:gids_get_serialnr:
  602|     12|{
  603|     12|	int r;
  604|     12|	u8 buffer[SC_MAX_EXT_APDU_BUFFER_SIZE];
  605|     12|	size_t buffersize;
  606|       |
  607|     12|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     12|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     12|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     12|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 12]
  |  |  ------------------
  ------------------
  608|       |
  609|     12|	buffersize = sizeof(buffer);
  610|     12|	r = gids_read_gidsfile(card, "", "cardid", buffer, &buffersize);
  611|     12|	LOG_TEST_RET(card->ctx, r, "unable to read cardid");
  ------------------
  |  |  174|     12|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     12|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     12|	int _ret = (r); \
  |  |  |  |  168|     12|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     12|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     12|		return _ret; \
  |  |  |  |  172|     12|	} \
  |  |  |  |  173|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|       |
  613|      0|	if (SC_MAX_SERIALNR < buffersize)
  ------------------
  |  |  372|      0|#define SC_MAX_SERIALNR         32
  ------------------
  |  Branch (613:6): [True: 0, False: 0]
  ------------------
  614|      0|	{
  615|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  616|      0|	}
  617|       |
  618|       |	/* cache serial number */
  619|      0|	card->serialnr.len = buffersize;
  620|      0|	memcpy(card->serialnr.value, buffer, card->serialnr.len);
  621|       |
  622|       |	/* return cached serial number */
  623|      0|	if (serial)
  ------------------
  |  Branch (623:6): [True: 0, False: 0]
  ------------------
  624|      0|		memcpy(serial, &card->serialnr, sizeof(*serial));
  625|       |
  626|      0|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  627|      0|}
card-gids.c:gids_read_gidsfile:
  385|     72|static int gids_read_gidsfile(sc_card_t* card, char *directory, char *filename, u8* response, size_t *responselen) {
  386|     72|	struct gids_private_data* privatedata = (struct gids_private_data*) card->drv_data;
  387|     72|	int r;
  388|     72|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     72|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     72|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     72|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 72]
  |  |  ------------------
  ------------------
  389|     72|	if (privatedata->masterfilesize == sizeof(privatedata->masterfile)) {
  ------------------
  |  Branch (389:6): [True: 9, False: 63]
  ------------------
  390|      9|		r = gids_read_masterfile(card);
  391|      9|		LOG_TEST_RET(card->ctx, r, "unable to get the masterfile");
  ------------------
  |  |  174|      9|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      9|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      9|	int _ret = (r); \
  |  |  |  |  168|      9|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      8|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      8|		return _ret; \
  |  |  |  |  172|      8|	} \
  |  |  |  |  173|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|      9|	}
  393|     64|	r = gids_read_gidsfile_without_cache(card, privatedata->masterfile, privatedata->masterfilesize,
  394|     64|		directory, filename, response, responselen);
  395|     64|	LOG_TEST_RET(card->ctx, r, "unable to read the file");
  ------------------
  |  |  174|     64|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     64|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     64|	int _ret = (r); \
  |  |  |  |  168|     64|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 64, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     64|		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|     64|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     64|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     64|		return _ret; \
  |  |  |  |  172|     64|	} \
  |  |  |  |  173|     64|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  396|      0|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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]
  |  |  ------------------
  ------------------
  397|      0|}
card-gids.c:gids_read_masterfile:
  340|    112|static int gids_read_masterfile(sc_card_t* card) {
  341|    112|	struct gids_private_data* data = (struct gids_private_data*) card->drv_data;
  342|    112|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    112|#define SC_SUCCESS				0
  ------------------
  343|       |
  344|    112|	data->masterfilesize = sizeof(data->masterfile);
  345|    112|	r = gids_get_DO(card, MF_FI, MF_DO, data->masterfile, &data->masterfilesize);
  ------------------
  |  |   66|    112|#define MF_FI UserCreateDeleteDirAc_FI
  |  |  ------------------
  |  |  |  |   63|    112|#define UserCreateDeleteDirAc_FI 0xA000
  |  |  ------------------
  ------------------
              	r = gids_get_DO(card, MF_FI, MF_DO, data->masterfile, &data->masterfilesize);
  ------------------
  |  |   67|    112|#define MF_DO 0xDF1F
  ------------------
  346|    112|	if (r<0) {
  ------------------
  |  Branch (346:6): [True: 45, False: 67]
  ------------------
  347|     45|		data->masterfilesize = sizeof(data->masterfile);
  348|     45|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|     45|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     45|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     45|	int _ret = r; \
  |  |  |  |  155|     45|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 45, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     45|		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|     45|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 45, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     45|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     45|	} 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|     45|	return _ret; \
  |  |  |  |  163|     45|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  349|     45|	}
  350|     67|	if (data->masterfilesize < 1 || data->masterfile[0] != 1) {
  ------------------
  |  Branch (350:6): [True: 1, False: 66]
  |  Branch (350:34): [True: 5, False: 61]
  ------------------
  351|      6|		data->masterfilesize = sizeof(data->masterfile);
  352|      6|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|      6|	}
  354|     61|	return r;
  355|     67|}
card-gids.c:gids_read_gidsfile_without_cache:
  308|     64|static int gids_read_gidsfile_without_cache(sc_card_t* card, u8* masterfile, size_t masterfilesize, char *directory, char *filename, u8* response, size_t *responselen) {
  309|     64|	int r;
  310|     64|	int fileIdentifier;
  311|     64|	int dataObjectIdentifier;
  312|       |
  313|     64|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     64|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     64|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     64|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 64]
  |  |  ------------------
  ------------------
  314|     64|	r = gids_get_identifiers(card, masterfile, masterfilesize, directory, filename, &fileIdentifier, &dataObjectIdentifier);
  315|     64|	LOG_TEST_RET(card->ctx, r, "unable to get the identifier for the gids file");
  ------------------
  |  |  174|     64|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     64|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     64|	int _ret = (r); \
  |  |  |  |  168|     64|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 63, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|     63|		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|     63|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     63|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     63|		return _ret; \
  |  |  |  |  172|     63|	} \
  |  |  |  |  173|     64|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  316|      1|	r = gids_get_DO(card, fileIdentifier, dataObjectIdentifier, response, responselen);
  317|      1|	LOG_TEST_RET(card->ctx, r, "unable to get the data from the file");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  318|      0|	return r;
  319|      1|}
card-gids.c:gids_get_identifiers:
  163|     64|static int gids_get_identifiers(sc_card_t* card, u8* masterfile, size_t masterfilesize, char *directory, char *filename, int *fileIdentifier, int *dataObjectIdentifier) {
  164|     64|	gids_mf_record_t *records = (gids_mf_record_t *) (masterfile+1);
  165|     64|	size_t recordcount = ((masterfilesize-1) / sizeof(gids_mf_record_t));
  166|     64|	size_t i;
  167|     64|	if (masterfilesize < 1)
  ------------------
  |  Branch (167:6): [True: 0, False: 64]
  ------------------
  168|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  169|       |
  170|    149|	for (i = 0; i < recordcount; i++) {
  ------------------
  |  Branch (170:14): [True: 86, False: 63]
  ------------------
  171|     86|		if (strncmp(directory, records[i].directory, sizeof(records[i].directory)) == 0 && strncmp(filename, records[i].filename, sizeof(records[i].filename)) == 0) {
  ------------------
  |  Branch (171:7): [True: 23, False: 63]
  |  Branch (171:86): [True: 1, False: 22]
  ------------------
  172|      1|			*fileIdentifier = records[i].fileIdentifier;
  173|      1|			*dataObjectIdentifier = records[i].dataObjectIdentifier;
  174|      1|			sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  175|      1|		"Identifiers of %s %s is fileIdentifier=%x, dataObjectIdentifier=%x\n", directory, filename, *fileIdentifier, *dataObjectIdentifier);
  176|      1|			return 0;
  177|      1|		}
  178|     86|	}
  179|     63|	sc_log(card->ctx, "file %s %s not found\n", directory, filename);
  ------------------
  |  |   71|     63|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  180|     63|	return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     63|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  181|     64|}
card-gids.c:gids_get_all_containers:
 1074|    103|gids_get_all_containers(sc_card_t* card, size_t *recordsnum) {
 1075|    103|	int r;
 1076|    103|	struct gids_private_data *privatedata = (struct gids_private_data *) card->drv_data;
 1077|    103|	r = gids_read_masterfile(card);
 1078|    103|	LOG_TEST_RET(card->ctx, r, "unable to read the masterfile");
  ------------------
  |  |  174|    103|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    103|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    103|	int _ret = (r); \
  |  |  |  |  168|    103|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 43, False: 60]
  |  |  |  |  ------------------
  |  |  |  |  169|     43|		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|     43|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     43|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     43|		return _ret; \
  |  |  |  |  172|     43|	} \
  |  |  |  |  173|    103|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1079|     60|	r = gids_read_cmapfile(card);
 1080|     60|	LOG_TEST_RET(card->ctx, r, "unable to read the cmapfile");
  ------------------
  |  |  174|     60|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     60|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     60|	int _ret = (r); \
  |  |  |  |  168|     60|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 60, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     60|		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|     60|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     60|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     60|		return _ret; \
  |  |  |  |  172|     60|	} \
  |  |  |  |  173|     60|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1081|      0|	*recordsnum = (privatedata ->cmapfilesize / sizeof(CONTAINER_MAP_RECORD));
 1082|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1083|     60|}
card-gids.c:gids_read_cmapfile:
  427|     60|static int gids_read_cmapfile(sc_card_t* card) {
  428|     60|	struct gids_private_data* data = (struct gids_private_data*) card->drv_data;
  429|     60|	int r = SC_SUCCESS;
  ------------------
  |  |   28|     60|#define SC_SUCCESS				0
  ------------------
  430|       |
  431|     60|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     60|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     60|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     60|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 60]
  |  |  ------------------
  ------------------
  432|     60|	data->cmapfilesize = sizeof(data->cmapfile);
  433|     60|	r = gids_read_gidsfile(card, "mscp", "cmapfile", data->cmapfile, &data->cmapfilesize);
  434|     60|	if (r<0) {
  ------------------
  |  Branch (434:6): [True: 60, False: 0]
  ------------------
  435|     60|		data->cmapfilesize = sizeof(data->cmapfile);
  436|     60|	}
  437|     60|	LOG_TEST_RET(card->ctx, r, "unable to get the cmapfile");
  ------------------
  |  |  174|     60|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     60|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     60|	int _ret = (r); \
  |  |  |  |  168|     60|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 60, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     60|		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|     60|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     60|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     60|		return _ret; \
  |  |  |  |  172|     60|	} \
  |  |  |  |  173|     60|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|      0|	return r;
  439|     60|}
card-gids.c:gids_pin_cmd:
 1022|     12|gids_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data) {
 1023|     12|	if (data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  418|     12|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1023:6): [True: 12, False: 0]
  ------------------
 1024|     12|		return gids_get_pin_policy(card, data);
 1025|     12|	} else {
 1026|      0|		return iso_ops->pin_cmd(card, data);
 1027|      0|	}
 1028|     12|}
card-gids.c:gids_get_pin_policy:
 1006|     12|static int gids_get_pin_policy(struct sc_card *card, struct sc_pin_cmd_data *data) {
 1007|     12|	int r;
 1008|     12|	if (data->pin_type != SC_AC_CHV) {
  ------------------
  |  |  151|     12|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1008:6): [True: 0, False: 12]
  ------------------
 1009|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1010|      0|	}
 1011|     12|	r = gids_get_pin_status(card, data->pin_reference, &(data->pin1.tries_left), &(data->pin1.max_tries));
 1012|     12|	LOG_TEST_RET(card->ctx, r, "gids_get_pin_status failed");
  ------------------
  |  |  174|     12|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     12|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     12|	int _ret = (r); \
  |  |  |  |  168|     12|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     12|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     12|		return _ret; \
  |  |  |  |  172|     12|	} \
  |  |  |  |  173|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1013|      0|	data->pin1.max_length = 16;
 1014|      0|	data->pin1.min_length = 4;
 1015|      0|	data->pin1.encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|      0|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1016|      0|	data->pin1.offset = 5;
 1017|      0|	data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|      0|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 1018|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1019|     12|}
card-gids.c:gids_get_pin_status:
  516|     12|static int gids_get_pin_status(sc_card_t *card, int pinreference, int *tries_left, int *max_tries) {
  517|     12|	int dataObjectIdentifier, r;
  518|     12|	u8 buffer[100];
  519|     12|	const u8* p;
  520|     12|	size_t buffersize = sizeof(buffer);
  521|     12|	size_t datasize;
  522|       |
  523|     12|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     12|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     12|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     12|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 12]
  |  |  ------------------
  ------------------
  524|     12|	if (tries_left) *tries_left = -1;
  ------------------
  |  Branch (524:6): [True: 12, False: 0]
  ------------------
  525|     12|	if (max_tries) *max_tries = -1;
  ------------------
  |  Branch (525:6): [True: 12, False: 0]
  ------------------
  526|     12|	switch(pinreference) {
  527|      0|	case GIDS_PIN_IDENTIFIER:
  ------------------
  |  |  100|      0|#define GIDS_PIN_IDENTIFIER 0x80
  ------------------
  |  Branch (527:2): [True: 0, False: 12]
  ------------------
  528|      0|		dataObjectIdentifier = GIDS_PIN_STATUS_OBJECT_IDENTIFIER;
  ------------------
  |  |   80|      0|#define GIDS_PIN_STATUS_OBJECT_IDENTIFIER 0x7F71
  ------------------
  529|      0|		break;
  530|      0|	case GIDS_PUK_IDENTIFIER:
  ------------------
  |  |  101|      0|#define GIDS_PUK_IDENTIFIER 0x81
  ------------------
  |  Branch (530:2): [True: 0, False: 12]
  ------------------
  531|      0|		dataObjectIdentifier = GIDS_PUK_STATUS_OBJECT_IDENTIFIER;
  ------------------
  |  |   81|      0|#define GIDS_PUK_STATUS_OBJECT_IDENTIFIER 0x7F73
  ------------------
  532|      0|		break;
  533|     12|	default:
  ------------------
  |  Branch (533:2): [True: 12, False: 0]
  ------------------
  534|     12|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_FOUND);
  ------------------
  |  |  164|     12|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     12|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     12|	int _ret = r; \
  |  |  |  |  155|     12|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     12|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     12|	} 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|     12|	return _ret; \
  |  |  |  |  163|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|     12|	}
  536|      0|	r = gids_get_DO(card, GIDS_APPLET_EFID, dataObjectIdentifier, buffer, &buffersize);
  ------------------
  |  |   82|      0|#define GIDS_APPLET_EFID 0x3FFF
  ------------------
  537|      0|	LOG_TEST_RET(card->ctx, r, "unable to update the masterfile");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  538|       |
  539|      0|	buffersize = buffersize > sizeof(buffer) ? sizeof(buffer) : buffersize;
  ------------------
  |  Branch (539:15): [True: 0, False: 0]
  ------------------
  540|       |
  541|      0|	p = sc_asn1_find_tag(card->ctx, buffer, buffersize, GIDS_TRY_COUNTER_OLD_TAG, &datasize);
  ------------------
  |  |  102|      0|#define GIDS_TRY_COUNTER_OLD_TAG 0x9F17
  ------------------
  542|      0|	if (p && datasize == 1) {
  ------------------
  |  Branch (542:6): [True: 0, False: 0]
  |  Branch (542:11): [True: 0, False: 0]
  ------------------
  543|      0|		if (tries_left)
  ------------------
  |  Branch (543:7): [True: 0, False: 0]
  ------------------
  544|      0|			*tries_left = p[0];
  545|      0|	}
  546|      0|	p = sc_asn1_find_tag(card->ctx, buffer, buffersize, GIDS_TRY_COUNTER_TAG, &datasize);
  ------------------
  |  |  103|      0|#define GIDS_TRY_COUNTER_TAG 0x97
  ------------------
  547|      0|	if (p && datasize == 1) {
  ------------------
  |  Branch (547:6): [True: 0, False: 0]
  |  Branch (547:11): [True: 0, False: 0]
  ------------------
  548|      0|		if (tries_left)
  ------------------
  |  Branch (548:7): [True: 0, False: 0]
  ------------------
  549|      0|			*tries_left = p[0];
  550|      0|	}
  551|      0|	p = sc_asn1_find_tag(card->ctx, buffer, buffersize , GIDS_TRY_LIMIT_TAG, &datasize);
  ------------------
  |  |  104|      0|#define GIDS_TRY_LIMIT_TAG 0x93
  ------------------
  552|      0|	if (p && datasize == 1) {
  ------------------
  |  Branch (552:6): [True: 0, False: 0]
  |  Branch (552:11): [True: 0, False: 0]
  ------------------
  553|      0|		if (max_tries)
  ------------------
  |  Branch (553:7): [True: 0, False: 0]
  ------------------
  554|      0|			*max_tries = p[0];
  555|      0|	}
  556|       |
  557|      0|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 0, False: 0]
  |  |  |  Branch (71:122): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  558|      0|		"Pin information for PIN 0x%x: triesleft=%d trieslimit=%d\n", pinreference, (tries_left?*tries_left:-1), (max_tries?*max_tries:-1));
  559|      0|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  560|      0|}
card-gids.c:gids_card_reader_lock_obtained:
 2125|  3.83k|{
 2126|  3.83k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  3.83k|#define SC_SUCCESS				0
  ------------------
 2127|       |
 2128|  3.83k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.83k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.83k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.83k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.83k]
  |  |  ------------------
  ------------------
 2129|       |
 2130|  3.83k|	if (was_reset > 0) {
  ------------------
  |  Branch (2130:6): [True: 0, False: 3.83k]
  ------------------
 2131|      0|		u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 2132|      0|		size_t resplen = sizeof(rbuf);
 2133|      0|		r = gids_select_aid(card, gids_aid.value, gids_aid.len, rbuf, &resplen);
 2134|      0|	}
 2135|       |
 2136|  3.83k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  3.83k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.83k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.83k|	int _ret = r; \
  |  |  |  |  155|  3.83k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.83k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.83k|		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: 3.83k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.83k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.83k|	} 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|  3.83k|	return _ret; \
  |  |  |  |  163|  3.83k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2137|  3.83k|}

sc_invalidate_cache:
  164|  3.16k|{
  165|  3.16k|	if (card) {
  ------------------
  |  Branch (165:6): [True: 3.16k, False: 0]
  ------------------
  166|  3.16k|		struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  167|  3.16k|		sc_file_free(prv->cache.current_ef);
  168|  3.16k|		sc_file_free(prv->cache.current_df);
  169|  3.16k|		memset(&prv->cache, 0, sizeof(prv->cache));
  170|  3.16k|		prv->cache.valid = 0;
  171|  3.16k|	}
  172|  3.16k|}
iasecc_se_get_info:
 1609|    153|{
 1610|    153|	struct sc_context *ctx = card->ctx;
 1611|    153|	struct sc_apdu apdu;
 1612|    153|	unsigned char rbuf[0x100];
 1613|    153|	unsigned char sbuf_iasecc[10] = {
 1614|    153|		0x4D, 0x08, IASECC_SDO_TEMPLATE_TAG, 0x06,
  ------------------
  |  |   29|    153|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
 1615|    153|		IASECC_SDO_TAG_HEADER, IASECC_SDO_CLASS_SE | IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |   27|    153|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
              		IASECC_SDO_TAG_HEADER, IASECC_SDO_CLASS_SE | IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |  102|    153|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
              		IASECC_SDO_TAG_HEADER, IASECC_SDO_CLASS_SE | IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |   59|    153|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
 1616|    153|		se->reference & 0x3F,
 1617|    153|		0x02, IASECC_SDO_CLASS_SE, 0x80
  ------------------
  |  |  102|    153|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
 1618|    153|	};
 1619|    153|	int rv;
 1620|       |
 1621|    153|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    153|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    153|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    153|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    153|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1622|       |
 1623|    153|	if (iasecc_is_cpx(card)) {
  ------------------
  |  Branch (1623:6): [True: 23, False: 130]
  ------------------
 1624|     23|		rv = iasecc_select_mf(card, NULL);
 1625|     23|		LOG_TEST_RET(ctx, rv, "MF invalid");
  ------------------
  |  |  174|     23|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     23|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     23|	int _ret = (r); \
  |  |  |  |  168|     23|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  169|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      9|		return _ret; \
  |  |  |  |  172|      9|	} \
  |  |  |  |  173|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1626|     23|	}
 1627|       |
 1628|    144|	if (se->reference > IASECC_SE_REF_MAX)
  ------------------
  |  |   66|    144|#define IASECC_SE_REF_MAX	0x0F
  ------------------
  |  Branch (1628:6): [True: 0, False: 144]
  ------------------
 1629|    144|                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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1630|       |
 1631|    144|	rv = iasecc_se_get_info_from_cache(card, se);
 1632|    144|	if (rv == SC_ERROR_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   88|    144|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1632:6): [True: 144, False: 0]
  ------------------
 1633|    144|		sc_log(ctx, "No SE#%X info in cache, try to use 'GET DATA'", se->reference);
  ------------------
  |  |   71|    144|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1634|       |
 1635|    144|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xCB, 0x3F, 0xFF);
  ------------------
  |  |  294|    144|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1636|    144|		apdu.data = sbuf_iasecc;
 1637|    144|		apdu.datalen = sizeof(sbuf_iasecc);
 1638|    144|		apdu.lc = apdu.datalen;
 1639|    144|		apdu.resp = rbuf;
 1640|    144|		apdu.resplen = sizeof(rbuf);
 1641|    144|		apdu.le = sizeof(rbuf);
 1642|       |
 1643|    144|		rv = sc_transmit_apdu(card, &apdu);
 1644|    144|		LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    144|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    144|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    144|	int _ret = (r); \
  |  |  |  |  168|    144|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 138]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|    144|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 138]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1645|    138|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1646|    138|		LOG_TEST_RET(ctx, rv, "get SE data  error");
  ------------------
  |  |  174|    138|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    138|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    138|	int _ret = (r); \
  |  |  |  |  168|    138|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 19, False: 119]
  |  |  |  |  ------------------
  |  |  |  |  169|     19|		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|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     19|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     19|		return _ret; \
  |  |  |  |  172|     19|	} \
  |  |  |  |  173|    138|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 119]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1647|       |
 1648|    119|		rv = iasecc_se_parse(card, apdu.resp, apdu.resplen, se);
 1649|    119|		LOG_TEST_RET(ctx, rv, "cannot parse SE data");
  ------------------
  |  |  174|    119|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    119|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    119|	int _ret = (r); \
  |  |  |  |  168|    119|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 105, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  169|    105|		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|    105|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    105|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    105|		return _ret; \
  |  |  |  |  172|    105|	} \
  |  |  |  |  173|    119|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1650|       |
 1651|     14|		rv = iasecc_se_cache_info(card, se);
 1652|     14|		LOG_TEST_RET(ctx, rv, "failed to put SE data into cache");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1653|     14|	}
 1654|       |
 1655|     14|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		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: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} 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|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1656|     14|}
sc_get_iasecc_driver:
 3638|  17.0k|{
 3639|  17.0k|	return sc_get_driver();
 3640|  17.0k|}
card-iasecc.c:iasecc_is_cpx:
  586|  12.0k|{
  587|  12.0k|	switch(card->type) {
  588|  2.58k|		case SC_CARD_TYPE_IASECC_CPX:
  ------------------
  |  Branch (588:3): [True: 2.58k, False: 9.44k]
  ------------------
  589|  2.87k|		case SC_CARD_TYPE_IASECC_CPXCL:
  ------------------
  |  Branch (589:3): [True: 287, False: 11.7k]
  ------------------
  590|  2.87k|			return 1;
  591|  9.15k|		default:
  ------------------
  |  Branch (591:3): [True: 9.15k, False: 2.87k]
  ------------------
  592|  9.15k|			return 0;
  593|  12.0k|	}
  594|       |
  595|      0|	return 0;
  596|  12.0k|}
card-iasecc.c:iasecc_select_mf:
  283|  3.11k|{
  284|  3.11k|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  285|  3.11k|	struct sc_context *ctx = card->ctx;
  286|  3.11k|	struct sc_file *mf_file = NULL;
  287|  3.11k|	struct sc_path path;
  288|  3.11k|	int rv;
  289|       |
  290|  3.11k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.11k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.11k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.11k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.11k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.11k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|       |
  292|  3.11k|	if (file_out)
  ------------------
  |  Branch (292:6): [True: 2.09k, False: 1.02k]
  ------------------
  293|  2.09k|		*file_out = NULL;
  294|       |
  295|  3.11k|	memset(&path, 0, sizeof(struct sc_path));
  296|  3.11k|	if (!card->ef_atr || !card->ef_atr->aid.len)   {
  ------------------
  |  Branch (296:6): [True: 658, False: 2.46k]
  |  Branch (296:23): [True: 2.26k, False: 196]
  ------------------
  297|  2.92k|		struct sc_apdu apdu;
  298|  2.92k|		unsigned char apdu_resp[SC_MAX_APDU_BUFFER_SIZE];
  299|       |
  300|       |		/* ISO 'select' command fails when not FCP data returned */
  301|  2.92k|		sc_format_path("3F00", &path);
  302|  2.92k|		path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  2.92k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  303|       |
  304|  2.92k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x00, 0x0C);
  ------------------
  |  |  293|  2.92k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  305|  2.92k|		apdu.lc = path.len;
  306|  2.92k|		apdu.data = path.value;
  307|  2.92k|		apdu.datalen = path.len;
  308|  2.92k|		apdu.resplen = sizeof(apdu_resp);
  309|  2.92k|		apdu.resp = apdu_resp;
  310|       |
  311|       |		/* TODO: this might be obsolete now that 0x0c (no data) is default for p2 */
  312|  2.92k|		if (card->type == SC_CARD_TYPE_IASECC_MI2)
  ------------------
  |  Branch (312:7): [True: 0, False: 2.92k]
  ------------------
  313|      0|			apdu.p2 = 0x04;
  314|       |
  315|  2.92k|		rv = sc_transmit_apdu(card, &apdu);
  316|  2.92k|		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  2.92k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.92k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.92k|	int _ret = (r); \
  |  |  |  |  168|  2.92k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 2.91k]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|  2.92k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.91k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|  2.91k|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  318|  2.91k|		LOG_TEST_RET(card->ctx, rv, "Cannot select MF");
  ------------------
  |  |  174|  2.91k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.91k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.91k|	int _ret = (r); \
  |  |  |  |  168|  2.91k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.88k, False: 1.02k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.88k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.88k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.88k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.88k|		return _ret; \
  |  |  |  |  172|  1.88k|	} \
  |  |  |  |  173|  2.91k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.02k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  319|  2.91k|	}
  320|    196|	else   {
  321|    196|		memset(&path, 0, sizeof(path));
  322|    196|		path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    196|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  323|    196|		memcpy(path.value, card->ef_atr->aid.value, card->ef_atr->aid.len);
  324|    196|		path.len = card->ef_atr->aid.len;
  325|    196|		rv = iasecc_select_file(card, &path, file_out);
  326|    196|		LOG_TEST_RET(ctx, rv, "Unable to ROOT selection");
  ------------------
  |  |  174|    196|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    196|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    196|	int _ret = (r); \
  |  |  |  |  168|    196|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 90, False: 106]
  |  |  |  |  ------------------
  |  |  |  |  169|     90|		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|     90|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     90|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     90|		return _ret; \
  |  |  |  |  172|     90|	} \
  |  |  |  |  173|    196|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 106]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  327|    196|	}
  328|       |
  329|       |	/* Ignore the FCP of the MF, because:
  330|       |	 * - some cards do not return it;
  331|       |	 * - there is not need of it -- create/delete of the files in MF is not envisaged.
  332|       |	 */
  333|  1.13k|	mf_file = sc_file_new();
  334|  1.13k|	if (mf_file == NULL)
  ------------------
  |  Branch (334:6): [True: 0, False: 1.13k]
  ------------------
  335|  1.13k|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot allocate MF file");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  336|  1.13k|	mf_file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|  1.13k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  337|  1.13k|	mf_file->path = path;
  338|       |
  339|  1.13k|	sc_invalidate_cache(card);
  340|  1.13k|	sc_file_dup(&prv->cache.current_df, mf_file);
  341|  1.13k|	prv->cache.valid = 1;
  342|       |
  343|  1.13k|	if (file_out && *file_out == NULL)
  ------------------
  |  Branch (343:6): [True: 951, False: 179]
  |  Branch (343:18): [True: 924, False: 27]
  ------------------
  344|    924|		*file_out = mf_file;
  345|    206|	else
  346|    206|		sc_file_free(mf_file);
  347|       |
  348|  1.13k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  1.13k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.13k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.13k|	int _ret = r; \
  |  |  |  |  155|  1.13k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.13k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.13k|		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: 1.13k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.13k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.13k|	} 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|  1.13k|	return _ret; \
  |  |  |  |  163|  1.13k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  349|  1.13k|}
card-iasecc.c:iasecc_select_file:
  863|  6.94k|{
  864|  6.94k|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  865|  6.94k|	struct sc_context *ctx = card->ctx;
  866|  6.94k|	struct sc_path lpath;
  867|  6.94k|	int rv, ii;
  868|       |
  869|  6.94k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  6.94k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.94k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.94k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.94k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.94k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  870|  6.94k|	memcpy(&lpath, path, sizeof(struct sc_path));
  871|  6.94k|	if (file_out)
  ------------------
  |  Branch (871:6): [True: 3.33k, False: 3.61k]
  ------------------
  872|  3.33k|		*file_out = NULL;
  873|       |
  874|  6.94k|	sc_log(ctx, "iasecc_select_file(card:%p) path.len %zu; path.type %i; aid_len %zu",
  ------------------
  |  |   71|  6.94k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  875|  6.94k|			card, path->len, path->type, path->aid.len);
  876|  6.94k|	sc_log(ctx, "iasecc_select_file() path:%s", sc_print_path(path));
  ------------------
  |  |   71|  6.94k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  877|       |
  878|  6.94k|	if ((!iasecc_is_cpx(card)) &&
  ------------------
  |  Branch (878:6): [True: 6.04k, False: 899]
  ------------------
  879|  6.04k|	    (card->type != SC_CARD_TYPE_IASECC_GEMALTO) &&
  ------------------
  |  Branch (879:6): [True: 4.92k, False: 1.12k]
  ------------------
  880|  4.92k|	    (path->type != SC_PATH_TYPE_DF_NAME
  ------------------
  |  |  118|  9.84k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (880:7): [True: 3.26k, False: 1.66k]
  ------------------
  881|  3.26k|			&& lpath.len >= 2
  ------------------
  |  Branch (881:7): [True: 3.25k, False: 10]
  ------------------
  882|  3.25k|			&& lpath.value[0] == 0x3F && lpath.value[1] == 0x00))   {
  ------------------
  |  Branch (882:7): [True: 3.07k, False: 182]
  |  Branch (882:33): [True: 3.03k, False: 34]
  ------------------
  883|  3.03k|		sc_log(ctx, "EF.ATR(aid:'%s')", card->ef_atr ? sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len) : "");
  ------------------
  |  |   71|  6.07k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 2.39k, False: 646]
  |  |  ------------------
  ------------------
  884|       |
  885|  3.03k|		rv = iasecc_select_mf(card, file_out);
  886|  3.03k|		LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|  3.03k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.03k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.03k|	int _ret = (r); \
  |  |  |  |  168|  3.03k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.95k, False: 1.08k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.95k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.95k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.95k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.95k|		return _ret; \
  |  |  |  |  172|  1.95k|	} \
  |  |  |  |  173|  3.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.08k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|       |
  888|  1.08k|		memmove(&lpath.value[0], &lpath.value[2], lpath.len - 2);
  889|  1.08k|		lpath.len -=  2;
  890|  1.08k|	}
  891|       |
  892|  4.99k|	if (lpath.aid.len)	{
  ------------------
  |  Branch (892:6): [True: 235, False: 4.75k]
  ------------------
  893|    235|		struct sc_file *file = NULL;
  894|    235|		struct sc_path ppath;
  895|       |
  896|    235|		sc_log(ctx, "iasecc_select_file() select parent AID:%p/%zu", lpath.aid.value, lpath.aid.len);
  ------------------
  |  |   71|    235|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  897|    235|		sc_log(ctx, "iasecc_select_file() select parent AID:%s", sc_dump_hex(lpath.aid.value, lpath.aid.len));
  ------------------
  |  |   71|    235|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  898|    235|		memset(&ppath, 0, sizeof(ppath));
  899|    235|		memcpy(ppath.value, lpath.aid.value, lpath.aid.len);
  900|    235|		ppath.len = lpath.aid.len;
  901|    235|		ppath.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    235|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  902|       |
  903|    235|		rv = iasecc_select_file(card, &ppath, &file);
  904|    235|		LOG_TEST_GOTO_ERR(ctx, rv, "select AID path failed");
  ------------------
  |  |  184|    235|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    235|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    235|	int _ret = (r); \
  |  |  |  |  178|    235|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 95, False: 140]
  |  |  |  |  ------------------
  |  |  |  |  179|     95|		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|     95|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     95|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     95|		goto err; \
  |  |  |  |  182|     95|	} \
  |  |  |  |  183|    235|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 140]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  905|       |
  906|    140|		if (file_out) {
  ------------------
  |  Branch (906:7): [True: 140, False: 0]
  ------------------
  907|    140|			sc_file_free(*file_out);
  908|    140|			*file_out = file;
  909|    140|		} else {
  910|      0|			sc_file_free(file);
  911|      0|		}
  912|       |
  913|    140|		if (lpath.type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|    140|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (913:7): [True: 0, False: 140]
  ------------------
  914|      0|			lpath.type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|      0|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  915|    140|	}
  916|       |
  917|  4.89k|	if (lpath.type == SC_PATH_TYPE_PATH)
  ------------------
  |  |  119|  4.89k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (917:6): [True: 2.18k, False: 2.71k]
  ------------------
  918|  2.18k|		lpath.type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|  2.18k|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  919|       |
  920|  4.89k|	if (!lpath.len) {
  ------------------
  |  Branch (920:6): [True: 11, False: 4.88k]
  ------------------
  921|     11|		if (file_out) {
  ------------------
  |  Branch (921:7): [True: 10, False: 1]
  ------------------
  922|     10|			sc_file_free(*file_out);
  923|     10|			*file_out = NULL;
  924|     10|		}
  925|     11|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     11|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     11|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     11|	int _ret = r; \
  |  |  |  |  155|     11|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     11|		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: 11]
  |  |  |  |  ------------------
  |  |  |  |  157|     11|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     11|	} 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|     11|	return _ret; \
  |  |  |  |  163|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  926|     11|	}
  927|       |
  928|  4.88k|	do   {
  929|  4.88k|		struct sc_apdu apdu;
  930|  4.88k|		struct sc_file *file = NULL;
  931|  4.88k|		unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  932|  4.88k|		size_t pathlen = lpath.len;
  933|       |
  934|  4.88k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  4.88k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  935|       |
  936|  4.88k|		if (card->type != SC_CARD_TYPE_IASECC_GEMALTO
  ------------------
  |  Branch (936:7): [True: 3.80k, False: 1.08k]
  ------------------
  937|  3.80k|				&& card->type != SC_CARD_TYPE_IASECC_OBERTHUR
  ------------------
  |  Branch (937:8): [True: 3.55k, False: 254]
  ------------------
  938|  3.55k|				&& card->type != SC_CARD_TYPE_IASECC_SAGEM
  ------------------
  |  Branch (938:8): [True: 875, False: 2.67k]
  ------------------
  939|    875|				&& card->type != SC_CARD_TYPE_IASECC_AMOS
  ------------------
  |  Branch (939:8): [True: 875, False: 0]
  ------------------
  940|    875|				&& card->type != SC_CARD_TYPE_IASECC_MI
  ------------------
  |  Branch (940:8): [True: 875, False: 0]
  ------------------
  941|    875|				&& card->type != SC_CARD_TYPE_IASECC_MI2
  ------------------
  |  Branch (941:8): [True: 875, False: 0]
  ------------------
  942|    875|				&& !iasecc_is_cpx(card)) {
  ------------------
  |  Branch (942:8): [True: 0, False: 875]
  ------------------
  943|      0|			rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  944|      0|			LOG_TEST_GOTO_ERR(ctx, rv, "Unsupported card");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  945|      0|		}
  946|       |
  947|  4.88k|		if (lpath.type == SC_PATH_TYPE_FILE_ID)   {
  ------------------
  |  |  117|  4.88k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (947:7): [True: 15, False: 4.87k]
  ------------------
  948|     15|			apdu.p1 = 0x02;
  949|     15|			if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)
  ------------------
  |  Branch (949:8): [True: 0, False: 15]
  ------------------
  950|      0|				apdu.p1 = 0x01;
  951|     15|			if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR ||
  ------------------
  |  Branch (951:8): [True: 0, False: 15]
  ------------------
  952|     15|			    card->type == SC_CARD_TYPE_IASECC_AMOS ||
  ------------------
  |  Branch (952:8): [True: 0, False: 15]
  ------------------
  953|     15|			    card->type == SC_CARD_TYPE_IASECC_MI ||
  ------------------
  |  Branch (953:8): [True: 0, False: 15]
  ------------------
  954|     15|			    card->type == SC_CARD_TYPE_IASECC_MI2 ||
  ------------------
  |  Branch (954:8): [True: 0, False: 15]
  ------------------
  955|     15|			    card->type == SC_CARD_TYPE_IASECC_GEMALTO ||
  ------------------
  |  Branch (955:8): [True: 1, False: 14]
  ------------------
  956|     14|			    iasecc_is_cpx(card)
  ------------------
  |  Branch (956:8): [True: 3, False: 11]
  ------------------
  957|     15|			    )   {
  958|      4|				apdu.p2 = 0x04;
  959|      4|			}
  960|     15|		}
  961|  4.87k|		else if (lpath.type == SC_PATH_TYPE_FROM_CURRENT)  {
  ------------------
  |  |  122|  4.87k|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (961:12): [True: 2.17k, False: 2.70k]
  ------------------
  962|  2.17k|			apdu.p1 = 0x09;
  963|  2.17k|			if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR ||
  ------------------
  |  Branch (963:8): [True: 69, False: 2.10k]
  ------------------
  964|  2.10k|			    card->type == SC_CARD_TYPE_IASECC_AMOS ||
  ------------------
  |  Branch (964:8): [True: 0, False: 2.10k]
  ------------------
  965|  2.10k|			    card->type == SC_CARD_TYPE_IASECC_MI ||
  ------------------
  |  Branch (965:8): [True: 0, False: 2.10k]
  ------------------
  966|  2.10k|			    card->type == SC_CARD_TYPE_IASECC_MI2 ||
  ------------------
  |  Branch (966:8): [True: 0, False: 2.10k]
  ------------------
  967|  2.10k|			    card->type == SC_CARD_TYPE_IASECC_GEMALTO ||
  ------------------
  |  Branch (967:8): [True: 409, False: 1.69k]
  ------------------
  968|  1.69k|			    iasecc_is_cpx(card)) {
  ------------------
  |  Branch (968:8): [True: 502, False: 1.19k]
  ------------------
  969|    980|				apdu.p2 = 0x04;
  970|    980|			}
  971|  2.17k|		}
  972|  2.70k|		else if (lpath.type == SC_PATH_TYPE_PARENT)   {
  ------------------
  |  |  123|  2.70k|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (972:12): [True: 0, False: 2.70k]
  ------------------
  973|      0|			apdu.p1 = 0x03;
  974|      0|			pathlen = 0;
  975|      0|			apdu.cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  976|      0|		}
  977|  2.70k|		else if (lpath.type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  2.70k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (977:12): [True: 2.70k, False: 0]
  ------------------
  978|  2.70k|			apdu.p1 = 0x04;
  979|  2.70k|			if (card->type == SC_CARD_TYPE_IASECC_AMOS ||
  ------------------
  |  Branch (979:8): [True: 0, False: 2.70k]
  ------------------
  980|  2.70k|			    card->type == SC_CARD_TYPE_IASECC_MI2 ||
  ------------------
  |  Branch (980:8): [True: 0, False: 2.70k]
  ------------------
  981|  2.70k|			    card->type == SC_CARD_TYPE_IASECC_OBERTHUR ||
  ------------------
  |  Branch (981:8): [True: 185, False: 2.51k]
  ------------------
  982|  2.51k|			    card->type == SC_CARD_TYPE_IASECC_GEMALTO ||
  ------------------
  |  Branch (982:8): [True: 670, False: 1.84k]
  ------------------
  983|  1.84k|			    iasecc_is_cpx(card)) {
  ------------------
  |  Branch (983:8): [True: 370, False: 1.47k]
  ------------------
  984|  1.22k|				apdu.p2 = 0x04;
  985|  1.22k|			}
  986|  2.70k|		}
  987|      0|		else   {
  988|      0|			sc_log(ctx, "Invalid PATH type: 0x%X", lpath.type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  989|      0|			rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  990|      0|			LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_select_file() invalid PATH type");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  991|      0|		}
  992|       |
  993|  5.15k|		for (ii=0; ii<2; ii++)   {
  ------------------
  |  Branch (993:14): [True: 5.15k, False: 0]
  ------------------
  994|  5.15k|			apdu.lc = pathlen;
  995|  5.15k|			apdu.data = lpath.value;
  996|  5.15k|			apdu.datalen = pathlen;
  997|       |
  998|  5.15k|			apdu.resp = rbuf;
  999|  5.15k|			apdu.resplen = sizeof(rbuf);
 1000|  5.15k|			apdu.le = 256;
 1001|       |
 1002|  5.15k|			rv = sc_transmit_apdu(card, &apdu);
 1003|  5.15k|			LOG_TEST_GOTO_ERR(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  184|  5.15k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  5.15k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  5.15k|	int _ret = (r); \
  |  |  |  |  178|  5.15k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 119, False: 5.03k]
  |  |  |  |  ------------------
  |  |  |  |  179|    119|		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|    119|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    119|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    119|		goto err; \
  |  |  |  |  182|    119|	} \
  |  |  |  |  183|  5.15k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 5.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1004|  5.03k|			rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1005|  5.03k|			if (rv == SC_ERROR_INCORRECT_PARAMETERS &&
  ------------------
  |  |   55|  10.0k|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (1005:8): [True: 335, False: 4.69k]
  ------------------
 1006|    335|					lpath.type == SC_PATH_TYPE_DF_NAME && apdu.p2 == 0x00)   {
  ------------------
  |  |  118|  5.36k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1006:6): [True: 306, False: 29]
  |  Branch (1006:44): [True: 266, False: 40]
  ------------------
 1007|    266|				sc_log(ctx, "Warning: SC_ERROR_INCORRECT_PARAMETERS for SC_PATH_TYPE_DF_NAME, try again with P2=0x0C");
  ------------------
  |  |   71|    266|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1008|    266|				apdu.p2 = 0x0C;
 1009|    266|				continue;
 1010|    266|			}
 1011|       |
 1012|  4.76k|			if (ii)   {
  ------------------
  |  Branch (1012:8): [True: 266, False: 4.50k]
  ------------------
 1013|       |				/* 'SELECT AID' do not returned FCP. Try to emulate. */
 1014|    266|				apdu.resplen = sizeof(rbuf);
 1015|    266|				rv = iasecc_emulate_fcp(ctx, &apdu);
 1016|    266|				LOG_TEST_GOTO_ERR(ctx, rv, "Failed to emulate DF FCP");
  ------------------
  |  |  184|    266|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    266|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    266|	int _ret = (r); \
  |  |  |  |  178|    266|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 266]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    266|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 266]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1017|    266|			}
 1018|       |
 1019|  4.76k|			break;
 1020|  4.76k|		}
 1021|       |
 1022|  4.76k|		LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_select_file() check SW failed");
  ------------------
  |  |  184|  4.76k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.76k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.76k|	int _ret = (r); \
  |  |  |  |  178|  4.76k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.57k, False: 3.19k]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.57k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.57k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.57k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.57k|		goto err; \
  |  |  |  |  182|  1.57k|	} \
  |  |  |  |  183|  4.76k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 3.19k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1023|       |
 1024|  3.19k|		sc_log(ctx, "iasecc_select_file() apdu.resp %zu", apdu.resplen);
  ------------------
  |  |   71|  3.19k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1025|  3.19k|		if (apdu.resplen)   {
  ------------------
  |  Branch (1025:7): [True: 1.46k, False: 1.73k]
  ------------------
 1026|  1.46k|			sc_log(ctx, "apdu.resp %02X:%02X:%02X...", apdu.resp[0], apdu.resp[1], apdu.resp[2]);
  ------------------
  |  |   71|  1.46k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1027|       |
 1028|  1.46k|			switch (apdu.resp[0]) {
 1029|    309|			case 0x62:
  ------------------
  |  Branch (1029:4): [True: 309, False: 1.15k]
  ------------------
 1030|  1.23k|			case 0x6F:
  ------------------
  |  Branch (1030:4): [True: 928, False: 535]
  ------------------
 1031|  1.23k|				file = sc_file_new();
 1032|  1.23k|				if (file == NULL) {
  ------------------
  |  Branch (1032:9): [True: 0, False: 1.23k]
  ------------------
 1033|      0|					if (file_out) {
  ------------------
  |  Branch (1033:10): [True: 0, False: 0]
  ------------------
 1034|      0|						sc_file_free(*file_out);
 1035|      0|						*file_out = NULL;
 1036|      0|					}
 1037|      0|					LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1038|      0|				}
 1039|  1.23k|				file->path = lpath;
 1040|       |
 1041|  1.23k|				rv = iasecc_process_fci(card, file, apdu.resp, apdu.resplen);
 1042|  1.23k|				if (rv) {
  ------------------
  |  Branch (1042:9): [True: 117, False: 1.12k]
  ------------------
 1043|    117|					sc_file_free(file);
 1044|    117|					if (file_out) {
  ------------------
  |  Branch (1044:10): [True: 42, False: 75]
  ------------------
 1045|     42|						sc_file_free(*file_out);
 1046|     42|						*file_out = NULL;
 1047|     42|					}
 1048|    117|					LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    117|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    117|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    117|	int _ret = r; \
  |  |  |  |  155|    117|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 117, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    117|		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|    117|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 117, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    117|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    117|	} 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|    117|	return _ret; \
  |  |  |  |  163|    117|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1049|    117|				}
 1050|  1.12k|				break;
 1051|  1.12k|			default:
  ------------------
  |  Branch (1051:4): [True: 226, False: 1.23k]
  ------------------
 1052|    226|				if (file_out) {
  ------------------
  |  Branch (1052:9): [True: 59, False: 167]
  ------------------
 1053|     59|					sc_file_free(*file_out);
 1054|     59|					*file_out = NULL;
 1055|     59|				}
 1056|    226|				LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    226|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    226|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    226|	int _ret = r; \
  |  |  |  |  155|    226|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 226, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    226|		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|    226|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 226, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    226|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    226|	} 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|    226|	return _ret; \
  |  |  |  |  163|    226|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1057|  1.46k|			}
 1058|       |
 1059|  1.12k|			sc_log(ctx, "FileType %i", file->type);
  ------------------
  |  |   71|  1.12k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1060|  1.12k|			if (file->type == SC_FILE_TYPE_DF)   {
  ------------------
  |  |  214|  1.12k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1060:8): [True: 279, False: 841]
  ------------------
 1061|    279|				sc_invalidate_cache(card);
 1062|    279|				sc_file_dup(&prv->cache.current_df, file);
 1063|    279|				prv->cache.valid = 1;
 1064|    279|			}
 1065|    841|			else   {
 1066|    841|				sc_file_free(prv->cache.current_ef);
 1067|    841|				sc_file_dup(&prv->cache.current_ef, file);
 1068|    841|				prv->cache.valid = 1;
 1069|    841|			}
 1070|       |
 1071|  1.12k|			if (file_out)   {
  ------------------
  |  Branch (1071:8): [True: 692, False: 428]
  ------------------
 1072|    692|				sc_file_free(*file_out);
 1073|    692|				*file_out = file;
 1074|    692|			}
 1075|    428|			else   {
 1076|    428|				sc_file_free(file);
 1077|    428|			}
 1078|  1.12k|		}
 1079|  1.73k|		else if (lpath.type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  1.73k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1079:12): [True: 823, False: 908]
  ------------------
 1080|    823|			sc_invalidate_cache(card);
 1081|    823|			prv->cache.valid = 1;
 1082|    823|		}
 1083|  3.19k|	} while(0);
  ------------------
  |  Branch (1083:10): [Folded, False: 2.85k]
  ------------------
 1084|       |
 1085|  2.85k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  2.85k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.85k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.85k|	int _ret = r; \
  |  |  |  |  155|  2.85k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.85k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.85k|		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: 2.85k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.85k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.85k|	} 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|  2.85k|	return _ret; \
  |  |  |  |  163|  2.85k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1086|  1.78k|err:
 1087|  1.78k|	if (file_out) {
  ------------------
  |  Branch (1087:6): [True: 470, False: 1.31k]
  ------------------
 1088|    470|		sc_file_free(*file_out);
 1089|       |		*file_out = NULL;
 1090|    470|	}
 1091|  1.78k|	return rv;
 1092|  2.85k|}
card-iasecc.c:iasecc_emulate_fcp:
  828|    266|{
  829|    266|	unsigned char dummy_df_fcp[] = {
  830|    266|		0x62,0xFF,
  831|    266|			0x82,0x01,0x38,
  832|    266|			0x8A,0x01,0x05,
  833|    266|			0xA1,0x04,0x8C,0x02,0x02,0x00,
  834|    266|			0x84,0xFF,
  835|    266|				0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  836|    266|				0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
  837|    266|	};
  838|       |
  839|    266|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    266|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    266|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    266|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    266|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 266]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  840|       |
  841|    266|	if (apdu->p1 != 0x04)
  ------------------
  |  Branch (841:6): [True: 0, False: 266]
  ------------------
  842|    266|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "FCP emulation supported only for the DF-NAME selection type");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  843|    266|	if (apdu->datalen > 16)
  ------------------
  |  Branch (843:6): [True: 0, False: 266]
  ------------------
  844|    266|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid DF-NAME length");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|    266|	if (apdu->resplen < apdu->datalen + 16)
  ------------------
  |  Branch (845:6): [True: 0, False: 266]
  ------------------
  846|    266|		LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "not enough space for FCP data");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  847|       |
  848|    266|	memcpy(dummy_df_fcp + 16, apdu->data, apdu->datalen);
  849|    266|	dummy_df_fcp[15] = apdu->datalen;
  850|    266|	dummy_df_fcp[1] = apdu->datalen + 14;
  851|    266|	apdu->resplen = apdu->datalen + 16;
  852|    266|	memcpy(apdu->resp, dummy_df_fcp, apdu->resplen);
  853|       |
  854|    266|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    266|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    266|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    266|	int _ret = r; \
  |  |  |  |  155|    266|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 266, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    266|		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: 266]
  |  |  |  |  ------------------
  |  |  |  |  157|    266|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    266|	} 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|    266|	return _ret; \
  |  |  |  |  163|    266|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  855|    266|}
card-iasecc.c:iasecc_process_fci:
 1098|  1.23k|{
 1099|  1.23k|	struct sc_context *ctx = card->ctx;
 1100|  1.23k|	size_t taglen, offs, ii;
 1101|  1.23k|	int rv;
 1102|  1.23k|	const unsigned char *acls = NULL, *tag = NULL;
 1103|  1.23k|	unsigned char mask;
 1104|  1.23k|	unsigned char ops_DF[7] = {
 1105|  1.23k|		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_CREATE, 0xFF
  ------------------
  |  |  168|  1.23k|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_CREATE, 0xFF
  ------------------
  |  |  186|  1.23k|#define SC_AC_OP_ACTIVATE		20
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_CREATE, 0xFF
  ------------------
  |  |  187|  1.23k|#define SC_AC_OP_DEACTIVATE		21
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_CREATE, 0xFF
  ------------------
  |  |  169|  1.23k|#define SC_AC_OP_CREATE			3
  ------------------
 1106|  1.23k|	};
 1107|  1.23k|	unsigned char ops_EF[7] = {
 1108|  1.23k|		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  168|  1.23k|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  186|  1.23k|#define SC_AC_OP_ACTIVATE		20
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  187|  1.23k|#define SC_AC_OP_DEACTIVATE		21
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  189|  1.23k|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  188|  1.23k|#define SC_AC_OP_READ			22
  ------------------
 1109|  1.23k|	};
 1110|       |
 1111|  1.23k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.23k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.23k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.23k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.23k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1112|       |
 1113|  1.23k|	tag = sc_asn1_find_tag(ctx,  buf, buflen, 0x6F, &taglen);
 1114|  1.23k|	sc_log(ctx, "processing FCI: 0x6F tag %p", tag);
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1115|  1.23k|	if (tag != NULL) {
  ------------------
  |  Branch (1115:6): [True: 898, False: 339]
  ------------------
 1116|    898|		sc_log(ctx, "  FCP length %zu", taglen);
  ------------------
  |  |   71|    898|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1117|    898|		buf = tag;
 1118|    898|		buflen = taglen;
 1119|    898|	}
 1120|       |
 1121|  1.23k|	tag = sc_asn1_find_tag(ctx,  buf, buflen, 0x62, &taglen);
 1122|  1.23k|	sc_log(ctx, "processing FCI: 0x62 tag %p", tag);
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1123|  1.23k|	if (tag != NULL) {
  ------------------
  |  Branch (1123:6): [True: 287, False: 950]
  ------------------
 1124|    287|		sc_log(ctx, "  FCP length %zu", taglen);
  ------------------
  |  |   71|    287|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1125|    287|		buf = tag;
 1126|    287|		buflen = taglen;
 1127|    287|	}
 1128|       |
 1129|  1.23k|	rv = iso_ops->process_fci(card, file, buf, buflen);
 1130|  1.23k|	LOG_TEST_RET(ctx, rv, "ISO parse FCI failed");
  ------------------
  |  |  174|  1.23k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.23k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.23k|	int _ret = (r); \
  |  |  |  |  168|  1.23k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 1.23k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1131|       |/*
 1132|       |	Gemalto:  6F 19 80 02 02 ED 82 01 01 83 02 B0 01 88 00	8C 07 7B 17 17 17 17 17 00 8A 01 05 90 00
 1133|       |	Sagem:    6F 17 62 15 80 02 00 7D 82 01 01                   8C 02 01 00 83 02 2F 00 88 01 F0 8A 01 05 90 00
 1134|       |	Oberthur: 62 1B 80 02 05 DC 82 01 01 83 02 B0 01 88 00 A1 09 8C 07 7B 17 FF 17 17 17 00 8A 01 05 90 00
 1135|       |*/
 1136|       |
 1137|  1.23k|	sc_log(ctx, "iasecc_process_fci() type %i; let's parse file ACLs", file->type);
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1138|  1.23k|	tag = sc_asn1_find_tag(ctx, buf, buflen, IASECC_DOCP_TAG_ACLS, &taglen);
  ------------------
  |  |   39|  1.23k|#define IASECC_DOCP_TAG_ACLS			0xA1
  ------------------
 1139|  1.23k|	if (tag)
  ------------------
  |  Branch (1139:6): [True: 269, False: 968]
  ------------------
 1140|    269|		acls = sc_asn1_find_tag(ctx, tag, taglen, IASECC_DOCP_TAG_ACLS_CONTACT, &taglen);
  ------------------
  |  |   40|    269|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
 1141|    968|	else
 1142|    968|		acls = sc_asn1_find_tag(ctx, buf, buflen, IASECC_DOCP_TAG_ACLS_CONTACT, &taglen);
  ------------------
  |  |   40|    968|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
 1143|       |
 1144|  1.23k|	if (!acls)   {
  ------------------
  |  Branch (1144:6): [True: 117, False: 1.12k]
  ------------------
 1145|    117|		sc_log(ctx, "ACLs not found in data(%zu) %s", buflen, sc_dump_hex(buf, buflen));
  ------------------
  |  |   71|    117|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1146|    117|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "ACLs tag missing");
  ------------------
  |  |  174|    117|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    117|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    117|	int _ret = (r); \
  |  |  |  |  168|    117|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 117, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    117|		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|    117|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    117|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    117|		return _ret; \
  |  |  |  |  172|    117|	} \
  |  |  |  |  173|    117|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1147|    117|	}
 1148|       |
 1149|  1.12k|	sc_log(ctx, "ACLs(%zu) '%s'", taglen, sc_dump_hex(acls, taglen));
  ------------------
  |  |   71|  1.12k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1150|  1.12k|	mask = 0x40, offs = 1;
 1151|  7.78k|	for (ii = 0; ii < 7; ii++, mask /= 2)  {
  ------------------
  |  Branch (1151:15): [True: 7.09k, False: 690]
  ------------------
 1152|  7.09k|		unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii];
  ------------------
  |  |  214|  7.09k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1152:22): [True: 1.92k, False: 5.16k]
  ------------------
 1153|       |
 1154|       |		/* avoid any access to acls[offs] beyond the taglen */
 1155|  7.09k|		if (offs >= taglen) {
  ------------------
  |  Branch (1155:7): [True: 430, False: 6.66k]
  ------------------
 1156|    430|			sc_log(ctx, "Warning: Invalid offset reached during ACL parsing");
  ------------------
  |  |   71|    430|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1157|    430|			break;
 1158|    430|		}
 1159|  6.66k|		if (!(mask & acls[0]))
  ------------------
  |  Branch (1159:7): [True: 3.45k, False: 3.20k]
  ------------------
 1160|  3.45k|			continue;
 1161|       |
 1162|  3.20k|		sc_log(ctx, "ACLs mask 0x%X, offs %zu, op 0x%X, acls[offs] 0x%X", mask, offs, op, acls[offs]);
  ------------------
  |  |   71|  3.20k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1163|  3.20k|		if (op == 0xFF)   {
  ------------------
  |  Branch (1163:7): [True: 811, False: 2.39k]
  ------------------
 1164|    811|			;
 1165|    811|		}
 1166|  2.39k|		else if (acls[offs] == 0)   {
  ------------------
  |  Branch (1166:12): [True: 427, False: 1.97k]
  ------------------
 1167|    427|			sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|    427|#define SC_AC_NONE			0x00000000
  ------------------
 1168|    427|		}
 1169|  1.97k|		else if (acls[offs] == 0xFF)   {
  ------------------
  |  Branch (1169:12): [True: 262, False: 1.70k]
  ------------------
 1170|    262|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    262|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1171|    262|		}
 1172|  1.70k|		else if ((acls[offs] & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   89|  1.70k|#define IASECC_SCB_METHOD_MASK		0x70
  ------------------
              		else if ((acls[offs] & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   93|  1.70k|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
  |  Branch (1172:12): [True: 125, False: 1.58k]
  ------------------
 1173|    125|			sc_file_add_acl_entry(file, op, SC_AC_SEN, acls[offs] & IASECC_SCB_METHOD_MASK_REF);
  ------------------
  |  |  156|    125|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
              			sc_file_add_acl_entry(file, op, SC_AC_SEN, acls[offs] & IASECC_SCB_METHOD_MASK_REF);
  ------------------
  |  |   90|    125|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
 1174|    125|		}
 1175|  1.58k|		else if (acls[offs] & IASECC_SCB_METHOD_MASK)   {
  ------------------
  |  |   89|  1.58k|#define IASECC_SCB_METHOD_MASK		0x70
  ------------------
  |  Branch (1175:12): [True: 1.31k, False: 265]
  ------------------
 1176|  1.31k|			sc_file_add_acl_entry(file, op, SC_AC_SCB, acls[offs]);
  ------------------
  |  |  157|  1.31k|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
 1177|  1.31k|		}
 1178|    265|		else   {
 1179|    265|			sc_log(ctx, "Warning: non supported SCB method: %X", acls[offs]);
  ------------------
  |  |   71|    265|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1180|    265|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    265|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1181|    265|		}
 1182|       |
 1183|  3.20k|		offs++;
 1184|  3.20k|	}
 1185|       |
 1186|  1.12k|	LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  164|  1.12k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.12k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.12k|	int _ret = r; \
  |  |  |  |  155|  1.12k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.12k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.12k|		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: 1.12k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.12k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.12k|	} 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|  1.12k|	return _ret; \
  |  |  |  |  163|  1.12k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1187|  1.12k|}
card-iasecc.c:iasecc_se_get_info_from_cache:
 1568|    144|{
 1569|    144|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1570|    144|	struct sc_context *ctx = card->ctx;
 1571|    144|	struct iasecc_se_info *si = NULL;
 1572|    144|	int rv;
 1573|       |
 1574|    144|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    144|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    144|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    144|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    144|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 144]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1575|       |
 1576|    144|	for(si = prv->se_info; si; si = si->next)   {
  ------------------
  |  Branch (1576:25): [True: 0, False: 144]
  ------------------
 1577|      0|		if (si->reference != se->reference)
  ------------------
  |  Branch (1577:7): [True: 0, False: 0]
  ------------------
 1578|      0|			continue;
 1579|      0|		if (!(prv->cache.valid && prv->cache.current_df) && si->df)
  ------------------
  |  Branch (1579:9): [True: 0, False: 0]
  |  Branch (1579:29): [True: 0, False: 0]
  |  Branch (1579:55): [True: 0, False: 0]
  ------------------
 1580|      0|			continue;
 1581|      0|		if (prv->cache.valid && prv->cache.current_df && !si->df)
  ------------------
  |  Branch (1581:7): [True: 0, False: 0]
  |  Branch (1581:27): [True: 0, False: 0]
  |  Branch (1581:52): [True: 0, False: 0]
  ------------------
 1582|      0|			continue;
 1583|      0|		if (prv->cache.valid && prv->cache.current_df && si->df)
  ------------------
  |  Branch (1583:7): [True: 0, False: 0]
  |  Branch (1583:27): [True: 0, False: 0]
  |  Branch (1583:52): [True: 0, False: 0]
  ------------------
 1584|      0|			if (memcmp(&prv->cache.current_df->path, &si->df->path, sizeof(struct sc_path)))
  ------------------
  |  Branch (1584:8): [True: 0, False: 0]
  ------------------
 1585|      0|				continue;
 1586|      0|		break;
 1587|      0|	}
 1588|       |
 1589|    144|	if (!si)
  ------------------
  |  Branch (1589:6): [True: 144, False: 0]
  ------------------
 1590|    144|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    144|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1591|       |
 1592|      0|	memcpy(se, si, sizeof(struct iasecc_se_info));
 1593|       |
 1594|      0|	if (si->df)   {
  ------------------
  |  Branch (1594:6): [True: 0, False: 0]
  ------------------
 1595|      0|		sc_file_dup(&se->df, si->df);
 1596|      0|		if (se->df == NULL)
  ------------------
  |  Branch (1596:7): [True: 0, False: 0]
  ------------------
 1597|      0|			LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot duplicate current DF file");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1598|      0|	}
 1599|       |
 1600|      0|	rv = iasecc_docp_copy(ctx, &si->docp, &se->docp);
 1601|      0|	LOG_TEST_RET(ctx, rv, "Cannot make copy of DOCP");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1602|       |
 1603|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1604|      0|}
card-iasecc.c:iasecc_se_cache_info:
 1525|     14|{
 1526|     14|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1527|     14|	struct sc_context *ctx = card->ctx;
 1528|     14|	struct iasecc_se_info *se_info = NULL, *si = NULL;
 1529|     14|	int rv;
 1530|       |
 1531|     14|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     14|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     14|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     14|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     14|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1532|       |
 1533|     14|	se_info = calloc(1, sizeof(struct iasecc_se_info));
 1534|     14|	if (!se_info)
  ------------------
  |  Branch (1534:6): [True: 0, False: 14]
  ------------------
 1535|     14|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "SE info allocation error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1536|     14|	memcpy(se_info, se, sizeof(struct iasecc_se_info));
 1537|       |
 1538|     14|	if (prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  Branch (1538:6): [True: 14, False: 0]
  |  Branch (1538:26): [True: 13, False: 1]
  ------------------
 1539|     13|		sc_file_dup(&se_info->df, prv->cache.current_df);
 1540|     13|		if (se_info->df == NULL)   {
  ------------------
  |  Branch (1540:7): [True: 0, False: 13]
  ------------------
 1541|      0|			free(se_info);
 1542|      0|			LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot duplicate current DF file");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1543|      0|		}
 1544|     13|	}
 1545|       |
 1546|     14|	rv = iasecc_docp_copy(ctx, &se->docp, &se_info->docp);
 1547|     14|	if (rv < 0)   {
  ------------------
  |  Branch (1547:6): [True: 0, False: 14]
  ------------------
 1548|      0|		free(se_info->df);
 1549|      0|		free(se_info);
 1550|      0|		LOG_TEST_RET(ctx, rv, "Cannot make copy of DOCP");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1551|      0|	}
 1552|       |
 1553|     14|	if (!prv->se_info)   {
  ------------------
  |  Branch (1553:6): [True: 14, False: 0]
  ------------------
 1554|     14|		prv->se_info = se_info;
 1555|     14|	}
 1556|      0|	else    {
 1557|      0|		for (si = prv->se_info; si->next; si = si->next)
  ------------------
  |  Branch (1557:27): [True: 0, False: 0]
  ------------------
 1558|      0|			;
 1559|      0|		si->next = se_info;
 1560|      0|	}
 1561|       |
 1562|     14|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		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: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} 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|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1563|     14|}
card-iasecc.c:sc_get_driver:
 3591|  17.0k|{
 3592|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3593|       |
 3594|  17.0k|	if (!iso_ops)
  ------------------
  |  Branch (3594:6): [True: 1, False: 17.0k]
  ------------------
 3595|      1|		iso_ops = iso_drv->ops;
 3596|       |
 3597|  17.0k|	iasecc_ops = *iso_ops;
 3598|       |
 3599|  17.0k|	iasecc_ops.match_card = iasecc_match_card;
 3600|  17.0k|	iasecc_ops.init = iasecc_init;
 3601|  17.0k|	iasecc_ops.finish = iasecc_finish;
 3602|  17.0k|	iasecc_ops.read_binary = iasecc_read_binary;
 3603|       |	/*	write_binary: ISO7816 implementation works	*/
 3604|       |	/*	update_binary: ISO7816 implementation works	*/
 3605|  17.0k|	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|  17.0k|	iasecc_ops.select_file = iasecc_select_file;
 3612|       |	/*	get_response: Untested	*/
 3613|  17.0k|	iasecc_ops.get_challenge = iasecc_get_challenge;
 3614|  17.0k|	iasecc_ops.logout = iasecc_logout;
 3615|       |	/*	restore_security_env	*/
 3616|  17.0k|	iasecc_ops.set_security_env = iasecc_set_security_env;
 3617|  17.0k|	iasecc_ops.decipher = iasecc_decipher;
 3618|  17.0k|	iasecc_ops.compute_signature = iasecc_compute_signature;
 3619|  17.0k|	iasecc_ops.create_file = iasecc_create_file;
 3620|  17.0k|	iasecc_ops.delete_file = iasecc_delete_file;
 3621|       |	/*	list_files	*/
 3622|  17.0k|	iasecc_ops.check_sw = iasecc_check_sw;
 3623|  17.0k|	iasecc_ops.card_ctl = iasecc_card_ctl;
 3624|  17.0k|	iasecc_ops.process_fci = iasecc_process_fci;
 3625|       |	/*	construct_fci: Not needed	*/
 3626|  17.0k|	iasecc_ops.pin_cmd = iasecc_pin_cmd;
 3627|       |	/*	get_data: Not implemented	*/
 3628|       |	/*	put_data: Not implemented	*/
 3629|       |	/*	delete_record: Not implemented	*/
 3630|       |
 3631|  17.0k|	iasecc_ops.read_public_key = iasecc_read_public_key;
 3632|       |
 3633|  17.0k|	return &iasecc_drv;
 3634|  17.0k|}
card-iasecc.c:iasecc_match_card:
  353|  12.3k|{
  354|  12.3k|	struct sc_context *ctx = card->ctx;
  355|  12.3k|	int i;
  356|       |
  357|  12.3k|	i = _sc_match_atr(card, iasecc_known_atrs, &card->type);
  358|  12.3k|	if (i < 0)   {
  ------------------
  |  Branch (358:6): [True: 11.3k, False: 932]
  ------------------
  359|  11.3k|		sc_log(ctx, "card not matched");
  ------------------
  |  |   71|  11.3k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  360|  11.3k|		return 0;
  361|  11.3k|	}
  362|       |
  363|    932|	sc_log(ctx, "'%s' card matched", iasecc_known_atrs[i].name);
  ------------------
  |  |   71|    932|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  364|    932|	return 1;
  365|  12.3k|}
card-iasecc.c:iasecc_init:
  624|    932|{
  625|    932|	struct sc_context *ctx = card->ctx;
  626|    932|	struct iasecc_private_data *private_data = NULL;
  627|    932|	int rv = SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|    932|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
  628|    932|	void *old_drv_data = card->drv_data;
  629|       |
  630|    932|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    932|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    932|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    932|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    932|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 932]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|    932|	private_data = (struct iasecc_private_data *) calloc(1, sizeof(struct iasecc_private_data));
  632|    932|	if (private_data == NULL)
  ------------------
  |  Branch (632:6): [True: 0, False: 932]
  ------------------
  633|    932|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  634|       |
  635|    932|	card->cla  = 0x00;
  636|    932|	card->drv_data = private_data;
  637|       |
  638|    932|	if (card->type == SC_CARD_TYPE_IASECC_GEMALTO)
  ------------------
  |  Branch (638:6): [True: 118, False: 814]
  ------------------
  639|    118|		rv = iasecc_init_gemalto(card);
  640|    814|	else if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)
  ------------------
  |  Branch (640:11): [True: 46, False: 768]
  ------------------
  641|     46|		rv = iasecc_init_oberthur(card);
  642|    768|	else if (card->type == SC_CARD_TYPE_IASECC_SAGEM)
  ------------------
  |  Branch (642:11): [True: 596, False: 172]
  ------------------
  643|    596|		rv = iasecc_init_amos_or_sagem(card);
  644|    172|	else if (card->type == SC_CARD_TYPE_IASECC_AMOS)
  ------------------
  |  Branch (644:11): [True: 0, False: 172]
  ------------------
  645|      0|		rv = iasecc_init_amos_or_sagem(card);
  646|    172|	else if (card->type == SC_CARD_TYPE_IASECC_MI)
  ------------------
  |  Branch (646:11): [True: 0, False: 172]
  ------------------
  647|      0|		rv = iasecc_init_amos_or_sagem(card);
  648|    172|	else if (iasecc_is_cpx(card))
  ------------------
  |  Branch (648:11): [True: 172, False: 0]
  ------------------
  649|    172|		rv = iasecc_init_cpx(card);
  650|      0|	else {
  651|      0|		LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INVALID_CARD, "");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|      0|	}
  653|       |
  654|       |
  655|    932|	if (!rv)   {
  ------------------
  |  Branch (655:6): [True: 630, False: 302]
  ------------------
  656|    630|		if (card->ef_atr && card->ef_atr->aid.len)   {
  ------------------
  |  Branch (656:7): [True: 630, False: 0]
  |  Branch (656:23): [True: 28, False: 602]
  ------------------
  657|     28|			struct sc_path path;
  658|       |
  659|     28|			memset(&path, 0, sizeof(struct sc_path));
  660|     28|			path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|     28|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  661|     28|			memcpy(path.value, card->ef_atr->aid.value, card->ef_atr->aid.len);
  662|     28|			path.len = card->ef_atr->aid.len;
  663|       |
  664|     28|			rv = iasecc_select_file(card, &path, NULL);
  665|     28|			sc_log(ctx, "Select ECC ROOT with the AID from EF.ATR: rv %i", rv);
  ------------------
  |  |   71|     28|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  666|     28|			LOG_TEST_GOTO_ERR(ctx, rv, "Select EF.ATR AID failed");
  ------------------
  |  |  184|     28|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     28|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     28|	int _ret = (r); \
  |  |  |  |  178|     28|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  179|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      3|		goto err; \
  |  |  |  |  182|      3|	} \
  |  |  |  |  183|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  667|     28|		}
  668|       |
  669|    627|		iasecc_get_serialnr(card, NULL);
  670|    627|	}
  671|       |
  672|    929|#ifdef ENABLE_SM
  673|    929|	card->sm_ctx.ops.read_binary = _iasecc_sm_read_binary;
  674|    929|	card->sm_ctx.ops.update_binary = _iasecc_sm_update_binary;
  675|    929|#endif
  676|       |
  677|    929|	if (!rv && card->ef_atr && card->ef_atr->aid.len)   {
  ------------------
  |  Branch (677:6): [True: 627, False: 302]
  |  Branch (677:13): [True: 627, False: 0]
  |  Branch (677:29): [True: 25, False: 602]
  ------------------
  678|     25|		sc_log(ctx, "EF.ATR(aid:'%s')", sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len));
  ------------------
  |  |   71|     25|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  679|     25|	}
  680|       |
  681|    932|err:
  682|    932|	if (rv < 0) {
  ------------------
  |  Branch (682:6): [True: 305, False: 627]
  ------------------
  683|    305|		sc_invalidate_cache(card);
  684|    305|		free(private_data);
  685|    305|		card->drv_data = old_drv_data;
  686|    627|	} else {
  687|    627|		free(old_drv_data);
  688|    627|	}
  689|       |
  690|    932|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    932|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    932|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    932|	int _ret = r; \
  |  |  |  |  155|    932|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 932, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    932|		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|    305|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 305, False: 627]
  |  |  |  |  ------------------
  |  |  |  |  157|    932|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    932|	} 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|    932|	return _ret; \
  |  |  |  |  163|    932|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  691|    932|}
card-iasecc.c:iasecc_init_gemalto:
  419|    118|{
  420|    118|	struct sc_context *ctx = card->ctx;
  421|    118|	struct sc_path path;
  422|    118|	unsigned int flags;
  423|    118|	int rv = 0;
  424|       |
  425|    118|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    118|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    118|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    118|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    118|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|       |
  427|    118|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|    118|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|    118|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|    118|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|    118|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|    118|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|    118|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|    118|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|    118|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    118|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|    118|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|    118|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|    118|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|    118|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|    118|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|    118|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  428|       |
  429|    118|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|    118|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|    118|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  550|    118|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|    118|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  547|    118|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|    118|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  557|    118|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|    118|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  553|    118|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  430|       |
  431|    118|	sc_format_path("3F00", &path);
  432|    118|	if (SC_SUCCESS != sc_select_file(card, &path, NULL)) {
  ------------------
  |  |   28|    118|#define SC_SUCCESS				0
  ------------------
  |  Branch (432:6): [True: 93, False: 25]
  ------------------
  433|       |		/* Result ignored*/
  434|     93|		sc_log(card->ctx, "Warning, MF select failed");
  ------------------
  |  |   71|     93|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  435|     93|	}
  436|       |
  437|    118|	rv = iasecc_parse_ef_atr(card);
  438|    118|	sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   71|    118|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  439|    118|	if (rv == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|    118|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (439:6): [True: 2, False: 116]
  ------------------
  440|      2|		sc_log(ctx, "Select MF");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  441|      2|		rv = iasecc_select_mf(card, NULL);
  442|      2|		sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  443|      2|		LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|       |
  445|      1|		rv = iasecc_parse_ef_atr(card);
  446|      1|		sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  447|      1|	}
  448|    117|	sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   71|    117|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  449|    117|	LOG_TEST_RET(ctx, rv, "Cannot read/parse EF.ATR");
  ------------------
  |  |  174|    117|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    117|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    117|	int _ret = (r); \
  |  |  |  |  168|    117|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 57, False: 60]
  |  |  |  |  ------------------
  |  |  |  |  169|     57|		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|     57|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     57|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     57|		return _ret; \
  |  |  |  |  172|     57|	} \
  |  |  |  |  173|    117|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  450|       |
  451|     60|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  452|     60|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  453|       |
  454|     60|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     60|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     60|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     60|	int _ret = r; \
  |  |  |  |  155|     60|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 60, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     60|		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: 60]
  |  |  |  |  ------------------
  |  |  |  |  157|     60|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     60|	} 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|     60|	return _ret; \
  |  |  |  |  163|     60|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  455|     60|}
card-iasecc.c:iasecc_parse_ef_atr:
  369|    965|{
  370|    965|	struct sc_context *ctx = card->ctx;
  371|    965|	struct iasecc_private_data *pdata = (struct iasecc_private_data *) card->drv_data;
  372|    965|	struct iasecc_version *version = &pdata->version;
  373|    965|	struct iasecc_io_buffer_sizes *sizes = &pdata->max_sizes;
  374|    965|	int rv;
  375|       |
  376|    965|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    965|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    965|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    965|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    965|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 965]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  377|    965|	rv = sc_parse_ef_atr(card);
  378|    965|	LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|    965|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    965|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    965|	int _ret = (r); \
  |  |  |  |  168|    965|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 230, False: 735]
  |  |  |  |  ------------------
  |  |  |  |  169|    230|		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|    230|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    230|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    230|		return _ret; \
  |  |  |  |  172|    230|	} \
  |  |  |  |  173|    965|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 735]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  379|       |
  380|    735|	if (card->ef_atr->pre_issuing_len < 4)
  ------------------
  |  Branch (380:6): [True: 101, False: 634]
  ------------------
  381|    735|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid pre-issuing data");
  ------------------
  |  |  174|    101|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    101|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    101|	int _ret = (r); \
  |  |  |  |  168|    101|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 101, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    101|		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|    101|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    101|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    101|		return _ret; \
  |  |  |  |  172|    101|	} \
  |  |  |  |  173|    101|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|       |
  383|    634|	version->ic_manufacturer =	card->ef_atr->pre_issuing[0];
  384|    634|	version->ic_type =		card->ef_atr->pre_issuing[1];
  385|    634|	version->os_version =		card->ef_atr->pre_issuing[2];
  386|    634|	version->iasecc_version =	card->ef_atr->pre_issuing[3];
  387|    634|	sc_log(ctx, "EF.ATR: IC manufacturer/type %X/%X, OS/IasEcc versions %X/%X",
  ------------------
  |  |   71|    634|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  388|    634|		version->ic_manufacturer, version->ic_type, version->os_version, version->iasecc_version);
  389|       |
  390|    634|	if (card->ef_atr->issuer_data_len < 16)
  ------------------
  |  Branch (390:6): [True: 4, False: 630]
  ------------------
  391|    634|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid issuer data");
  ------------------
  |  |  174|      4|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      4|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      4|	int _ret = (r); \
  |  |  |  |  168|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      4|		return _ret; \
  |  |  |  |  172|      4|	} \
  |  |  |  |  173|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|       |
  393|    630|	sizes->send =	 card->ef_atr->issuer_data[2] * 0x100 + card->ef_atr->issuer_data[3];
  394|    630|	sizes->send_sc = card->ef_atr->issuer_data[6] * 0x100 + card->ef_atr->issuer_data[7];
  395|    630|	sizes->recv =	 card->ef_atr->issuer_data[10] * 0x100 + card->ef_atr->issuer_data[11];
  396|    630|	sizes->recv_sc = card->ef_atr->issuer_data[14] * 0x100 + card->ef_atr->issuer_data[15];
  397|       |
  398|    630|	sc_log(ctx, "EF.ATR: IO Buffer Size send/sc %zd/%zd recv/sc %zd/%zd",
  ------------------
  |  |   71|    630|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  399|    630|			sizes->send, sizes->send_sc, sizes->recv, sizes->recv_sc);
  400|       |
  401|    630|	card->max_send_size = sizes->send;
  402|    630|	card->max_recv_size = sizes->recv;
  403|       |
  404|       |	/* Most of the card producers interpret 'send' values as "maximum APDU data size".
  405|       |	 * Oberthur strictly follows specification and interpret these values as "maximum APDU command size".
  406|       |	 * Here we need 'data size'.
  407|       |	 */
  408|    630|	if (card->max_send_size > 0xFF)
  ------------------
  |  Branch (408:6): [True: 275, False: 355]
  ------------------
  409|    275|		card->max_send_size -= 5;
  410|       |
  411|    630|	sc_log(ctx, "EF.ATR: max send/recv sizes %zX/%zX", card->max_send_size, card->max_recv_size);
  ------------------
  |  |   71|    630|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  412|       |
  413|    630|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    630|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    630|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    630|	int _ret = r; \
  |  |  |  |  155|    630|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 630, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    630|		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: 630]
  |  |  |  |  ------------------
  |  |  |  |  157|    630|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    630|	} 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|    630|	return _ret; \
  |  |  |  |  163|    630|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  414|    630|}
card-iasecc.c:iasecc_init_oberthur:
  488|     46|{
  489|     46|	struct sc_context *ctx = card->ctx;
  490|     46|	unsigned int flags;
  491|     46|	int rv = 0;
  492|       |
  493|     46|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     46|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     46|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     46|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     46|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|       |
  495|     46|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|     46|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|     46|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|     46|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|     46|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|     46|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|     46|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|     46|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|     46|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|     46|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|     46|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|     46|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|     46|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|     46|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|     46|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|     46|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  496|       |
  497|     46|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  498|     46|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  499|       |
  500|     46|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|     46|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|     46|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  550|     46|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|     46|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  547|     46|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|     46|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  557|     46|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|     46|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  553|     46|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  501|       |
  502|     46|	iasecc_parse_ef_atr(card);
  503|       |
  504|       |	/* if we fail to select CM, */
  505|     46|	if (gp_select_card_manager(card)) {
  ------------------
  |  Branch (505:6): [True: 21, False: 25]
  ------------------
  506|     21|		gp_select_isd_rid(card);
  507|     21|	}
  508|       |
  509|     46|	rv = iasecc_oberthur_match(card);
  510|     46|	LOG_TEST_RET(ctx, rv, "unknown Oberthur's IAS/ECC card");
  ------------------
  |  |  174|     46|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     46|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     46|	int _ret = (r); \
  |  |  |  |  168|     46|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 46]
  |  |  |  |  ------------------
  |  |  |  |  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|     46|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  511|       |
  512|     46|	rv = iasecc_select_mf(card, NULL);
  513|     46|	LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|     46|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     46|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     46|	int _ret = (r); \
  |  |  |  |  168|     46|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 18, False: 28]
  |  |  |  |  ------------------
  |  |  |  |  169|     18|		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|     18|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     18|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     18|		return _ret; \
  |  |  |  |  172|     18|	} \
  |  |  |  |  173|     46|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  514|       |
  515|     28|	rv = iasecc_parse_ef_atr(card);
  516|     28|	LOG_TEST_RET(ctx, rv, "EF.ATR read or parse error");
  ------------------
  |  |  174|     28|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     28|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     28|	int _ret = (r); \
  |  |  |  |  168|     28|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  517|       |
  518|     14|	sc_log(ctx, "EF.ATR(aid:'%s')", sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len));
  ------------------
  |  |   71|     14|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  519|     14|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		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: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} 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|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  520|     14|}
card-iasecc.c:iasecc_oberthur_match:
  460|     46|{
  461|     46|	struct sc_context *ctx = card->ctx;
  462|     46|	unsigned char *hist = card->reader->atr_info.hist_bytes;
  463|       |
  464|     46|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     46|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     46|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     46|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     46|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  465|       |
  466|     46|	if (*hist != 0x80 || ((*(hist+1)&0xF0) != 0xF0))
  ------------------
  |  Branch (466:6): [True: 0, False: 46]
  |  Branch (466:23): [True: 0, False: 46]
  ------------------
  467|     46|		LOG_FUNC_RETURN(ctx, SC_ERROR_OBJECT_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  468|       |
  469|     46|	sc_log_hex(ctx, "AID in historical_bytes", hist + 2, *(hist+1) & 0x0F);
  ------------------
  |  |  129|     46|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     46|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|       |
  471|     46|	if (memcmp(hist + 2, OberthurIASECC_AID.value, *(hist+1) & 0x0F))
  ------------------
  |  Branch (471:6): [True: 0, False: 46]
  ------------------
  472|     46|		LOG_FUNC_RETURN(ctx, SC_ERROR_RECORD_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|       |
  474|     46|	if (!card->ef_atr)
  ------------------
  |  Branch (474:6): [True: 42, False: 4]
  ------------------
  475|     42|		card->ef_atr = calloc(1, sizeof(struct sc_ef_atr));
  476|     46|	if (!card->ef_atr)
  ------------------
  |  Branch (476:6): [True: 0, False: 46]
  ------------------
  477|     46|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  478|       |
  479|     46|	memcpy(card->ef_atr->aid.value, OberthurIASECC_AID.value, OberthurIASECC_AID.len);
  480|     46|	card->ef_atr->aid.len = OberthurIASECC_AID.len;
  481|       |
  482|     46|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     46|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     46|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     46|	int _ret = r; \
  |  |  |  |  155|     46|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 46, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     46|		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: 46]
  |  |  |  |  ------------------
  |  |  |  |  157|     46|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     46|	} 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|     46|	return _ret; \
  |  |  |  |  163|     46|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|     46|}
card-iasecc.c:iasecc_init_amos_or_sagem:
  550|    596|{
  551|    596|	struct sc_context *ctx = card->ctx;
  552|    596|	unsigned int flags;
  553|    596|	int rv = 0;
  554|       |
  555|    596|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    596|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    596|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    596|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    596|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 596]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|       |
  557|    596|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|    596|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|    596|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|    596|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|    596|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|    596|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|    596|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|    596|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|    596|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    596|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|    596|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|    596|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|    596|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|    596|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|    596|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|    596|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  558|       |
  559|    596|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  560|    596|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  561|       |
  562|    596|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|    596|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|    596|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  550|    596|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|    596|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  547|    596|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|    596|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  557|    596|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|    596|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  553|    596|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  563|       |
  564|    596|	if (card->type == SC_CARD_TYPE_IASECC_MI)   {
  ------------------
  |  Branch (564:6): [True: 0, False: 596]
  ------------------
  565|      0|		rv = iasecc_mi_match(card);
  566|      0|		if (rv)
  ------------------
  |  Branch (566:7): [True: 0, False: 0]
  ------------------
  567|      0|			card->type = SC_CARD_TYPE_IASECC_MI2;
  568|      0|		else
  569|      0|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  570|      0|	}
  571|       |
  572|    596|	rv = iasecc_parse_ef_atr(card);
  573|    596|	if (rv == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|    596|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (573:6): [True: 10, False: 586]
  ------------------
  574|     10|		rv = iasecc_select_mf(card, NULL);
  575|     10|		LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  576|       |
  577|      4|		rv = iasecc_parse_ef_atr(card);
  578|      4|	}
  579|    590|	LOG_TEST_RET(ctx, rv, "IASECC: ATR parse failed");
  ------------------
  |  |  174|    590|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    590|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    590|	int _ret = (r); \
  |  |  |  |  168|    590|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 112, False: 478]
  |  |  |  |  ------------------
  |  |  |  |  169|    112|		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|    112|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    112|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    112|		return _ret; \
  |  |  |  |  172|    112|	} \
  |  |  |  |  173|    590|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 478]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  580|       |
  581|    478|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    478|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    478|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    478|	int _ret = r; \
  |  |  |  |  155|    478|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 478, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    478|		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: 478]
  |  |  |  |  ------------------
  |  |  |  |  157|    478|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    478|	} 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|    478|	return _ret; \
  |  |  |  |  163|    478|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  582|    478|}
card-iasecc.c:iasecc_init_cpx:
  600|    172|{
  601|    172|	struct sc_context *ctx = card->ctx;
  602|    172|	unsigned int flags;
  603|    172|	int rv = 0;
  604|       |
  605|    172|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    172|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    172|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    172|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    172|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 172]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  606|       |
  607|    172|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|    172|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|    172|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  550|    172|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|    172|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  547|    172|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|    172|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  557|    172|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|    172|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  553|    172|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  608|       |
  609|    172|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|    172|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|    172|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |   93|    172|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|    172|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  106|    172|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|    172|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  111|    172|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|    172|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|    172|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|    172|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  133|    172|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|    172|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  134|    172|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|    172|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  138|    172|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  610|       |
  611|    172|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  612|    172|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  613|    172|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  614|       |
  615|    172|	rv = iasecc_parse_ef_atr(card);
  616|    172|	LOG_TEST_RET(ctx, rv, "Parse EF.ATR");
  ------------------
  |  |  174|    172|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    172|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    172|	int _ret = (r); \
  |  |  |  |  168|    172|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 94, False: 78]
  |  |  |  |  ------------------
  |  |  |  |  169|     94|		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|     94|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     94|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     94|		return _ret; \
  |  |  |  |  172|     94|	} \
  |  |  |  |  173|    172|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 78]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|       |
  618|     78|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     78|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     78|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     78|	int _ret = r; \
  |  |  |  |  155|     78|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 78, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     78|		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: 78]
  |  |  |  |  ------------------
  |  |  |  |  157|     78|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     78|	} 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|     78|	return _ret; \
  |  |  |  |  163|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  619|     78|}
card-iasecc.c:iasecc_get_serialnr:
 2464|    979|{
 2465|    979|	struct sc_context *ctx = card->ctx;
 2466|    979|	struct sc_iin *iin = &card->serialnr.iin;
 2467|    979|	struct sc_apdu apdu;
 2468|    979|	unsigned char rbuf[0xC0];
 2469|    979|	size_t ii, offs, len;
 2470|    979|	int rv;
 2471|       |
 2472|    979|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    979|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    979|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    979|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    979|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 979]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2473|    979|	if (card->serialnr.len)
  ------------------
  |  Branch (2473:6): [True: 7, False: 972]
  ------------------
 2474|      7|		goto end;
 2475|       |
 2476|    972|	memset(&card->serialnr, 0, sizeof(card->serialnr));
 2477|       |
 2478|    972|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, 0x80 | IASECC_SFI_EF_SN, 0);
  ------------------
  |  |  292|    972|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
              	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, 0x80 | IASECC_SFI_EF_SN, 0);
  ------------------
  |  |   73|    972|#define IASECC_SFI_EF_SN	0x1C
  ------------------
 2479|    972|	apdu.le = sizeof(rbuf);
 2480|    972|	apdu.resp = rbuf;
 2481|    972|	apdu.resplen = sizeof(rbuf);
 2482|       |
 2483|    972|	rv = sc_transmit_apdu(card, &apdu);
 2484|    972|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    972|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    972|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    972|	int _ret = (r); \
  |  |  |  |  168|    972|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 963]
  |  |  |  |  ------------------
  |  |  |  |  169|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      9|		return _ret; \
  |  |  |  |  172|      9|	} \
  |  |  |  |  173|    972|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 963]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2485|    963|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2486|    963|	LOG_TEST_RET(ctx, rv, "Get 'serial number' data failed");
  ------------------
  |  |  174|    963|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    963|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    963|	int _ret = (r); \
  |  |  |  |  168|    963|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 634, False: 329]
  |  |  |  |  ------------------
  |  |  |  |  169|    634|		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|    634|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    634|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    634|		return _ret; \
  |  |  |  |  172|    634|	} \
  |  |  |  |  173|    963|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 329]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2487|       |
 2488|    329|	if (apdu.resplen < 2 || rbuf[0] != ISO7812_PAN_SN_TAG || rbuf[1] > (apdu.resplen-2))
  ------------------
  |  |   29|    370|#define ISO7812_PAN_SN_TAG	0x5A
  ------------------
  |  Branch (2488:6): [True: 288, False: 41]
  |  Branch (2488:26): [True: 24, False: 17]
  |  Branch (2488:59): [True: 1, False: 16]
  ------------------
 2489|    329|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "serial number parse error");
  ------------------
  |  |  174|    313|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    313|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    313|	int _ret = (r); \
  |  |  |  |  168|    313|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 313, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    313|		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|    313|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    313|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    313|		return _ret; \
  |  |  |  |  172|    313|	} \
  |  |  |  |  173|    313|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2490|     16|	len = rbuf[1];
 2491|       |
 2492|     16|	iin->mii = (rbuf[2] >> 4) & 0x0F;
 2493|       |
 2494|     16|	iin->country = 0;
 2495|     64|	for (ii=5; ii<8; ii++)   {
  ------------------
  |  Branch (2495:13): [True: 48, False: 16]
  ------------------
 2496|     48|		iin->country *= 10;
 2497|     48|		iin->country += (rbuf[ii/2] >> ((ii & 0x01) ? 0 : 4)) & 0x0F;
  ------------------
  |  Branch (2497:35): [True: 32, False: 16]
  ------------------
 2498|     48|	}
 2499|       |
 2500|     16|	iin->issuer_id = 0;
 2501|     48|	for (ii=8; ii<10; ii++)   {
  ------------------
  |  Branch (2501:13): [True: 32, False: 16]
  ------------------
 2502|     32|		iin->issuer_id *= 10;
 2503|     32|		iin->issuer_id += (rbuf[ii/2] >> (ii & 0x01 ? 0 : 4)) & 0x0F;
  ------------------
  |  Branch (2503:37): [True: 16, False: 16]
  ------------------
 2504|     32|	}
 2505|       |
 2506|       |	/* Copy the serial number from the last 8 bytes (at most) */
 2507|     16|	offs = len > 8 ? len - 8 : 0;
  ------------------
  |  Branch (2507:9): [True: 5, False: 11]
  ------------------
 2508|     16|	if (card->type == SC_CARD_TYPE_IASECC_SAGEM)   {
  ------------------
  |  Branch (2508:6): [True: 6, False: 10]
  ------------------
 2509|       |		/* 5A 0A 92 50 00 20 10 10 25 00 01 3F */
 2510|       |		/*            00 02 01 01 02 50 00 13  */
 2511|     26|		for (ii=0; ii < len - offs; ii++)
  ------------------
  |  Branch (2511:14): [True: 20, False: 6]
  ------------------
 2512|     20|			*(card->serialnr.value + ii) = ((rbuf[ii + offs + 1] & 0x0F) << 4)
 2513|     20|				+ ((rbuf[ii + offs + 2] & 0xF0) >> 4) ;
 2514|      6|		card->serialnr.len = ii;
 2515|      6|	}
 2516|     10|	else   {
 2517|     62|		for (ii=0; ii < len - offs; ii++)
  ------------------
  |  Branch (2517:14): [True: 52, False: 10]
  ------------------
 2518|     52|			*(card->serialnr.value + ii) = rbuf[ii + offs + 2];
 2519|     10|		card->serialnr.len = ii;
 2520|     10|	}
 2521|       |
 2522|     16|	do  {
 2523|     16|		char txt[0x200];
 2524|       |
 2525|     88|		for (ii=0;ii<card->serialnr.len;ii++)
  ------------------
  |  Branch (2525:13): [True: 72, False: 16]
  ------------------
 2526|     72|			sprintf(txt + ii*2, "%02X", *(card->serialnr.value + ii));
 2527|       |
 2528|     16|		sc_log(ctx, "serial number '%s'; mii %i; country %i; issuer_id %li", txt, iin->mii, iin->country, iin->issuer_id);
  ------------------
  |  |   71|     16|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2529|     16|	} while(0);
  ------------------
  |  Branch (2529:10): [Folded, False: 16]
  ------------------
 2530|       |
 2531|     23|end:
 2532|     23|	if (serial)
  ------------------
  |  Branch (2532:6): [True: 10, False: 13]
  ------------------
 2533|     10|		memcpy(serial, &card->serialnr, sizeof(*serial));
 2534|       |
 2535|     23|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     23|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     23|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     23|	int _ret = r; \
  |  |  |  |  155|     23|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     23|		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: 23]
  |  |  |  |  ------------------
  |  |  |  |  157|     23|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     23|	} 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|     23|	return _ret; \
  |  |  |  |  163|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2536|     23|}
card-iasecc.c:_iasecc_sm_read_binary:
  760|    215|{
  761|    215|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  762|    215|	struct sc_context *ctx = card->ctx;
  763|    215|	const struct sc_acl_entry *entry = NULL;
  764|    215|	int rv;
  765|       |
  766|    215|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    215|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    215|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    215|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    215|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 215]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  767|    215|	sc_log(ctx, "iasecc_sm_read_binary() card:%p offs:%i count:%zu ", card, offs, count);
  ------------------
  |  |   71|    215|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  768|    215|	if (offs > 0x7fff)
  ------------------
  |  Branch (768:6): [True: 0, False: 215]
  ------------------
  769|    215|		LOG_TEST_RET(ctx, SC_ERROR_OFFSET_TOO_LARGE, "Invalid arguments");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  770|       |
  771|    215|	if (count == 0)
  ------------------
  |  Branch (771:6): [True: 0, False: 215]
  ------------------
  772|      0|		return 0;
  773|       |
  774|    215|	if (prv->cache.valid && prv->cache.current_ef) {
  ------------------
  |  Branch (774:6): [True: 215, False: 0]
  |  Branch (774:26): [True: 214, False: 1]
  ------------------
  775|    214|		entry = sc_file_get_acl_entry(prv->cache.current_ef, SC_AC_OP_READ);
  ------------------
  |  |  188|    214|#define SC_AC_OP_READ			22
  ------------------
  776|    214|		if (!entry)
  ------------------
  |  Branch (776:7): [True: 28, False: 186]
  ------------------
  777|    214|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "iasecc_sm_read() 'READ' ACL not present");
  ------------------
  |  |  174|     28|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     28|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     28|	int _ret = (r); \
  |  |  |  |  168|     28|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 28, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     28|		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|     28|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     28|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     28|		return _ret; \
  |  |  |  |  172|     28|	} \
  |  |  |  |  173|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|       |
  779|    186|		sc_log(ctx, "READ method/reference %X/%X", entry->method, entry->key_ref);
  ------------------
  |  |   71|    186|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  780|    186|		if ((entry->method == SC_AC_SCB) && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |  157|    186|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
              		if ((entry->method == SC_AC_SCB) && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |   91|    161|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
  |  Branch (780:7): [True: 161, False: 25]
  |  Branch (780:39): [True: 153, False: 8]
  ------------------
  781|    153|			unsigned char se_num = entry->key_ref & IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|    153|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
  782|       |
  783|    153|			rv = iasecc_sm_read_binary(card, se_num, offs, buff, count);
  784|    153|			LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    153|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    153|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    153|	int _ret = r; \
  |  |  |  |  155|    153|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 153, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    153|		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|    153|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 153, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    153|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    153|	} 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|    153|	return _ret; \
  |  |  |  |  163|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  785|    153|		}
  786|    186|	}
  787|       |
  788|     34|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     34|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     34|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     34|	int _ret = r; \
  |  |  |  |  155|     34|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 34, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     34|		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: 34]
  |  |  |  |  ------------------
  |  |  |  |  157|     34|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     34|	} 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|     34|	return _ret; \
  |  |  |  |  163|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  789|     34|}
card-iasecc.c:iasecc_finish:
 1414|    627|{
 1415|    627|	struct sc_context *ctx = card->ctx;
 1416|    627|	struct iasecc_private_data *private_data = (struct iasecc_private_data *)card->drv_data;
 1417|    627|	struct iasecc_se_info *se_info = private_data->se_info, *next;
 1418|       |
 1419|    627|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    627|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    627|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    627|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    627|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 627]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1420|       |
 1421|    627|	sc_invalidate_cache(card);
 1422|       |
 1423|    641|	while (se_info)   {
  ------------------
  |  Branch (1423:9): [True: 14, False: 627]
  ------------------
 1424|     14|		sc_file_free(se_info->df);
 1425|     14|		next = se_info->next;
 1426|     14|		free(se_info);
 1427|     14|		se_info = next;
 1428|     14|	}
 1429|       |
 1430|    627|	free(card->drv_data);
 1431|    627|	card->drv_data = NULL;
 1432|       |
 1433|    627|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    627|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    627|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    627|	int _ret = r; \
  |  |  |  |  155|    627|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 627, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    627|		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: 627]
  |  |  |  |  ------------------
  |  |  |  |  157|    627|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    627|	} 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|    627|	return _ret; \
  |  |  |  |  163|    627|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1434|    627|}
card-iasecc.c:iasecc_read_binary:
  697|  2.38k|{
  698|  2.38k|	struct sc_context *ctx = card->ctx;
  699|  2.38k|	struct sc_apdu apdu;
  700|  2.38k|	int rv;
  701|       |
  702|  2.38k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.38k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.38k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.38k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.38k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.38k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  703|  2.38k|	sc_log(ctx, "iasecc_read_binary(card:%p) offs %i; count %zu", card, offs, count);
  ------------------
  |  |   71|  2.38k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  704|  2.38k|	if (offs > 0x7fff) {
  ------------------
  |  Branch (704:6): [True: 1, False: 2.37k]
  ------------------
  705|      1|		sc_log(ctx, "invalid EF offset: 0x%X > 0x7FFF", offs);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  706|      1|		return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      1|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
  707|      1|	}
  708|       |
  709|  2.37k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, (offs >> 8) & 0x7F, offs & 0xFF);
  ------------------
  |  |  292|  2.37k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  710|  2.37k|	apdu.le = count < 0x100 ? count : 0x100;
  ------------------
  |  Branch (710:12): [True: 277, False: 2.10k]
  ------------------
  711|  2.37k|	apdu.resplen = count;
  712|  2.37k|	apdu.resp = buf;
  713|       |
  714|  2.37k|	rv = sc_transmit_apdu(card, &apdu);
  715|  2.37k|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  2.37k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.37k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.37k|	int _ret = (r); \
  |  |  |  |  168|  2.37k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 2.36k]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|  2.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.36k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  716|  2.36k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  717|  2.36k|	LOG_TEST_RET(ctx, rv, "iasecc_read_binary() failed");
  ------------------
  |  |  174|  2.36k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.36k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.36k|	int _ret = (r); \
  |  |  |  |  168|  2.36k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 577, False: 1.78k]
  |  |  |  |  ------------------
  |  |  |  |  169|    577|		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|    577|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    577|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    577|		return _ret; \
  |  |  |  |  172|    577|	} \
  |  |  |  |  173|  2.36k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  718|  1.78k|	sc_log(ctx, "iasecc_read_binary() apdu.resplen %zu", apdu.resplen);
  ------------------
  |  |   71|  1.78k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  719|       |
  720|  1.78k|	if (apdu.resplen == IASECC_READ_BINARY_LENGTH_MAX && apdu.resplen < count)   {
  ------------------
  |  |   76|  3.57k|#define IASECC_READ_BINARY_LENGTH_MAX	0xE7
  ------------------
  |  Branch (720:6): [True: 32, False: 1.75k]
  |  Branch (720:55): [True: 31, False: 1]
  ------------------
  721|     31|		rv = iasecc_read_binary(card, (int)(offs + apdu.resplen), buf + apdu.resplen, count - apdu.resplen, flags);
  722|     31|		if (rv != SC_ERROR_WRONG_LENGTH)   {
  ------------------
  |  |   56|     31|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  |  Branch (722:7): [True: 30, False: 1]
  ------------------
  723|     30|			LOG_TEST_RET(ctx, rv, "iasecc_read_binary() read tail failed");
  ------------------
  |  |  174|     30|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     30|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     30|	int _ret = (r); \
  |  |  |  |  168|     30|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 16, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  169|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     16|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     16|		return _ret; \
  |  |  |  |  172|     16|	} \
  |  |  |  |  173|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  724|     14|			apdu.resplen += rv;
  725|     14|		}
  726|     31|	}
  727|       |
  728|  1.77k|	LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  164|  1.77k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.77k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.77k|	int _ret = r; \
  |  |  |  |  155|  1.77k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 243, False: 1.52k]
  |  |  |  |  ------------------
  |  |  |  |  156|    243|		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: 243]
  |  |  |  |  ------------------
  |  |  |  |  157|    243|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.52k|	} else { \
  |  |  |  |  159|  1.52k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.52k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.52k|	} \
  |  |  |  |  162|  1.77k|	return _ret; \
  |  |  |  |  163|  1.77k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  729|  1.77k|}
card-iasecc.c:iasecc_get_challenge:
 1367|    475|{
 1368|       |	/* As IAS/ECC cannot handle other data length than 0x08 */
 1369|    475|	u8 rbuf[8];
 1370|    475|	size_t out_len;
 1371|    475|	int r;
 1372|       |
 1373|    475|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    475|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    475|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    475|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    475|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 475]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1374|       |
 1375|    475|	r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
 1376|    475|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE cmd failed");
  ------------------
  |  |  174|    475|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    475|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    475|	int _ret = (r); \
  |  |  |  |  168|    475|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 277, False: 198]
  |  |  |  |  ------------------
  |  |  |  |  169|    277|		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|    277|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    277|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    277|		return _ret; \
  |  |  |  |  172|    277|	} \
  |  |  |  |  173|    475|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 198]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1377|       |
 1378|    198|	if (len < (size_t) r) {
  ------------------
  |  Branch (1378:6): [True: 1, False: 197]
  ------------------
 1379|      1|		out_len = len;
 1380|    197|	} else {
 1381|    197|		out_len = (size_t) r;
 1382|    197|	}
 1383|    198|	memcpy(rnd, rbuf, out_len);
 1384|       |
 1385|    198|	LOG_FUNC_RETURN(card->ctx, (int) out_len);
  ------------------
  |  |  164|    198|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    198|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    198|	int _ret = r; \
  |  |  |  |  155|    198|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 195]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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: 3]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    195|	} else { \
  |  |  |  |  159|    195|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    195|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    195|	} \
  |  |  |  |  162|    198|	return _ret; \
  |  |  |  |  163|    198|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1386|    198|}
card-iasecc.c:iasecc_sdo_get_data:
 2848|    314|{
 2849|    314|	struct sc_context *ctx = card->ctx;
 2850|    314|	int rv, sdo_tag;
 2851|       |
 2852|    314|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    314|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    314|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    314|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    314|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 314]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2853|       |
 2854|    314|	sdo_tag = iasecc_sdo_tag_from_class(sdo->sdo_class);
 2855|       |
 2856|    314|	rv = iasecc_sdo_get_tagged_data(card, sdo_tag, sdo);
 2857|       |	/* When there is no public data 'GET DATA' returns error */
 2858|    314|	if (rv != SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   55|    314|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (2858:6): [True: 305, False: 9]
  ------------------
 2859|    314|		LOG_TEST_RET(ctx, rv, "cannot parse ECC SDO data");
  ------------------
  |  |  174|    305|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    305|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    305|	int _ret = (r); \
  |  |  |  |  168|    305|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 300, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  169|    300|		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|    300|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    300|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    300|		return _ret; \
  |  |  |  |  172|    300|	} \
  |  |  |  |  173|    305|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2860|       |
 2861|     14|	rv = iasecc_sdo_get_tagged_data(card, IASECC_DOCP_TAG, sdo);
  ------------------
  |  |   31|     14|#define IASECC_DOCP_TAG				0xA0
  ------------------
 2862|     14|	LOG_TEST_RET(ctx, rv, "cannot parse ECC DOCP data");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2863|       |
 2864|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2865|      0|}
card-iasecc.c:iasecc_sdo_tag_from_class:
 2749|    314|{
 2750|    314|	switch (sdo_class & ~IASECC_OBJECT_REF_LOCAL)   {
  ------------------
  |  |   59|    314|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  |  Branch (2750:10): [True: 314, False: 0]
  ------------------
 2751|    314|	case IASECC_SDO_CLASS_CHV:
  ------------------
  |  |   98|    314|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
  |  Branch (2751:2): [True: 314, False: 0]
  ------------------
 2752|    314|		return IASECC_SDO_CHV_TAG;
  ------------------
  |  |   63|    314|#define IASECC_SDO_CHV_TAG		0x7F41
  ------------------
 2753|      0|	case IASECC_SDO_CLASS_RSA_PRIVATE:
  ------------------
  |  |  100|      0|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  |  Branch (2753:2): [True: 0, False: 314]
  ------------------
 2754|      0|		return IASECC_SDO_PRVKEY_TAG;
  ------------------
  |  |   68|      0|#define IASECC_SDO_PRVKEY_TAG			0x7F48
  ------------------
 2755|      0|	case IASECC_SDO_CLASS_RSA_PUBLIC:
  ------------------
  |  |  101|      0|#define IASECC_SDO_CLASS_RSA_PUBLIC	0x20
  ------------------
  |  Branch (2755:2): [True: 0, False: 314]
  ------------------
 2756|      0|		return IASECC_SDO_PUBKEY_TAG;
  ------------------
  |  |   76|      0|#define IASECC_SDO_PUBKEY_TAG			0x7F49
  ------------------
 2757|      0|	case IASECC_SDO_CLASS_SE:
  ------------------
  |  |  102|      0|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
  |  Branch (2757:2): [True: 0, False: 314]
  ------------------
 2758|      0|		return IASECC_SDO_CLASS_SE;
  ------------------
  |  |  102|      0|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
 2759|      0|	case IASECC_SDO_CLASS_KEYSET:
  ------------------
  |  |   99|      0|#define IASECC_SDO_CLASS_KEYSET		0x0A
  ------------------
  |  Branch (2759:2): [True: 0, False: 314]
  ------------------
 2760|      0|		return IASECC_SDO_KEYSET_TAG;
  ------------------
  |  |   83|      0|#define IASECC_SDO_KEYSET_TAG			0xA2
  ------------------
 2761|    314|	}
 2762|       |
 2763|      0|	return -1;
 2764|    314|}
card-iasecc.c:iasecc_sdo_get_tagged_data:
 2769|    328|{
 2770|    328|	struct sc_context *ctx = card->ctx;
 2771|    328|	struct sc_apdu apdu;
 2772|    328|	unsigned char sbuf[0x100];
 2773|    328|	size_t offs = sizeof(sbuf) - 1;
 2774|    328|	unsigned char rbuf[0x400];
 2775|    328|	int rv;
 2776|       |
 2777|    328|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    328|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    328|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    328|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    328|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 328]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2778|       |
 2779|    328|	sc_log(ctx, "sdo_tag=0x%x sdo_ref=0x%x sdo_class=0x%x", sdo_tag,
  ------------------
  |  |   71|    328|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2780|    328|			sdo->sdo_ref, sdo->sdo_class);
 2781|       |
 2782|       |	/* XXX: for the CPx, the SDO are available from some specific path */
 2783|    328|	if (iasecc_is_cpx(card)) {
  ------------------
  |  Branch (2783:6): [True: 28, False: 300]
  ------------------
 2784|     28|		struct sc_path path;
 2785|     28|		char *path_str = NULL;
 2786|     28|		switch(sdo_tag) {
 2787|      0|			case IASECC_SDO_PRVKEY_TAG:
  ------------------
  |  |   68|      0|#define IASECC_SDO_PRVKEY_TAG			0x7F48
  ------------------
  |  Branch (2787:4): [True: 0, False: 28]
  ------------------
 2788|       |			/* APDU 00 CB 3F FF 0B 4D 09 70 07 BF 90 02 03 7F 48 80 */
 2789|      0|			path_str = "3F00:0001";
 2790|      0|			break;
 2791|     20|			case IASECC_SDO_CHV_TAG:
  ------------------
  |  |   63|     20|#define IASECC_SDO_CHV_TAG		0x7F41
  ------------------
  |  Branch (2791:4): [True: 20, False: 8]
  ------------------
 2792|       |			/* APDU 00 CB 3F FF 0B 4D 09 70 07 BF 81 01 03 7F 41 80 */
 2793|     20|			path_str = "3F00";
 2794|     20|			break;
 2795|      8|			default:
  ------------------
  |  Branch (2795:4): [True: 8, False: 20]
  ------------------
 2796|      8|			path_str = NULL;
 2797|      8|			break;
 2798|     28|		}
 2799|     28|		if (path_str) {
  ------------------
  |  Branch (2799:7): [True: 20, False: 8]
  ------------------
 2800|     20|			sc_log(ctx, "Warning: Enforce the path=%s", path_str);
  ------------------
  |  |   71|     20|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2801|     20|			sc_format_path(path_str, &path);
 2802|     20|			rv = iasecc_select_file(card, &path, NULL);
 2803|     20|			LOG_TEST_RET(ctx, rv, "path error");
  ------------------
  |  |  174|     20|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     20|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     20|	int _ret = (r); \
  |  |  |  |  168|     20|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2804|     20|		}
 2805|     28|	}
 2806|       |
 2807|    318|	sbuf[offs--] = 0x80;
 2808|    318|	sbuf[offs--] = sdo_tag & 0xFF;
 2809|    318|	if ((sdo_tag >> 8) & 0xFF)
  ------------------
  |  Branch (2809:6): [True: 304, False: 14]
  ------------------
 2810|    304|		sbuf[offs--] = (sdo_tag >> 8) & 0xFF;
 2811|    318|	sbuf[offs] = sizeof(sbuf) - offs - 1;
 2812|    318|	offs--;
 2813|       |
 2814|    318|	sbuf[offs--] = sdo->sdo_ref & 0x9F;
 2815|    318|	sbuf[offs--] = sdo->sdo_class | IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|    318|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
 2816|    318|	sbuf[offs--] = IASECC_SDO_TAG_HEADER;
  ------------------
  |  |   27|    318|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
 2817|       |
 2818|    318|	sbuf[offs] = sizeof(sbuf) - offs - 1;
 2819|    318|	offs--;
 2820|    318|	sbuf[offs--] = IASECC_SDO_TEMPLATE_TAG;
  ------------------
  |  |   29|    318|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
 2821|       |
 2822|    318|	sbuf[offs] = sizeof(sbuf) - offs - 1;
 2823|    318|	offs--;
 2824|    318|	sbuf[offs] = 0x4D;
 2825|       |
 2826|    318|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xCB, 0x3F, 0xFF);
  ------------------
  |  |  294|    318|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 2827|    318|	apdu.data = sbuf + offs;
 2828|    318|	apdu.datalen = sizeof(sbuf) - offs;
 2829|    318|	apdu.lc = sizeof(sbuf) - offs;
 2830|    318|	apdu.resp = rbuf;
 2831|    318|	apdu.resplen = sizeof(rbuf);
 2832|    318|	apdu.le = 0x100;
 2833|       |
 2834|    318|	rv = sc_transmit_apdu(card, &apdu);
 2835|    318|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    318|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    318|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    318|	int _ret = (r); \
  |  |  |  |  168|    318|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 308]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|    318|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 308]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2836|    308|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2837|    308|	LOG_TEST_RET(ctx, rv, "SDO get data error");
  ------------------
  |  |  174|    308|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    308|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    308|	int _ret = (r); \
  |  |  |  |  168|    308|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 44, False: 264]
  |  |  |  |  ------------------
  |  |  |  |  169|     44|		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|     44|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     44|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     44|		return _ret; \
  |  |  |  |  172|     44|	} \
  |  |  |  |  173|    308|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 264]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2838|       |
 2839|    264|	rv = iasecc_sdo_parse(card, apdu.resp, apdu.resplen, sdo);
 2840|    264|	LOG_TEST_RET(ctx, rv, "cannot parse SDO data");
  ------------------
  |  |  174|    264|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    264|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    264|	int _ret = (r); \
  |  |  |  |  168|    264|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 259, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  169|    259|		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|    259|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    259|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    259|		return _ret; \
  |  |  |  |  172|    259|	} \
  |  |  |  |  173|    264|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2841|       |
 2842|      5|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|      5|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      5|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      5|	int _ret = r; \
  |  |  |  |  155|      5|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      5|		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: 5]
  |  |  |  |  ------------------
  |  |  |  |  157|      5|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      5|	} 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|      5|	return _ret; \
  |  |  |  |  163|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2843|      5|}
card-iasecc.c:iasecc_check_sw:
 1487|  16.0k|{
 1488|  16.0k|	if (sw1 == 0x62 && sw2 == 0x82)
  ------------------
  |  Branch (1488:6): [True: 2.15k, False: 13.8k]
  |  Branch (1488:21): [True: 2.09k, False: 65]
  ------------------
 1489|  2.09k|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.09k|#define SC_SUCCESS				0
  ------------------
 1490|       |
 1491|  13.9k|	return iso_ops->check_sw(card, sw1, sw2);
 1492|  16.0k|}
card-iasecc.c:iasecc_card_ctl:
 2973|    650|{
 2974|    650|	struct sc_context *ctx = card->ctx;
 2975|    650|	struct iasecc_sdo *sdo = (struct iasecc_sdo *) ptr;
 2976|       |
 2977|    650|	switch (cmd) {
  ------------------
  |  Branch (2977:10): [True: 352, False: 298]
  ------------------
 2978|    352|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (2978:2): [True: 352, False: 298]
  ------------------
 2979|    352|		return iasecc_get_serialnr(card, (struct sc_serial_number *)ptr);
 2980|      0|	case SC_CARDCTL_IASECC_SDO_CREATE:
  ------------------
  |  Branch (2980:2): [True: 0, False: 650]
  ------------------
 2981|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_CREATE: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2982|      0|		return iasecc_sdo_create(card, (struct iasecc_sdo *) ptr);
 2983|      0|	case SC_CARDCTL_IASECC_SDO_DELETE:
  ------------------
  |  Branch (2983:2): [True: 0, False: 650]
  ------------------
 2984|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_DELETE: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2985|      0|		return iasecc_sdo_delete(card, (struct iasecc_sdo *) ptr);
 2986|      0|	case SC_CARDCTL_IASECC_SDO_PUT_DATA:
  ------------------
  |  Branch (2986:2): [True: 0, False: 650]
  ------------------
 2987|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_PUT_DATA: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2988|      0|		return iasecc_sdo_put_data(card, (struct iasecc_sdo_update *) ptr);
 2989|      0|	case SC_CARDCTL_IASECC_SDO_KEY_RSA_PUT_DATA:
  ------------------
  |  Branch (2989:2): [True: 0, False: 650]
  ------------------
 2990|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_KEY_RSA_PUT_DATA");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2991|      0|		return iasecc_sdo_key_rsa_put_data(card, (struct iasecc_sdo_rsa_update *) ptr);
 2992|      0|	case SC_CARDCTL_IASECC_SDO_GET_DATA:
  ------------------
  |  Branch (2992:2): [True: 0, False: 650]
  ------------------
 2993|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_GET_DATA: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2994|      0|		return iasecc_sdo_get_data(card, (struct iasecc_sdo *) ptr);
 2995|      0|	case SC_CARDCTL_IASECC_SDO_GENERATE:
  ------------------
  |  Branch (2995:2): [True: 0, False: 650]
  ------------------
 2996|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_GET_DATA: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2997|      0|		return iasecc_sdo_generate(card, (struct iasecc_sdo *) ptr);
 2998|      0|	case SC_CARDCTL_GET_SE_INFO:
  ------------------
  |  Branch (2998:2): [True: 0, False: 650]
  ------------------
 2999|      0|		sc_log(ctx, "CMD SC_CARDCTL_GET_SE_INFO: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3000|      0|		return iasecc_se_get_info(card, (struct iasecc_se_info *) ptr);
 3001|      0|	case SC_CARDCTL_GET_CHV_REFERENCE_IN_SE:
  ------------------
  |  Branch (3001:2): [True: 0, False: 650]
  ------------------
 3002|      0|		sc_log(ctx, "CMD SC_CARDCTL_GET_CHV_REFERENCE_IN_SE");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3003|      0|		return iasecc_get_chv_reference_from_se(card, (int *)ptr);
 3004|      0|	case SC_CARDCTL_IASECC_GET_FREE_KEY_REFERENCE:
  ------------------
  |  Branch (3004:2): [True: 0, False: 650]
  ------------------
 3005|      0|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_GET_FREE_KEY_REFERENCE");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3006|      0|		return iasecc_get_free_reference(card, (struct iasecc_ctl_get_free_reference *)ptr);
 3007|    650|	}
 3008|    298|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    298|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 3009|    650|}
card-iasecc.c:iasecc_pin_cmd:
 2428|    352|{
 2429|    352|	struct sc_context *ctx = card->ctx;
 2430|    352|	int rv;
 2431|       |
 2432|    352|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    352|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    352|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    352|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    352|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 352]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2433|    352|	sc_log(ctx, "iasecc_pin_cmd() cmd 0x%X, PIN type 0x%X, PIN reference %i, PIN-1 %p:%zu, PIN-2 %p:%zu",
  ------------------
  |  |   71|    352|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2434|    352|			data->cmd, data->pin_type, data->pin_reference,
 2435|    352|			data->pin1.data, data->pin1.len, data->pin2.data, data->pin2.len);
 2436|       |
 2437|    352|	switch (data->cmd)   {
 2438|      0|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (2438:2): [True: 0, False: 352]
  ------------------
 2439|      0|		rv = iasecc_pin_verify(card, data);
 2440|      0|		break;
 2441|      0|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (2441:2): [True: 0, False: 352]
  ------------------
 2442|      0|		if (data->pin_type == SC_AC_AUT)
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (2442:7): [True: 0, False: 0]
  ------------------
 2443|      0|			rv = iasecc_keyset_change(card, data);
 2444|      0|		else
 2445|      0|			rv = iasecc_pin_change(card, data);
 2446|      0|		break;
 2447|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2447:2): [True: 0, False: 352]
  ------------------
 2448|      0|		rv = iasecc_pin_reset(card, data);
 2449|      0|		break;
 2450|    352|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  418|    352|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (2450:2): [True: 352, False: 0]
  ------------------
 2451|    352|		rv = iasecc_pin_get_info(card, data);
 2452|    352|		break;
 2453|      0|	default:
  ------------------
  |  Branch (2453:2): [True: 0, False: 352]
  ------------------
 2454|      0|		sc_log(ctx, "Other pin commands not supported yet: 0x%X", data->cmd);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2455|      0|		rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2456|    352|	}
 2457|       |
 2458|    352|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    352|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    352|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    352|	int _ret = r; \
  |  |  |  |  155|    352|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 352, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    352|		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|    352|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 352, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    352|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    352|	} 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|    352|	return _ret; \
  |  |  |  |  163|    352|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2459|    352|}
card-iasecc.c:iasecc_pin_get_status:
 1895|    352|{
 1896|    352|	struct sc_context *ctx = card->ctx;
 1897|    352|	struct sc_pin_cmd_data info;
 1898|    352|	int rv;
 1899|       |
 1900|    352|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    352|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    352|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    352|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    352|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 352]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1901|       |
 1902|    352|	if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|    352|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1902:6): [True: 0, False: 352]
  ------------------
 1903|    352|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "PIN type is not supported for status");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1904|       |
 1905|    352|	memset(&info, 0, sizeof(info));
 1906|    352|	info.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|    352|#define SC_PIN_CMD_GET_INFO	3
  ------------------
 1907|    352|	info.pin_type = data->pin_type;
 1908|    352|	info.pin_reference = data->pin_reference;
 1909|       |
 1910|    352|	rv = iso_ops->pin_cmd(card, &info);
 1911|    352|	LOG_TEST_RET(ctx, rv, "Failed to get PIN info");
  ------------------
  |  |  174|    352|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    352|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    352|	int _ret = (r); \
  |  |  |  |  168|    352|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 31, False: 321]
  |  |  |  |  ------------------
  |  |  |  |  169|     31|		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|     31|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     31|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     31|		return _ret; \
  |  |  |  |  172|     31|	} \
  |  |  |  |  173|    352|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 321]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1912|       |
 1913|    321|	data->pin1.max_tries = info.pin1.max_tries;
 1914|    321|	data->pin1.tries_left = info.pin1.tries_left;
 1915|    321|	data->pin1.logged_in = info.pin1.logged_in;
 1916|       |
 1917|    321|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    321|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    321|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    321|	int _ret = r; \
  |  |  |  |  155|    321|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 321, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    321|		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: 321]
  |  |  |  |  ------------------
  |  |  |  |  157|    321|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    321|	} 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|    321|	return _ret; \
  |  |  |  |  163|    321|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1918|    321|}
card-iasecc.c:iasecc_pin_get_policy:
 2014|    321|{
 2015|    321|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 2016|    321|	struct sc_context *ctx = card->ctx;
 2017|    321|	struct sc_file *save_current_df = NULL, *save_current_ef = NULL;
 2018|    321|	struct iasecc_sdo sdo;
 2019|    321|	struct sc_path path;
 2020|    321|	int rv;
 2021|       |
 2022|    321|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    321|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    321|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    321|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    321|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 321]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2023|    321|	sc_log(ctx, "iasecc_pin_get_policy(card:%p)", card);
  ------------------
  |  |   71|    321|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2024|       |
 2025|    321|	if (data->pin_type != SC_AC_CHV)   {
  ------------------
  |  |  151|    321|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (2025:6): [True: 0, False: 321]
  ------------------
 2026|      0|		sc_log(ctx, "PIN policy only available for CHV type");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2027|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2028|      0|	}
 2029|       |
 2030|    321|	if (prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  Branch (2030:6): [True: 321, False: 0]
  |  Branch (2030:26): [True: 8, False: 313]
  ------------------
 2031|      8|		sc_file_dup(&save_current_df, prv->cache.current_df);
 2032|      8|		if (save_current_df == NULL) {
  ------------------
  |  Branch (2032:7): [True: 0, False: 8]
  ------------------
 2033|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2034|      0|			sc_log(ctx, "Cannot duplicate current DF file");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2035|      0|			goto err;
 2036|      0|		}
 2037|      8|	}
 2038|       |
 2039|    321|	if (prv->cache.valid && prv->cache.current_ef) {
  ------------------
  |  Branch (2039:6): [True: 321, False: 0]
  |  Branch (2039:26): [True: 42, False: 279]
  ------------------
 2040|     42|		sc_file_dup(&save_current_ef, prv->cache.current_ef);
 2041|     42|		if (save_current_ef == NULL) {
  ------------------
  |  Branch (2041:7): [True: 0, False: 42]
  ------------------
 2042|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2043|      0|			sc_log(ctx, "Cannot duplicate current EF file");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2044|      0|			goto err;
 2045|      0|		}
 2046|     42|	}
 2047|       |
 2048|    321|	if (!(data->pin_reference & IASECC_OBJECT_REF_LOCAL) && prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  |   59|    321|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  |  Branch (2048:6): [True: 321, False: 0]
  |  Branch (2048:58): [True: 321, False: 0]
  |  Branch (2048:78): [True: 8, False: 313]
  ------------------
 2049|      8|		sc_format_path("3F00", &path);
 2050|      8|		path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      8|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 2051|      8|		rv = iasecc_select_file(card, &path, NULL);
 2052|      8|		LOG_TEST_GOTO_ERR(ctx, rv, "Unable to select MF");
  ------------------
  |  |  184|      8|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      8|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      8|	int _ret = (r); \
  |  |  |  |  178|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 7, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  179|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      7|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      7|		goto err; \
  |  |  |  |  182|      7|	} \
  |  |  |  |  183|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2053|      8|	}
 2054|       |
 2055|    314|	memset(&sdo, 0, sizeof(sdo));
 2056|    314|	sdo.sdo_class = IASECC_SDO_CLASS_CHV;
  ------------------
  |  |   98|    314|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
 2057|       |
 2058|    314|	sdo.sdo_ref = data->pin_reference & ~IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|    314|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
 2059|       |
 2060|    314|	sc_log(ctx, "iasecc_pin_get_policy() reference %i", sdo.sdo_ref);
  ------------------
  |  |   71|    314|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2061|       |
 2062|    314|	rv = iasecc_sdo_get_data(card, &sdo);
 2063|    314|	LOG_TEST_GOTO_ERR(ctx, rv, "Cannot get SDO PIN data");
  ------------------
  |  |  184|    314|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    314|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    314|	int _ret = (r); \
  |  |  |  |  178|    314|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 314, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    314|		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|    314|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    314|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    314|		goto err; \
  |  |  |  |  182|    314|	} \
  |  |  |  |  183|    314|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2064|       |
 2065|      0|	if (sdo.docp.acls_contact.size == 0) {
  ------------------
  |  Branch (2065:6): [True: 0, False: 0]
  ------------------
 2066|      0|		rv = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2067|      0|		sc_log(ctx, "Extremely strange ... there is no ACLs");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2068|      0|		goto err;
 2069|      0|	}
 2070|       |
 2071|      0|	sc_log(ctx, "iasecc_pin_get_policy() sdo.docp.size.size %zu", sdo.docp.size.size);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2072|       |
 2073|      0|	memcpy(pin->scbs, sdo.docp.scbs, sizeof(pin->scbs));
 2074|       |
 2075|      0|	pin->min_length = (sdo.data.chv.size_min.value ? *sdo.data.chv.size_min.value : -1);
  ------------------
  |  Branch (2075:21): [True: 0, False: 0]
  ------------------
 2076|      0|	pin->max_length = (sdo.data.chv.size_max.value ? *sdo.data.chv.size_max.value : -1);
  ------------------
  |  Branch (2076:21): [True: 0, False: 0]
  ------------------
 2077|      0|	pin->tries_maximum = (sdo.docp.tries_maximum.value ? *sdo.docp.tries_maximum.value : -1);
  ------------------
  |  Branch (2077:24): [True: 0, False: 0]
  ------------------
 2078|      0|	pin->tries_remaining = (sdo.docp.tries_remaining.value ? *sdo.docp.tries_remaining.value : -1);
  ------------------
  |  Branch (2078:26): [True: 0, False: 0]
  ------------------
 2079|      0|	if (sdo.docp.size.value && sdo.docp.size.size <= sizeof(int)) {
  ------------------
  |  Branch (2079:6): [True: 0, False: 0]
  |  Branch (2079:29): [True: 0, False: 0]
  ------------------
 2080|      0|		unsigned int n = 0;
 2081|      0|		unsigned int i;
 2082|      0|		for (i=0; i<sdo.docp.size.size; i++)
  ------------------
  |  Branch (2082:13): [True: 0, False: 0]
  ------------------
 2083|      0|			n = (n << 8) + *(sdo.docp.size.value + i);
 2084|      0|		pin->stored_length = n;
 2085|      0|	} else {
 2086|      0|		pin->stored_length = -1;
 2087|      0|	}
 2088|       |
 2089|      0|	sc_log(ctx, "PIN policy: size max/min %i/%i, tries max/left %i/%i",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2090|      0|	       pin->max_length, pin->min_length, pin->tries_maximum, pin->tries_remaining);
 2091|      0|	iasecc_sdo_free_fields(card, &sdo);
 2092|       |
 2093|      0|	if (save_current_df)   {
  ------------------
  |  Branch (2093:6): [True: 0, False: 0]
  ------------------
 2094|      0|		sc_log(ctx, "iasecc_pin_get_policy() restore current DF");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2095|      0|		rv = iasecc_select_file(card, &save_current_df->path, NULL);
 2096|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Cannot return to saved DF");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2097|      0|	}
 2098|       |
 2099|      0|	if (save_current_ef)   {
  ------------------
  |  Branch (2099:6): [True: 0, False: 0]
  ------------------
 2100|      0|		sc_log(ctx, "iasecc_pin_get_policy() restore current EF");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2101|      0|		rv = iasecc_select_file(card, &save_current_ef->path, NULL);
 2102|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Cannot return to saved EF");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2103|      0|	}
 2104|       |
 2105|    321|err:
 2106|    321|	sc_file_free(save_current_df);
 2107|    321|	sc_file_free(save_current_ef);
 2108|       |
 2109|    321|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    321|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    321|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    321|	int _ret = r; \
  |  |  |  |  155|    321|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 321, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    321|		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|    321|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 321, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    321|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    321|	} 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|    321|	return _ret; \
  |  |  |  |  163|    321|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2110|    321|}
card-iasecc.c:iasecc_pin_get_info:
 2115|    352|{
 2116|    352|	struct sc_context *ctx = card->ctx;
 2117|    352|	struct iasecc_pin_policy policy;
 2118|    352|	int rv;
 2119|       |
 2120|    352|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    352|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    352|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    352|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    352|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 352]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2121|    352|	sc_log(ctx, "iasecc_pin_get_info(card:%p)", card);
  ------------------
  |  |   71|    352|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2122|       |
 2123|       |	/*
 2124|       |	 * Get PIN status first and thereafter update with info from PIN policy, when available.
 2125|       |	 * The first one is typically used for the PIN verification status and number of remaining
 2126|       |	 * tries, and the second one for the maximum tries. If a field is present in both, the
 2127|       |	 * policy takes precedence.
 2128|       |	 */
 2129|    352|	rv = iasecc_pin_get_status(card, data);
 2130|    352|	LOG_TEST_RET(ctx, rv, "Failed to get PIN status");
  ------------------
  |  |  174|    352|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    352|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    352|	int _ret = (r); \
  |  |  |  |  168|    352|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 31, False: 321]
  |  |  |  |  ------------------
  |  |  |  |  169|     31|		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|     31|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     31|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     31|		return _ret; \
  |  |  |  |  172|     31|	} \
  |  |  |  |  173|    352|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 321]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2131|       |
 2132|    321|	rv = iasecc_pin_get_policy(card, data, &policy);
 2133|    321|	LOG_TEST_RET(ctx, rv, "Failed to get PIN policy");
  ------------------
  |  |  174|    321|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    321|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    321|	int _ret = (r); \
  |  |  |  |  168|    321|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 321, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    321|		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|    321|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    321|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    321|		return _ret; \
  |  |  |  |  172|    321|	} \
  |  |  |  |  173|    321|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2134|       |
 2135|       |	/*
 2136|       |	 * We only care about the tries_xxx fields in the PIN policy, since the other ones are not
 2137|       |	 * commonly expected or used in a SC_PIN_CMD_GET_INFO response.	Note that max_tries is
 2138|       |	 * always taken from the policy, since it is never expected to be available in status (it
 2139|       |	 * is set to -1 when not available in policy).
 2140|       |	 */
 2141|      0|	data->pin1.max_tries = policy.tries_maximum;
 2142|      0|	if (policy.tries_remaining >= 0)
  ------------------
  |  Branch (2142:6): [True: 0, False: 0]
  ------------------
 2143|      0|		data->pin1.tries_left = policy.tries_remaining;
 2144|       |
 2145|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2146|      0|}

idprime_free_private_data:
  225|    529|{
  226|    529|	free(priv->cache_buf);
  227|    529|	list_destroy(&priv->pki_list);
  228|    529|	list_destroy(&priv->containers);
  229|    529|	list_destroy(&priv->keyrefmap);
  230|    529|	free(priv);
  231|    529|	return;
  232|    529|}
idprime_new_private_data:
  235|    529|{
  236|    529|	idprime_private_data_t *priv;
  237|       |
  238|    529|	priv = calloc(1, sizeof(idprime_private_data_t));
  239|    529|	if (priv == NULL)
  ------------------
  |  Branch (239:6): [True: 0, False: 529]
  ------------------
  240|      0|		return NULL;
  241|       |
  242|       |	/* Initialize PKI Applets list */
  243|    529|	if (list_init(&priv->pki_list) != 0 ||
  ------------------
  |  Branch (243:6): [True: 0, False: 529]
  ------------------
  244|    529|	    list_attributes_copy(&priv->pki_list, idprime_list_meter, 1) != 0) {
  ------------------
  |  Branch (244:6): [True: 0, False: 529]
  ------------------
  245|      0|		idprime_free_private_data(priv);
  246|      0|		return NULL;
  247|      0|	}
  248|       |
  249|       |	/* Initialize container list */
  250|    529|	if (list_init(&priv->containers) != 0 ||
  ------------------
  |  Branch (250:6): [True: 0, False: 529]
  ------------------
  251|    529|	    list_attributes_copy(&priv->containers, idprime_container_list_meter, 1) != 0 ||
  ------------------
  |  Branch (251:6): [True: 0, False: 529]
  ------------------
  252|    529|	    list_attributes_seeker(&priv->containers, idprime_container_list_seeker) != 0) {
  ------------------
  |  Branch (252:6): [True: 0, False: 529]
  ------------------
  253|      0|		idprime_free_private_data(priv);
  254|      0|		return NULL;
  255|      0|	}
  256|       |
  257|       |	/* Initialize keyref list */
  258|    529|	if (list_init(&priv->keyrefmap) != 0 ||
  ------------------
  |  Branch (258:6): [True: 0, False: 529]
  ------------------
  259|    529|	    list_attributes_copy(&priv->keyrefmap, idprime_keyref_list_meter, 1) != 0 ||
  ------------------
  |  Branch (259:6): [True: 0, False: 529]
  ------------------
  260|    529|	    list_attributes_seeker(&priv->keyrefmap, idprime_keyref_list_seeker) != 0) {
  ------------------
  |  Branch (260:6): [True: 0, False: 529]
  ------------------
  261|      0|		idprime_free_private_data(priv);
  262|      0|		return NULL;
  263|      0|	}
  264|    529|	return priv;
  265|    529|}
idprime_add_object_to_list:
  268|    586|{
  269|    586|	if (list_append(list, object) < 0)
  ------------------
  |  Branch (269:6): [True: 0, False: 586]
  ------------------
  270|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  271|    586|	return SC_SUCCESS;
  ------------------
  |  |   28|    586|#define SC_SUCCESS				0
  ------------------
  272|    586|}
sc_get_idprime_driver:
 1281|  17.0k|{
 1282|  17.0k|	return sc_get_driver();
 1283|  17.0k|}
card-idprime.c:idprime_list_meter:
  176|    586|static size_t idprime_list_meter(const void *el) {
  177|    586|	return sizeof(idprime_object_t);
  178|    586|}
card-idprime.c:idprime_container_list_meter:
  180|     97|static size_t idprime_container_list_meter(const void *el) {
  181|     97|	return sizeof(idprime_container_t);
  182|     97|}
card-idprime.c:idprime_container_list_seeker:
  196|     21|{
  197|     21|	const idprime_container_t *container = (idprime_container_t *)el;
  198|       |
  199|     21|	if ((el == NULL) || (key == NULL))
  ------------------
  |  Branch (199:6): [True: 0, False: 21]
  |  Branch (199:22): [True: 0, False: 21]
  ------------------
  200|      0|		return 0;
  201|     21|	if (container->index == *(uint8_t *)key)
  ------------------
  |  Branch (201:6): [True: 20, False: 1]
  ------------------
  202|     20|		return 1;
  203|      1|	return 0;
  204|     21|}
card-idprime.c:idprime_keyref_list_meter:
  184|  10.9k|static size_t idprime_keyref_list_meter(const void *el) {
  185|  10.9k|	return sizeof(idprime_keyref_t);
  186|  10.9k|}
card-idprime.c:idprime_keyref_list_seeker:
  214|    178|{
  215|    178|	const idprime_keyref_t *keyref = (idprime_keyref_t *)el;
  216|       |
  217|    178|	if ((el == NULL) || (key == NULL))
  ------------------
  |  Branch (217:6): [True: 0, False: 178]
  |  Branch (217:22): [True: 0, False: 178]
  ------------------
  218|      0|		return 0;
  219|    178|	if (keyref->index == *(uint8_t *)key)
  ------------------
  |  Branch (219:6): [True: 46, False: 132]
  ------------------
  220|     46|		return 1;
  221|    132|	return 0;
  222|    178|}
card-idprime.c:sc_get_driver:
 1258|  17.0k|{
 1259|  17.0k|	if (iso_ops == NULL) {
  ------------------
  |  Branch (1259:6): [True: 1, False: 17.0k]
  ------------------
 1260|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1261|      1|	}
 1262|       |
 1263|  17.0k|	idprime_ops = *iso_ops;
 1264|  17.0k|	idprime_ops.match_card = idprime_match_card;
 1265|  17.0k|	idprime_ops.init = idprime_init;
 1266|  17.0k|	idprime_ops.finish = idprime_finish;
 1267|       |
 1268|  17.0k|	idprime_ops.read_binary = idprime_read_binary;
 1269|  17.0k|	idprime_ops.select_file = idprime_select_file;
 1270|  17.0k|	idprime_ops.card_ctl = idprime_card_ctl;
 1271|  17.0k|	idprime_ops.set_security_env = idprime_set_security_env;
 1272|  17.0k|	idprime_ops.compute_signature = idprime_compute_signature;
 1273|  17.0k|	idprime_ops.decipher = idprime_decipher;
 1274|       |
 1275|  17.0k|	idprime_ops.get_challenge = idprime_get_challenge;
 1276|       |
 1277|  17.0k|	return &idprime_drv;
 1278|  17.0k|}
card-idprime.c:idprime_match_card:
  754|  9.26k|{
  755|  9.26k|	int i, r;
  756|       |
  757|  9.26k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  9.26k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  9.26k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  9.26k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 9.26k]
  |  |  ------------------
  ------------------
  758|  9.26k|	i = _sc_match_atr(card, idprime_atrs, &card->type);
  759|  9.26k|	if (i < 0)
  ------------------
  |  Branch (759:6): [True: 8.71k, False: 554]
  ------------------
  760|  8.71k|		return 0;
  761|       |
  762|    554|	r = idprime_select_file_by_path(card, "0101");
  763|    554|	LOG_FUNC_RETURN(card->ctx, r > 0);
  ------------------
  |  |  164|    554|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    554|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    554|	int _ret = r; \
  |  |  |  |  155|    554|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 25, False: 529]
  |  |  |  |  ------------------
  |  |  |  |  156|     25|		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: 25]
  |  |  |  |  ------------------
  |  |  |  |  157|     25|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    529|	} else { \
  |  |  |  |  159|    529|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    529|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    529|	} \
  |  |  |  |  162|    554|	return _ret; \
  |  |  |  |  163|    554|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  764|    554|}
card-idprime.c:idprime_select_file_by_path:
  283|  1.55k|{
  284|  1.55k|	int r;
  285|  1.55k|	sc_file_t *file = NULL;
  286|  1.55k|	sc_path_t index_path;
  287|       |
  288|       |	/* First, we need to make sure the IDPrime AID is selected */
  289|  1.55k|	r = idprime_select_idprime(card);
  290|  1.55k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  1.55k|#define SC_SUCCESS				0
  ------------------
  |  Branch (290:6): [True: 130, False: 1.42k]
  ------------------
  291|    130|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    130|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    130|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    130|	int _ret = r; \
  |  |  |  |  155|    130|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 130, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    130|		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|    130|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 130, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    130|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    130|	} 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|    130|	return _ret; \
  |  |  |  |  163|    130|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|    130|	}
  293|       |
  294|       |	/* Returns FCI with expected length of data */
  295|  1.42k|	sc_format_path(str_path, &index_path);
  296|  1.42k|	r = iso_ops->select_file(card, &index_path, &file);
  297|       |
  298|  1.42k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  1.42k|#define SC_SUCCESS				0
  ------------------
  |  Branch (298:6): [True: 8, False: 1.41k]
  ------------------
  299|      8|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      8|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      8|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      8|	int _ret = r; \
  |  |  |  |  155|      8|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      8|	} 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|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  300|      8|	}
  301|       |	/* Ignore too large files */
  302|  1.41k|	if (file->size > MAX_FILE_SIZE) {
  ------------------
  |  |  220|  1.41k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (302:6): [True: 0, False: 1.41k]
  ------------------
  303|      0|		r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  304|  1.41k|	} else {
  305|  1.41k|		r = (int)file->size;
  306|  1.41k|	}
  307|  1.41k|	sc_file_free(file);
  308|  1.41k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.41k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.41k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.41k|	int _ret = r; \
  |  |  |  |  155|  1.41k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 1.40k]
  |  |  |  |  ------------------
  |  |  |  |  156|      4|		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: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.40k|	} else { \
  |  |  |  |  159|  1.40k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.40k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.40k|	} \
  |  |  |  |  162|  1.41k|	return _ret; \
  |  |  |  |  163|  1.41k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  309|  1.41k|}
card-idprime.c:idprime_select_idprime:
  277|  1.55k|{
  278|       |	return iso_ops->select_file(card, &idprime_path, NULL);
  279|  1.55k|}
card-idprime.c:idprime_init:
  565|    529|{
  566|    529|	int r;
  567|    529|	unsigned long flags, ext_flags;
  568|    529|	idprime_private_data_t *priv = NULL;
  569|    529|	struct sc_apdu apdu;
  570|    529|	u8 rbuf[CPLC_LENGTH];
  571|    529|	size_t rbuflen = sizeof(rbuf);
  572|       |
  573|    529|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    529|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    529|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    529|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 529]
  |  |  ------------------
  ------------------
  574|       |
  575|       |	/* We need to differentiate the OS version since they behave slightly differently */
  576|    529|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xCA, 0x9F, 0x7F);
  ------------------
  |  |  301|    529|#define SC_APDU_CASE_2			0x22
  ------------------
  577|    529|	apdu.resp = rbuf;
  578|    529|	apdu.resplen = rbuflen;
  579|    529|	apdu.le = rbuflen;
  580|    529|	r = sc_transmit_apdu(card, &apdu);
  581|    529|	if (r == SC_SUCCESS && apdu.resplen == CPLC_LENGTH) {
  ------------------
  |  |   28|  1.05k|#define SC_SUCCESS				0
  ------------------
              	if (r == SC_SUCCESS && apdu.resplen == CPLC_LENGTH) {
  ------------------
  |  |  563|    526|#define CPLC_LENGTH 45
  ------------------
  |  Branch (581:6): [True: 526, False: 3]
  |  Branch (581:25): [True: 7, False: 519]
  ------------------
  582|       |		/* We are interested in the OS release level here */
  583|      7|		switch (rbuf[11]) {
  584|      1|		case 0x01:
  ------------------
  |  Branch (584:3): [True: 1, False: 6]
  ------------------
  585|      1|			sc_log(card->ctx, "Detected IDPrime applet version 1");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  586|      1|			break;
  587|      2|		case 0x02:
  ------------------
  |  Branch (587:3): [True: 2, False: 5]
  ------------------
  588|      2|			sc_log(card->ctx, "Detected IDPrime applet version 2");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  589|      2|			break;
  590|      1|		case 0x03:
  ------------------
  |  Branch (590:3): [True: 1, False: 6]
  ------------------
  591|      1|			sc_log(card->ctx, "Detected IDPrime applet version 3");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  592|      1|			break;
  593|      1|		case 0x04:
  ------------------
  |  Branch (593:3): [True: 1, False: 6]
  ------------------
  594|      1|			sc_log(card->ctx, "Detected IDPrime applet version 4");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  595|      1|			break;
  596|      2|		default:
  ------------------
  |  Branch (596:3): [True: 2, False: 5]
  ------------------
  597|      2|			sc_log(card->ctx, "Unknown OS version received: %d", rbuf[11]);
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  598|      2|			break;
  599|      7|		}
  600|    522|	} else {
  601|    522|		sc_log(card->ctx, "Failed to get CPLC data or invalid length returned, err=%d, len=%zu",
  ------------------
  |  |   71|    522|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  602|    522|				r, apdu.resplen);
  603|    522|	}
  604|       |
  605|       |	/* Proprietary data -- Applet version */
  606|    529|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xCA, 0xDF, 0x30);
  ------------------
  |  |  301|    529|#define SC_APDU_CASE_2			0x22
  ------------------
  607|    529|	apdu.resp = rbuf;
  608|    529|	apdu.resplen = rbuflen;
  609|    529|	apdu.le = rbuflen;
  610|    529|	r = sc_transmit_apdu(card, &apdu);
  611|    529|	if (r == SC_SUCCESS && apdu.resplen >= 10) {
  ------------------
  |  |   28|  1.05k|#define SC_SUCCESS				0
  ------------------
  |  Branch (611:6): [True: 528, False: 1]
  |  Branch (611:25): [True: 21, False: 507]
  ------------------
  612|       |		/* Ber-TLV encoded */
  613|     21|		if (rbuf[0] == 0xDF && rbuf[1] == 0x30 && rbuf[2] == apdu.resplen - 3) {
  ------------------
  |  Branch (613:7): [True: 11, False: 10]
  |  Branch (613:26): [True: 10, False: 1]
  |  Branch (613:45): [True: 1, False: 9]
  ------------------
  614|      1|			sc_log(card->ctx, "IDPrime Java Applet version %.*s", (int)apdu.resplen - 3, rbuf + 3);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  615|      1|		}
  616|     21|	}
  617|       |
  618|    529|	priv = idprime_new_private_data();
  619|    529|	if (!priv) {
  ------------------
  |  Branch (619:6): [True: 0, False: 529]
  ------------------
  620|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  621|      0|	}
  622|       |
  623|       |	/* Select and process container file */
  624|    529|	r = idprime_select_file_by_path(card, "0204");;
  625|    529|	if (r <= 0) {
  ------------------
  |  Branch (625:6): [True: 52, False: 477]
  ------------------
  626|     52|		idprime_free_private_data(priv);
  627|     52|		if (r == 0)
  ------------------
  |  Branch (627:7): [True: 1, False: 51]
  ------------------
  628|      1|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  629|     52|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     52|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     52|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     52|	int _ret = r; \
  |  |  |  |  155|     52|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 52, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     52|		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|     52|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 52, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     52|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     52|	} 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|     52|	return _ret; \
  |  |  |  |  163|     52|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|     52|	}
  631|       |
  632|    477|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Container file found");
  ------------------
  |  |   70|    477|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  633|       |
  634|    477|	r = idprime_process_containermap(card, priv, r);
  635|    477|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    477|#define SC_SUCCESS				0
  ------------------
  |  Branch (635:6): [True: 59, False: 418]
  ------------------
  636|     59|		idprime_free_private_data(priv);
  637|     59|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     59|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     59|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     59|	int _ret = r; \
  |  |  |  |  155|     59|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 59, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     59|		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|     59|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 59, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     59|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     59|	} 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|     59|	return _ret; \
  |  |  |  |  163|     59|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|     59|	}
  639|       |
  640|    418|	if (card->type == SC_CARD_TYPE_IDPRIME_940) {
  ------------------
  |  Branch (640:6): [True: 88, False: 330]
  ------------------
  641|     88|		if ((r = idprime_select_file_by_path(card, "0005")) <= 0) {
  ------------------
  |  Branch (641:7): [True: 10, False: 78]
  ------------------
  642|     10|			idprime_free_private_data(priv);
  643|     10|			if (r == 0)
  ------------------
  |  Branch (643:8): [True: 1, False: 9]
  ------------------
  644|      1|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  645|     10|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     10|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     10|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     10|	int _ret = r; \
  |  |  |  |  155|     10|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     10|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     10|	} 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|     10|	return _ret; \
  |  |  |  |  163|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  646|     10|		}
  647|       |
  648|     78|		if ((r = idprime_process_keyrefmap(card, priv, r)) != SC_SUCCESS) {
  ------------------
  |  |   28|     78|#define SC_SUCCESS				0
  ------------------
  |  Branch (648:7): [True: 28, False: 50]
  ------------------
  649|     28|			idprime_free_private_data(priv);
  650|     28|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     28|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     28|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     28|	int _ret = r; \
  |  |  |  |  155|     28|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 28, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     28|		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|     28|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 28, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     28|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     28|	} 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|     28|	return _ret; \
  |  |  |  |  163|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  651|     28|		}
  652|     78|	}
  653|       |
  654|       |	/* Select and process the index file */
  655|    380|	r = idprime_select_file_by_path(card, "0101");
  656|    380|	if (r <= 0) {
  ------------------
  |  Branch (656:6): [True: 55, False: 325]
  ------------------
  657|     55|		idprime_free_private_data(priv);
  658|     55|		if (r == 0)
  ------------------
  |  Branch (658:7): [True: 1, False: 54]
  ------------------
  659|      1|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  660|     55|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     55|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     55|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     55|	int _ret = r; \
  |  |  |  |  155|     55|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 55, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     55|		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|     55|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 55, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     55|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     55|	} 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|     55|	return _ret; \
  |  |  |  |  163|     55|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  661|     55|	}
  662|       |
  663|    325|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Index file found");
  ------------------
  |  |   70|    325|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  664|       |
  665|    325|	r = idprime_process_index(card, priv, r);
  666|    325|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    325|#define SC_SUCCESS				0
  ------------------
  |  Branch (666:6): [True: 35, False: 290]
  ------------------
  667|     35|		idprime_free_private_data(priv);
  668|     35|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     35|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     35|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     35|	int _ret = r; \
  |  |  |  |  155|     35|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 35, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     35|		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|     35|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 35, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     35|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     35|	} 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|     35|	return _ret; \
  |  |  |  |  163|     35|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  669|     35|	}
  670|       |
  671|    290|	card->drv_data = priv;
  672|       |
  673|    290|	switch (card->type) {
  674|      1|	case SC_CARD_TYPE_IDPRIME_3810:
  ------------------
  |  Branch (674:2): [True: 1, False: 289]
  ------------------
  675|      1|		card->name = "Gemalto IDPrime 3810";
  676|      1|		break;
  677|      1|	case SC_CARD_TYPE_IDPRIME_830:
  ------------------
  |  Branch (677:2): [True: 1, False: 289]
  ------------------
  678|      1|		card->name = "Gemalto IDPrime MD 830";
  679|      1|		break;
  680|     50|	case SC_CARD_TYPE_IDPRIME_930:
  ------------------
  |  Branch (680:2): [True: 50, False: 240]
  ------------------
  681|     50|	case SC_CARD_TYPE_IDPRIME_930_PLUS:
  ------------------
  |  Branch (681:2): [True: 0, False: 290]
  ------------------
  682|     50|		card->name = "Gemalto IDPrime 930/3930";
  683|     50|		break;
  684|     17|	case SC_CARD_TYPE_IDPRIME_940:
  ------------------
  |  Branch (684:2): [True: 17, False: 273]
  ------------------
  685|     17|		card->name = "Gemalto IDPrime 940";
  686|     17|		break;
  687|      9|	case SC_CARD_TYPE_IDPRIME_840:
  ------------------
  |  Branch (687:2): [True: 9, False: 281]
  ------------------
  688|      9|		card->name = "Gemalto IDPrime MD 840";
  689|      9|		break;
  690|    212|	case SC_CARD_TYPE_IDPRIME_GENERIC:
  ------------------
  |  Branch (690:2): [True: 212, False: 78]
  ------------------
  691|    212|	default:
  ------------------
  |  Branch (691:2): [True: 0, False: 290]
  ------------------
  692|    212|		card->name = "Gemalto IDPrime (generic)";
  693|    212|		break;
  694|    290|	}
  695|    290|	card->cla = 0x00;
  696|       |
  697|       |	/* Set up algorithm info for RSA. */
  698|    290|	flags = SC_ALGORITHM_RSA_PAD_PKCS1
  ------------------
  |  |  111|    290|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    290|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    290|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  699|    290|		| SC_ALGORITHM_RSA_PAD_PSS
  ------------------
  |  |  107|    290|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  700|    290|		| SC_ALGORITHM_RSA_PAD_OAEP
  ------------------
  |  |  108|    290|#define SC_ALGORITHM_RSA_PAD_OAEP	0x00000020 /* PKCS#1 v2.0 OAEP */
  ------------------
  701|       |		/* SHA-1 mechanisms are not allowed in the card I have */
  702|    290|		| (SC_ALGORITHM_RSA_HASH_SHA256 | SC_ALGORITHM_RSA_HASH_SHA384 | SC_ALGORITHM_RSA_HASH_SHA512)
  ------------------
  |  |  138|    290|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
              		| (SC_ALGORITHM_RSA_HASH_SHA256 | SC_ALGORITHM_RSA_HASH_SHA384 | SC_ALGORITHM_RSA_HASH_SHA512)
  ------------------
  |  |  139|    290|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
              		| (SC_ALGORITHM_RSA_HASH_SHA256 | SC_ALGORITHM_RSA_HASH_SHA384 | SC_ALGORITHM_RSA_HASH_SHA512)
  ------------------
  |  |  140|    290|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
  703|    290|		| (SC_ALGORITHM_MGF1_SHA256 | SC_ALGORITHM_MGF1_SHA384 | SC_ALGORITHM_MGF1_SHA512)
  ------------------
  |  |  146|    290|#define SC_ALGORITHM_MGF1_SHA256	0x00200000
  ------------------
              		| (SC_ALGORITHM_MGF1_SHA256 | SC_ALGORITHM_MGF1_SHA384 | SC_ALGORITHM_MGF1_SHA512)
  ------------------
  |  |  147|    290|#define SC_ALGORITHM_MGF1_SHA384	0x00400000
  ------------------
              		| (SC_ALGORITHM_MGF1_SHA256 | SC_ALGORITHM_MGF1_SHA384 | SC_ALGORITHM_MGF1_SHA512)
  ------------------
  |  |  148|    290|#define SC_ALGORITHM_MGF1_SHA512	0x00800000
  ------------------
  704|    290|		;
  705|       |
  706|    290|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  707|    290|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  708|    290|	switch (card->type) {
  709|      0|	case SC_CARD_TYPE_IDPRIME_930_PLUS:
  ------------------
  |  Branch (709:2): [True: 0, False: 290]
  ------------------
  710|     17|	case SC_CARD_TYPE_IDPRIME_940:
  ------------------
  |  Branch (710:2): [True: 17, False: 273]
  ------------------
  711|     17|		_sc_card_add_rsa_alg(card, 3072, flags, 0);
  712|       |		/* fallthrough */
  713|     67|	case SC_CARD_TYPE_IDPRIME_930:
  ------------------
  |  Branch (713:2): [True: 50, False: 240]
  ------------------
  714|     67|		_sc_card_add_rsa_alg(card, 4096, flags, 0);
  715|       |		/* fallthrough */
  716|     76|	case SC_CARD_TYPE_IDPRIME_840:
  ------------------
  |  Branch (716:2): [True: 9, False: 281]
  ------------------
  717|       |		/* Set up algorithm info for EC */
  718|     76|		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  174|     76|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|     76|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|     76|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  719|     76|		if (card->type == SC_CARD_TYPE_IDPRIME_930_PLUS || card->type == SC_CARD_TYPE_IDPRIME_940) {
  ------------------
  |  Branch (719:7): [True: 0, False: 76]
  |  Branch (719:54): [True: 17, False: 59]
  ------------------
  720|     17|			flags |= SC_ALGORITHM_ECDH_CDH_RAW;
  ------------------
  |  |  173|     17|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  721|     17|		}
  722|     76|		ext_flags = SC_ALGORITHM_EXT_EC_F_P
  ------------------
  |  |  198|     76|#define SC_ALGORITHM_EXT_EC_F_P          0x00000001
  ------------------
  723|     76|			| SC_ALGORITHM_EXT_EC_ECPARAMETERS
  ------------------
  |  |  200|     76|#define SC_ALGORITHM_EXT_EC_ECPARAMETERS 0x00000004
  ------------------
  724|     76|			| SC_ALGORITHM_EXT_EC_NAMEDCURVE
  ------------------
  |  |  201|     76|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  725|     76|			| SC_ALGORITHM_EXT_EC_UNCOMPRESES
  ------------------
  |  |  202|     76|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  726|     76|			;
  727|     76|		_sc_card_add_ec_alg(card, 256, flags, ext_flags, NULL);
  728|     76|		_sc_card_add_ec_alg(card, 384, flags, ext_flags, NULL);
  729|     76|		_sc_card_add_ec_alg(card, 521, flags, ext_flags, NULL);
  730|     76|		break;
  731|    214|	default:
  ------------------
  |  Branch (731:2): [True: 214, False: 76]
  ------------------
  732|    214|		break;
  733|    290|	}
  734|       |
  735|    290|	card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    290|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  736|       |
  737|    290|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    290|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  738|       |
  739|    290|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|    290|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    290|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    290|	int _ret = r; \
  |  |  |  |  155|    290|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 290, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    290|		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: 290]
  |  |  |  |  ------------------
  |  |  |  |  157|    290|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    290|	} 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|    290|	return _ret; \
  |  |  |  |  163|    290|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|    290|}
card-idprime.c:idprime_process_containermap:
  312|    477|{
  313|    477|	u8 *buf = NULL;
  314|    477|	int r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|    477|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  315|    477|	int i;
  316|    477|	uint8_t max_entries, container_index;
  317|       |
  318|    477|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    477|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    477|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    477|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 477]
  |  |  ------------------
  ------------------
  319|       |
  320|    477|	buf = malloc(length);
  321|    477|	if (buf == NULL) {
  ------------------
  |  Branch (321:6): [True: 0, False: 477]
  ------------------
  322|      0|		goto done;
  323|      0|	}
  324|       |
  325|    477|	r = 0;
  326|  1.23k|	do {
  327|       |		/* Read at most CONTAINER_OBJ_LEN bytes */
  328|  1.23k|		int read_length = length - r > CONTAINER_OBJ_LEN ? CONTAINER_OBJ_LEN : length - r;
  ------------------
  |  |  142|  1.23k|#define CONTAINER_OBJ_LEN 86
  ------------------
              		int read_length = length - r > CONTAINER_OBJ_LEN ? CONTAINER_OBJ_LEN : length - r;
  ------------------
  |  |  142|    697|#define CONTAINER_OBJ_LEN 86
  ------------------
  |  Branch (328:21): [True: 697, False: 539]
  ------------------
  329|  1.23k|		if (length == r) {
  ------------------
  |  Branch (329:7): [True: 0, False: 1.23k]
  ------------------
  330|      0|			r = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|      0|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  331|      0|			goto done;
  332|      0|		}
  333|  1.23k|		const int got = iso_ops->read_binary(card, r, buf + r, read_length, 0);
  334|  1.23k|		if (got < 1) {
  ------------------
  |  Branch (334:7): [True: 59, False: 1.17k]
  ------------------
  335|     59|			if (got < 0) {
  ------------------
  |  Branch (335:8): [True: 58, False: 1]
  ------------------
  336|     58|				r = got;
  337|     58|			} else {
  338|      1|				r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      1|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  339|      1|			}
  340|     59|			goto done;
  341|     59|		}
  342|       |
  343|  1.17k|		r += got;
  344|       |
  345|       |		/* Try to read chunks of container size and stop when last container looks empty */
  346|  1.17k|		container_index = r > CONTAINER_OBJ_LEN ? (r / CONTAINER_OBJ_LEN - 1) * CONTAINER_OBJ_LEN : 0;
  ------------------
  |  |  142|  1.17k|#define CONTAINER_OBJ_LEN 86
  ------------------
              		container_index = r > CONTAINER_OBJ_LEN ? (r / CONTAINER_OBJ_LEN - 1) * CONTAINER_OBJ_LEN : 0;
  ------------------
  |  |  142|    488|#define CONTAINER_OBJ_LEN 86
  ------------------
              		container_index = r > CONTAINER_OBJ_LEN ? (r / CONTAINER_OBJ_LEN - 1) * CONTAINER_OBJ_LEN : 0;
  ------------------
  |  |  142|    488|#define CONTAINER_OBJ_LEN 86
  ------------------
  |  Branch (346:21): [True: 488, False: 689]
  ------------------
  347|  1.17k|	} while(length - r > 0 && buf[container_index] != 0);
  ------------------
  |  Branch (347:10): [True: 771, False: 406]
  |  Branch (347:28): [True: 759, False: 12]
  ------------------
  348|    418|	max_entries = r / CONTAINER_OBJ_LEN;
  ------------------
  |  |  142|    418|#define CONTAINER_OBJ_LEN 86
  ------------------
  349|       |
  350|    515|	for (i = 0; i < max_entries; i++) {
  ------------------
  |  Branch (350:14): [True: 98, False: 417]
  ------------------
  351|     98|		u8 *start = &buf[i * CONTAINER_OBJ_LEN];
  ------------------
  |  |  142|     98|#define CONTAINER_OBJ_LEN 86
  ------------------
  352|     98|		idprime_container_t new_container = {0};
  353|     98|		if (start[0] == 0) /* Empty record */
  ------------------
  |  Branch (353:7): [True: 1, False: 97]
  ------------------
  354|      1|			break;
  355|       |
  356|     97|		new_container.index = i;
  357|       |		/* Reading UNICODE characters but skipping second byte */
  358|     97|		int j = 0;
  359|  1.79k|		for (j = 0; j < MAX_CONTAINER_NAME_LEN; j++) {
  ------------------
  |  |  141|  1.79k|#define MAX_CONTAINER_NAME_LEN 39
  ------------------
  |  Branch (359:15): [True: 1.76k, False: 34]
  ------------------
  360|  1.76k|			if (start[2 * j] == 0)
  ------------------
  |  Branch (360:8): [True: 63, False: 1.69k]
  ------------------
  361|     63|				break;
  362|  1.69k|			new_container.guid[j] = start[2 * j];
  363|  1.69k|		}
  364|       |
  365|     97|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found container with index=%d, guid=%s", new_container.index, new_container.guid);
  ------------------
  |  |   70|     97|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  366|       |
  367|     97|		if ((r = idprime_add_container_to_list(&priv->containers, &new_container)) != SC_SUCCESS) {
  ------------------
  |  |   28|     97|#define SC_SUCCESS				0
  ------------------
  |  Branch (367:7): [True: 0, False: 97]
  ------------------
  368|      0|			goto done;
  369|      0|		}
  370|     97|	}
  371|       |
  372|    418|	r = SC_SUCCESS;
  ------------------
  |  |   28|    418|#define SC_SUCCESS				0
  ------------------
  373|    477|done:
  374|    477|	free(buf);
  375|    477|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    477|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    477|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    477|	int _ret = r; \
  |  |  |  |  155|    477|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 477, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    477|		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|     59|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 59, False: 418]
  |  |  |  |  ------------------
  |  |  |  |  157|    477|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    477|	} 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|    477|	return _ret; \
  |  |  |  |  163|    477|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  376|    477|}
card-idprime.c:idprime_add_container_to_list:
  189|     97|{
  190|     97|	if (list_append(list, container) < 0)
  ------------------
  |  Branch (190:6): [True: 0, False: 97]
  ------------------
  191|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  192|     97|	return SC_SUCCESS;
  ------------------
  |  |   28|     97|#define SC_SUCCESS				0
  ------------------
  193|     97|}
card-idprime.c:idprime_process_keyrefmap:
  379|     78|{
  380|     78|	u8 *buf = NULL;
  381|     78|	int r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|     78|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  382|     78|	int i, max_entries;
  383|       |
  384|     78|	buf = malloc(length);
  385|     78|	if (buf == NULL) {
  ------------------
  |  Branch (385:6): [True: 0, False: 78]
  ------------------
  386|      0|		goto done;
  387|      0|	}
  388|       |
  389|     78|	r = 0;
  390|    377|	do {
  391|    377|		if (length == r) {
  ------------------
  |  Branch (391:7): [True: 0, False: 377]
  ------------------
  392|      0|			r = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|      0|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  393|      0|			goto done;
  394|      0|		}
  395|    377|		const int got = iso_ops->read_binary(card, r, buf + r, length - r, 0);
  396|    377|		if (got < 1) {
  ------------------
  |  Branch (396:7): [True: 28, False: 349]
  ------------------
  397|     28|			r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|     28|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  398|     28|			goto done;
  399|     28|		}
  400|       |
  401|    349|		r += got;
  402|    349|	} while(length - r > 0);
  ------------------
  |  Branch (402:10): [True: 299, False: 50]
  ------------------
  403|     50|	max_entries = r / KEYREF_OBJ_LEN;
  ------------------
  |  |  151|     50|#define KEYREF_OBJ_LEN 8
  ------------------
  404|       |
  405|  13.5k|	for (i = 0; i < max_entries; i++) {
  ------------------
  |  Branch (405:14): [True: 13.4k, False: 50]
  ------------------
  406|  13.4k|		idprime_keyref_t new_keyref;
  407|  13.4k|		u8 *start = &buf[i * KEYREF_OBJ_LEN];
  ------------------
  |  |  151|  13.4k|#define KEYREF_OBJ_LEN 8
  ------------------
  408|  13.4k|		if (start[0] == 0) /* Empty key ref */
  ------------------
  |  Branch (408:7): [True: 2.55k, False: 10.9k]
  ------------------
  409|  2.55k|			continue;
  410|       |
  411|  10.9k|		new_keyref.index = start[2];
  412|  10.9k|		new_keyref.key_reference = start[1];
  413|  10.9k|		new_keyref.pin_index = start[7];
  414|  10.9k|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found key reference with index=%d, pin=%d, keyref=%d", new_keyref.index, new_keyref.pin_index, new_keyref.key_reference);
  ------------------
  |  |   70|  10.9k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  415|       |
  416|  10.9k|		if ((r = idprime_add_keyref_to_list(&priv->keyrefmap, &new_keyref)) != SC_SUCCESS) {
  ------------------
  |  |   28|  10.9k|#define SC_SUCCESS				0
  ------------------
  |  Branch (416:7): [True: 0, False: 10.9k]
  ------------------
  417|      0|			goto done;
  418|      0|		}
  419|  10.9k|	}
  420|     50|	r = SC_SUCCESS;
  ------------------
  |  |   28|     50|#define SC_SUCCESS				0
  ------------------
  421|     78|done:
  422|     78|	free(buf);
  423|     78|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     78|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     78|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     78|	int _ret = r; \
  |  |  |  |  155|     78|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 78, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     78|		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|     28|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 28, False: 50]
  |  |  |  |  ------------------
  |  |  |  |  157|     78|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     78|	} 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|     78|	return _ret; \
  |  |  |  |  163|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  424|     78|}
card-idprime.c:idprime_add_keyref_to_list:
  207|  10.9k|{
  208|  10.9k|	if (list_append(list, keyref) < 0)
  ------------------
  |  Branch (208:6): [True: 0, False: 10.9k]
  ------------------
  209|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  210|  10.9k|	return SC_SUCCESS;
  ------------------
  |  |   28|  10.9k|#define SC_SUCCESS				0
  ------------------
  211|  10.9k|}
card-idprime.c:idprime_process_index:
  427|    325|{
  428|    325|	u8 *buf = NULL;
  429|    325|	int r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|    325|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  430|    325|	int i, num_entries;
  431|    325|	idprime_object_t new_object;
  432|       |
  433|    325|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    325|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    325|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    325|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 325]
  |  |  ------------------
  ------------------
  434|       |
  435|    325|	buf = malloc(length);
  436|    325|	if (buf == NULL) {
  ------------------
  |  Branch (436:6): [True: 0, False: 325]
  ------------------
  437|      0|		goto done;
  438|      0|	}
  439|       |
  440|    325|	r = 0;
  441|    566|	do {
  442|    566|		if (length == r) {
  ------------------
  |  Branch (442:7): [True: 1, False: 565]
  ------------------
  443|      1|			r = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|      1|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  444|      1|			goto done;
  445|      1|		}
  446|    565|		const int got = iso_ops->read_binary(card, r, buf + r, length - r, 0);
  447|    565|		if (got < 1) {
  ------------------
  |  Branch (447:7): [True: 34, False: 531]
  ------------------
  448|     34|			r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|     34|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  449|     34|			goto done;
  450|     34|		}
  451|       |		/* First byte shows the number of entries, each of them 21 bytes long */
  452|    531|		num_entries = buf[0];
  453|    531|		r += got;
  454|    531|	} while(r < num_entries * 21 + 1);
  ------------------
  |  Branch (454:10): [True: 241, False: 290]
  ------------------
  455|       |
  456|    290|	new_object.fd = 0;
  457|  5.41k|	for (i = 0; i < num_entries; i++) {
  ------------------
  |  Branch (457:14): [True: 5.12k, False: 290]
  ------------------
  458|  5.12k|		u8 *start = &buf[i*21+1];
  459|       |
  460|       |		/* First two bytes specify the object DF */
  461|  5.12k|		new_object.df[0] = start[0];
  462|  5.12k|		new_object.df[1] = start[1];
  463|       |		/* Second two bytes refer to the object size */
  464|  5.12k|		new_object.length = bebytes2ushort(&start[2]);
  465|  5.12k|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "df=%s, len=%u",
  ------------------
  |  |   70|  5.12k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  466|  5.12k|			sc_dump_hex(new_object.df, sizeof(new_object.df)), new_object.length);
  467|       |		/* in minidriver, mscp/kxcNN or kscNN lists certificates */
  468|  5.12k|		if (((memcmp(&start[4], "ksc", 3) == 0) || memcmp(&start[4], "kxc", 3) == 0)
  ------------------
  |  Branch (468:8): [True: 827, False: 4.30k]
  |  Branch (468:46): [True: 16, False: 4.28k]
  ------------------
  469|    843|			&& (memcmp(&start[12], "mscp", 5) == 0)) {
  ------------------
  |  Branch (469:7): [True: 586, False: 257]
  ------------------
  470|    586|			uint8_t cert_id = 0;
  471|    586|			idprime_container_t *container = NULL;
  472|       |
  473|    586|			if (start[7] >= '0' && start[7] <= '9' && start[8] >= '0' && start[8] <= '9') {
  ------------------
  |  Branch (473:8): [True: 548, False: 38]
  |  Branch (473:27): [True: 451, False: 97]
  |  Branch (473:46): [True: 155, False: 296]
  |  Branch (473:65): [True: 39, False: 116]
  ------------------
  474|     39|				cert_id = (start[7] - '0') * 10 + start[8] - '0';
  475|     39|			}
  476|    586|			new_object.fd++;
  477|    586|			new_object.key_reference = -1;
  478|    586|			new_object.valid_key_ref = 0;
  479|    586|			new_object.pin_index = 1;
  480|       |
  481|    586|			container = (idprime_container_t *) list_seek(&priv->containers, &cert_id);
  482|    586|			if (!container) {
  ------------------
  |  Branch (482:8): [True: 566, False: 20]
  ------------------
  483|       |				/* Container map missing container with certificate ID */
  484|    566|				sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "No corresponding container with private key found for certificate with id=%d", cert_id);
  ------------------
  |  |   70|    566|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  485|    566|				if (card->type != SC_CARD_TYPE_IDPRIME_940) {
  ------------------
  |  Branch (485:9): [True: 503, False: 63]
  ------------------
  486|       |					/* For cards other than the 940, we don't know how to recognize
  487|       |					certificates missing keys other than to check
  488|       |					that there is a corresponding entry in the container map.*/
  489|    503|					sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Adding certificate with fd=%d", new_object.fd);
  ------------------
  |  |   70|    503|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  490|    503|					idprime_add_object_to_list(&priv->pki_list, &new_object);
  491|    503|					continue;
  492|    503|				}
  493|    566|			}
  494|       |
  495|     83|			switch (card->type) {
  496|      0|			case SC_CARD_TYPE_IDPRIME_3810:
  ------------------
  |  Branch (496:4): [True: 0, False: 83]
  ------------------
  497|      0|				new_object.key_reference = 0x31 + cert_id;
  498|      0|				break;
  499|      0|			case SC_CARD_TYPE_IDPRIME_830:
  ------------------
  |  Branch (499:4): [True: 0, False: 83]
  ------------------
  500|      0|				new_object.key_reference = 0x41 + cert_id;
  501|      0|				break;
  502|      0|			case SC_CARD_TYPE_IDPRIME_930:
  ------------------
  |  Branch (502:4): [True: 0, False: 83]
  ------------------
  503|      0|				new_object.key_reference = 0x11 + cert_id * 2;
  504|      0|				break;
  505|      0|			case SC_CARD_TYPE_IDPRIME_930_PLUS:
  ------------------
  |  Branch (505:4): [True: 0, False: 83]
  ------------------
  506|      0|				new_object.key_reference = 0x10 + cert_id * 2;
  507|      0|				break;
  508|     63|			case SC_CARD_TYPE_IDPRIME_940: {
  ------------------
  |  Branch (508:4): [True: 63, False: 20]
  ------------------
  509|     63|					idprime_keyref_t *keyref = (idprime_keyref_t *) list_seek(&priv->keyrefmap, &cert_id);
  510|     63|					if (!keyref) {
  ------------------
  |  Branch (510:10): [True: 17, False: 46]
  ------------------
  511|       |						/* Key reference file does not contain record of the key for given certificate */
  512|     17|						sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "No corresponding key reference found for certificate with id=%d", cert_id);
  ------------------
  |  |   70|     17|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  513|     17|						sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Adding certificate with fd=%d", new_object.fd);
  ------------------
  |  |   70|     17|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  514|     17|						idprime_add_object_to_list(&priv->pki_list, &new_object);
  515|     17|						continue;
  516|     17|					}
  517|     46|					new_object.key_reference = keyref->key_reference;
  518|     46|					new_object.pin_index = keyref->pin_index;
  519|     46|					break;
  520|     63|				}
  521|     10|			case SC_CARD_TYPE_IDPRIME_840:
  ------------------
  |  Branch (521:4): [True: 10, False: 73]
  ------------------
  522|     10|				new_object.key_reference = 0xf7 + cert_id;
  523|     10|				break;
  524|     10|			default:
  ------------------
  |  Branch (524:4): [True: 10, False: 73]
  ------------------
  525|     10|				new_object.key_reference = 0x56 + cert_id;
  526|     10|				break;
  527|     83|			}
  528|     66|			new_object.valid_key_ref = 1;
  529|     66|			if (container != NULL) {
  ------------------
  |  Branch (529:8): [True: 20, False: 46]
  ------------------
  530|     20|				sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found certificate with fd=%d, key_ref=%d corresponding to container \"%s\"",
  ------------------
  |  |   70|     20|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  531|     20|					new_object.fd, new_object.key_reference, container->guid);
  532|     46|			} else {
  533|     46|				sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found certificate with fd=%d, key_ref=%d without corresponding container",
  ------------------
  |  |   70|     46|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  534|     46|					new_object.fd, new_object.key_reference);
  535|     46|			}
  536|       |
  537|     66|			idprime_add_object_to_list(&priv->pki_list, &new_object);
  538|       |
  539|       |		/* This looks like non-standard extension listing pkcs11 token info label in my card */
  540|  4.54k|		} else if ((memcmp(&start[4], "tinfo", 6) == 0) && (memcmp(&start[12], "p11", 4) == 0)) {
  ------------------
  |  Branch (540:14): [True: 61, False: 4.48k]
  |  Branch (540:54): [True: 30, False: 31]
  ------------------
  541|     30|			memcpy(priv->tinfo_df, new_object.df, sizeof(priv->tinfo_df));
  542|     30|			priv->tinfo_present = 1;
  543|     30|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found p11/tinfo object");
  ------------------
  |  |   70|     30|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  544|  4.51k|		} else if ((memcmp(&start[4], "cmapfile", 8) == 0) && (memcmp(&start[12], "mscp", 4) == 0)) {
  ------------------
  |  Branch (544:14): [True: 74, False: 4.43k]
  |  Branch (544:57): [True: 50, False: 24]
  ------------------
  545|     50|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found mscp/cmapfile object %s",
  ------------------
  |  |   70|    189|#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: 39, False: 11]
  |  |  |  Branch (70:115): [True: 6, False: 33]
  |  |  ------------------
  ------------------
  546|     50|					(start[0] == 02 && start[1] == 04 ? "(already processed)" : "(in non-standard path!)"));
  547|  4.46k|		} else if (memcmp(&start[4], "cardapps", 8) == 0) {
  ------------------
  |  Branch (547:14): [True: 18, False: 4.44k]
  ------------------
  548|     18|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found cardapps object");
  ------------------
  |  |   70|     18|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  549|  4.44k|		} else if (memcmp(&start[4], "cardid", 6) == 0) {
  ------------------
  |  Branch (549:14): [True: 10, False: 4.43k]
  ------------------
  550|     10|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found cardid object");
  ------------------
  |  |   70|     10|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  551|  4.43k|		} else if (memcmp(&start[4], "cardcf", 6) == 0) {
  ------------------
  |  Branch (551:14): [True: 15, False: 4.42k]
  ------------------
  552|     15|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found cardcf object");
  ------------------
  |  |   70|     15|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  553|     15|		}
  554|  5.12k|	}
  555|       |
  556|    290|	r = SC_SUCCESS;
  ------------------
  |  |   28|    290|#define SC_SUCCESS				0
  ------------------
  557|    325|done:
  558|    325|	free(buf);
  559|    325|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    325|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    325|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    325|	int _ret = r; \
  |  |  |  |  155|    325|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 325, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    325|		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|     35|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 35, False: 290]
  |  |  |  |  ------------------
  |  |  |  |  157|    325|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    325|	} 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|    325|	return _ret; \
  |  |  |  |  163|    325|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  560|    325|}
card-idprime.c:idprime_finish:
  743|    290|{
  744|    290|	idprime_private_data_t * priv = card->drv_data;
  745|       |
  746|    290|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    290|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    290|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    290|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 290]
  |  |  ------------------
  ------------------
  747|    290|	if (priv) {
  ------------------
  |  Branch (747:6): [True: 290, False: 0]
  ------------------
  748|    290|		idprime_free_private_data(priv);
  749|    290|	}
  750|    290|	return SC_SUCCESS;
  ------------------
  |  |   28|    290|#define SC_SUCCESS				0
  ------------------
  751|    290|}
card-idprime.c:idprime_read_binary:
  968|    923|{
  969|    923|	struct idprime_private_data *priv = card->drv_data;
  970|    923|	int r = 0;
  971|    923|	int size;
  972|    923|	size_t sz;
  973|       |
  974|    923|	sc_log(card->ctx, "called; %zu bytes at offset %d", count, offset);
  ------------------
  |  |   71|    923|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  975|       |
  976|    923|	if (!priv->cached && offset == 0) {
  ------------------
  |  Branch (976:6): [True: 146, False: 777]
  |  Branch (976:23): [True: 146, False: 0]
  ------------------
  977|       |		/* Read what was reported by FCI from select command */
  978|    146|		size_t left = priv->file_size;
  979|    146|		unsigned read = 0;
  980|       |
  981|       |		// this function is called to read and uncompress the certificate
  982|    146|		u8 buffer[SC_MAX_EXT_APDU_BUFFER_SIZE];
  983|    146|		u8 *data_buffer = buffer;
  984|    146|		if (sizeof(buffer) < count || sizeof(buffer) < priv->file_size) {
  ------------------
  |  Branch (984:7): [True: 0, False: 146]
  |  Branch (984:33): [True: 0, False: 146]
  ------------------
  985|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  986|      0|		}
  987|    238|		while (left > 0) {
  ------------------
  |  Branch (987:10): [True: 143, False: 95]
  ------------------
  988|    143|			r = iso_ops->read_binary(card, read, buffer + read, priv->file_size - read, flags);
  989|    143|			if (r <= 0) {
  ------------------
  |  Branch (989:8): [True: 51, False: 92]
  ------------------
  990|     51|				LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     51|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     51|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     51|	int _ret = r; \
  |  |  |  |  155|     51|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 51, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     51|		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|     50|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 50, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|     51|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     51|	} 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|     51|	return _ret; \
  |  |  |  |  163|     51|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  991|     51|			}
  992|     92|			left -= r;
  993|     92|			read += r;
  994|     92|		}
  995|     95|		if (read < 4 || read != priv->file_size) {
  ------------------
  |  Branch (995:7): [True: 33, False: 62]
  |  Branch (995:19): [True: 0, False: 62]
  ------------------
  996|     33|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|     33|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     33|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     33|	int _ret = r; \
  |  |  |  |  155|     33|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 33, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     33|		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|     33|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 33, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     33|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     33|	} 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|     33|	return _ret; \
  |  |  |  |  163|     33|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  997|     33|		}
  998|     62|		if (buffer[0] == 1 && buffer[1] == 0) {
  ------------------
  |  Branch (998:7): [True: 17, False: 45]
  |  Branch (998:25): [True: 16, False: 1]
  ------------------
  999|       |			/* Data will be decompressed later */
 1000|     16|			data_buffer += 4;
 1001|     16|			sz = priv->file_size - 4;
 1002|     16|			if (flags)
  ------------------
  |  Branch (1002:8): [True: 14, False: 2]
  ------------------
 1003|     14|				*flags |= SC_FILE_FLAG_COMPRESSED_AUTO;
  ------------------
  |  |  230|     14|#define SC_FILE_FLAG_COMPRESSED_AUTO		0x01
  ------------------
 1004|     46|		} else {
 1005|     46|			sz = priv->file_size;
 1006|     46|		}
 1007|     62|		priv->cache_buf = malloc(sz);
 1008|     62|		if (priv->cache_buf == NULL) {
  ------------------
  |  Branch (1008:7): [True: 0, False: 62]
  ------------------
 1009|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1010|      0|		}
 1011|     62|		memcpy(priv->cache_buf, data_buffer, sz);
 1012|     62|		priv->cache_buf_len = sz;
 1013|     62|		priv->cached = 1;
 1014|     62|	}
 1015|    839|	if (offset >= priv->cache_buf_len) {
  ------------------
  |  Branch (1015:6): [True: 16, False: 823]
  ------------------
 1016|     16|		return 0;
 1017|     16|	}
 1018|    823|	size = (int) MIN((priv->cache_buf_len - offset), count);
  ------------------
  |  |   69|    823|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 16, False: 807]
  |  |  ------------------
  ------------------
 1019|    823|	memcpy(buf, priv->cache_buf + offset, size);
 1020|    823|	return size;
 1021|    839|}
card-idprime.c:idprime_select_file:
  942|  1.72k|{
  943|  1.72k|	int r;
  944|  1.72k|	idprime_private_data_t * priv = card->drv_data;
  945|       |
  946|  1.72k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.72k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.72k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.72k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.72k]
  |  |  ------------------
  ------------------
  947|       |
  948|       |	/* forget any old cached values */
  949|  1.72k|	if (priv->cache_buf) {
  ------------------
  |  Branch (949:6): [True: 46, False: 1.67k]
  ------------------
  950|     46|		free(priv->cache_buf);
  951|     46|		priv->cache_buf = NULL;
  952|     46|	}
  953|  1.72k|	priv->cache_buf_len = 0;
  954|  1.72k|	priv->cached = 0;
  955|       |
  956|  1.72k|	r = iso_ops->select_file(card, in_path, file_out);
  957|  1.72k|	if (r == SC_SUCCESS && file_out != NULL) {
  ------------------
  |  |   28|  3.44k|#define SC_SUCCESS				0
  ------------------
  |  Branch (957:6): [True: 318, False: 1.40k]
  |  Branch (957:25): [True: 259, False: 59]
  ------------------
  958|       | 	 	/* Cache the real file size for the caching read_binary() */
  959|    259| 	 	priv->file_size = (*file_out)->size;
  960|    259|	}
  961|       |	/* Return the exit code of the select command */
  962|  1.72k|	return r;
  963|  1.72k|}
card-idprime.c:idprime_card_ctl:
  909|  2.79k|{
  910|  2.79k|	idprime_private_data_t * priv = card->drv_data;
  911|       |
  912|  2.79k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.79k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.79k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.79k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.79k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.79k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  913|  2.79k|	sc_log(card->ctx, "cmd=%ld ptr=%p", cmd, ptr);
  ------------------
  |  |   71|  2.79k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  914|       |
  915|  2.79k|	if (priv == NULL) {
  ------------------
  |  Branch (915:6): [True: 0, False: 2.79k]
  ------------------
  916|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  917|      0|	}
  918|  2.79k|	switch (cmd) {
  ------------------
  |  Branch (918:10): [True: 2.49k, False: 300]
  ------------------
  919|    309|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (919:3): [True: 309, False: 2.48k]
  ------------------
  920|    309|			return idprime_get_serial(card, (sc_serial_number_t *) ptr);
  921|    309|		case SC_CARDCTL_IDPRIME_GET_TOKEN_NAME:
  ------------------
  |  Branch (921:3): [True: 309, False: 2.48k]
  ------------------
  922|    309|			return idprime_get_token_name(card, (char **) ptr);
  923|    309|		case SC_CARDCTL_IDPRIME_INIT_GET_OBJECTS:
  ------------------
  |  Branch (923:3): [True: 309, False: 2.48k]
  ------------------
  924|    309|			return idprime_get_init_and_get_count(&priv->pki_list, &priv->pki_current,
  925|    309|				(int *)ptr);
  926|    628|		case SC_CARDCTL_IDPRIME_GET_NEXT_OBJECT:
  ------------------
  |  Branch (926:3): [True: 628, False: 2.16k]
  ------------------
  927|    628|			return idprime_fill_prkey_info(&priv->pki_list, &priv->pki_current,
  928|    628|				(sc_pkcs15_prkey_info_t *)ptr);
  929|    309|		case SC_CARDCTL_IDPRIME_FINAL_GET_OBJECTS:
  ------------------
  |  Branch (929:3): [True: 309, False: 2.48k]
  ------------------
  930|    309|			return idprime_final_iterator(&priv->pki_list);
  931|    628|		case SC_CARDCTL_IDPRIME_GET_PIN_ID:
  ------------------
  |  Branch (931:3): [True: 628, False: 2.16k]
  ------------------
  932|    628|			return idprime_get_pin_id(&priv->pki_list, &priv->pki_current,
  933|    628|				(const char **)ptr);
  934|  2.79k|	}
  935|       |
  936|    300|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    300|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    300|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    300|	int _ret = r; \
  |  |  |  |  155|    300|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 300, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    300|		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|    300|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 300, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    300|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    300|	} 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|    300|	return _ret; \
  |  |  |  |  163|    300|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  937|    300|}
card-idprime.c:idprime_get_serial:
  826|    309|{
  827|    309|	sc_path_t cardid_path;
  828|    309|	sc_file_t *file = NULL;
  829|    309|	u8 buf[IDPRIME_CARDID_LEN];
  830|    309|	int r;
  831|       |
  832|    309|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    309|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    309|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    309|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    309|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 309]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  833|       |
  834|       |	/* XXX this is assumed to be cardid for windows. It can be read from the index file */
  835|    309|	sc_format_path("0201", &cardid_path);
  836|    309|	r = iso_ops->select_file(card, &cardid_path, &file);
  837|    309|	if (r != SC_SUCCESS || file->size != IDPRIME_CARDID_LEN) { /* The cardid is always 16 B */
  ------------------
  |  |   28|    618|#define SC_SUCCESS				0
  ------------------
              	if (r != SC_SUCCESS || file->size != IDPRIME_CARDID_LEN) { /* The cardid is always 16 B */
  ------------------
  |  |  823|     18|#define IDPRIME_CARDID_LEN 16
  ------------------
  |  Branch (837:6): [True: 291, False: 18]
  |  Branch (837:25): [True: 14, False: 4]
  ------------------
  838|    305|		sc_file_free(file);
  839|    305|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH);
  ------------------
  |  |  164|    305|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    305|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    305|	int _ret = r; \
  |  |  |  |  155|    305|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 305, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    305|		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|    305|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 305, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    305|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    305|	} 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|    305|	return _ret; \
  |  |  |  |  163|    305|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  840|    305|	}
  841|       |
  842|      4|	r = iso_ops->read_binary(card, 0, buf, file->size, 0);
  843|      4|	sc_file_free(file);
  844|      4|	if (r < 1) {
  ------------------
  |  Branch (844:6): [True: 2, False: 2]
  ------------------
  845|      2|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  846|      2|	} else if (r != IDPRIME_CARDID_LEN) {
  ------------------
  |  |  823|      2|#define IDPRIME_CARDID_LEN 16
  ------------------
  |  Branch (846:13): [True: 1, False: 1]
  ------------------
  847|      1|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  848|      1|	}
  849|       |
  850|      1|	serial->len = MIN(IDPRIME_CARDID_LEN, SC_MAX_SERIALNR);
  ------------------
  |  |   69|      1|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 1, Folded]
  |  |  ------------------
  ------------------
  851|      1|	memcpy(serial->value, buf, serial->len);
  852|      1|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  853|      1|}
card-idprime.c:idprime_get_token_name:
  856|    309|{
  857|    309|	idprime_private_data_t * priv = card->drv_data;
  858|    309|	sc_path_t tinfo_path = {"\x00\x00", 2, 0, 0, SC_PATH_TYPE_PATH, {"", 0}};
  ------------------
  |  |  119|    309|#define SC_PATH_TYPE_PATH		2
  ------------------
  859|    309|	sc_file_t *file = NULL;
  860|    309|	u8 buf[2];
  861|    309|	char *name;
  862|    309|	int r;
  863|       |
  864|    309|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    309|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    309|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    309|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    309|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 309]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  865|       |
  866|    309|	if (tname == NULL) {
  ------------------
  |  Branch (866:6): [True: 0, False: 309]
  ------------------
  867|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  868|      0|	}
  869|       |
  870|    309|	if (!priv->tinfo_present) {
  ------------------
  |  Branch (870:6): [True: 281, False: 28]
  ------------------
  871|    281|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    281|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    281|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    281|	int _ret = r; \
  |  |  |  |  155|    281|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 281, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    281|		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|    281|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 281, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    281|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    281|	} 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|    281|	return _ret; \
  |  |  |  |  163|    281|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  872|    281|	}
  873|       |
  874|     28|	memcpy(tinfo_path.value, priv->tinfo_df, 2);
  875|     28|	r = iso_ops->select_file(card, &tinfo_path, &file);
  876|     28|	if (r != SC_SUCCESS || file->size == 0) {
  ------------------
  |  |   28|     56|#define SC_SUCCESS				0
  ------------------
  |  Branch (876:6): [True: 17, False: 11]
  |  Branch (876:25): [True: 1, False: 10]
  ------------------
  877|     18|		sc_file_free(file);
  878|     18|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     18|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     18|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     18|	int _ret = r; \
  |  |  |  |  155|     18|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     18|		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|     18|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     18|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     18|	} 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|     18|	return _ret; \
  |  |  |  |  163|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  879|     18|	}
  880|       |
  881|       |	/* First two bytes lists 0x01, the second indicates length */
  882|     10|	r = iso_ops->read_binary(card, 0, buf, 2, 0);
  883|     10|	if (r < 2 || buf[1] > file->size) { /* make sure we do not overrun */
  ------------------
  |  Branch (883:6): [True: 2, False: 8]
  |  Branch (883:15): [True: 1, False: 7]
  ------------------
  884|      3|		sc_file_free(file);
  885|      3|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} else { \
  |  |  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      1|	} \
  |  |  |  |  162|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|      3|	}
  887|      7|	sc_file_free(file);
  888|       |
  889|      7|	name = malloc(buf[1]);
  890|      7|	if (name == NULL) {
  ------------------
  |  Branch (890:6): [True: 0, False: 7]
  ------------------
  891|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  892|      0|	}
  893|       |
  894|      7|	r = iso_ops->read_binary(card, 2, (unsigned char *)name, buf[1], 0);
  895|      7|	if (r < 1) {
  ------------------
  |  Branch (895:6): [True: 3, False: 4]
  ------------------
  896|      3|		free(name);
  897|      3|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} 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|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  898|      3|	}
  899|       |
  900|      4|	if (name[r-1] != '\0') {
  ------------------
  |  Branch (900:6): [True: 2, False: 2]
  ------------------
  901|      2|		name[r-1] = '\0';
  902|      2|	}
  903|      4|	*tname = name;
  904|       |
  905|      4|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      4|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      4|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      4|	int _ret = r; \
  |  |  |  |  155|      4|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      4|		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: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      4|	} 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|      4|	return _ret; \
  |  |  |  |  163|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  906|      4|}
card-idprime.c:idprime_get_init_and_get_count:
  768|    309|{
  769|    309|	if (countp == NULL || entry == NULL) {
  ------------------
  |  Branch (769:6): [True: 0, False: 309]
  |  Branch (769:24): [True: 0, False: 309]
  ------------------
  770|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  771|      0|	}
  772|    309|	*countp = list_size(list);
  773|    309|	list_iterator_start(list);
  774|    309|	*entry = list_iterator_next(list);
  775|    309|	return SC_SUCCESS;
  ------------------
  |  |   28|    309|#define SC_SUCCESS				0
  ------------------
  776|    309|}
card-idprime.c:idprime_fill_prkey_info:
  787|    628|{
  788|    628|	memset(prkey_info, 0, sizeof(sc_pkcs15_prkey_info_t));
  789|    628|	if (*entry == NULL) {
  ------------------
  |  Branch (789:6): [True: 0, False: 628]
  ------------------
  790|      0|		return SC_ERROR_FILE_END_REACHED;
  ------------------
  |  |   69|      0|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  791|      0|	}
  792|       |
  793|    628|	prkey_info->path.len = sizeof((*entry)->df);
  794|    628|	memcpy(prkey_info->path.value, (*entry)->df, sizeof((*entry)->df));
  795|    628|	prkey_info->path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    628|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  796|       |	/* Do not specify the length -- it will be read from the FCI */
  797|    628|	prkey_info->path.count = -1;
  798|       |
  799|       |	/* TODO figure out the IDs as the original driver? */
  800|    628|	prkey_info->id.value[0] = ((*entry)->fd >> 8) & 0xff;
  801|    628|	prkey_info->id.value[1] = (*entry)->fd & 0xff;
  802|    628|	prkey_info->id.len = 2;
  803|    628|	if ((*entry)->valid_key_ref)
  ------------------
  |  Branch (803:6): [True: 66, False: 562]
  ------------------
  804|     66|		prkey_info->key_reference = (*entry)->key_reference;
  805|    562|	else
  806|    562|		prkey_info->key_reference = -1;
  807|    628|	*entry = list_iterator_next(list);
  808|    628|	return SC_SUCCESS;
  ------------------
  |  |   28|    628|#define SC_SUCCESS				0
  ------------------
  809|    628|}
card-idprime.c:idprime_final_iterator:
  780|    309|{
  781|    309|	list_iterator_stop(list);
  782|    309|	return SC_SUCCESS;
  ------------------
  |  |   28|    309|#define SC_SUCCESS				0
  ------------------
  783|    309|}
card-idprime.c:idprime_get_pin_id:
  813|    628|{
  814|    628|	if (pin_id == NULL || entry == NULL) {
  ------------------
  |  Branch (814:6): [True: 0, False: 628]
  |  Branch (814:24): [True: 0, False: 628]
  ------------------
  815|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  816|      0|	}
  817|    628|	*pin_id = "11"; // normal PIN id
  818|    628|	if ((*entry)->pin_index != 1)
  ------------------
  |  Branch (818:6): [True: 46, False: 582]
  ------------------
  819|     46|		*pin_id = "83"; // signature PIN id
  820|    628|	return SC_SUCCESS;
  ------------------
  |  |   28|    628|#define SC_SUCCESS				0
  ------------------
  821|    628|}
card-idprime.c:idprime_get_challenge:
 1226|    415|{
 1227|    415|	u8 rbuf[16];
 1228|    415|	size_t out_len;
 1229|    415|	struct sc_apdu apdu;
 1230|    415|	int r;
 1231|       |
 1232|    415|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    415|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    415|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    415|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    415|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 415]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1233|       |
 1234|    415|	if (len <= 8) {
  ------------------
  |  Branch (1234:6): [True: 20, False: 395]
  ------------------
 1235|       |		/* official closed driver always calls this regardless the length */
 1236|     20|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x84, 0x00, 0x01);
  ------------------
  |  |  301|     20|#define SC_APDU_CASE_2			0x22
  ------------------
 1237|     20|		apdu.le = apdu.resplen = 8;
 1238|    395|	} else {
 1239|       |		/* this was discovered accidentally - all 16 bytes seem random */
 1240|    395|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x84, 0x00, 0x00);
  ------------------
  |  |  301|    395|#define SC_APDU_CASE_2			0x22
  ------------------
 1241|    395|		apdu.le = apdu.resplen = 16;
 1242|    395|	}
 1243|    415|	apdu.resp = rbuf;
 1244|       |
 1245|    415|	r = sc_transmit_apdu(card, &apdu);
 1246|    415|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    415|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    415|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    415|	int _ret = (r); \
  |  |  |  |  168|    415|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 413]
  |  |  |  |  ------------------
  |  |  |  |  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|    415|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 413]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1247|       |
 1248|    413|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1249|    413|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE failed");
  ------------------
  |  |  174|    413|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    413|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    413|	int _ret = (r); \
  |  |  |  |  168|    413|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 156, False: 257]
  |  |  |  |  ------------------
  |  |  |  |  169|    156|		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|    156|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    156|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    156|		return _ret; \
  |  |  |  |  172|    156|	} \
  |  |  |  |  173|    413|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 257]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1250|       |
 1251|    257|	out_len = len < apdu.resplen ? len : apdu.resplen;
  ------------------
  |  Branch (1251:12): [True: 2, False: 255]
  ------------------
 1252|    257|	memcpy(rnd, rbuf, out_len);
 1253|       |
 1254|    257|	LOG_FUNC_RETURN(card->ctx, (int) out_len);
  ------------------
  |  |  164|    257|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    257|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    257|	int _ret = r; \
  |  |  |  |  155|    257|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 253]
  |  |  |  |  ------------------
  |  |  |  |  156|      4|		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: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    253|	} else { \
  |  |  |  |  159|    253|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    253|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    253|	} \
  |  |  |  |  162|    257|	return _ret; \
  |  |  |  |  163|    257|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1255|    257|}

sc_get_isoApplet_driver:
 1295|  17.0k|{
 1296|  17.0k|	return sc_get_driver();
 1297|  17.0k|}
card-isoApplet.c:sc_get_driver:
 1259|  17.0k|{
 1260|  17.0k|	sc_card_driver_t *iso_drv = sc_get_iso7816_driver();
 1261|       |
 1262|  17.0k|	if(iso_ops == NULL)
  ------------------
  |  Branch (1262:5): [True: 1, False: 17.0k]
  ------------------
 1263|      1|	{
 1264|      1|		iso_ops = iso_drv->ops;
 1265|      1|	}
 1266|       |
 1267|  17.0k|	isoApplet_ops = *iso_drv->ops;
 1268|       |
 1269|  17.0k|	isoApplet_ops.match_card = isoApplet_match_card;
 1270|  17.0k|	isoApplet_ops.init = isoApplet_init;
 1271|  17.0k|	isoApplet_ops.finish = isoApplet_finish;
 1272|       |
 1273|  17.0k|	isoApplet_ops.card_ctl = isoApplet_card_ctl;
 1274|       |
 1275|  17.0k|	isoApplet_ops.create_file = isoApplet_create_file;
 1276|  17.0k|	isoApplet_ops.process_fci = isoApplet_process_fci;
 1277|  17.0k|	isoApplet_ops.set_security_env = isoApplet_set_security_env;
 1278|  17.0k|	isoApplet_ops.compute_signature = isoApplet_compute_signature;
 1279|  17.0k|	isoApplet_ops.get_challenge = isoApplet_get_challenge;
 1280|  17.0k|	isoApplet_ops.card_reader_lock_obtained = isoApplet_card_reader_lock_obtained;
 1281|  17.0k|	isoApplet_ops.logout = isoApplet_logout;
 1282|       |
 1283|       |	/* unsupported functions */
 1284|  17.0k|	isoApplet_ops.write_binary = NULL;
 1285|  17.0k|	isoApplet_ops.read_record = NULL;
 1286|  17.0k|	isoApplet_ops.write_record = NULL;
 1287|  17.0k|	isoApplet_ops.append_record = NULL;
 1288|  17.0k|	isoApplet_ops.update_record = NULL;
 1289|  17.0k|	isoApplet_ops.restore_security_env = NULL;
 1290|       |
 1291|  17.0k|	return &isoApplet_drv;
 1292|  17.0k|}
card-isoApplet.c:isoApplet_match_card:
  111|  3.70k|{
  112|  3.70k|	int rv;
  113|       |
  114|  3.70k|	rv = iso7816_select_aid(card, isoApplet_aid, sizeof(isoApplet_aid), NULL, NULL);
  115|  3.70k|	if(rv != SC_SUCCESS)
  ------------------
  |  |   28|  3.70k|#define SC_SUCCESS				0
  ------------------
  |  Branch (115:5): [True: 3.61k, False: 90]
  ------------------
  116|  3.61k|	{
  117|  3.61k|		return 0;
  118|  3.61k|	}
  119|       |
  120|     90|	return 1;
  121|  3.70k|}
card-isoApplet.c:isoApplet_init:
  155|     90|{
  156|     90|	int i, r;
  157|     90|	unsigned int major_version = 0;
  158|     90|	unsigned long flags = 0;
  159|     90|	unsigned long ext_flags = 0;
  160|     90|	struct isoApplet_drv_data *drvdata;
  161|       |
  162|     90|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     90|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     90|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     90|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     90|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|       |
  164|     90|	drvdata=calloc(1, sizeof(*drvdata));
  165|     90|	if (!drvdata)
  ------------------
  |  Branch (165:6): [True: 0, False: 90]
  ------------------
  166|     90|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|       |
  168|     90|	card->drv_data = drvdata;
  169|     90|	card->cla = 0x00;
  170|       |
  171|       |	/* Obtain applet version and specific features */
  172|     90|	r = isoApplet_get_info(card, drvdata);
  173|     90|	LOG_TEST_GOTO_ERR(card->ctx, r, "Error obtaining information about applet.");
  ------------------
  |  |  184|     90|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     90|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     90|	int _ret = (r); \
  |  |  |  |  178|     90|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 10, False: 80]
  |  |  |  |  ------------------
  |  |  |  |  179|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     10|		goto err; \
  |  |  |  |  182|     10|	} \
  |  |  |  |  183|     90|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 80]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  174|       |
  175|     80|	major_version = drvdata->isoapplet_version & 0xFF00;
  176|     80|	if(major_version != (ISOAPPLET_VERSION_V0 & 0xFF00) && major_version != (ISOAPPLET_VERSION_V1 & 0xFF00))
  ------------------
  |  |   36|     80|#define ISOAPPLET_VERSION_V0 0x0006
  ------------------
              	if(major_version != (ISOAPPLET_VERSION_V0 & 0xFF00) && major_version != (ISOAPPLET_VERSION_V1 & 0xFF00))
  ------------------
  |  |   37|      7|#define ISOAPPLET_VERSION_V1 0x0100
  ------------------
  |  Branch (176:5): [True: 7, False: 73]
  |  Branch (176:57): [True: 5, False: 2]
  ------------------
  177|      5|	{
  178|      5|		sc_log(card->ctx, "IsoApplet: Mismatching major API version. Not proceeding. "
  ------------------
  |  |   71|      5|#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)
  |  |  ------------------
  |  |  |  |  180|      5|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      5|#define ISOAPPLET_VERSION_V0 0x0006
  |  |  |  |  ------------------
  |  |  |  |               			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      5|#define ISOAPPLET_VERSION_V1 0x0100
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  179|      5|			   "API versions: Driver (%04X or %04X), applet (%04X). Please update accordingly.",
  180|      5|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  181|      5|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      5|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  182|      5|		goto err;
  183|      5|	}
  184|     75|	else if(drvdata->isoapplet_version != ISOAPPLET_VERSION_V0 && drvdata->isoapplet_version != ISOAPPLET_VERSION_V1)
  ------------------
  |  |   36|    150|#define ISOAPPLET_VERSION_V0 0x0006
  ------------------
              	else if(drvdata->isoapplet_version != ISOAPPLET_VERSION_V0 && drvdata->isoapplet_version != ISOAPPLET_VERSION_V1)
  ------------------
  |  |   37|     74|#define ISOAPPLET_VERSION_V1 0x0100
  ------------------
  |  Branch (184:10): [True: 74, False: 1]
  |  Branch (184:64): [True: 73, False: 1]
  ------------------
  185|     73|	{
  186|     73|		sc_log(card->ctx, "IsoApplet: Mismatching minor version. Proceeding anyway. "
  ------------------
  |  |   71|     73|#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)
  |  |  ------------------
  |  |  |  |  189|     73|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|     73|#define ISOAPPLET_VERSION_V0 0x0006
  |  |  |  |  ------------------
  |  |  |  |               			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|     73|#define ISOAPPLET_VERSION_V1 0x0100
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  187|     73|			   "API versions: Driver (%04X or %04X), applet (%04X). "
  188|     73|			   "Please update accordingly whenever possible.",
  189|     73|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  190|     73|	}
  191|       |
  192|     75|	if(drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_EXT_APDU)
  ------------------
  |  |   39|     75|#define ISOAPPLET_API_FEATURE_EXT_APDU 0x01
  ------------------
  |  Branch (192:5): [True: 6, False: 69]
  ------------------
  193|      6|		card->caps |=  SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|      6|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  194|     75|	if(drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_SECURE_RANDOM)
  ------------------
  |  |   40|     75|#define ISOAPPLET_API_FEATURE_SECURE_RANDOM 0x02
  ------------------
  |  Branch (194:5): [True: 24, False: 51]
  ------------------
  195|     24|		card->caps |=  SC_CARD_CAP_RNG;
  ------------------
  |  |  550|     24|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  196|     75|	if(drvdata->isoapplet_version <= 0x0005
  ------------------
  |  Branch (196:5): [True: 56, False: 19]
  ------------------
  197|     19|			|| drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_ECC)
  ------------------
  |  |   41|     19|#define ISOAPPLET_API_FEATURE_ECC 0x04
  ------------------
  |  Branch (197:7): [True: 13, False: 6]
  ------------------
  198|     69|	{
  199|       |		/* There are Java Cards that do not support ECDSA at all. The IsoApplet
  200|       |		 * started to report this with version 00.06.
  201|       |		 *
  202|       |		 * Curves supported by the pkcs15-init driver are indicated per curve. This
  203|       |		 * should be kept in sync with the explicit parameters in the pkcs15-init
  204|       |		 * driver. */
  205|     69|		flags = 0;
  206|     69|		if (major_version == (ISOAPPLET_VERSION_V0 & 0xFF00)) {
  ------------------
  |  |   36|     69|#define ISOAPPLET_VERSION_V0 0x0006
  ------------------
  |  Branch (206:7): [True: 67, False: 2]
  ------------------
  207|     67|			flags |= SC_ALGORITHM_ECDSA_HASH_SHA1;
  ------------------
  |  |  176|     67|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|     67|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
  208|     67|		} else { // ISOAPPLET_VERSION_V1
  209|      2|			flags |= SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|      2|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  210|      2|			flags |= SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|      2|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|      2|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  211|      2|		}
  212|     69|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|     69|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  213|     69|		ext_flags = SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  202|     69|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  214|     69|		ext_flags |=  SC_ALGORITHM_EXT_EC_NAMEDCURVE;
  ------------------
  |  |  201|     69|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  215|     69|		ext_flags |= SC_ALGORITHM_EXT_EC_F_P;
  ------------------
  |  |  198|     69|#define SC_ALGORITHM_EXT_EC_F_P          0x00000001
  ------------------
  216|    759|		for (i=0; ec_curves[i].oid.value[0] >= 0; i++)
  ------------------
  |  Branch (216:13): [True: 690, False: 69]
  ------------------
  217|    690|		{
  218|    690|			if(drvdata->isoapplet_version >= ec_curves[i].min_applet_version)
  ------------------
  |  Branch (218:7): [True: 578, False: 112]
  ------------------
  219|    578|				_sc_card_add_ec_alg(card, ec_curves[i].size, flags, ext_flags, &ec_curves[i].oid);
  220|    690|		}
  221|     69|	}
  222|       |
  223|       |	/* RSA */
  224|     75|	flags = 0;
  225|     75|	flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|     75|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     75|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     75|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  226|     75|	flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|     75|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  227|     75|	if(drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_RSA_PSS) {
  ------------------
  |  |   42|     75|#define ISOAPPLET_API_FEATURE_RSA_PSS 0x08
  ------------------
  |  Branch (227:5): [True: 13, False: 62]
  ------------------
  228|     13|		flags |= SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  107|     13|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  229|     13|	}
  230|       |	/* Key-generation: */
  231|     75|	flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|     75|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  232|       |	/* Modulus lengths: */
  233|     75|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  234|     75|	if (drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_RSA_4096) {
  ------------------
  |  |   43|     75|#define ISOAPPLET_API_FEATURE_RSA_4096 0x20
  ------------------
  |  Branch (234:6): [True: 11, False: 64]
  ------------------
  235|     11|		_sc_card_add_rsa_alg(card, 4096, flags, 0);
  236|     11|	}
  237|       |
  238|     75|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     75|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     75|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     75|	int _ret = r; \
  |  |  |  |  155|     75|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 75, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     75|		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: 75]
  |  |  |  |  ------------------
  |  |  |  |  157|     75|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     75|	} 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|     75|	return _ret; \
  |  |  |  |  163|     75|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  239|     15|err:
  240|     15|	free(drvdata);
  241|     15|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     15|	} 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|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|     15|}
card-isoApplet.c:isoApplet_get_info:
  124|     90|isoApplet_get_info(sc_card_t * card, struct isoApplet_drv_data * drvdata) {
  125|     90|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  126|     90|	int rv;
  127|     90|	sc_context_t * ctx = card->ctx;
  128|       |
  129|     90|	rv = sc_get_data(card, 0x0101, rbuf, 3);
  130|     90|	if(rv == SC_ERROR_INS_NOT_SUPPORTED) {
  ------------------
  |  |   54|     90|#define SC_ERROR_INS_NOT_SUPPORTED		-1204
  ------------------
  |  Branch (130:5): [True: 8, False: 82]
  ------------------
  131|       |		/* INS not supported. This is an older IsoApplet that might return the
  132|       |		 * applet information upon selection. For backward compatibility, try this. */
  133|      8|		size_t rlen = sizeof(rbuf);
  134|      8|		rv = iso7816_select_aid(card, isoApplet_aid, sizeof(isoApplet_aid), rbuf, &rlen);
  135|      8|		LOG_TEST_RET(ctx, rv, "Error selecting applet.");
  ------------------
  |  |  174|      8|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      8|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      8|	int _ret = (r); \
  |  |  |  |  168|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      4|		return _ret; \
  |  |  |  |  172|      4|	} \
  |  |  |  |  173|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  136|      4|		rv = (int)rlen;
  137|      4|	}
  138|       |
  139|     86|	if (rv < 0) {
  ------------------
  |  Branch (139:6): [True: 6, False: 80]
  ------------------
  140|      6|		LOG_TEST_RET(ctx, rv, "Card returned error.");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|      6|	}
  142|       |
  143|       |	/* Fill up drvdata */
  144|     80|	if(rv >= 3)
  ------------------
  |  Branch (144:5): [True: 35, False: 45]
  ------------------
  145|     35|	{
  146|     35|		drvdata->isoapplet_version = rbuf[0] << 8 | rbuf[1];
  147|     35|		drvdata->isoapplet_features = rbuf[2];
  148|     35|	}
  149|       |
  150|     80|	return SC_SUCCESS;
  ------------------
  |  |   28|     80|#define SC_SUCCESS				0
  ------------------
  151|     86|}
card-isoApplet.c:isoApplet_finish:
   97|     75|{
   98|     75|	struct isoApplet_drv_data *drvdata=DRVDATA(card);
  ------------------
  |  |   59|     75|#define DRVDATA(card)	((struct isoApplet_drv_data *) ((card)->drv_data))
  ------------------
   99|       |
  100|     75|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     75|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     75|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     75|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     75|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 75]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|     75|	if (drvdata)
  ------------------
  |  Branch (101:6): [True: 75, False: 0]
  ------------------
  102|     75|	{
  103|     75|		free(drvdata);
  104|     75|		card->drv_data=NULL;
  105|     75|	}
  106|     75|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     75|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     75|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     75|	int _ret = r; \
  |  |  |  |  155|     75|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 75, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     75|		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: 75]
  |  |  |  |  ------------------
  |  |  |  |  157|     75|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     75|	} 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|     75|	return _ret; \
  |  |  |  |  163|     75|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|     75|}
card-isoApplet.c:isoApplet_card_ctl:
 1037|     48|{
 1038|     48|	int r = 0;
 1039|       |
 1040|     48|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     48|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     48|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     48|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     48|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1041|     48|	switch (cmd)
 1042|     48|	{
 1043|      0|	case SC_CARDCTL_ISOAPPLET_GENERATE_KEY:
  ------------------
  |  Branch (1043:2): [True: 0, False: 48]
  ------------------
 1044|      0|		r = isoApplet_ctl_generate_key(card,
 1045|      0|		                               (sc_cardctl_isoApplet_genkey_t *) ptr);
 1046|      0|		break;
 1047|      0|	case SC_CARDCTL_ISOAPPLET_IMPORT_KEY:
  ------------------
  |  Branch (1047:2): [True: 0, False: 48]
  ------------------
 1048|      0|		r = isoApplet_ctl_import_key(card,
 1049|      0|		                             (sc_cardctl_isoApplet_import_key_t *) ptr);
 1050|      0|		break;
 1051|     48|	default:
  ------------------
  |  Branch (1051:2): [True: 48, False: 0]
  ------------------
 1052|     48|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     48|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1053|     48|	}
 1054|     48|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     48|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     48|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     48|	int _ret = r; \
  |  |  |  |  155|     48|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 48, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     48|		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|     48|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 48, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     48|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     48|	} 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|     48|	return _ret; \
  |  |  |  |  163|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1055|     48|}
card-isoApplet.c:isoApplet_process_fci:
  405|     70|{
  406|     70|	int r;
  407|     70|	u8 *sa = NULL;
  408|       |
  409|     70|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     70|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     70|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     70|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     70|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 70]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  410|       |
  411|     70|	r = iso_ops->process_fci(card, file, buf, buflen);
  412|     70|	LOG_TEST_RET(card->ctx, r, "Error while processing the FCI.");
  ------------------
  |  |  174|     70|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     70|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     70|	int _ret = (r); \
  |  |  |  |  168|     70|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 70]
  |  |  |  |  ------------------
  |  |  |  |  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|     70|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 70]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  413|       |	/* Construct the ACL from the sec_attr. */
  414|     70|	if(file->sec_attr && file->sec_attr_len == 8)
  ------------------
  |  Branch (414:5): [True: 53, False: 17]
  |  Branch (414:23): [True: 41, False: 12]
  ------------------
  415|     41|	{
  416|     41|		sa = file->sec_attr;
  417|     41|		if(sa[0] != 0xFF)
  ------------------
  |  Branch (417:6): [True: 6, False: 35]
  ------------------
  418|      6|		{
  419|      6|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA,
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  420|      6|			             "File security attribute does not contain a ACL byte for every operation.");
  421|      6|		}
  422|     35|		if(file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|     35|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (422:6): [True: 10, False: 25]
  ------------------
  423|     10|		{
  424|     10|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DELETE_SELF, sa[1]);
  ------------------
  |  |  174|     10|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  425|     10|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|     10|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_LOCK, sa[2]);
  ------------------
  |  |  167|     10|#define SC_AC_OP_LOCK			1
  ------------------
  427|     10|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  428|     10|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_ACTIVATE, sa[3]);
  ------------------
  |  |  186|     10|#define SC_AC_OP_ACTIVATE		20
  ------------------
  429|     10|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  430|     10|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DEACTIVATE, sa[4]);
  ------------------
  |  |  187|     10|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  431|     10|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|     10|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_CREATE_DF, sa[5]);
  ------------------
  |  |  194|     10|#define SC_AC_OP_CREATE_DF		28
  ------------------
  433|     10|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|     10|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_CREATE_EF, sa[6]);
  ------------------
  |  |  193|     10|#define SC_AC_OP_CREATE_EF		27
  ------------------
  435|     10|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|     10|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DELETE, sa[7]);
  ------------------
  |  |  168|     10|#define SC_AC_OP_DELETE			2
  ------------------
  437|     10|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|     10|		}
  439|     25|		else if(file->type == SC_FILE_TYPE_INTERNAL_EF
  ------------------
  |  |  215|     50|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (439:11): [True: 11, False: 14]
  ------------------
  440|     14|		        || file->type == SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|     14|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (440:14): [True: 8, False: 6]
  ------------------
  441|     19|		{
  442|     19|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DELETE_SELF, sa[1]);
  ------------------
  |  |  174|     19|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  443|     19|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     19|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     19|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     19|	int _ret = (r); \
  |  |  |  |  168|     19|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|     19|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_LOCK, sa[2]);
  ------------------
  |  |  167|     19|#define SC_AC_OP_LOCK			1
  ------------------
  445|     19|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     19|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     19|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     19|	int _ret = (r); \
  |  |  |  |  168|     19|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|     19|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_ACTIVATE, sa[3]);
  ------------------
  |  |  186|     19|#define SC_AC_OP_ACTIVATE		20
  ------------------
  447|     19|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     19|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     19|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     19|	int _ret = (r); \
  |  |  |  |  168|     19|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  448|     19|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DEACTIVATE, sa[4]);
  ------------------
  |  |  187|     19|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  449|     19|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     19|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     19|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     19|	int _ret = (r); \
  |  |  |  |  168|     19|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  450|     19|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_WRITE, sa[5]);
  ------------------
  |  |  190|     19|#define SC_AC_OP_WRITE			24
  ------------------
  451|     19|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     19|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     19|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     19|	int _ret = (r); \
  |  |  |  |  168|     19|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  452|     19|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_UPDATE, sa[6]);
  ------------------
  |  |  189|     19|#define SC_AC_OP_UPDATE			23
  ------------------
  453|     19|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     19|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     19|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     19|	int _ret = (r); \
  |  |  |  |  168|     19|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|     19|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_READ, sa[7]);
  ------------------
  |  |  188|     19|#define SC_AC_OP_READ			22
  ------------------
  455|     19|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  174|     19|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     19|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     19|	int _ret = (r); \
  |  |  |  |  168|     19|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  456|     19|		}
  457|       |
  458|     35|	}
  459|       |
  460|     64|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     64|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     64|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     64|	int _ret = r; \
  |  |  |  |  155|     64|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 64, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     64|		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: 64]
  |  |  |  |  ------------------
  |  |  |  |  157|     64|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     64|	} 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|     64|	return _ret; \
  |  |  |  |  163|     64|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  461|     64|}
card-isoApplet.c:isoApplet_add_sa_to_acl:
  368|    203|{
  369|    203|	int r;
  370|       |
  371|    203|	switch(saByte)
  372|    203|	{
  373|     40|	case 0x90:
  ------------------
  |  Branch (373:2): [True: 40, False: 163]
  ------------------
  374|     40|		r = sc_file_add_acl_entry(file, operation, SC_AC_CHV, 1);
  ------------------
  |  |  151|     40|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  375|     40|		if(r < 0)
  ------------------
  |  Branch (375:6): [True: 0, False: 40]
  ------------------
  376|      0|			return r;
  377|     40|		break;
  378|     40|	case 0xFF:
  ------------------
  |  Branch (378:2): [True: 34, False: 169]
  ------------------
  379|     34|		r = sc_file_add_acl_entry(file, operation, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  163|     34|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		r = sc_file_add_acl_entry(file, operation, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     34|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  380|     34|		if(r < 0)
  ------------------
  |  Branch (380:6): [True: 0, False: 34]
  ------------------
  381|      0|			return r;
  382|     34|		break;
  383|     44|	case 0x00:
  ------------------
  |  Branch (383:2): [True: 44, False: 159]
  ------------------
  384|     44|		r = sc_file_add_acl_entry(file, operation, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     44|#define SC_AC_NONE			0x00000000
  ------------------
              		r = sc_file_add_acl_entry(file, operation, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     44|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  385|     44|		if(r < 0)
  ------------------
  |  Branch (385:6): [True: 0, False: 44]
  ------------------
  386|      0|			return r;
  387|     44|		break;
  388|     85|	default:
  ------------------
  |  Branch (388:2): [True: 85, False: 118]
  ------------------
  389|     85|		r = sc_file_add_acl_entry(file, operation, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  162|     85|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		r = sc_file_add_acl_entry(file, operation, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     85|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  390|     85|		if(r < 0)
  ------------------
  |  Branch (390:6): [True: 0, False: 85]
  ------------------
  391|      0|			return r;
  392|    203|	}
  393|    203|	return SC_SUCCESS;
  ------------------
  |  |   28|    203|#define SC_SUCCESS				0
  ------------------
  394|    203|}
card-isoApplet.c:isoApplet_get_challenge:
 1226|    262|{
 1227|    262|	int r;
 1228|       |
 1229|    262|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    262|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    262|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    262|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    262|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 262]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1230|       |
 1231|    262|	if(card->caps & SC_CARD_CAP_RNG) {
  ------------------
  |  |  550|    262|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  |  Branch (1231:5): [True: 259, False: 3]
  ------------------
 1232|    259|		r = iso_ops->get_challenge(card, rnd, len);
 1233|    259|	} else   {
 1234|      3|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      3|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1235|      3|	}
 1236|       |
 1237|    262|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    262|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    262|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    262|	int _ret = r; \
  |  |  |  |  155|    262|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 247]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 14, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    247|	} else { \
  |  |  |  |  159|    247|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    247|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    247|	} \
  |  |  |  |  162|    262|	return _ret; \
  |  |  |  |  163|    262|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1238|    262|}
card-isoApplet.c:isoApplet_card_reader_lock_obtained:
 1241|  4.01k|{
 1242|  4.01k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  4.01k|#define SC_SUCCESS				0
  ------------------
 1243|       |
 1244|  4.01k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  4.01k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  4.01k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  4.01k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 4.01k]
  |  |  ------------------
  ------------------
 1245|       |
 1246|  4.01k|	if (was_reset > 0) {
  ------------------
  |  Branch (1246:6): [True: 0, False: 4.01k]
  ------------------
 1247|      0|		r = iso7816_select_aid(card, isoApplet_aid, sizeof(isoApplet_aid), NULL, NULL);
 1248|      0|	}
 1249|       |
 1250|  4.01k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  4.01k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.01k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.01k|	int _ret = r; \
  |  |  |  |  155|  4.01k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.01k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.01k|		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: 4.01k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.01k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.01k|	} 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|  4.01k|	return _ret; \
  |  |  |  |  163|  4.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1251|  4.01k|}

sc_get_itacns_driver:
  523|  17.0k|{
  524|  17.0k|	return sc_get_driver();
  525|  17.0k|}
card-itacns.c:sc_get_driver:
  504|  17.0k|{
  505|  17.0k|	if (!default_ops)
  ------------------
  |  Branch (505:6): [True: 1, False: 17.0k]
  ------------------
  506|      1|		default_ops = sc_get_iso7816_driver()->ops;
  507|  17.0k|	itacns_ops = *default_ops;
  508|  17.0k|	itacns_ops.match_card = itacns_match_card;
  509|  17.0k|	itacns_ops.init = itacns_init;
  510|  17.0k|	itacns_ops.finish = itacns_finish;
  511|  17.0k|	itacns_ops.set_security_env = itacns_set_security_env;
  512|  17.0k|	itacns_ops.restore_security_env = itacns_restore_security_env;
  513|  17.0k|	itacns_ops.pin_cmd = itacns_pin_cmd;
  514|  17.0k|	itacns_ops.read_binary = itacns_read_binary;
  515|  17.0k|	itacns_ops.list_files = itacns_list_files;
  516|  17.0k|	itacns_ops.select_file = itacns_select_file;
  517|  17.0k|	itacns_ops.card_ctl = itacns_card_ctl;
  518|  17.0k|	itacns_ops.get_challenge = itacns_get_challenge;
  519|  17.0k|	return &itacns_drv;
  520|  17.0k|}
card-itacns.c:itacns_match_card:
  122|  3.99k|{
  123|  3.99k|	int r = 0;
  124|       |
  125|       |	/* Try table first */
  126|  3.99k|	r = _sc_match_atr(card, itacns_atrs, &card->type);
  127|  3.99k|	if(r >= 0) return 1;
  ------------------
  |  Branch (127:5): [True: 64, False: 3.93k]
  ------------------
  128|       |
  129|  3.93k|	if (itacns_match_cns_card(card)) return 1;
  ------------------
  |  Branch (129:6): [True: 112, False: 3.82k]
  ------------------
  130|  3.82k|	if (itacns_match_cie_card(card)) return 1;
  ------------------
  |  Branch (130:6): [True: 119, False: 3.70k]
  ------------------
  131|       |
  132|       |	/* No card type was matched. */
  133|  3.70k|	return 0;
  134|  3.82k|}
card-itacns.c:itacns_match_cns_card:
   85|  3.93k|{
   86|  3.93k|	u8 manufacturer_code;
   87|  3.93k|	u8 manufacturer_mask;
   88|  3.93k|	u8 fw_major;
   89|       |
   90|  3.93k|	if (15 != card->reader->atr_info.hist_bytes_len ||
  ------------------
  |  Branch (90:6): [True: 3.63k, False: 301]
  ------------------
   91|    301|	    0 != memcmp(card->reader->atr_info.hist_bytes+9, "CNS", 3))
  ------------------
  |  Branch (91:6): [True: 189, False: 112]
  ------------------
   92|  3.82k|		return 0;
   93|       |
   94|    112|	card->type = SC_CARD_TYPE_ITACNS_CNS;
   95|       |
   96|    112|	manufacturer_code = card->reader->atr_info.hist_bytes[2];
   97|    112|	manufacturer_mask = card->reader->atr_info.hist_bytes[3];
   98|    112|	fw_major = card->reader->atr_info.hist_bytes[4];
   99|       |
  100|    112|	if (manufacturer_code == ITACNS_ICMAN_INFINEON &&
  ------------------
  |  |    9|    224|#define ITACNS_ICMAN_INFINEON		0x05
  ------------------
  |  Branch (100:6): [True: 8, False: 104]
  ------------------
  101|      8|	    manufacturer_mask == ITACNS_MASKMAN_IDEMIA &&
  ------------------
  |  |   11|    120|#define ITACNS_MASKMAN_IDEMIA		0x05
  ------------------
  |  Branch (101:6): [True: 7, False: 1]
  ------------------
  102|      7|	    fw_major >= 32) {
  ------------------
  |  Branch (102:6): [True: 2, False: 5]
  ------------------
  103|      2|			card->type = SC_CARD_TYPE_ITACNS_CNS_IDEMIA_2021;
  104|      2|	}
  105|       |
  106|    112|	return 1;
  107|  3.93k|}
card-itacns.c:itacns_match_cie_card:
  110|  3.82k|{
  111|  3.82k|	u8 h7_to_h15[] = { 0x02, 'I', 'T', 'I', 'D', 0x20, 0x20, 0x31, 0x80, };
  112|  3.82k|	if (15 != card->reader->atr_info.hist_bytes_len ||
  ------------------
  |  Branch (112:6): [True: 3.63k, False: 189]
  ------------------
  113|    189|	    0 != memcmp(card->reader->atr_info.hist_bytes+6,
  ------------------
  |  Branch (113:6): [True: 70, False: 119]
  ------------------
  114|    189|			h7_to_h15, sizeof h7_to_h15))
  115|  3.70k|		return 0;
  116|       |
  117|    119|	card->type = SC_CARD_TYPE_ITACNS_CIE_V2;
  118|    119|	return 1;
  119|  3.82k|}
card-itacns.c:itacns_init:
  141|    295|{
  142|    295|	unsigned long	flags;
  143|       |
  144|    295|	SC_FUNC_CALLED(card->ctx, 1);
  ------------------
  |  |  148|    295|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    295|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    295|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 295]
  |  |  ------------------
  ------------------
  145|       |
  146|    295|	card->name = "CNS card";
  147|    295|	card->cla = 0x00;
  148|       |
  149|    295|	card->drv_data = calloc(1, sizeof(itacns_drv_data_t));
  150|    295|	if (!card->drv_data)
  ------------------
  |  Branch (150:6): [True: 0, False: 295]
  ------------------
  151|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  152|       |
  153|    295|	if (card->type == SC_CARD_TYPE_ITACNS_CNS)
  ------------------
  |  Branch (153:6): [True: 110, False: 185]
  ------------------
  154|    110|		itacns_init_cns_card(card);
  155|       |
  156|    295|	DRVDATA(card)->ic_manufacturer_code = card->reader->atr_info.hist_bytes[2];
  ------------------
  |  |   64|    295|#define DRVDATA(card) ((itacns_drv_data_t *) card->drv_data)
  ------------------
  157|    295|	DRVDATA(card)->mask_manufacturer_code = card->reader->atr_info.hist_bytes[3];
  ------------------
  |  |   64|    295|#define DRVDATA(card) ((itacns_drv_data_t *) card->drv_data)
  ------------------
  158|    295|	card->version.fw_major = card->reader->atr_info.hist_bytes[4];
  159|    295|	card->version.fw_minor = card->reader->atr_info.hist_bytes[5];
  160|       |
  161|       |	/* Set up algorithm info. */
  162|    295|	flags = SC_ALGORITHM_NEED_USAGE
  ------------------
  |  |   95|    295|#define SC_ALGORITHM_NEED_USAGE		0x40000000
  ------------------
  163|    295|		| SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  102|    295|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  164|    295|		| SC_ALGORITHM_RSA_HASHES
  ------------------
  |  |  142|    295|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
  165|    295|		;
  166|       |
  167|    295|	if ((card->version.hw_major >= 1 && card->version.hw_minor >= 1) ||
  ------------------
  |  Branch (167:7): [True: 48, False: 247]
  |  Branch (167:38): [True: 39, False: 9]
  ------------------
  168|    256|	    card->type == SC_CARD_TYPE_ITACNS_CNS_IDEMIA_2021) {
  ------------------
  |  Branch (168:6): [True: 66, False: 190]
  ------------------
  169|    105|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|    105|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  170|    105|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  171|    190|	} else {
  172|    190|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  173|    190|	}
  174|    295|	return SC_SUCCESS;
  ------------------
  |  |   28|    295|#define SC_SUCCESS				0
  ------------------
  175|    295|}
card-itacns.c:itacns_init_cns_card:
   67|    110|{
   68|    110|	if (15 != card->reader->atr_info.hist_bytes_len)
  ------------------
  |  Branch (68:6): [True: 0, False: 110]
  ------------------
   69|      0|		return;
   70|       |
   71|    110|	u8 cns_version = card->reader->atr_info.hist_bytes[12];
   72|    110|	card->version.hw_major = (cns_version >> 4) & 0x0f;
   73|    110|	card->version.hw_minor = cns_version & 0x0f;
   74|       |
   75|       |	/* Warn if version is not 1.X. */
   76|    110|	if (cns_version != 0x10 && cns_version != 0x11) {
  ------------------
  |  Branch (76:6): [True: 109, False: 1]
  |  Branch (76:29): [True: 108, False: 1]
  ------------------
   77|    108|		char version[8];
   78|    108|		snprintf(version, sizeof(version), "%d.%d", card->version.hw_major, card->version.hw_minor);
   79|    108|		sc_log(card->ctx, "CNS card version %s; no official specifications "
  ------------------
  |  |   71|    108|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   80|    108|		       "are published. Proceeding anyway.\n", version);
   81|    108|	}
   82|    110|}
card-itacns.c:itacns_finish:
  178|    295|{
  179|    295|	if(card->drv_data) {
  ------------------
  |  Branch (179:5): [True: 295, False: 0]
  ------------------
  180|    295|		free(card->drv_data);
  181|    295|	}
  182|    295|	return 0;
  183|    295|}
card-itacns.c:itacns_pin_cmd:
  297|     52|{
  298|     52|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|     52|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  299|       |	/* Enable backtracking for STIncard cards. */
  300|     52|	if(DRVDATA(card)->mask_manufacturer_code == ITACNS_MASKMAN_STINCARD) {
  ------------------
  |  |   64|     52|#define DRVDATA(card) ((itacns_drv_data_t *) card->drv_data)
  ------------------
              	if(DRVDATA(card)->mask_manufacturer_code == ITACNS_MASKMAN_STINCARD) {
  ------------------
  |  |   13|     52|#define ITACNS_MASKMAN_STINCARD		0x09
  ------------------
  |  Branch (300:5): [True: 7, False: 45]
  ------------------
  301|      7|		data->pin_reference |= 0x80;
  302|      7|	}
  303|       |
  304|       |	/* FIXME: the following values depend on what pin length was
  305|       |	 * used when creating the BS objects */
  306|     52|	if (data->pin1.max_length == 0)
  ------------------
  |  Branch (306:6): [True: 52, False: 0]
  ------------------
  307|     52|		data->pin1.max_length = 8;
  308|     52|	if (data->pin2.max_length == 0)
  ------------------
  |  Branch (308:6): [True: 52, False: 0]
  ------------------
  309|     52|		data->pin2.max_length = 8;
  310|     52|	return default_ops->pin_cmd(card, data);
  311|     52|}
card-itacns.c:itacns_read_binary:
  316|  2.43k|{
  317|  2.43k|	size_t already_read = 0;
  318|  2.43k|	size_t requested;
  319|  2.43k|	int r;
  320|  3.20k|	while(1) {
  ------------------
  |  Branch (320:8): [True: 3.20k, Folded]
  ------------------
  321|  3.20k|		requested = count - already_read;
  322|  3.20k|		if(requested > ITACNS_MAX_PAYLOAD)
  ------------------
  |  |   36|  3.20k|#define ITACNS_MAX_PAYLOAD 0xff
  ------------------
  |  Branch (322:6): [True: 1.93k, False: 1.27k]
  ------------------
  323|  1.93k|			requested = ITACNS_MAX_PAYLOAD;
  ------------------
  |  |   36|  1.93k|#define ITACNS_MAX_PAYLOAD 0xff
  ------------------
  324|  3.20k|		r = default_ops->read_binary(card, (unsigned)(idx + already_read),
  325|  3.20k|			&buf[already_read], requested, flags);
  326|  3.20k|		if(r < 0)
  ------------------
  |  Branch (326:6): [True: 549, False: 2.66k]
  ------------------
  327|    549|			return r;
  328|  2.66k|		already_read += r;
  329|  2.66k|		if (r == 0 || (size_t)r < requested || already_read == count) {
  ------------------
  |  Branch (329:7): [True: 122, False: 2.53k]
  |  Branch (329:17): [True: 727, False: 1.81k]
  |  Branch (329:42): [True: 1.03k, False: 774]
  ------------------
  330|       |			/* We have finished */
  331|  1.88k|			return (int)already_read;
  332|  1.88k|		}
  333|  2.66k|	}
  334|  2.43k|}
card-itacns.c:itacns_select_file:
  421|  3.50k|{
  422|  3.50k|	int r;
  423|       |
  424|  3.50k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.50k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.50k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.50k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.50k]
  |  |  ------------------
  ------------------
  425|  3.50k|	r = default_ops->select_file(card, in_path, file);
  426|  3.50k|	if (r >= 0 && file) {
  ------------------
  |  Branch (426:6): [True: 1.81k, False: 1.68k]
  |  Branch (426:16): [True: 697, False: 1.11k]
  ------------------
  427|    697|		parse_sec_attr((*file), (*file)->sec_attr,
  428|    697|			(*file)->sec_attr_len);
  429|    697|	}
  430|  3.50k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  3.50k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.50k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.50k|	int _ret = r; \
  |  |  |  |  155|  3.50k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.50k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.50k|		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|  1.68k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.68k, False: 1.81k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.50k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.50k|	} 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|  3.50k|	return _ret; \
  |  |  |  |  163|  3.50k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  431|  3.50k|}
card-itacns.c:parse_sec_attr:
  403|    697|{
  404|    697|	size_t i;
  405|    697|	const int *idx;
  406|       |
  407|    697|	idx = (file->type == SC_FILE_TYPE_DF) ?  df_acl : ef_acl;
  ------------------
  |  |  214|    697|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (407:8): [True: 3, False: 694]
  ------------------
  408|       |
  409|       |	/* acl defaults to 0xFF if unspecified */
  410|  6.97k|	for (i = 0; i < 9; i++) {
  ------------------
  |  Branch (410:14): [True: 6.27k, False: 697]
  ------------------
  411|  6.27k|		if (idx[i] != -1) {
  ------------------
  |  Branch (411:7): [True: 4.87k, False: 1.39k]
  ------------------
  412|  4.87k|			add_acl_entry(file, idx[i],
  413|  4.87k|				(u8)((i < len) ? buf[i] : 0xFF));
  ------------------
  |  Branch (413:10): [True: 147, False: 4.73k]
  ------------------
  414|  4.87k|		}
  415|  6.27k|	}
  416|    697|}
card-itacns.c:add_acl_entry:
  350|  4.87k|{
  351|  4.87k|	unsigned int method, key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  4.87k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  352|       |
  353|  4.87k|	switch (byte) {
  354|     27|	case 0x00:
  ------------------
  |  Branch (354:2): [True: 27, False: 4.85k]
  ------------------
  355|     27|		method = SC_AC_NONE;
  ------------------
  |  |  150|     27|#define SC_AC_NONE			0x00000000
  ------------------
  356|     27|		break;
  357|  4.74k|	case 0xFF:
  ------------------
  |  Branch (357:2): [True: 4.74k, False: 138]
  ------------------
  358|  4.75k|	case 0x66:
  ------------------
  |  Branch (358:2): [True: 11, False: 4.86k]
  ------------------
  359|  4.75k|		method = SC_AC_NEVER;
  ------------------
  |  |  163|  4.75k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  360|  4.75k|		break;
  361|    100|	default:
  ------------------
  |  Branch (361:2): [True: 100, False: 4.77k]
  ------------------
  362|    100|		if (byte > 0x1F) {
  ------------------
  |  Branch (362:7): [True: 54, False: 46]
  ------------------
  363|     54|			method = SC_AC_UNKNOWN;
  ------------------
  |  |  162|     54|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  364|     54|		} else {
  365|     46|			method = SC_AC_CHV;
  ------------------
  |  |  151|     46|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  366|     46|			key_ref = byte;
  367|     46|		}
  368|    100|		break;
  369|  4.87k|	}
  370|  4.87k|	sc_file_add_acl_entry(file, op, method, key_ref);
  371|  4.87k|}
card-itacns.c:itacns_card_ctl:
  486|    118|{
  487|    118|	switch (cmd) {
  ------------------
  |  Branch (487:10): [True: 52, False: 66]
  ------------------
  488|     52|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (488:3): [True: 52, False: 66]
  ------------------
  489|     52|		return itacns_get_serialnr(card, ptr);
  490|    118|	}
  491|     66|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     66|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  492|    118|}
card-itacns.c:itacns_get_serialnr:
  434|     52|{
  435|     52|	sc_path_t path;
  436|     52|	sc_file_t *file;
  437|     52|	size_t    len;
  438|     52|	int r;
  439|     52|	u8        rbuf[256];
  440|       |
  441|     52|	if (!serial) return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  |  Branch (441:6): [True: 0, False: 52]
  ------------------
  442|       |
  443|       |	/* see if we have cached serial number */
  444|     52|	if (card->serialnr.len) {
  ------------------
  |  Branch (444:6): [True: 0, False: 52]
  ------------------
  445|      0|		memcpy(serial, &card->serialnr, sizeof(*serial));
  446|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  447|      0|	}
  448|       |
  449|     52|	sc_log(card->ctx, "Reading EF_IDCarta.\n");
  ------------------
  |  |   71|     52|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  450|       |
  451|     52|	sc_format_path("3F0010001003", &path);
  452|       |
  453|     52|	r = sc_select_file(card, &path, &file);
  454|     52|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     52|#define SC_SUCCESS				0
  ------------------
  |  Branch (454:6): [True: 28, False: 24]
  ------------------
  455|     28|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|     28|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  456|     28|	}
  457|     24|	len = file->size;
  458|     24|	sc_file_free(file);
  459|       |
  460|       |	//Returned file->size should be 16.
  461|       |	//We choose to not consider it as critical, because some cards
  462|       |	//do not return FCI/FCP templates that include the file size.
  463|       |	//Notify abnormal length anyway.
  464|     24|	if (len != 16) {
  ------------------
  |  Branch (464:6): [True: 23, False: 1]
  ------------------
  465|     23|		sc_log(card->ctx,
  ------------------
  |  |   71|     23|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  466|     23|				"Unexpected file length of EF_IDCarta (%lu)\n",
  467|     23|				(unsigned long) len);
  468|     23|	}
  469|       |
  470|     24|	r = sc_read_binary(card, 0, rbuf, 256, 0);
  471|     24|	if ( r != 16 ) {
  ------------------
  |  Branch (471:7): [True: 23, False: 1]
  ------------------
  472|     23|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|     23|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  473|     23|	}
  474|       |
  475|       |	/* cache serial number */
  476|      1|	memcpy(card->serialnr.value, rbuf, 16);
  477|      1|	card->serialnr.len = 16;
  478|       |	/* copy and return serial number */
  479|      1|	memcpy(serial, &card->serialnr, sizeof(*serial));
  480|       |
  481|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  482|     24|}
card-itacns.c:itacns_get_challenge:
  496|    228|{
  497|    228|	if (card->type == SC_CARD_TYPE_ITACNS_CNS_IDEMIA_2021)
  ------------------
  |  Branch (497:6): [True: 162, False: 66]
  ------------------
  498|    162|		len = MIN (0x20, len);
  ------------------
  |  |   69|    162|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 96, False: 66]
  |  |  ------------------
  ------------------
  499|       |
  500|    228|	return default_ops->get_challenge(card, rnd, len);
  501|    228|}

jpki_select_ap:
   46|  2.93k|{
   47|  2.93k|	int rc;
   48|  2.93k|	sc_path_t path;
   49|       |
   50|  2.93k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.93k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.93k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.93k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.93k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.93k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   51|       |
   52|       |	/* Select JPKI application */
   53|  2.93k|	sc_format_path(AID_JPKI, &path);
  ------------------
  |  |   27|  2.93k|#define AID_JPKI "D392f000260100000001"
  ------------------
   54|  2.93k|	path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  2.93k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
   55|  2.93k|	rc = sc_select_file(card, &path, NULL);
   56|  2.93k|	LOG_TEST_RET(card->ctx, rc, "select JPKI AP failed");
  ------------------
  |  |  174|  2.93k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.93k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.93k|	int _ret = (r); \
  |  |  |  |  168|  2.93k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.80k, False: 133]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.80k|		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.80k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.80k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.80k|		return _ret; \
  |  |  |  |  172|  2.80k|	} \
  |  |  |  |  173|  2.93k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 133]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   57|       |
   58|    133|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    133|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    133|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    133|	int _ret = r; \
  |  |  |  |  155|    133|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 133, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    133|		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: 133]
  |  |  |  |  ------------------
  |  |  |  |  157|    133|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    133|	} 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|    133|	return _ret; \
  |  |  |  |  163|    133|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   59|    133|}
sc_get_jpki_driver:
  382|  17.0k|{
  383|  17.0k|	return sc_get_driver();
  384|  17.0k|}
card-jpki.c:sc_get_driver:
  363|  17.0k|{
  364|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  365|       |
  366|  17.0k|	jpki_ops = *iso_drv->ops;
  367|  17.0k|	jpki_ops.match_card = jpki_match_card;
  368|  17.0k|	jpki_ops.init = jpki_init;
  369|  17.0k|	jpki_ops.finish = jpki_finish;
  370|  17.0k|	jpki_ops.select_file = jpki_select_file;
  371|  17.0k|	jpki_ops.pin_cmd = jpki_pin_cmd;
  372|  17.0k|	jpki_ops.set_security_env = jpki_set_security_env;
  373|  17.0k|	jpki_ops.compute_signature = jpki_compute_signature;
  374|  17.0k|	jpki_ops.card_reader_lock_obtained = jpki_card_reader_lock_obtained;
  375|  17.0k|	jpki_ops.logout = jpki_logout;
  376|       |
  377|  17.0k|	return &jpki_drv;
  378|  17.0k|}
card-jpki.c:jpki_match_card:
   63|  2.86k|{
   64|  2.86k|	int i, rc;
   65|       |
   66|  2.86k|	i = _sc_match_atr(card, jpki_atrs, &card->type);
   67|  2.86k|	if (i >= 0) {
  ------------------
  |  Branch (67:6): [True: 0, False: 2.86k]
  ------------------
   68|      0|		return 1;
   69|      0|	}
   70|       |
   71|  2.86k|	rc = jpki_select_ap(card);
   72|  2.86k|	if (rc == SC_SUCCESS) {
  ------------------
  |  |   28|  2.86k|#define SC_SUCCESS				0
  ------------------
  |  Branch (72:6): [True: 72, False: 2.78k]
  ------------------
   73|     72|		card->type = SC_CARD_TYPE_JPKI_BASE;
   74|     72|		return 1;
   75|     72|	}
   76|  2.78k|	return 0;
   77|  2.86k|}
card-jpki.c:jpki_init:
   95|     72|{
   96|     72|	struct jpki_private_data *drvdata;
   97|     72|	sc_file_t *mf;
   98|     72|	int flags;
   99|       |
  100|     72|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     72|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     72|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     72|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     72|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 72]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|       |
  102|     72|	drvdata = malloc(sizeof (struct jpki_private_data));
  103|     72|	if (!drvdata)
  ------------------
  |  Branch (103:6): [True: 0, False: 72]
  ------------------
  104|     72|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|       |
  106|     72|	memset(drvdata, 0, sizeof (struct jpki_private_data));
  107|       |
  108|       |	/* create virtual MF */
  109|     72|	mf = sc_file_new();
  110|     72|	if (!mf) {
  ------------------
  |  Branch (110:6): [True: 0, False: 72]
  ------------------
  111|      0|		free(drvdata);
  112|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|      0|	}
  114|     72|	sc_format_path("3f00", &mf->path);
  115|     72|	mf->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     72|#define SC_FILE_TYPE_DF			0x04
  ------------------
  116|     72|	mf->shareable = 0;
  117|     72|	mf->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|     72|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  118|     72|	mf->size = 0;
  119|     72|	mf->id = 0x3f00;
  120|     72|	mf->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|     72|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  121|     72|	sc_file_add_acl_entry(mf, SC_AC_OP_SELECT, SC_AC_NONE, 0);
  ------------------
  |  |  166|     72|#define SC_AC_OP_SELECT			0
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_SELECT, SC_AC_NONE, 0);
  ------------------
  |  |  150|     72|#define SC_AC_NONE			0x00000000
  ------------------
  122|     72|	sc_file_add_acl_entry(mf, SC_AC_OP_LIST_FILES, SC_AC_NONE, 0);
  ------------------
  |  |  172|     72|#define SC_AC_OP_LIST_FILES		6
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_LIST_FILES, SC_AC_NONE, 0);
  ------------------
  |  |  150|     72|#define SC_AC_NONE			0x00000000
  ------------------
  123|     72|	sc_file_add_acl_entry(mf, SC_AC_OP_LOCK, SC_AC_NEVER, 0);
  ------------------
  |  |  167|     72|#define SC_AC_OP_LOCK			1
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_LOCK, SC_AC_NEVER, 0);
  ------------------
  |  |  163|     72|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  124|     72|	sc_file_add_acl_entry(mf, SC_AC_OP_DELETE, SC_AC_NEVER, 0);
  ------------------
  |  |  168|     72|#define SC_AC_OP_DELETE			2
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_DELETE, SC_AC_NEVER, 0);
  ------------------
  |  |  163|     72|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  125|     72|	sc_file_add_acl_entry(mf, SC_AC_OP_CREATE, SC_AC_NEVER, 0);
  ------------------
  |  |  169|     72|#define SC_AC_OP_CREATE			3
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_CREATE, SC_AC_NEVER, 0);
  ------------------
  |  |  163|     72|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  126|     72|	drvdata->mf = mf;
  127|     72|	drvdata->selected = SELECT_MF;
  ------------------
  |  |   24|     72|#define SELECT_MF 0
  ------------------
  128|       |
  129|     72|	card->name = "jpki";
  130|     72|	card->drv_data = drvdata;
  131|       |
  132|     72|	flags = SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  133|     72|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              	flags = SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|     72|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     72|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     72|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  133|     72|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  134|       |
  135|     72|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     72|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     72|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     72|	int _ret = r; \
  |  |  |  |  155|     72|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 72, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     72|		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: 72]
  |  |  |  |  ------------------
  |  |  |  |  157|     72|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     72|	} 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|     72|	return _ret; \
  |  |  |  |  163|     72|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  136|     72|}
card-jpki.c:jpki_finish:
   81|     72|{
   82|     72|	struct jpki_private_data *drvdata = JPKI_DRVDATA(card);
  ------------------
  |  |   36|     72|#define JPKI_DRVDATA(card) ((struct jpki_private_data *) ((card)->drv_data))
  ------------------
   83|       |
   84|     72|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     72|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     72|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     72|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     72|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 72]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   85|     72|	if (drvdata) {
  ------------------
  |  Branch (85:6): [True: 72, False: 0]
  ------------------
   86|     72|		sc_file_free(drvdata->mf);
   87|     72|		free(drvdata);
   88|     72|		card->drv_data = NULL;
   89|     72|	}
   90|     72|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     72|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     72|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     72|	int _ret = r; \
  |  |  |  |  155|     72|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 72, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     72|		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: 72]
  |  |  |  |  ------------------
  |  |  |  |  157|     72|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     72|	} 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|     72|	return _ret; \
  |  |  |  |  163|     72|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|     72|}
card-jpki.c:jpki_select_file:
  141|  3.52k|{
  142|  3.52k|	struct jpki_private_data *drvdata = JPKI_DRVDATA(card);
  ------------------
  |  |   36|  3.52k|#define JPKI_DRVDATA(card) ((struct jpki_private_data *) ((card)->drv_data))
  ------------------
  143|  3.52k|	int rc;
  144|  3.52k|	sc_apdu_t apdu;
  145|  3.52k|	struct sc_file *file = NULL;
  146|       |
  147|  3.52k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.52k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.52k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.52k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.52k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.52k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  148|  3.52k|	sc_log(card->ctx, "jpki_select_file: path=%s, len=%zu", sc_print_path(path), path->len);
  ------------------
  |  |   71|  3.52k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  149|  3.52k|	if (path->len == 2 && memcmp(path->value, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (149:6): [True: 288, False: 3.23k]
  |  Branch (149:24): [True: 0, False: 288]
  ------------------
  150|      0|		drvdata->selected = SELECT_MF;
  ------------------
  |  |   24|      0|#define SELECT_MF 0
  ------------------
  151|      0|		if (file_out) {
  ------------------
  |  Branch (151:7): [True: 0, False: 0]
  ------------------
  152|      0|			sc_file_dup(file_out, drvdata->mf);
  153|      0|			if (*file_out == NULL) {
  ------------------
  |  Branch (153:8): [True: 0, False: 0]
  ------------------
  154|      0|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  155|      0|			}
  156|      0|		}
  157|      0|		return 0;
  158|      0|	}
  159|       |
  160|  3.52k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  293|  3.52k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  161|  3.52k|	switch (path->type) {
  162|    272|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|    272|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (162:2): [True: 272, False: 3.25k]
  ------------------
  163|    272|		apdu.p1 = 2;
  164|    272|		break;
  165|  3.02k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  3.02k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (165:2): [True: 3.02k, False: 504]
  ------------------
  166|  3.02k|		apdu.p1 = 4;
  167|  3.02k|		break;
  168|    232|	default:
  ------------------
  |  Branch (168:2): [True: 232, False: 3.29k]
  ------------------
  169|    232|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|    232|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    232|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    232|	int _ret = r; \
  |  |  |  |  155|    232|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 232, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    232|		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|    232|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 232, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    232|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    232|	} 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|    232|	return _ret; \
  |  |  |  |  163|    232|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  170|  3.52k|	}
  171|  3.29k|	apdu.p2 = 0x0C;
  172|  3.29k|	apdu.data = path->value;
  173|  3.29k|	apdu.datalen = path->len;
  174|  3.29k|	apdu.lc = path->len;
  175|       |
  176|  3.29k|	rc = sc_transmit_apdu(card, &apdu);
  177|  3.29k|	LOG_TEST_RET(card->ctx, rc, "APDU transmit failed");
  ------------------
  |  |  174|  3.29k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.29k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.29k|	int _ret = (r); \
  |  |  |  |  168|  3.29k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 18, False: 3.27k]
  |  |  |  |  ------------------
  |  |  |  |  169|     18|		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|     18|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     18|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     18|		return _ret; \
  |  |  |  |  172|     18|	} \
  |  |  |  |  173|  3.29k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.27k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  178|  3.27k|	rc = sc_check_sw(card, apdu.sw1, apdu.sw2);
  179|  3.27k|	LOG_TEST_RET(card->ctx, rc, "SW Check failed");
  ------------------
  |  |  174|  3.27k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.27k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.27k|	int _ret = (r); \
  |  |  |  |  168|  3.27k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.96k, False: 309]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.96k|		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.96k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.96k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.96k|		return _ret; \
  |  |  |  |  172|  2.96k|	} \
  |  |  |  |  173|  3.27k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 309]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  180|    309|	if (!file_out) {
  ------------------
  |  Branch (180:6): [True: 292, False: 17]
  ------------------
  181|    292|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    292|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    292|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    292|	int _ret = r; \
  |  |  |  |  155|    292|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 292, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    292|		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: 292]
  |  |  |  |  ------------------
  |  |  |  |  157|    292|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    292|	} 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|    292|	return _ret; \
  |  |  |  |  163|    292|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|    292|	}
  183|       |
  184|       |	/* read certificate file size */
  185|     17|	if (path->len == 2 && (
  ------------------
  |  Branch (185:6): [True: 17, False: 0]
  ------------------
  186|     17|		    memcmp(path->value, "\x00\x0A", 2) == 0 ||
  ------------------
  |  Branch (186:7): [True: 17, False: 0]
  ------------------
  187|      0|		    memcmp(path->value, "\x00\x01", 2) == 0 ||
  ------------------
  |  Branch (187:7): [True: 0, False: 0]
  ------------------
  188|      0|		    memcmp(path->value, "\x00\x0B", 2) == 0 ||
  ------------------
  |  Branch (188:7): [True: 0, False: 0]
  ------------------
  189|      0|		    memcmp(path->value, "\x00\x02", 2) == 0 )
  ------------------
  |  Branch (189:7): [True: 0, False: 0]
  ------------------
  190|     17|		) {
  191|     17|		u8 buf[4];
  192|     17|		rc = sc_read_binary(card, 0, buf, 4, 0);
  193|     17|		LOG_TEST_RET(card->ctx, rc, "SW Check failed");
  ------------------
  |  |  174|     17|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     17|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     17|	int _ret = (r); \
  |  |  |  |  168|     17|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  169|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      7|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      7|		return _ret; \
  |  |  |  |  172|      7|	} \
  |  |  |  |  173|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  194|     10|		if (rc < 4)
  ------------------
  |  Branch (194:7): [True: 4, False: 6]
  ------------------
  195|     10|			LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Received data too short");
  ------------------
  |  |  174|      4|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      4|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      4|	int _ret = (r); \
  |  |  |  |  168|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      4|		return _ret; \
  |  |  |  |  172|      4|	} \
  |  |  |  |  173|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|      6|		file = sc_file_new();
  197|      6|		if (!file) {
  ------------------
  |  Branch (197:7): [True: 0, False: 6]
  ------------------
  198|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|      0|		}
  200|      6|		file->path = *path;
  201|      6|		file->size = (buf[2] << 8 | buf[3]) + 4;
  202|      6|		*file_out = file;
  203|      6|	}
  204|      6|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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: 6]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  205|      6|}
card-jpki.c:jpki_pin_cmd:
  209|    184|{
  210|    184|	int rc;
  211|    184|	sc_path_t path;
  212|    184|	sc_apdu_t apdu;
  213|    184|	struct jpki_private_data *priv = JPKI_DRVDATA(card);
  ------------------
  |  |   36|    184|#define JPKI_DRVDATA(card) ((struct jpki_private_data *) ((card)->drv_data))
  ------------------
  214|    184|	int max_tries = 0;
  215|       |
  216|    184|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    184|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    184|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    184|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    184|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 184]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|       |
  218|    184|	switch (data->pin_reference) {
  219|    117|	case 1:
  ------------------
  |  Branch (219:2): [True: 117, False: 67]
  ------------------
  220|    117|		sc_format_path(JPKI_AUTH_PIN, &path);
  ------------------
  |  |   29|    117|#define JPKI_AUTH_PIN "0018"
  ------------------
  221|    117|		path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    117|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  222|    117|		rc = sc_select_file(card, &path, NULL);
  223|    117|		max_tries = JPKI_AUTH_PIN_MAX_TRIES;
  ------------------
  |  |   30|    117|#define JPKI_AUTH_PIN_MAX_TRIES 3
  ------------------
  224|    117|		break;
  225|     67|	case 2:
  ------------------
  |  Branch (225:2): [True: 67, False: 117]
  ------------------
  226|     67|		sc_format_path(JPKI_SIGN_PIN, &path);
  ------------------
  |  |   33|     67|#define JPKI_SIGN_PIN "001B"
  ------------------
  227|     67|		path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     67|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  228|     67|		rc = sc_select_file(card, &path, NULL);
  229|     67|		max_tries = JPKI_SIGN_PIN_MAX_TRIES;
  ------------------
  |  |   34|     67|#define JPKI_SIGN_PIN_MAX_TRIES 5
  ------------------
  230|     67|		break;
  231|      0|	default:
  ------------------
  |  Branch (231:2): [True: 0, False: 184]
  ------------------
  232|      0|		sc_log(card->ctx, "Unknown PIN reference: %d", data->pin_reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  233|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|    184|	}
  235|    184|	LOG_TEST_RET(card->ctx, rc, "SELECT_FILE error");
  ------------------
  |  |  174|    184|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    184|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    184|	int _ret = (r); \
  |  |  |  |  168|    184|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 66, False: 118]
  |  |  |  |  ------------------
  |  |  |  |  169|     66|		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|     66|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     66|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     66|		return _ret; \
  |  |  |  |  172|     66|	} \
  |  |  |  |  173|    184|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|       |
  237|    118|	switch (data->cmd) {
  238|      9|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|      9|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (238:2): [True: 9, False: 109]
  ------------------
  239|       |		/* detect overloaded APDU with SC_PIN_CMD_GET_INFO */
  240|      9|		if (data->pin1.len == 0 && !(data->flags & SC_PIN_CMD_USE_PINPAD))
  ------------------
  |  |  421|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (240:7): [True: 0, False: 9]
  |  Branch (240:30): [True: 0, False: 0]
  ------------------
  241|      9|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_PIN_LENGTH);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|      9|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3, 0x20, 0x00, 0x80);
  ------------------
  |  |  302|      9|#define SC_APDU_CASE_3			0x23
  ------------------
  243|      9|		apdu.data = data->pin1.data;
  244|      9|		apdu.datalen = data->pin1.len;
  245|      9|		apdu.lc = data->pin1.len;
  246|      9|		rc = sc_transmit_apdu(card, &apdu);
  247|      9|		LOG_TEST_RET(card->ctx, rc, "APDU transmit failed");
  ------------------
  |  |  174|      9|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      9|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      9|	int _ret = (r); \
  |  |  |  |  168|      9|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  248|      8|		rc = sc_check_sw(card, apdu.sw1, apdu.sw2);
  249|      8|		if (rc == SC_SUCCESS) {
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  |  Branch (249:7): [True: 6, False: 2]
  ------------------
  250|      6|			data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  432|      6|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
  251|      6|			data->pin1.tries_left = max_tries;
  252|      6|		} else {
  253|      2|			data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  431|      2|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
  254|      2|			data->pin1.tries_left = apdu.sw2 & 0xF;
  255|      2|		}
  256|      8|		priv->logged_in = data->pin1.logged_in;
  257|      8|		LOG_TEST_RET(card->ctx, rc, "VERIFY failed");
  ------------------
  |  |  174|      8|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      8|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      8|	int _ret = (r); \
  |  |  |  |  168|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  258|      6|		break;
  259|    108|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  418|    108|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (259:2): [True: 108, False: 10]
  ------------------
  260|    108|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x20, 0x00, 0x80);
  ------------------
  |  |  291|    108|#define SC_APDU_CASE_1			0x01
  ------------------
  261|    108|		rc = sc_transmit_apdu(card, &apdu);
  262|    108|		LOG_TEST_RET(card->ctx, rc, "APDU transmit failed");
  ------------------
  |  |  174|    108|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    108|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    108|	int _ret = (r); \
  |  |  |  |  168|    108|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 105]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|    108|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 105]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  263|    105|		if (apdu.sw1 != 0x63) {
  ------------------
  |  Branch (263:7): [True: 17, False: 88]
  ------------------
  264|     17|			sc_log(card->ctx, "VERIFY GET_INFO error");
  ------------------
  |  |   71|     17|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  265|     17|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  164|     17|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     17|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     17|	int _ret = r; \
  |  |  |  |  155|     17|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 17, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     17|		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|     17|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 17, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     17|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     17|	} 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|     17|	return _ret; \
  |  |  |  |  163|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  266|     17|		}
  267|     88|		data->pin1.logged_in = priv->logged_in;
  268|     88|		data->pin1.tries_left = apdu.sw2 & 0xF;
  269|     88|		break;
  270|      1|	default:
  ------------------
  |  Branch (270:2): [True: 1, False: 117]
  ------------------
  271|      1|		sc_log(card->ctx, "Card does not support PIN command: %d", data->cmd);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  272|      1|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  273|    118|	}
  274|       |
  275|     94|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     94|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     94|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     94|	int _ret = r; \
  |  |  |  |  155|     94|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 94, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     94|		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: 94]
  |  |  |  |  ------------------
  |  |  |  |  157|     94|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     94|	} 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|     94|	return _ret; \
  |  |  |  |  163|     94|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  276|     94|}
card-jpki.c:jpki_set_security_env:
  281|      7|{
  282|      7|	int rc;
  283|      7|	sc_path_t path;
  284|       |
  285|      7|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      7|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      7|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      7|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      7|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  286|      7|	sc_log(card->ctx, "flags=%08lx op=%d alg=%lu algf=%08lx algr=%08lx kr0=%02x, krfl=%zu",
  ------------------
  |  |   71|      7|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  287|      7|			env->flags, env->operation, env->algorithm, env->algorithm_flags, env->algorithm_ref,
  288|      7|			env->key_ref[0], env->key_ref_len);
  289|       |
  290|      7|	switch (env->operation) {
  291|      7|	case SC_SEC_OPERATION_SIGN:
  ------------------
  |  |   48|      7|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (291:2): [True: 7, False: 0]
  ------------------
  292|      7|		break;
  293|      0|	default:
  ------------------
  |  Branch (293:2): [True: 0, False: 7]
  ------------------
  294|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|      7|	}
  296|       |
  297|      7|	switch (env->key_ref[0]) {
  298|      7|	case 1:
  ------------------
  |  Branch (298:2): [True: 7, False: 0]
  ------------------
  299|      7|		sc_format_path(JPKI_AUTH_KEY, &path);
  ------------------
  |  |   28|      7|#define JPKI_AUTH_KEY "0017"
  ------------------
  300|      7|		break;
  301|      0|	case 2:
  ------------------
  |  Branch (301:2): [True: 0, False: 7]
  ------------------
  302|      0|		sc_format_path(JPKI_SIGN_KEY, &path);
  ------------------
  |  |   32|      0|#define JPKI_SIGN_KEY "001A"
  ------------------
  303|      0|		break;
  304|      0|	default:
  ------------------
  |  Branch (304:2): [True: 0, False: 7]
  ------------------
  305|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  306|      7|	}
  307|      7|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      7|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  308|      7|	rc = sc_select_file(card, &path, NULL);
  309|      7|	LOG_TEST_RET(card->ctx, rc, "select key failed");
  ------------------
  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  310|       |
  311|      4|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      4|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      4|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      4|	int _ret = r; \
  |  |  |  |  155|      4|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      4|		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: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      4|	} 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|      4|	return _ret; \
  |  |  |  |  163|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  312|      4|}
card-jpki.c:jpki_compute_signature:
  317|      4|{
  318|      4|	int rc;
  319|      4|	sc_apdu_t apdu;
  320|      4|	unsigned char resp[SC_MAX_APDU_BUFFER_SIZE];
  321|       |
  322|      4|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      4|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      4|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      4|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      4|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  323|       |
  324|      4|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x00, 0x80);
  ------------------
  |  |  294|      4|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  325|      4|	apdu.cla = 0x80;
  326|      4|	apdu.data = data;
  327|      4|	apdu.datalen = datalen;
  328|      4|	apdu.lc = datalen;
  329|      4|	apdu.resp = resp;
  330|      4|	apdu.resplen = sizeof(resp);
  331|      4|	apdu.le = 0;
  332|      4|	rc = sc_transmit_apdu(card, &apdu);
  333|      4|	LOG_TEST_RET(card->ctx, rc, "APDU transmit failed");
  ------------------
  |  |  174|      4|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      4|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      4|	int _ret = (r); \
  |  |  |  |  168|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  334|      3|	rc = sc_check_sw(card, apdu.sw1, apdu.sw2);
  335|      3|	LOG_TEST_RET(card->ctx, rc, "SW Check failed");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  336|      2|	if (apdu.resplen > outlen) {
  ------------------
  |  Branch (336:6): [True: 0, False: 2]
  ------------------
  337|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  338|      0|	}
  339|      2|	memcpy(out, resp, apdu.resplen);
  340|      2|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} else { \
  |  |  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      1|	} \
  |  |  |  |  162|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|      2|}
card-jpki.c:jpki_card_reader_lock_obtained:
  344|  3.09k|{
  345|  3.09k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  3.09k|#define SC_SUCCESS				0
  ------------------
  346|       |
  347|  3.09k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.09k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.09k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.09k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.09k]
  |  |  ------------------
  ------------------
  348|       |
  349|  3.09k|	if (was_reset > 0) {
  ------------------
  |  Branch (349:6): [True: 0, False: 3.09k]
  ------------------
  350|      0|		r = jpki_select_ap(card);
  351|      0|	}
  352|       |
  353|  3.09k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  3.09k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.09k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.09k|	int _ret = r; \
  |  |  |  |  155|  3.09k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.09k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.09k|		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: 3.09k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.09k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.09k|	} 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|  3.09k|	return _ret; \
  |  |  |  |  163|  3.09k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  354|  3.09k|}

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

sc_get_masktech_driver:
  374|  17.0k|{
  375|  17.0k|	return sc_get_driver();
  376|  17.0k|}
card-masktech.c:sc_get_driver:
  355|  17.0k|{
  356|       |
  357|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (357:6): [True: 1, False: 17.0k]
  ------------------
  358|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  359|       |
  360|  17.0k|	masktech_ops = *iso_ops;
  361|       |
  362|  17.0k|	masktech_ops.match_card = masktech_match_card;
  363|  17.0k|	masktech_ops.init = masktech_init;
  364|  17.0k|	masktech_ops.finish = masktech_finish;
  365|  17.0k|	masktech_ops.set_security_env = masktech_set_security_env;
  366|  17.0k|	masktech_ops.compute_signature = masktech_compute_signature;
  367|  17.0k|	masktech_ops.decipher = masktech_decipher;
  368|  17.0k|	masktech_ops.pin_cmd = masktech_pin_cmd;
  369|  17.0k|	masktech_ops.card_ctl = masktech_card_ctl;
  370|  17.0k|	return &masktech_drv;
  371|  17.0k|}
card-masktech.c:masktech_match_card:
   62|  9.29k|{
   63|       |	/* check if the ATR is in the known ATR */
   64|  9.29k|	if (_sc_match_atr(card, masktech_atrs, &card->type) < 0)
  ------------------
  |  Branch (64:6): [True: 9.26k, False: 27]
  ------------------
   65|  9.26k|		return 0;
   66|       |
   67|     27|	return 1;
   68|  9.29k|}
card-masktech.c:masktech_init:
   71|     27|{
   72|     27|	unsigned long flags;
   73|     27|	struct masktech_private_data *data;
   74|       |
   75|     27|	sc_log(card->ctx,  "masktech_init()\n");
  ------------------
  |  |   71|     27|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   76|       |
   77|       |	/* private data kept during the live of the driver */
   78|     27|	if (!(data = (struct masktech_private_data *) malloc(sizeof(*data))))
  ------------------
  |  Branch (78:6): [True: 0, False: 27]
  ------------------
   79|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
   80|     27|	card->drv_data = data;
   81|       |
   82|       |	/* supported RSA keys and how padding is done */
   83|     27|	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  111|     27|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     27|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     27|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|     27|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
   84|     27|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
   85|     27|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
   86|     27|	_sc_card_add_rsa_alg(card, 3072, flags, 0);
   87|     27|	card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|     27|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
   88|     27|	return SC_SUCCESS;
  ------------------
  |  |   28|     27|#define SC_SUCCESS				0
  ------------------
   89|     27|}
card-masktech.c:masktech_finish:
   93|     27|{
   94|       |	/* free the private data */
   95|     27|	if (card->drv_data) {
  ------------------
  |  Branch (95:6): [True: 27, False: 0]
  ------------------
   96|     27|		free(card->drv_data);
   97|       |		card->drv_data = NULL;
   98|     27|	}
   99|     27|	return 0;
  100|     27|}
card-masktech.c:masktech_pin_cmd:
  283|     20|{
  284|     20|	int       rv;
  285|     20|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     20|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     20|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     20|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 20]
  |  |  ------------------
  ------------------
  286|       |
  287|     20|	switch(data->cmd)
  288|     20|	{
  289|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (289:2): [True: 0, False: 20]
  ------------------
  290|      0|		rv = masktech_pin_unblock(card, data);
  291|      0|		break;
  292|      0|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (292:2): [True: 0, False: 20]
  ------------------
  293|      0|		rv = masktech_pin_change(card, data);
  294|      0|		break;
  295|     20|	default:
  ------------------
  |  Branch (295:2): [True: 20, False: 0]
  ------------------
  296|     20|		rv = iso_ops->pin_cmd(card, data);
  297|     20|		break;
  298|     20|	}
  299|     20|	return rv;
  300|       |
  301|       |
  302|     20|}
card-masktech.c:masktech_card_ctl:
  344|     44|{
  345|     44|	sc_log(card->ctx,  "masktech_card_ctl()\n");
  ------------------
  |  |   71|     44|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  346|     44|	switch (cmd) {
  347|     20|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (347:3): [True: 20, False: 24]
  ------------------
  348|     20|			return masktech_get_serialnr(card, (sc_serial_number_t *) ptr);
  349|     24|		default:
  ------------------
  |  Branch (349:3): [True: 24, False: 20]
  ------------------
  350|     24|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     24|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  351|     44|	}
  352|     44|}
card-masktech.c:masktech_get_serialnr:
  305|     20|{
  306|     20|	struct sc_apdu apdu;
  307|     20|	unsigned char apdu_resp[SC_MAX_APDU_BUFFER_SIZE-2];
  308|     20|	int rv;
  309|       |
  310|     20|	if (!serial)
  ------------------
  |  Branch (310:6): [True: 0, False: 20]
  ------------------
  311|     20|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  312|       |
  313|       |	/* Get smart card serial number */
  314|     20|	card->cla = 0x80;
  315|     20|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x08, 0x00, 0x00);
  ------------------
  |  |  292|     20|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  316|     20|	apdu.resplen = sizeof(apdu_resp);
  317|     20|	apdu.resp = apdu_resp;
  318|       |
  319|     20|	rv = sc_transmit_apdu(card, &apdu);
  320|     20|	card->cla = 0x00;
  321|       |
  322|     20|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|     20|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     20|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     20|	int _ret = (r); \
  |  |  |  |  168|     20|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  323|       |
  324|     18|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (324:6): [True: 10, False: 8]
  |  Branch (324:26): [True: 4, False: 4]
  ------------------
  325|     14|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     14|#define SC_ERROR_INTERNAL			-1400
  ------------------
  326|       |
  327|      4|	if (SC_MAX_SERIALNR < apdu.resplen)
  ------------------
  |  |  372|      4|#define SC_MAX_SERIALNR         32
  ------------------
  |  Branch (327:6): [True: 1, False: 3]
  ------------------
  328|      1|	{
  329|      1|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  330|      1|	}
  331|       |	/* cache serial number */
  332|      3|	card->serialnr.len = apdu.resplen;
  333|      3|	memcpy(card->serialnr.value, apdu.resp, card->serialnr.len);
  334|       |
  335|       |	/* copy and return serial number */
  336|      3|	if (serial)
  ------------------
  |  Branch (336:6): [True: 3, False: 0]
  ------------------
  337|      3|		memcpy(serial, &card->serialnr, sizeof(*serial));
  338|       |
  339|      3|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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: 3]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} 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|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  340|      3|}

sc_get_mcrd_driver:
 1066|  17.0k|{
 1067|  17.0k|	return sc_get_driver();
 1068|  17.0k|}
card-mcrd.c:sc_get_driver:
 1047|  17.0k|{
 1048|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1049|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1049:6): [True: 1, False: 17.0k]
  ------------------
 1050|      1|		iso_ops = iso_drv->ops;
 1051|       |
 1052|  17.0k|	mcrd_ops = *iso_drv->ops;
 1053|  17.0k|	mcrd_ops.match_card = mcrd_match_card;
 1054|  17.0k|	mcrd_ops.init = mcrd_init;
 1055|  17.0k|	mcrd_ops.finish = mcrd_finish;
 1056|  17.0k|	mcrd_ops.select_file = mcrd_select_file;
 1057|  17.0k|	mcrd_ops.set_security_env = mcrd_set_security_env;
 1058|  17.0k|	mcrd_ops.compute_signature = mcrd_compute_signature;
 1059|  17.0k|	mcrd_ops.pin_cmd = mcrd_pin_cmd;
 1060|  17.0k|	mcrd_ops.logout = mcrd_logout;
 1061|       |
 1062|  17.0k|	return &mcrd_drv;
 1063|  17.0k|}
card-mcrd.c:mcrd_match_card:
  191|  16.3k|{
  192|  16.3k|	int i = 0;
  193|       |
  194|  16.3k|	i = _sc_match_atr(card, mcrd_atrs, &card->type);
  195|  16.3k|	if (i >= 0) {
  ------------------
  |  Branch (195:6): [True: 0, False: 16.3k]
  ------------------
  196|      0|		card->name = mcrd_atrs[i].name;
  197|      0|		return 1;
  198|      0|	}
  199|       |
  200|  16.3k|	return 0;
  201|  16.3k|}

sc_get_muscle_driver:
  903|  17.0k|{
  904|  17.0k|	return sc_get_driver();
  905|  17.0k|}
card-muscle.c:sc_get_driver:
  871|  17.0k|{
  872|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  873|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (873:6): [True: 1, False: 17.0k]
  ------------------
  874|      1|		iso_ops = iso_drv->ops;
  875|       |
  876|  17.0k|	muscle_ops = *iso_drv->ops;
  877|  17.0k|	muscle_ops.check_sw = muscle_check_sw;
  878|  17.0k|	muscle_ops.pin_cmd = muscle_pin_cmd;
  879|  17.0k|	muscle_ops.match_card = muscle_match_card;
  880|  17.0k|	muscle_ops.init = muscle_init;
  881|  17.0k|	muscle_ops.finish = muscle_finish;
  882|       |
  883|  17.0k|	muscle_ops.get_challenge = muscle_get_challenge;
  884|       |
  885|  17.0k|	muscle_ops.set_security_env = muscle_set_security_env;
  886|  17.0k|	muscle_ops.restore_security_env = muscle_restore_security_env;
  887|  17.0k|	muscle_ops.compute_signature = muscle_compute_signature;
  888|  17.0k|	muscle_ops.decipher = muscle_decipher;
  889|  17.0k|	muscle_ops.card_ctl = muscle_card_ctl;
  890|  17.0k|	muscle_ops.read_binary = muscle_read_binary;
  891|  17.0k|	muscle_ops.update_binary = muscle_update_binary;
  892|  17.0k|	muscle_ops.create_file = muscle_create_file;
  893|  17.0k|	muscle_ops.select_file = muscle_select_file;
  894|  17.0k|	muscle_ops.delete_file = muscle_delete_file;
  895|  17.0k|	muscle_ops.list_files = muscle_list_files;
  896|  17.0k|	muscle_ops.card_reader_lock_obtained = muscle_card_reader_lock_obtained;
  897|  17.0k|	muscle_ops.logout = muscle_logout;
  898|       |
  899|  17.0k|	return &muscle_drv;
  900|  17.0k|}
card-muscle.c:muscle_check_sw:
  809|  41.1k|static int muscle_check_sw(sc_card_t * card, unsigned int sw1, unsigned int sw2) {
  810|  41.1k|	if(sw1 == 0x9C) {
  ------------------
  |  Branch (810:5): [True: 150, False: 40.9k]
  ------------------
  811|    150|		switch(sw2) {
  ------------------
  |  Branch (811:10): [True: 140, False: 10]
  ------------------
  812|     14|			case 0x01: /* SW_NO_MEMORY_LEFT */
  ------------------
  |  Branch (812:4): [True: 14, False: 136]
  ------------------
  813|     14|				return SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|     14|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  814|     11|			case 0x02: /* SW_AUTH_FAILED */
  ------------------
  |  Branch (814:4): [True: 11, False: 139]
  ------------------
  815|     11|				return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|     11|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  816|     10|			case 0x03: /* SW_OPERATION_NOT_ALLOWED */
  ------------------
  |  Branch (816:4): [True: 10, False: 140]
  ------------------
  817|     10|				return SC_ERROR_NOT_ALLOWED;
  ------------------
  |  |   59|     10|#define SC_ERROR_NOT_ALLOWED			-1209
  ------------------
  818|     11|			case 0x05: /* SW_UNSUPPORTED_FEATURE */
  ------------------
  |  Branch (818:4): [True: 11, False: 139]
  ------------------
  819|     11|				return SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|     11|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
  820|     10|			case 0x06: /* SW_UNAUTHORIZED */
  ------------------
  |  Branch (820:4): [True: 10, False: 140]
  ------------------
  821|     10|				return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|     10|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  822|     12|			case 0x07: /* SW_OBJECT_NOT_FOUND */
  ------------------
  |  Branch (822:4): [True: 12, False: 138]
  ------------------
  823|     12|				return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     12|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  824|     10|			case 0x08: /* SW_OBJECT_EXISTS */
  ------------------
  |  Branch (824:4): [True: 10, False: 140]
  ------------------
  825|     10|				return SC_ERROR_FILE_ALREADY_EXISTS;
  ------------------
  |  |   65|     10|#define SC_ERROR_FILE_ALREADY_EXISTS		-1215
  ------------------
  826|     10|			case 0x09: /* SW_INCORRECT_ALG */
  ------------------
  |  Branch (826:4): [True: 10, False: 140]
  ------------------
  827|     10|				return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|     10|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  828|     10|			case 0x0B: /* SW_SIGNATURE_INVALID */
  ------------------
  |  Branch (828:4): [True: 10, False: 140]
  ------------------
  829|     10|				return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|     10|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  830|     10|			case 0x0C: /* SW_IDENTITY_BLOCKED */
  ------------------
  |  Branch (830:4): [True: 10, False: 140]
  ------------------
  831|     10|				return SC_ERROR_AUTH_METHOD_BLOCKED;
  ------------------
  |  |   62|     10|#define SC_ERROR_AUTH_METHOD_BLOCKED		-1212
  ------------------
  832|     11|			case 0x0F: /* SW_INVALID_PARAMETER */
  ------------------
  |  Branch (832:4): [True: 11, False: 139]
  ------------------
  833|     21|			case 0x10: /* SW_INCORRECT_P1 */
  ------------------
  |  Branch (833:4): [True: 10, False: 140]
  ------------------
  834|     32|			case 0x11: /* SW_INCORRECT_P2 */
  ------------------
  |  Branch (834:4): [True: 11, False: 139]
  ------------------
  835|     32|				return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|     32|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  836|    150|		}
  837|    150|	}
  838|  41.0k|	return iso_ops->check_sw(card, sw1, sw2);
  839|  41.1k|}
card-muscle.c:muscle_match_card:
   79|  7.54k|{
   80|  7.54k|	sc_apdu_t apdu;
   81|  7.54k|	u8 response[64];
   82|  7.54k|	int r;
   83|       |
   84|  7.54k|	if (msc_select_applet(card, muscleAppletId, sizeof muscleAppletId) == 1) {
  ------------------
  |  Branch (84:6): [True: 797, False: 6.75k]
  ------------------
   85|       |		/* Muscle applet is present, check the protocol version to be sure */
   86|    797|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x3C, 0x00, 0x00);
  ------------------
  |  |  301|    797|#define SC_APDU_CASE_2			0x22
  ------------------
   87|    797|		apdu.cla = 0xB0;
   88|    797|		apdu.le = 64;
   89|    797|		apdu.resplen = 64;
   90|    797|		apdu.resp = response;
   91|    797|		r = sc_transmit_apdu(card, &apdu);
   92|    797|		if (r == SC_SUCCESS && apdu.resplen > 1 && response[0] == 0x01) {
  ------------------
  |  |   28|  1.59k|#define SC_SUCCESS				0
  ------------------
  |  Branch (92:7): [True: 770, False: 27]
  |  Branch (92:26): [True: 43, False: 727]
  |  Branch (92:46): [True: 1, False: 42]
  ------------------
   93|      1|			card->type = SC_CARD_TYPE_MUSCLE_V1;
   94|    796|		} else {
   95|    796|			card->type = SC_CARD_TYPE_MUSCLE_GENERIC;
   96|    796|		}
   97|    797|		return 1;
   98|    797|	}
   99|  6.75k|	return 0;
  100|  7.54k|}
card-muscle.c:muscle_init:
  464|    797|{
  465|    797|	muscle_private_t *priv;
  466|    797|	int r;
  467|       |
  468|    797|	card->name = "MuscleApplet";
  469|    797|	card->drv_data = malloc(sizeof(muscle_private_t));
  470|    797|	if(!card->drv_data) {
  ------------------
  |  Branch (470:5): [True: 0, False: 797]
  ------------------
  471|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  472|      0|	}
  473|    797|	memset(card->drv_data, 0, sizeof(muscle_private_t));
  474|    797|	priv = MUSCLE_DATA(card);
  ------------------
  |  |   57|    797|#define MUSCLE_DATA(card) ( (muscle_private_t*)card->drv_data )
  ------------------
  475|    797|	priv->verifiedPins = 0;
  476|    797|	priv->fs = mscfs_new();
  477|    797|	if(!priv->fs) {
  ------------------
  |  Branch (477:5): [True: 0, False: 797]
  ------------------
  478|      0|		free(card->drv_data);
  479|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|      0|	}
  481|    797|	priv->fs->udata = card;
  482|    797|	priv->fs->listFile = _listFile;
  483|       |
  484|    797|	card->cla = 0xB0;
  485|       |
  486|    797|	card->flags |= SC_CARD_FLAG_RNG;
  ------------------
  |  |  536|    797|#define SC_CARD_FLAG_RNG		0x00000002
  ------------------
  487|    797|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    797|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  488|       |
  489|       |	/* Card type detection */
  490|    797|	r = _sc_match_atr(card, muscle_atrs, &card->type);
  491|    797|	if (r < 0) {
  ------------------
  |  Branch (491:6): [True: 795, False: 2]
  ------------------
  492|    795|		sc_log(card->ctx, "Failed to match the ATRs");
  ------------------
  |  |   71|    795|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  493|    795|	}
  494|    797|	if(card->type == SC_CARD_TYPE_MUSCLE_ETOKEN_72K) {
  ------------------
  |  Branch (494:5): [True: 0, False: 797]
  ------------------
  495|      0|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|      0|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  496|      0|	}
  497|    797|	if(card->type == SC_CARD_TYPE_MUSCLE_JCOP241) {
  ------------------
  |  Branch (497:5): [True: 2, False: 795]
  ------------------
  498|      2|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|      2|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  499|      2|	}
  500|    797|	if (!(card->caps & SC_CARD_CAP_APDU_EXT)) {
  ------------------
  |  |  547|    797|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (500:6): [True: 795, False: 2]
  ------------------
  501|    795|		card->max_recv_size = 255;
  502|    795|		card->max_send_size = 255;
  503|    795|	}
  504|    797|	if(card->type == SC_CARD_TYPE_MUSCLE_JCOP242R2_NO_EXT_APDU) {
  ------------------
  |  Branch (504:5): [True: 0, False: 797]
  ------------------
  505|       |	        /* Tyfone JCOP v242R2 card that doesn't support extended APDUs */
  506|      0|	}
  507|       |
  508|       |
  509|       |	/* FIXME: Card type detection */
  510|    797|	if (1) {
  ------------------
  |  Branch (510:6): [True: 797, Folded]
  ------------------
  511|    797|		unsigned long flags;
  512|       |
  513|    797|		flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|    797|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  514|    797|		flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    797|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  515|    797|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    797|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  516|       |
  517|    797|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  518|    797|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  519|    797|	}
  520|    797|	return SC_SUCCESS;
  ------------------
  |  |   28|    797|#define SC_SUCCESS				0
  ------------------
  521|    797|}
card-muscle.c:_listFile:
  458|  41.1k|{
  459|  41.1k|	int next = reset ? 0x00 : 0x01;
  ------------------
  |  Branch (459:13): [True: 2.59k, False: 38.5k]
  ------------------
  460|  41.1k|	return msc_list_objects( (sc_card_t*)udata, next, file);
  461|  41.1k|}
card-muscle.c:muscle_finish:
   68|    797|{
   69|    797|	muscle_private_t *priv = MUSCLE_DATA(card);
  ------------------
  |  |   57|    797|#define MUSCLE_DATA(card) ( (muscle_private_t*)card->drv_data )
  ------------------
   70|    797|	mscfs_free(priv->fs);
   71|    797|	free(priv);
   72|    797|	return 0;
   73|    797|}
card-muscle.c:muscle_get_challenge:
  798|     35|{
  799|     35|	if (len == 0)
  ------------------
  |  Branch (799:6): [True: 0, False: 35]
  ------------------
  800|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  801|     35|	else {
  802|     35|		LOG_TEST_RET(card->ctx,
  ------------------
  |  |  174|     35|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     35|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     35|	int _ret = (r); \
  |  |  |  |  168|     35|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 34, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|     34|		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|     34|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     34|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     34|		return _ret; \
  |  |  |  |  172|     34|	} \
  |  |  |  |  173|     35|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  803|      1|				msc_get_challenge(card, len, 0, NULL, rnd),
  804|      1|				"GET CHALLENGE cmd failed");
  805|      1|		return (int) len;
  806|     35|	}
  807|     35|}
card-muscle.c:muscle_card_ctl:
  674|     41|{
  675|     41|	switch(request) {
  676|      0|	case SC_CARDCTL_MUSCLE_GENERATE_KEY:
  ------------------
  |  Branch (676:2): [True: 0, False: 41]
  ------------------
  677|      0|		return muscle_card_generate_key(card, (sc_cardctl_muscle_gen_key_info_t*) data);
  678|      0|	case SC_CARDCTL_MUSCLE_EXTRACT_KEY:
  ------------------
  |  Branch (678:2): [True: 0, False: 41]
  ------------------
  679|      0|		return muscle_card_extract_key(card, (sc_cardctl_muscle_key_info_t*) data);
  680|      0|	case SC_CARDCTL_MUSCLE_IMPORT_KEY:
  ------------------
  |  Branch (680:2): [True: 0, False: 41]
  ------------------
  681|      0|		return muscle_card_import_key(card, (sc_cardctl_muscle_key_info_t*) data);
  682|      0|	case SC_CARDCTL_MUSCLE_VERIFIED_PINS:
  ------------------
  |  Branch (682:2): [True: 0, False: 41]
  ------------------
  683|      0|		return muscle_card_verified_pins(card, (sc_cardctl_muscle_verified_pins_info_t*) data);
  684|     41|	default:
  ------------------
  |  Branch (684:2): [True: 41, False: 0]
  ------------------
  685|     41|		return SC_ERROR_NOT_SUPPORTED; /* Unsupported.. whatever it is */
  ------------------
  |  |   89|     41|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  686|     41|	}
  687|     41|}
card-muscle.c:muscle_read_binary:
  199|    376|{
  200|    376|	mscfs_t *fs = MUSCLE_FS(card);
  ------------------
  |  |   58|    376|#define MUSCLE_FS(card) ( ((muscle_private_t*)card->drv_data)->fs )
  ------------------
  201|    376|	int r;
  202|    376|	msc_id objectId;
  203|    376|	u8* oid = objectId.id;
  204|    376|	mscfs_file_t *file;
  205|       |
  206|    376|	r = mscfs_check_selection(fs, -1);
  207|    376|	if(r < 0) LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (207:5): [True: 0, False: 376]
  ------------------
  208|    376|	file = &fs->cache.array[fs->currentFileIndex];
  209|    376|	objectId = file->objectId;
  210|       |	/* memcpy(objectId.id, file->objectId.id, 4); */
  211|    376|	if(!file->ef) {
  ------------------
  |  Branch (211:5): [True: 48, False: 328]
  ------------------
  212|     48|		oid[0] = oid[2];
  213|     48|		oid[1] = oid[3];
  214|     48|		oid[2] = oid[3] = 0;
  215|     48|	}
  216|    376|	r = msc_read_object(card, objectId, idx, buf, count);
  217|    376|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    376|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    376|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    376|	int _ret = r; \
  |  |  |  |  155|    376|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 109, False: 267]
  |  |  |  |  ------------------
  |  |  |  |  156|    109|		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|    109|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 109, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    109|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    267|	} else { \
  |  |  |  |  159|    267|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    267|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    267|	} \
  |  |  |  |  162|    376|	return _ret; \
  |  |  |  |  163|    376|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  218|    376|}
card-muscle.c:muscle_select_file:
  434|  3.81k|{
  435|  3.81k|	int r;
  436|       |
  437|  3.81k|	if (card == NULL || path_in == NULL)
  ------------------
  |  Branch (437:6): [True: 0, False: 3.81k]
  |  Branch (437:22): [True: 0, False: 3.81k]
  ------------------
  438|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  439|       |
  440|  3.81k|	switch (path_in->type) {
  441|     45|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|     45|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (441:2): [True: 45, False: 3.76k]
  ------------------
  442|     45|		r = select_item(card, path_in, file_out, 1);
  443|     45|		break;
  444|  1.40k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  1.40k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (444:2): [True: 1.40k, False: 2.41k]
  ------------------
  445|  1.40k|		r = select_item(card, path_in, file_out, 0);
  446|  1.40k|		break;
  447|  2.36k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  2.36k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (447:2): [True: 2.36k, False: 1.44k]
  ------------------
  448|  2.36k|		r = select_item(card, path_in, file_out, -1);
  449|  2.36k|		break;
  450|      0|	default:
  ------------------
  |  Branch (450:2): [True: 0, False: 3.81k]
  ------------------
  451|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  452|  3.81k|	}
  453|  3.81k|	if(r > 0) r = 0;
  ------------------
  |  Branch (453:5): [True: 0, False: 3.81k]
  ------------------
  454|  3.81k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,r);
  ------------------
  |  |  153|  3.81k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  3.81k|	int _ret = r; \
  |  |  155|  3.81k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 3.81k, False: 0]
  |  |  ------------------
  |  |  156|  3.81k|		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|  3.11k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 3.11k, False: 697]
  |  |  ------------------
  |  |  157|  3.81k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  3.81k|	} 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|  3.81k|	return _ret; \
  |  |  163|  3.81k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  455|  3.81k|}
card-muscle.c:select_item:
  370|  3.81k|{
  371|  3.81k|	mscfs_t *fs = MUSCLE_FS(card);
  ------------------
  |  |   58|  3.81k|#define MUSCLE_FS(card) ( ((muscle_private_t*)card->drv_data)->fs )
  ------------------
  372|  3.81k|	mscfs_file_t *file_data = NULL;
  373|  3.81k|	size_t pathlen = path_in->len;
  374|  3.81k|	int r = 0;
  375|  3.81k|	int objectIndex;
  376|  3.81k|	u8* oid;
  377|       |
  378|  3.81k|	r = mscfs_check_cache(fs);
  379|  3.81k|	if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  2.28k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  2.28k|	int _ret = r; \
  |  |  155|  2.28k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 2.28k, False: 0]
  |  |  ------------------
  |  |  156|  2.28k|		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|  2.28k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 2.28k, False: 0]
  |  |  ------------------
  |  |  157|  2.28k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  2.28k|	} 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|  2.28k|	return _ret; \
  |  |  163|  2.28k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (379:5): [True: 2.28k, False: 1.53k]
  ------------------
  380|  1.53k|	r = mscfs_loadFileInfo(fs, path_in->value, path_in->len, &file_data, &objectIndex);
  381|  1.53k|	if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,r);
  ------------------
  |  |  153|    811|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    811|	int _ret = r; \
  |  |  155|    811|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 811, False: 0]
  |  |  ------------------
  |  |  156|    811|		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|    811|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 811, False: 0]
  |  |  ------------------
  |  |  157|    811|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    811|	} 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|    811|	return _ret; \
  |  |  163|    811|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (381:5): [True: 811, False: 721]
  ------------------
  382|       |
  383|       |	/* Check if its the right type */
  384|    721|	if(requiredType >= 0 && requiredType != file_data->ef) {
  ------------------
  |  Branch (384:5): [True: 66, False: 655]
  |  Branch (384:26): [True: 14, False: 52]
  ------------------
  385|     14|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} 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|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  386|     14|	}
  387|    707|	oid = file_data->objectId.id;
  388|       |	/* Is it a file or directory */
  389|    707|	if(file_data->ef) {
  ------------------
  |  Branch (389:5): [True: 355, False: 352]
  ------------------
  390|    355|		fs->currentPath[0] = oid[0];
  391|    355|		fs->currentPath[1] = oid[1];
  392|    355|		fs->currentFile[0] = oid[2];
  393|    355|		fs->currentFile[1] = oid[3];
  394|    355|	} else {
  395|    352|		if(pathlen < 2) {
  ------------------
  |  Branch (395:6): [True: 10, False: 342]
  ------------------
  396|     10|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     10|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     10|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     10|	int _ret = r; \
  |  |  |  |  155|     10|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     10|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     10|	} 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|     10|	return _ret; \
  |  |  |  |  163|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  397|     10|		}
  398|    342|		fs->currentPath[0] = oid[pathlen - 2];
  399|    342|		fs->currentPath[1] = oid[pathlen - 1];
  400|    342|		fs->currentFile[0] = 0;
  401|    342|		fs->currentFile[1] = 0;
  402|    342|	}
  403|       |
  404|    697|	fs->currentFileIndex = objectIndex;
  405|    697|	if(file_out) {
  ------------------
  |  Branch (405:5): [True: 363, False: 334]
  ------------------
  406|    363|		sc_file_t *file;
  407|    363|		file = sc_file_new();
  408|    363|		file->path = *path_in;
  409|    363|		file->size = file_data->size;
  410|    363|		file->id = (oid[2] << 8) | oid[3];
  411|    363|		if(!file_data->ef) {
  ------------------
  |  Branch (411:6): [True: 8, False: 355]
  ------------------
  412|      8|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      8|#define SC_FILE_TYPE_DF			0x04
  ------------------
  413|    355|		} else {
  414|    355|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    355|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  415|    355|			file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|    355|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  416|    355|		}
  417|       |
  418|       |		/* Setup ACLS */
  419|    363|		if(file_data->ef) {
  ------------------
  |  Branch (419:6): [True: 355, False: 8]
  ------------------
  420|    355|			muscle_load_file_acls(file, file_data);
  421|    355|		} else {
  422|      8|			muscle_load_dir_acls(file, file_data);
  423|       |			/* Setup directory acls... */
  424|      8|		}
  425|       |
  426|    363|		file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|    363|#define SC_FILE_MAGIC			0x14426950
  ------------------
  427|    363|		*file_out = file;
  428|    363|	}
  429|    697|	return 0;
  430|    707|}
card-muscle.c:muscle_load_file_acls:
  353|    355|{
  354|    355|	muscle_load_single_acl(file, SC_AC_OP_READ, file_data->read);
  ------------------
  |  |  188|    355|#define SC_AC_OP_READ			22
  ------------------
  355|    355|	muscle_load_single_acl(file, SC_AC_OP_WRITE, file_data->write);
  ------------------
  |  |  190|    355|#define SC_AC_OP_WRITE			24
  ------------------
  356|    355|	muscle_load_single_acl(file, SC_AC_OP_UPDATE, file_data->write);
  ------------------
  |  |  189|    355|#define SC_AC_OP_UPDATE			23
  ------------------
  357|    355|	muscle_load_single_acl(file, SC_AC_OP_DELETE, file_data->delete);
  ------------------
  |  |  168|    355|#define SC_AC_OP_DELETE			2
  ------------------
  358|    355|}
card-muscle.c:muscle_load_single_acl:
  338|  1.46k|{
  339|  1.46k|	int key;
  340|       |	/* Everybody by default.... */
  341|  1.46k|	sc_file_add_acl_entry(file, operation, SC_AC_NONE, 0);
  ------------------
  |  |  150|  1.46k|#define SC_AC_NONE			0x00000000
  ------------------
  342|  1.46k|	if(acl == 0xFFFF) {
  ------------------
  |  Branch (342:5): [True: 224, False: 1.23k]
  ------------------
  343|    224|		sc_file_add_acl_entry(file, operation, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    224|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  344|    224|		return;
  345|    224|	}
  346|  21.0k|	for(key = 0; key < 16; key++) {
  ------------------
  |  Branch (346:15): [True: 19.7k, False: 1.23k]
  ------------------
  347|  19.7k|		if(acl >> key & 1) {
  ------------------
  |  Branch (347:6): [True: 7.33k, False: 12.4k]
  ------------------
  348|  7.33k|			sc_file_add_acl_entry(file, operation, SC_AC_CHV, key);
  ------------------
  |  |  151|  7.33k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  349|  7.33k|		}
  350|  19.7k|	}
  351|  1.23k|}
card-muscle.c:muscle_load_dir_acls:
  360|      8|{
  361|      8|	muscle_load_single_acl(file, SC_AC_OP_SELECT, 0);
  ------------------
  |  |  166|      8|#define SC_AC_OP_SELECT			0
  ------------------
  362|      8|	muscle_load_single_acl(file, SC_AC_OP_LIST_FILES, 0);
  ------------------
  |  |  172|      8|#define SC_AC_OP_LIST_FILES		6
  ------------------
  363|      8|	muscle_load_single_acl(file, SC_AC_OP_LOCK, 0xFFFF);
  ------------------
  |  |  167|      8|#define SC_AC_OP_LOCK			1
  ------------------
  364|      8|	muscle_load_single_acl(file, SC_AC_OP_DELETE, file_data->delete);
  ------------------
  |  |  168|      8|#define SC_AC_OP_DELETE			2
  ------------------
  365|      8|	muscle_load_single_acl(file, SC_AC_OP_CREATE, file_data->write);
  ------------------
  |  |  169|      8|#define SC_AC_OP_CREATE			3
  ------------------
  366|      8|}
card-muscle.c:muscle_card_reader_lock_obtained:
  842|  42.6k|{
  843|  42.6k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  42.6k|#define SC_SUCCESS				0
  ------------------
  844|       |
  845|  42.6k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  42.6k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  42.6k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  42.6k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 42.6k]
  |  |  ------------------
  ------------------
  846|       |
  847|  42.6k|	if (was_reset > 0) {
  ------------------
  |  Branch (847:6): [True: 0, False: 42.6k]
  ------------------
  848|      0|		if (msc_select_applet(card, muscleAppletId, sizeof muscleAppletId) != 1) {
  ------------------
  |  Branch (848:7): [True: 0, False: 0]
  ------------------
  849|      0|			r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  850|      0|		}
  851|      0|	}
  852|       |
  853|  42.6k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  42.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  42.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  42.6k|	int _ret = r; \
  |  |  |  |  155|  42.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 42.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  42.6k|		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: 42.6k]
  |  |  |  |  ------------------
  |  |  |  |  157|  42.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  42.6k|	} 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|  42.6k|	return _ret; \
  |  |  |  |  163|  42.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  854|  42.6k|}

sc_get_myeid_driver:
 2183|  17.0k|{
 2184|  17.0k|	return sc_get_driver();
 2185|  17.0k|}
card-myeid.c:sc_get_driver:
 2148|  17.0k|{
 2149|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2150|       |
 2151|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2151:6): [True: 1, False: 17.0k]
  ------------------
 2152|      1|		iso_ops = iso_drv->ops;
 2153|       |
 2154|  17.0k|	myeid_ops			= *iso_drv->ops;
 2155|  17.0k|	myeid_ops.match_card		= myeid_match_card;
 2156|  17.0k|	myeid_ops.init			= myeid_init;
 2157|  17.0k|	myeid_ops.finish		= myeid_finish;
 2158|       |	/* no record oriented file services */
 2159|  17.0k|	myeid_ops.read_record		= NULL;
 2160|  17.0k|	myeid_ops.write_record		= NULL;
 2161|  17.0k|	myeid_ops.append_record		= NULL;
 2162|       |	myeid_ops.update_record		= NULL;
 2163|  17.0k|	myeid_ops.select_file		= myeid_select_file;
 2164|  17.0k|	myeid_ops.get_response		= iso_ops->get_response;
 2165|  17.0k|	myeid_ops.logout		= myeid_logout;
 2166|  17.0k|	myeid_ops.create_file		= myeid_create_file;
 2167|  17.0k|	myeid_ops.delete_file		= myeid_delete_file;
 2168|  17.0k|	myeid_ops.list_files		= myeid_list_files;
 2169|  17.0k|	myeid_ops.set_security_env	= myeid_set_security_env;
 2170|  17.0k|	myeid_ops.compute_signature	= myeid_compute_signature;
 2171|  17.0k|	myeid_ops.decipher		= myeid_decipher;
 2172|  17.0k|	myeid_ops.process_fci		= myeid_process_fci;
 2173|  17.0k|	myeid_ops.card_ctl		= myeid_card_ctl;
 2174|  17.0k|	myeid_ops.pin_cmd		= myeid_pin_cmd;
 2175|  17.0k|	myeid_ops.wrap			= myeid_wrap_key;
 2176|  17.0k|	myeid_ops.unwrap		= myeid_unwrap_key;
 2177|  17.0k|	myeid_ops.encrypt_sym		= myeid_encrypt_sym;
 2178|  17.0k|	myeid_ops.decrypt_sym		= myeid_decrypt_sym;
 2179|  17.0k|	return &myeid_drv;
 2180|  17.0k|}
card-myeid.c:myeid_match_card:
  122|  10.2k|{
  123|  10.2k|	size_t len = card->reader->atr_info.hist_bytes_len;
  124|       |	/* Normally the historical bytes are exactly "MyEID", but there might
  125|       |	 * be some historic units which have a small prefix byte sequence. */
  126|  10.2k|	if (len >= 5) {
  ------------------
  |  Branch (126:6): [True: 3.83k, False: 6.37k]
  ------------------
  127|  3.83k|		if (!memcmp(&card->reader->atr_info.hist_bytes[len - 5], "MyEID", 5)) {
  ------------------
  |  Branch (127:7): [True: 164, False: 3.66k]
  ------------------
  128|    164|			sc_log(card->ctx, "Matched MyEID card");
  ------------------
  |  |   71|    164|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  129|    164|			card->type = SC_CARD_TYPE_MYEID_GENERIC;
  130|    164|			return 1;
  131|    164|		}
  132|       |		/* The software implementation of MyEID is identified by OsEID bytes */
  133|  3.66k|		if (!memcmp(&card->reader->atr_info.hist_bytes[len - 5], "OsEID", 5)) {
  ------------------
  |  Branch (133:7): [True: 131, False: 3.53k]
  ------------------
  134|    131|			sc_log(card->ctx, "Matched OsEID card");
  ------------------
  |  |   71|    131|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  135|    131|			card->type = SC_CARD_TYPE_MYEID_OSEID;
  136|    131|			return 1;
  137|    131|		}
  138|  3.66k|	}
  139|  9.91k|	return 0;
  140|  10.2k|}
card-myeid.c:myeid_init:
  171|    295|{
  172|    295|	unsigned long flags = 0, ext_flags = 0;
  173|    295|	myeid_private_data_t *priv;
  174|    295|	u8 appletInfo[20];
  175|    295|	size_t appletInfoLen;
  176|    295|	myeid_card_caps_t card_caps;
  177|    295|	static struct sc_aid myeid_aid = { "\xA0\x00\x00\x00\x63\x50\x4B\x43\x53\x2D\x31\x35", 0x0C };
  178|    295|	int rv = 0;
  179|    295|	void *old_drv_data = card->drv_data;
  180|       |
  181|    295|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    295|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    295|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    295|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    295|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 295]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|       |
  183|    295|	switch (card->type) {
  184|    131|	case SC_CARD_TYPE_MYEID_OSEID:
  ------------------
  |  Branch (184:2): [True: 131, False: 164]
  ------------------
  185|    131|		card->name = oseid_card_name;
  186|    131|		break;
  187|    164|	case SC_CARD_TYPE_MYEID_GENERIC:
  ------------------
  |  Branch (187:2): [True: 164, False: 131]
  ------------------
  188|    164|		card->name = myeid_card_name;
  189|    164|		break;
  190|      0|	default:
  ------------------
  |  Branch (190:2): [True: 0, False: 295]
  ------------------
  191|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|    295|	}
  193|       |
  194|    295|	priv = calloc(1, sizeof(myeid_private_data_t));
  195|       |
  196|    295|	if (!priv)
  ------------------
  |  Branch (196:6): [True: 0, False: 295]
  ------------------
  197|    295|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|       |
  199|    295|	rv = myeid_load_options (card->ctx, priv);
  200|    295|	LOG_TEST_GOTO_ERR(card->ctx, rv, "Unable to read options from opensc.conf");
  ------------------
  |  |  184|    295|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    295|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    295|	int _ret = (r); \
  |  |  |  |  178|    295|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 295]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    295|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 295]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|       |
  202|    295|	priv->card_state = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|    295|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  203|    295|	card->drv_data = priv;
  204|       |
  205|       |	/* Ensure that the MyEID applet is selected. */
  206|    295|	rv = iso7816_select_aid(card, myeid_aid.value, myeid_aid.len, NULL, NULL);
  207|    295|	LOG_TEST_GOTO_ERR(card->ctx, rv, "Failed to select MyEID applet.");
  ------------------
  |  |  184|    295|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    295|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    295|	int _ret = (r); \
  |  |  |  |  178|    295|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 10, False: 285]
  |  |  |  |  ------------------
  |  |  |  |  179|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     10|		goto err; \
  |  |  |  |  182|     10|	} \
  |  |  |  |  183|    295|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 285]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  208|       |
  209|       |	/* find out MyEID version */
  210|       |
  211|    285|	appletInfoLen = 20;
  212|       |
  213|    285|	if (0 > myeid_get_info(card, appletInfo, appletInfoLen))
  ------------------
  |  Branch (213:6): [True: 109, False: 176]
  ------------------
  214|    285|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_CARD, "Failed to get MyEID applet information.");
  ------------------
  |  |  184|    109|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    109|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    109|	int _ret = (r); \
  |  |  |  |  178|    109|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 109, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    109|		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|    109|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    109|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    109|		goto err; \
  |  |  |  |  182|    109|	} \
  |  |  |  |  183|    109|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|       |
  216|    176|	priv->change_counter = appletInfo[19] | appletInfo[18] << 8;
  217|       |
  218|    176|	memset(&card_caps, 0, sizeof(myeid_card_caps_t));
  219|    176|	card_caps.max_ecc_key_length = 256;
  220|    176|	card_caps.max_rsa_key_length = 2048;
  221|       |
  222|    176|	if (card->version.fw_major >= 40) {
  ------------------
  |  Branch (222:6): [True: 82, False: 94]
  ------------------
  223|       |	    /* Since 4.0, we can query available algorithms and key sizes.
  224|       |	     * Since 3.5.0 RSA up to 2048 and ECC up to 256 are always supported, so we check only max ECC key length. */
  225|     82|	    if (myeid_get_card_caps(card, &card_caps) != SC_SUCCESS) {
  ------------------
  |  |   28|     82|#define SC_SUCCESS				0
  ------------------
  |  Branch (225:10): [True: 35, False: 47]
  ------------------
  226|     35|			sc_log(card->ctx, "Failed to get card capabilities. Using default max ECC key length 256.");
  ------------------
  |  |   71|     35|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  227|     35|	    }
  228|     82|	}
  229|       |
  230|    176|	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    176|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    176|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  231|    176|	if (priv->disable_hw_pkcs1_padding == 0)
  ------------------
  |  Branch (231:6): [True: 176, False: 0]
  ------------------
  232|    176|		flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|    176|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    176|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    176|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  233|    176|	flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    176|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  234|       |
  235|    176|	_sc_card_add_rsa_alg(card,  512, flags, 0);
  236|    176|	_sc_card_add_rsa_alg(card,  768, flags, 0);
  237|    176|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  238|    176|	_sc_card_add_rsa_alg(card, 1536, flags, 0);
  239|    176|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  240|       |
  241|    176|	if (card_caps.card_supported_features & MYEID_CARD_CAP_RSA) {
  ------------------
  |  |   50|    176|#define MYEID_CARD_CAP_RSA		0x01
  ------------------
  |  Branch (241:6): [True: 42, False: 134]
  ------------------
  242|     42|		if (card_caps.max_rsa_key_length >= 3072)
  ------------------
  |  Branch (242:7): [True: 31, False: 11]
  ------------------
  243|     31|			_sc_card_add_rsa_alg(card, 3072, flags, 0);
  244|     42|		if (card_caps.max_rsa_key_length >= 4096)
  ------------------
  |  Branch (244:7): [True: 28, False: 14]
  ------------------
  245|     28|			_sc_card_add_rsa_alg(card, 4096, flags, 0);
  246|     42|	}
  247|       |
  248|       |	/* show ECC algorithms if the applet version of the inserted card supports them */
  249|    176|	if (card->version.fw_major >= 35) {
  ------------------
  |  Branch (249:6): [True: 85, False: 91]
  ------------------
  250|     85|		int i;
  251|       |
  252|     85|		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  174|     85|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  173|     85|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|     85|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  253|     85|		flags |= SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|     85|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|     85|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  254|     85|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  201|     85|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  202|     85|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  255|       |
  256|    425|		for (i=0; ec_curves[i].curve_name != NULL; i++) {
  ------------------
  |  Branch (256:13): [True: 340, False: 85]
  ------------------
  257|    340|			if (card_caps.max_ecc_key_length >= ec_curves[i].size)
  ------------------
  |  Branch (257:8): [True: 199, False: 141]
  ------------------
  258|    199|				_sc_card_add_ec_alg(card, ec_curves[i].size, flags, ext_flags, &ec_curves[i].curve_oid);
  259|    340|		}
  260|     85|	}
  261|       |
  262|       |	/* show supported symmetric algorithms */
  263|    176|	flags = 0;
  264|    176|	if (card_caps.card_supported_features & MYEID_CARD_CAP_3DES) {
  ------------------
  |  |   51|    176|#define MYEID_CARD_CAP_3DES		0x02
  ------------------
  |  Branch (264:6): [True: 41, False: 135]
  ------------------
  265|     41|		if (card_caps.max_des_key_length >= 64)
  ------------------
  |  Branch (265:7): [True: 35, False: 6]
  ------------------
  266|     35|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_DES, 64, flags);
  ------------------
  |  |   76|     35|#define SC_ALGORITHM_DES		64
  ------------------
  267|     41|		if (card_caps.max_des_key_length >= 128)
  ------------------
  |  Branch (267:7): [True: 29, False: 12]
  ------------------
  268|     29|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_3DES, 128, flags);
  ------------------
  |  |   77|     29|#define SC_ALGORITHM_3DES		65
  ------------------
  269|     41|		if (card_caps.max_des_key_length >= 192)
  ------------------
  |  Branch (269:7): [True: 26, False: 15]
  ------------------
  270|     26|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_3DES, 192, flags);
  ------------------
  |  |   77|     26|#define SC_ALGORITHM_3DES		65
  ------------------
  271|     41|	}
  272|    176|	if (card_caps.card_supported_features & MYEID_CARD_CAP_AES) {
  ------------------
  |  |   52|    176|#define MYEID_CARD_CAP_AES		0x04
  ------------------
  |  Branch (272:6): [True: 36, False: 140]
  ------------------
  273|     36|		if (card_caps.max_aes_key_length >= 128)
  ------------------
  |  Branch (273:7): [True: 31, False: 5]
  ------------------
  274|     31|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_AES, 128, flags);
  ------------------
  |  |   79|     31|#define SC_ALGORITHM_AES		67
  ------------------
  275|     36|		if (card_caps.max_aes_key_length >= 256)
  ------------------
  |  Branch (275:7): [True: 21, False: 15]
  ------------------
  276|     21|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_AES, 256, flags);
  ------------------
  |  |   79|     21|#define SC_ALGORITHM_AES		67
  ------------------
  277|     36|	}
  278|       |
  279|       |	/* State that we have an RNG */
  280|    176|	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  550|    176|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    176|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  281|       |
  282|    176|	if ((card->version.fw_major == 40 && card->version.fw_minor >= 10 )
  ------------------
  |  Branch (282:7): [True: 11, False: 165]
  |  Branch (282:39): [True: 9, False: 2]
  ------------------
  283|    167|		|| card->version.fw_major >= 41)
  ------------------
  |  Branch (283:6): [True: 71, False: 96]
  ------------------
  284|     80|		card->caps |= SC_CARD_CAP_WRAP_KEY | SC_CARD_CAP_UNWRAP_KEY
  ------------------
  |  |  572|     80|#define SC_CARD_CAP_WRAP_KEY			0x00000800
  ------------------
              		card->caps |= SC_CARD_CAP_WRAP_KEY | SC_CARD_CAP_UNWRAP_KEY
  ------------------
  |  |  574|     80|#define SC_CARD_CAP_UNWRAP_KEY			0x00001000
  ------------------
  285|     80|			   | SC_CARD_CAP_ONCARD_SESSION_OBJECTS;
  ------------------
  |  |  569|     80|#define SC_CARD_CAP_ONCARD_SESSION_OBJECTS	0x00000400
  ------------------
  286|       |
  287|    176|	if (card->version.fw_major >= 45)
  ------------------
  |  Branch (287:6): [True: 67, False: 109]
  ------------------
  288|     67|		priv->cap_chaining = 1;
  289|    176|	if (card->version.fw_major >= 40)
  ------------------
  |  Branch (289:6): [True: 82, False: 94]
  ------------------
  290|     82|		card->max_recv_size = 256;
  291|     94|	else
  292|     94|		card->max_recv_size = 255;
  293|    176|	card->max_send_size = 255;
  294|       |
  295|    176|	rv = SC_SUCCESS;
  ------------------
  |  |   28|    176|#define SC_SUCCESS				0
  ------------------
  296|       |
  297|    295|err:
  298|    295|	if (rv < 0) {
  ------------------
  |  Branch (298:6): [True: 10, False: 285]
  ------------------
  299|     10|		free(priv);
  300|     10|		card->drv_data = old_drv_data;
  301|     10|	}
  302|       |
  303|    295|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    295|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    295|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    295|	int _ret = r; \
  |  |  |  |  155|    295|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 295, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    295|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10, False: 285]
  |  |  |  |  ------------------
  |  |  |  |  157|    295|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    295|	} 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|    295|	return _ret; \
  |  |  |  |  163|    295|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  304|    295|}
card-myeid.c:myeid_load_options:
  143|    295|{
  144|    295|	int r;
  145|    295|	size_t i, j;
  146|    295|	scconf_block **found_blocks, *block;
  147|       |
  148|    295|	if (!ctx || !priv) {
  ------------------
  |  Branch (148:6): [True: 0, False: 295]
  |  Branch (148:14): [True: 0, False: 295]
  ------------------
  149|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  150|      0|		goto err;
  151|      0|	}
  152|    295|	priv->disable_hw_pkcs1_padding = 0;
  153|    590|	for (i = 0; ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (153:14): [True: 295, False: 295]
  ------------------
  154|    295|		found_blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i],
  155|    295|				"card_driver", "myeid");
  156|    295|		if (!found_blocks)
  ------------------
  |  Branch (156:7): [True: 0, False: 295]
  ------------------
  157|      0|			continue;
  158|    295|		for (j = 0, block = found_blocks[j]; block; j++, block = found_blocks[j]) {
  ------------------
  |  Branch (158:40): [True: 0, False: 295]
  ------------------
  159|      0|			priv->disable_hw_pkcs1_padding = scconf_get_int(block, "disable_hw_pkcs1_padding", 0);
  160|      0|			sc_log(ctx,"Found config option: disable_hw_pkcs1_padding = %d\n", priv->disable_hw_pkcs1_padding);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  161|      0|		}
  162|    295|		free(found_blocks);
  163|    295|	}
  164|    295|	r = SC_SUCCESS;
  ------------------
  |  |   28|    295|#define SC_SUCCESS				0
  ------------------
  165|       |
  166|    295|err:
  167|    295|	return r;
  168|    295|}
card-myeid.c:myeid_get_info:
 1740|    400|{
 1741|    400|	sc_apdu_t apdu;
 1742|    400|	int r;
 1743|       |
 1744|    400|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    400|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    400|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    400|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    400|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 400]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1745|       |
 1746|    400|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0xA0);
  ------------------
  |  |  292|    400|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1747|    400|	apdu.resp    = rbuf;
 1748|    400|	apdu.resplen = buflen;
 1749|    400|	apdu.le      = buflen;
 1750|       |
 1751|    400|	r = sc_transmit_apdu(card, &apdu);
 1752|    400|	LOG_TEST_RET(card->ctx, r,  "APDU transmit failed");
  ------------------
  |  |  174|    400|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    400|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    400|	int _ret = (r); \
  |  |  |  |  168|    400|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 390]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|    400|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 390]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1753|       |
 1754|    390|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1754:6): [True: 177, False: 213]
  |  Branch (1754:26): [True: 14, False: 199]
  ------------------
 1755|    191|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    191|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1756|       |
 1757|    199|	if (apdu.resplen != 20)
  ------------------
  |  Branch (1757:6): [True: 21, False: 178]
  ------------------
 1758|     21|	{
 1759|     21|		sc_log(card->ctx, "Unexpected response to GET DATA (applet info)");
  ------------------
  |  |   71|     21|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1760|     21|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     21|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1761|     21|	}
 1762|       |
 1763|       |	/* store the applet version */
 1764|    178|	card->version.fw_major = rbuf[5] * 10 + rbuf[6];
 1765|    178|	card->version.fw_minor = rbuf[7];
 1766|       |	/* add version to name */
 1767|    178|	snprintf(card_name_buf, sizeof(card_name_buf),
 1768|    178|			"%s %d.%d.%d", card->name, rbuf[5], rbuf[6], rbuf[7]);
 1769|    178|	card->name = card_name_buf;
 1770|       |
 1771|    178|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    178|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    178|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    178|	int _ret = r; \
  |  |  |  |  155|    178|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 178, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    178|		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: 178]
  |  |  |  |  ------------------
  |  |  |  |  157|    178|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    178|	} 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|    178|	return _ret; \
  |  |  |  |  163|    178|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1772|    178|}
card-myeid.c:myeid_get_card_caps:
 1823|     82|{
 1824|     82|	sc_apdu_t apdu;
 1825|     82|	int r;
 1826|     82|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1827|       |
 1828|     82|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     82|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     82|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     82|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     82|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 82]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1829|       |
 1830|     82|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0xAA);
  ------------------
  |  |  292|     82|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1831|     82|	apdu.resp    = rbuf;
 1832|     82|	apdu.resplen = sizeof(myeid_card_caps_t);
 1833|     82|	apdu.le      = sizeof(myeid_card_caps_t);
 1834|       |
 1835|     82|	r = sc_transmit_apdu(card, &apdu);
 1836|     82|	LOG_TEST_RET(card->ctx, r,  "APDU transmit failed");
  ------------------
  |  |  174|     82|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     82|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     82|	int _ret = (r); \
  |  |  |  |  168|     82|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 81]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     82|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1837|       |
 1838|     81|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1838:6): [True: 26, False: 55]
  |  Branch (1838:26): [True: 6, False: 49]
  ------------------
 1839|     32|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     32|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1840|       |
 1841|     49|	if (apdu.resplen < 11) {
  ------------------
  |  Branch (1841:6): [True: 2, False: 47]
  ------------------
 1842|      2|		sc_log(card->ctx, "Unexpected response to GET DATA (MyEIC card capabilities)");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1843|      2|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      2|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1844|      2|	}
 1845|       |
 1846|     47|	card_caps->card_caps_ver = rbuf[0];
 1847|       |	/* the card returns big endian values */
 1848|     47|	card_caps->card_supported_features = (unsigned short) rbuf[1] << 8 | rbuf[2];
 1849|     47|	card_caps->max_rsa_key_length = (unsigned short) rbuf[3] << 8 | rbuf[4];
 1850|     47|	card_caps->max_des_key_length = (unsigned short) rbuf[5] << 8 | rbuf[6];
 1851|     47|	card_caps->max_aes_key_length = (unsigned short) rbuf[7] << 8 | rbuf[8];
 1852|     47|	card_caps->max_ecc_key_length = (unsigned short) rbuf[9] << 8 | rbuf[10];
 1853|       |
 1854|     47|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     47|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     47|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     47|	int _ret = r; \
  |  |  |  |  155|     47|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 47, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     47|		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: 47]
  |  |  |  |  ------------------
  |  |  |  |  157|     47|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     47|	} 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|     47|	return _ret; \
  |  |  |  |  163|     47|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1855|     47|}
card-myeid.c:myeid_finish:
 1893|    285|{
 1894|    285|	struct myeid_private_data *priv = (struct myeid_private_data *) card->drv_data;
 1895|    285|	free(priv);
 1896|    285|	return SC_SUCCESS;
  ------------------
  |  |   28|    285|#define SC_SUCCESS				0
  ------------------
 1897|    285|}
card-myeid.c:myeid_select_file:
  392|  2.03k|{
  393|  2.03k|	int r;
  394|       |
  395|  2.03k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.03k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.03k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.03k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.03k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  396|  2.03k|	r = iso_ops->select_file(card, in_path, file);
  397|       |
  398|  2.03k|	if (r == 0 && file != NULL && *file != NULL)
  ------------------
  |  Branch (398:6): [True: 516, False: 1.52k]
  |  Branch (398:16): [True: 172, False: 344]
  |  Branch (398:32): [True: 172, False: 0]
  ------------------
  399|    172|		parse_sec_attr(*file, (*file)->sec_attr, (*file)->sec_attr_len);
  400|       |
  401|  2.03k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  2.03k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.03k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.03k|	int _ret = r; \
  |  |  |  |  155|  2.03k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.03k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.03k|		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|  1.52k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.52k, False: 516]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.03k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.03k|	} 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|  2.03k|	return _ret; \
  |  |  |  |  163|  2.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  402|  2.03k|}
card-myeid.c:parse_sec_attr:
  350|    172|{
  351|    172|	int i;
  352|    172|	const int df_ops[4] =
  353|    172|		{ SC_AC_OP_CREATE, SC_AC_OP_CREATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  169|    172|#define SC_AC_OP_CREATE			3
  ------------------
              		{ SC_AC_OP_CREATE, SC_AC_OP_CREATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  169|    172|#define SC_AC_OP_CREATE			3
  ------------------
              		{ SC_AC_OP_CREATE, SC_AC_OP_CREATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  168|    172|#define SC_AC_OP_DELETE			2
  ------------------
  354|    172|	const int ef_ops[4] =
  355|    172|		{ SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  188|    172|#define SC_AC_OP_READ			22
  ------------------
              		{ SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  189|    172|#define SC_AC_OP_UPDATE			23
  ------------------
              		{ SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  168|    172|#define SC_AC_OP_DELETE			2
  ------------------
  356|    172|	const int key_ops[4] =
  357|    172|		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  173|    172|#define SC_AC_OP_CRYPTO			7
  ------------------
              		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  189|    172|#define SC_AC_OP_UPDATE			23
  ------------------
              		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  168|    172|#define SC_AC_OP_DELETE			2
  ------------------
              		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  192|    172|#define SC_AC_OP_GENERATE		26
  ------------------
  358|       |
  359|    172|	const int *ops;
  360|       |
  361|    172|	if (len < 2)
  ------------------
  |  Branch (361:6): [True: 98, False: 74]
  ------------------
  362|     98|		return;
  363|       |
  364|     74|	switch (file->type) {
  365|      9|	case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|      9|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (365:2): [True: 9, False: 65]
  ------------------
  366|      9|		ops = ef_ops;
  367|      9|		break;
  368|      6|	case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|      6|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (368:2): [True: 6, False: 68]
  ------------------
  369|      6|		ops = key_ops;
  370|      6|		break;
  371|     16|	case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|     16|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (371:2): [True: 16, False: 58]
  ------------------
  372|     16|		ops = df_ops;
  373|     16|		break;
  374|     43|	default:
  ------------------
  |  Branch (374:2): [True: 43, False: 31]
  ------------------
  375|     43|		ops = key_ops;
  376|     43|		break;
  377|     74|	}
  378|       |
  379|    370|	for (i = 0; i < 4; i++)
  ------------------
  |  Branch (379:14): [True: 296, False: 74]
  ------------------
  380|    296|	{
  381|    296|		if (ops[i] == -1)
  ------------------
  |  Branch (381:7): [True: 25, False: 271]
  ------------------
  382|     25|			continue;
  383|    271|		if ((i & 1) == 0)
  ------------------
  |  Branch (383:7): [True: 148, False: 123]
  ------------------
  384|    148|			add_acl_entry(file, ops[i], (u8)(buf[i / 2] >> 4));
  385|    123|		else
  386|    123|			add_acl_entry(file, ops[i], (u8)(buf[i / 2] & 0x0F));
  387|    271|	}
  388|     74|}
card-myeid.c:add_acl_entry:
  330|    271|{
  331|    271|	unsigned int method, key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|    271|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  332|       |
  333|    271|	switch (byte)
  334|    271|	{
  335|    153|	case 0:
  ------------------
  |  Branch (335:2): [True: 153, False: 118]
  ------------------
  336|    153|		method = SC_AC_NONE;
  ------------------
  |  |  150|    153|#define SC_AC_NONE			0x00000000
  ------------------
  337|    153|		break;
  338|     26|	case 15:
  ------------------
  |  Branch (338:2): [True: 26, False: 245]
  ------------------
  339|     26|		method = SC_AC_NEVER;
  ------------------
  |  |  163|     26|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  340|     26|		break;
  341|     92|	default:
  ------------------
  |  Branch (341:2): [True: 92, False: 179]
  ------------------
  342|     92|		method = SC_AC_CHV;
  ------------------
  |  |  151|     92|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  343|     92|		key_ref = byte;
  344|     92|		break;
  345|    271|	}
  346|    271|	sc_file_add_acl_entry(file, op, method, key_ref);
  347|    271|}
card-myeid.c:myeid_set_security_env:
  985|     92|{
  986|     92|	struct sc_context *ctx = card->ctx;
  987|     92|	myeid_private_data_t* priv;
  988|       |
  989|     92|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     92|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     92|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     92|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     92|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 92]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  990|       |
  991|     92|	priv = (myeid_private_data_t*) card->drv_data;
  992|       |	/* store security environment to differentiate between ECDH and RSA in decipher - Hannu*/
  993|     92|	priv->sec_env = env;
  994|       |
  995|       |	/* for symmetric operation save algo and algo flags */
  996|     92|	priv->algorithm_flags = env->algorithm_flags;
  997|     92|	priv->algorithm = env->algorithm;
  998|       |
  999|     92|	if (env->flags & SC_SEC_ENV_ALG_PRESENT)
  ------------------
  |  |   60|     92|#define SC_SEC_ENV_ALG_PRESENT		0x0010
  ------------------
  |  Branch (999:6): [True: 92, False: 0]
  ------------------
 1000|     92|	{
 1001|     92|		sc_security_env_t tmp;
 1002|       |
 1003|     92|		tmp = *env;
 1004|     92|		tmp.flags &= ~SC_SEC_ENV_ALG_PRESENT;
  ------------------
  |  |   60|     92|#define SC_SEC_ENV_ALG_PRESENT		0x0010
  ------------------
 1005|     92|		tmp.flags |= SC_SEC_ENV_ALG_REF_PRESENT;
  ------------------
  |  |   56|     92|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
 1006|       |
 1007|     92|		if (tmp.algorithm == SC_ALGORITHM_RSA)
  ------------------
  |  |   69|     92|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1007:7): [True: 92, False: 0]
  ------------------
 1008|     92|		{
 1009|     92|			if (tmp.operation == SC_SEC_OPERATION_UNWRAP || tmp.operation == SC_SEC_OPERATION_WRAP)
  ------------------
  |  |   52|    184|#define SC_SEC_OPERATION_UNWRAP		0x0006
  ------------------
              			if (tmp.operation == SC_SEC_OPERATION_UNWRAP || tmp.operation == SC_SEC_OPERATION_WRAP)
  ------------------
  |  |   51|     92|#define SC_SEC_OPERATION_WRAP		0x0005
  ------------------
  |  Branch (1009:8): [True: 0, False: 92]
  |  Branch (1009:52): [True: 0, False: 92]
  ------------------
 1010|      0|			{
 1011|      0|			    tmp.algorithm_ref = 0x0A;
 1012|      0|			}
 1013|     92|			else
 1014|     92|			{
 1015|     92|				tmp.algorithm_ref = 0x00;
 1016|       |				/* potential FIXME: return an error, if an unsupported
 1017|       |				* pad or hash was requested, although this shouldn't happen */
 1018|     92|				if ((env->operation == SC_SEC_OPERATION_SIGN && env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01)
  ------------------
  |  |   48|    184|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
              				if ((env->operation == SC_SEC_OPERATION_SIGN && env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01)
  ------------------
  |  |  109|     54|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (1018:10): [True: 54, False: 38]
  |  Branch (1018:53): [True: 17, False: 37]
  ------------------
 1019|     75|					|| (env->operation == SC_SEC_OPERATION_DECIPHER && env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02))
  ------------------
  |  |   47|    150|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
              					|| (env->operation == SC_SEC_OPERATION_DECIPHER && env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02))
  ------------------
  |  |  110|     38|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  |  Branch (1019:10): [True: 38, False: 37]
  |  Branch (1019:57): [True: 0, False: 38]
  ------------------
 1020|     17|					tmp.algorithm_ref = 0x02;
 1021|     92|				if (tmp.algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA1)
  ------------------
  |  |  134|     92|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  |  Branch (1021:9): [True: 0, False: 92]
  ------------------
 1022|      0|					tmp.algorithm_ref |= 0x10;
 1023|     92|			}
 1024|       |
 1025|     92|			return myeid_set_security_env_rsa(card, &tmp, se_num);
 1026|     92|		}
 1027|      0|		else if (tmp.algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1027:12): [True: 0, False: 0]
  ------------------
 1028|      0|		{
 1029|      0|			tmp.algorithm_ref = 0x04;
 1030|      0|			tmp.algorithm_flags = 0;
 1031|      0|			return myeid_set_security_env_ec(card, &tmp, se_num);
 1032|      0|		}
 1033|      0|		else if (tmp.algorithm == SC_ALGORITHM_AES)
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_AES		67
  ------------------
  |  Branch (1033:12): [True: 0, False: 0]
  ------------------
 1034|      0|		{
 1035|      0|			if (tmp.operation == SC_SEC_OPERATION_UNWRAP || tmp.operation == SC_SEC_OPERATION_WRAP)
  ------------------
  |  |   52|      0|#define SC_SEC_OPERATION_UNWRAP		0x0006
  ------------------
              			if (tmp.operation == SC_SEC_OPERATION_UNWRAP || tmp.operation == SC_SEC_OPERATION_WRAP)
  ------------------
  |  |   51|      0|#define SC_SEC_OPERATION_WRAP		0x0005
  ------------------
  |  Branch (1035:8): [True: 0, False: 0]
  |  Branch (1035:52): [True: 0, False: 0]
  ------------------
 1036|      0|			{
 1037|      0|				tmp.algorithm_ref = 0x0A;
 1038|      0|			}
 1039|      0|			else
 1040|      0|			{
 1041|      0|				tmp.algorithm_ref = 0x00;
 1042|      0|			}
 1043|       |
 1044|      0|			if ((tmp.algorithm_flags & SC_ALGORITHM_AES_CBC_PAD) == SC_ALGORITHM_AES_CBC_PAD)
  ------------------
  |  |  208|      0|#define SC_ALGORITHM_AES_CBC_PAD	 0x04000000
  ------------------
              			if ((tmp.algorithm_flags & SC_ALGORITHM_AES_CBC_PAD) == SC_ALGORITHM_AES_CBC_PAD)
  ------------------
  |  |  208|      0|#define SC_ALGORITHM_AES_CBC_PAD	 0x04000000
  ------------------
  |  Branch (1044:8): [True: 0, False: 0]
  ------------------
 1045|      0|				tmp.algorithm_ref |= 0x80;		/* set PKCS#7 padding */
 1046|       |			/* Tag 0x80 algorithm_ref - value 0x80 or 0x8A is working only for UNWRAP/WRAP
 1047|       |			 * AES is supported from version 4.0 but without pkcs#7 padding.
 1048|       |			 * For SC_SEC_OPERATION_ENCRYPT_SYM and SC_SEC_OPERATION_DECRYPT_SYM we running
 1049|       |			 * PKCS#7 in software, here we fix the algorithm_ref variable.
 1050|       |			 */
 1051|      0|			if (IS_SYMETRIC_CRYPT(env->operation))
  ------------------
  |  |  739|      0|#define IS_SYMETRIC_CRYPT(x) ((x) == SC_SEC_OPERATION_ENCRYPT_SYM || (x) == SC_SEC_OPERATION_DECRYPT_SYM)
  |  |  ------------------
  |  |  |  |   53|      0|#define SC_SEC_OPERATION_ENCRYPT_SYM	0x0007
  |  |  ------------------
  |  |               #define IS_SYMETRIC_CRYPT(x) ((x) == SC_SEC_OPERATION_ENCRYPT_SYM || (x) == SC_SEC_OPERATION_DECRYPT_SYM)
  |  |  ------------------
  |  |  |  |   54|      0|#define SC_SEC_OPERATION_DECRYPT_SYM	0x0008
  |  |  ------------------
  |  |  |  Branch (739:31): [True: 0, False: 0]
  |  |  |  Branch (739:70): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1052|      0|				tmp.algorithm_ref &= ~0x80; /* do not handle padding in card */
 1053|       |
 1054|       |			/* from this point, there's no difference to RSA SE */
 1055|      0|			return myeid_set_security_env_rsa(card, &tmp, se_num);
 1056|      0|		}
 1057|      0|		else
 1058|      0|		{
 1059|       |
 1060|      0|			sc_log(ctx, "Unsupported algorithm.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1061|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1062|      0|		}
 1063|     92|	}
 1064|      0|	return myeid_set_security_env_rsa(card, env, se_num);
 1065|     92|}
card-myeid.c:myeid_set_security_env_rsa:
  743|    119|{
  744|    119|	sc_apdu_t apdu;
  745|    119|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
  746|    119|	u8 *p;
  747|    119|	int r;
  748|    119|	size_t i, sz;
  749|    119|	sc_path_t *target_file;
  750|       |
  751|    119|	if (card == NULL || env == NULL)
  ------------------
  |  Branch (751:6): [True: 0, False: 119]
  |  Branch (751:22): [True: 0, False: 119]
  ------------------
  752|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  753|    119|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    119|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    119|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    119|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    119|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 119]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|       |
  755|    119|	if (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC)
  ------------------
  |  |   59|    119|#define SC_SEC_ENV_KEY_REF_SYMMETRIC	0x0008
  ------------------
  |  Branch (755:6): [True: 0, False: 119]
  ------------------
  756|      0|	{
  757|      0|		sc_log(card->ctx, "symmetric keyref not supported.\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  758|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  759|      0|	}
  760|    119|	if (se_num > 0)
  ------------------
  |  Branch (760:6): [True: 0, False: 119]
  ------------------
  761|      0|	{
  762|      0|		sc_log(card->ctx, "restore security environment not supported.\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  763|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  764|      0|	}
  765|       |
  766|    119|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0, 0);
  ------------------
  |  |  293|    119|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  767|    119|	switch (env->operation)
  768|    119|	{
  769|     65|	case SC_SEC_OPERATION_DECIPHER:
  ------------------
  |  |   47|     65|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
  |  Branch (769:2): [True: 65, False: 54]
  ------------------
  770|     65|		apdu.p1 = 0x41;
  771|     65|		apdu.p2 = 0xB8;
  772|     65|		break;
  773|     54|	case SC_SEC_OPERATION_SIGN:
  ------------------
  |  |   48|     54|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (773:2): [True: 54, False: 65]
  ------------------
  774|     54|		apdu.p1 = 0x41;
  775|     54|		apdu.p2 = 0xB6;
  776|     54|		break;
  777|      0|	case SC_SEC_OPERATION_UNWRAP:
  ------------------
  |  |   52|      0|#define SC_SEC_OPERATION_UNWRAP		0x0006
  ------------------
  |  Branch (777:2): [True: 0, False: 119]
  ------------------
  778|      0|		apdu.p1 = 0x41;
  779|      0|		apdu.p2 = 0xB8;
  780|      0|		break;
  781|      0|	case SC_SEC_OPERATION_WRAP:
  ------------------
  |  |   51|      0|#define SC_SEC_OPERATION_WRAP		0x0005
  ------------------
  |  Branch (781:2): [True: 0, False: 119]
  ------------------
  782|      0|		apdu.p1 = 0x81;
  783|      0|		apdu.p2 = 0xB8;
  784|      0|		break;
  785|      0|	case SC_SEC_OPERATION_ENCRYPT_SYM:
  ------------------
  |  |   53|      0|#define SC_SEC_OPERATION_ENCRYPT_SYM	0x0007
  ------------------
  |  Branch (785:2): [True: 0, False: 119]
  ------------------
  786|      0|		apdu.p1 = 0x81;
  787|      0|		apdu.p2 = 0xB8;
  788|      0|		break;
  789|      0|	case SC_SEC_OPERATION_DECRYPT_SYM:
  ------------------
  |  |   54|      0|#define SC_SEC_OPERATION_DECRYPT_SYM	0x0008
  ------------------
  |  Branch (789:2): [True: 0, False: 119]
  ------------------
  790|      0|		apdu.p1 = 0x41;
  791|      0|		apdu.p2 = 0xB8;
  792|      0|		break;
  793|      0|	default:
  ------------------
  |  Branch (793:2): [True: 0, False: 119]
  ------------------
  794|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  795|    119|	}
  796|    119|	apdu.le = 0;
  797|    119|	p = sbuf;
  798|    119|	if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT)
  ------------------
  |  |   56|    119|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
  |  Branch (798:6): [True: 119, False: 0]
  ------------------
  799|    119|	{
  800|    119|		*p++ = 0x80;	/* algorithm reference */
  801|    119|		*p++ = 0x01;
  802|    119|		*p++ = env->algorithm_ref & 0xFF;
  803|    119|	}
  804|    119|	if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT)
  ------------------
  |  |   57|    119|#define SC_SEC_ENV_FILE_REF_PRESENT	0x0002
  ------------------
  |  Branch (804:6): [True: 27, False: 92]
  ------------------
  805|     27|	{
  806|     27|		*p++ = 0x81;
  807|     27|		*p++ = 2;
  808|     27|		memcpy(p, env->file_ref.value, 2);
  809|     27|		p += 2;
  810|     27|	}
  811|       |	/* symmetric operations: we need to set the key reference */
  812|    119|	if (IS_SYMETRIC_CRYPT(env->operation)) {
  ------------------
  |  |  739|    119|#define IS_SYMETRIC_CRYPT(x) ((x) == SC_SEC_OPERATION_ENCRYPT_SYM || (x) == SC_SEC_OPERATION_DECRYPT_SYM)
  |  |  ------------------
  |  |  |  |   53|    238|#define SC_SEC_OPERATION_ENCRYPT_SYM	0x0007
  |  |  ------------------
  |  |               #define IS_SYMETRIC_CRYPT(x) ((x) == SC_SEC_OPERATION_ENCRYPT_SYM || (x) == SC_SEC_OPERATION_DECRYPT_SYM)
  |  |  ------------------
  |  |  |  |   54|    119|#define SC_SEC_OPERATION_DECRYPT_SYM	0x0008
  |  |  ------------------
  |  |  |  Branch (739:31): [True: 0, False: 119]
  |  |  |  Branch (739:70): [True: 0, False: 119]
  |  |  ------------------
  ------------------
  813|      0|		*p++ = 0x83;
  814|      0|		*p++ = 1;
  815|      0|		*p++ = 0;
  816|      0|	}
  817|    119|	if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT && env->operation != SC_SEC_OPERATION_UNWRAP &&
  ------------------
  |  |   58|    238|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
              	if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT && env->operation != SC_SEC_OPERATION_UNWRAP &&
  ------------------
  |  |   52|    238|#define SC_SEC_OPERATION_UNWRAP		0x0006
  ------------------
  |  Branch (817:6): [True: 119, False: 0]
  |  Branch (817:49): [True: 119, False: 0]
  ------------------
  818|    119|			env->operation != SC_SEC_OPERATION_WRAP &&
  ------------------
  |  |   51|    238|#define SC_SEC_OPERATION_WRAP		0x0005
  ------------------
  |  Branch (818:4): [True: 119, False: 0]
  ------------------
  819|    119|			env->operation != SC_SEC_OPERATION_ENCRYPT_SYM &&
  ------------------
  |  |   53|    238|#define SC_SEC_OPERATION_ENCRYPT_SYM	0x0007
  ------------------
  |  Branch (819:4): [True: 119, False: 0]
  ------------------
  820|    119|			env->operation != SC_SEC_OPERATION_DECRYPT_SYM) {
  ------------------
  |  |   54|    119|#define SC_SEC_OPERATION_DECRYPT_SYM	0x0008
  ------------------
  |  Branch (820:4): [True: 119, False: 0]
  ------------------
  821|    119|		*p++ = 0x84;
  822|    119|		*p++ = 1;
  823|    119|		*p++ = 0;
  824|    119|	}
  825|  1.30k|	for (i = 0; i < SC_SEC_ENV_MAX_PARAMS; i++)
  ------------------
  |  |   64|  1.30k|#define SC_SEC_ENV_MAX_PARAMS		10
  ------------------
  |  Branch (825:14): [True: 1.19k, False: 119]
  ------------------
  826|  1.19k|	    if (env->params[i].param_type == SC_SEC_ENV_PARAM_TARGET_FILE) {
  ------------------
  |  |   66|  1.19k|#define SC_SEC_ENV_PARAM_TARGET_FILE	2
  ------------------
  |  Branch (826:10): [True: 0, False: 1.19k]
  ------------------
  827|      0|			target_file = (sc_path_t*) env->params[i].value;
  828|      0|			if (env->params[i].value_len < sizeof(sc_path_t) || target_file->len != 2) {
  ------------------
  |  Branch (828:8): [True: 0, False: 0]
  |  Branch (828:56): [True: 0, False: 0]
  ------------------
  829|      0|				sc_log(card->ctx, "wrong length of target file reference.\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  830|      0|				return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  831|      0|			}
  832|      0|			*p++ = 0x83;
  833|      0|			*p++ = 2;
  834|      0|			memcpy(p, target_file->value, 2);
  835|      0|			p+= 2;
  836|      0|			break;
  837|      0|	    }
  838|       |
  839|    119|	r = 0;
  840|    119|	if (env->operation == SC_SEC_OPERATION_UNWRAP || env->operation == SC_SEC_OPERATION_WRAP ||
  ------------------
  |  |   52|    238|#define SC_SEC_OPERATION_UNWRAP		0x0006
  ------------------
              	if (env->operation == SC_SEC_OPERATION_UNWRAP || env->operation == SC_SEC_OPERATION_WRAP ||
  ------------------
  |  |   51|    238|#define SC_SEC_OPERATION_WRAP		0x0005
  ------------------
  |  Branch (840:6): [True: 0, False: 119]
  |  Branch (840:51): [True: 0, False: 119]
  ------------------
  841|    119|			IS_SYMETRIC_CRYPT(env->operation)) {
  ------------------
  |  |  739|    119|#define IS_SYMETRIC_CRYPT(x) ((x) == SC_SEC_OPERATION_ENCRYPT_SYM || (x) == SC_SEC_OPERATION_DECRYPT_SYM)
  |  |  ------------------
  |  |  |  |   53|    238|#define SC_SEC_OPERATION_ENCRYPT_SYM	0x0007
  |  |  ------------------
  |  |               #define IS_SYMETRIC_CRYPT(x) ((x) == SC_SEC_OPERATION_ENCRYPT_SYM || (x) == SC_SEC_OPERATION_DECRYPT_SYM)
  |  |  ------------------
  |  |  |  |   54|    119|#define SC_SEC_OPERATION_DECRYPT_SYM	0x0008
  |  |  ------------------
  |  |  |  Branch (739:31): [True: 0, False: 119]
  |  |  |  Branch (739:70): [True: 0, False: 119]
  |  |  ------------------
  ------------------
  842|       |		/* add IV if present */
  843|      0|		for (i = 0; i < SC_SEC_ENV_MAX_PARAMS; i++)
  ------------------
  |  |   64|      0|#define SC_SEC_ENV_MAX_PARAMS		10
  ------------------
  |  Branch (843:15): [True: 0, False: 0]
  ------------------
  844|      0|			if (env->params[i].param_type == SC_SEC_ENV_PARAM_IV) {
  ------------------
  |  |   65|      0|#define SC_SEC_ENV_PARAM_IV		1
  ------------------
  |  Branch (844:8): [True: 0, False: 0]
  ------------------
  845|      0|				r = 1;
  846|      0|				*p++ = 0x87;
  847|      0|				*p++ = (unsigned char) env->params[i].value_len;
  848|      0|				if (p + env->params[i].value_len >= sbuf + SC_MAX_APDU_BUFFER_SIZE) {
  ------------------
  |  |   34|      0|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
  |  Branch (848:9): [True: 0, False: 0]
  ------------------
  849|      0|					sc_log(card->ctx, "IV too long.\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  850|      0|					return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  851|      0|				}
  852|      0|				memcpy(p, env->params[i].value, env->params[i].value_len);
  853|      0|				p+=(unsigned char) env->params[i].value_len;
  854|      0|				break;
  855|      0|			}
  856|      0|	}
  857|       |	/* for AES_ECB we need to reset the IV but we respect if the IV is already present */
  858|    119|	if (IS_SYMETRIC_CRYPT(env->operation) && env->algorithm == SC_ALGORITHM_AES &&
  ------------------
  |  |  739|    238|#define IS_SYMETRIC_CRYPT(x) ((x) == SC_SEC_OPERATION_ENCRYPT_SYM || (x) == SC_SEC_OPERATION_DECRYPT_SYM)
  |  |  ------------------
  |  |  |  |   53|    238|#define SC_SEC_OPERATION_ENCRYPT_SYM	0x0007
  |  |  ------------------
  |  |               #define IS_SYMETRIC_CRYPT(x) ((x) == SC_SEC_OPERATION_ENCRYPT_SYM || (x) == SC_SEC_OPERATION_DECRYPT_SYM)
  |  |  ------------------
  |  |  |  |   54|    119|#define SC_SEC_OPERATION_DECRYPT_SYM	0x0008
  |  |  ------------------
  |  |  |  Branch (739:31): [True: 0, False: 119]
  |  |  |  Branch (739:70): [True: 0, False: 119]
  |  |  ------------------
  ------------------
              	if (IS_SYMETRIC_CRYPT(env->operation) && env->algorithm == SC_ALGORITHM_AES &&
  ------------------
  |  |   79|    119|#define SC_ALGORITHM_AES		67
  ------------------
  |  Branch (858:43): [True: 0, False: 0]
  ------------------
  859|      0|			env->algorithm_flags == SC_ALGORITHM_AES_ECB && r == 0) {
  ------------------
  |  |  206|    119|#define SC_ALGORITHM_AES_ECB		 0x01000000
  ------------------
  |  Branch (859:4): [True: 0, False: 0]
  |  Branch (859:52): [True: 0, False: 0]
  ------------------
  860|      0|		*p++ = 0x87;
  861|      0|		*p++ = 16;
  862|      0|		memset(p, 0, 16);
  863|      0|		p += 16;
  864|      0|	}
  865|       |
  866|    119|	sz = p - sbuf;
  867|    119|	apdu.lc = sz;
  868|    119|	apdu.datalen = sz;
  869|    119|	apdu.data = sbuf;
  870|    119|	apdu.resplen = 0;
  871|    119|	r = (int)sz;
  872|    119|	if (apdu.datalen != 0)
  ------------------
  |  Branch (872:6): [True: 119, False: 0]
  ------------------
  873|    119|	{
  874|    119|		r = sc_transmit_apdu(card, &apdu);
  875|    119|		if (r)
  ------------------
  |  Branch (875:7): [True: 1, False: 118]
  ------------------
  876|      1|		{
  877|      1|			sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  878|      1|				"%s: APDU transmit failed", sc_strerror(r));
  879|      1|			goto err;
  880|      1|		}
  881|    118|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  882|    118|		if (r)
  ------------------
  |  Branch (882:7): [True: 23, False: 95]
  ------------------
  883|     23|		{
  884|     23|			sc_log(card->ctx,
  ------------------
  |  |   71|     23|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  885|     23|				"%s: Card returned error", sc_strerror(r));
  886|     23|			goto err;
  887|     23|		}
  888|    118|	}
  889|    119|err:
  890|    119|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    119|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    119|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    119|	int _ret = r; \
  |  |  |  |  155|    119|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 119, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    119|		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|     24|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 24, False: 95]
  |  |  |  |  ------------------
  |  |  |  |  157|    119|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    119|	} 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|    119|	return _ret; \
  |  |  |  |  163|    119|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  891|    119|}
card-myeid.c:myeid_compute_signature:
 1198|     39|{
 1199|     39|	struct sc_context *ctx;
 1200|     39|	struct sc_apdu apdu;
 1201|     39|	u8 rbuf[MYEID_MAX_EXT_APDU_BUFFER_SIZE];
 1202|     39|	u8 sbuf[MYEID_MAX_EXT_APDU_BUFFER_SIZE];
 1203|     39|	struct myeid_private_data* priv;
 1204|     39|	int r;
 1205|     39|	size_t field_length = 0;
 1206|     39|	size_t pad_chars = 0;
 1207|       |
 1208|     39|	if (card == NULL || data == NULL || out == NULL)
  ------------------
  |  Branch (1208:6): [True: 0, False: 39]
  |  Branch (1208:22): [True: 0, False: 39]
  |  Branch (1208:38): [True: 0, False: 39]
  ------------------
 1209|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1210|     39|	ctx = card->ctx;
 1211|     39|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     39|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     39|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     39|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     39|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1212|       |
 1213|     39|	priv = (myeid_private_data_t*) card->drv_data;
 1214|     39|	sc_log(ctx, "key type %lu, key length %lu", priv->sec_env->algorithm, priv->sec_env->algorithm_ref);
  ------------------
  |  |   71|     39|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1215|       |
 1216|     39|	if (priv->sec_env->algorithm == SC_ALGORITHM_EC ) {
  ------------------
  |  |   70|     39|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1216:6): [True: 0, False: 39]
  ------------------
 1217|       |
 1218|      0|	    field_length = priv->sec_env->algorithm_ref;
 1219|       |
 1220|       |	    /* pad with zeros if needed */
 1221|      0|		if (datalen < BYTES4BITS(field_length)) {
  ------------------
  |  |  145|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  |  Branch (1221:7): [True: 0, False: 0]
  ------------------
 1222|      0|			pad_chars = BYTES4BITS(field_length) - datalen;
  ------------------
  |  |  145|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 1223|       |
 1224|      0|			memset(sbuf, 0, pad_chars);
 1225|      0|		}
 1226|      0|	}
 1227|       |
 1228|     39|	if ((datalen + pad_chars) > sizeof(sbuf))
  ------------------
  |  Branch (1228:6): [True: 0, False: 39]
  ------------------
 1229|     39|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1230|       |
 1231|     39|	if (priv->sec_env->algorithm == SC_ALGORITHM_RSA && datalen == 256 && !priv->cap_chaining)
  ------------------
  |  |   69|     78|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1231:6): [True: 39, False: 0]
  |  Branch (1231:54): [True: 30, False: 9]
  |  Branch (1231:72): [True: 27, False: 3]
  ------------------
 1232|     27|		return myeid_compute_raw_2048_signature(card, data, datalen, out, outlen);
 1233|       |
 1234|       |	/* INS: 0x2A  PERFORM SECURITY OPERATION
 1235|       |		* P1:  0x9E  Resp: Digital Signature
 1236|       |		* P2:  0x9A  Cmd: Input for Digital Signature */
 1237|     12|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x9E, 0x9A);
  ------------------
  |  |  294|     12|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1238|     12|	apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     12|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 1239|     12|	apdu.resp = rbuf;
 1240|     12|	apdu.resplen = sizeof(rbuf);
 1241|     12|	apdu.le = 256;
 1242|     12|	memcpy(sbuf + pad_chars, data, datalen);
 1243|     12|	apdu.lc = datalen + pad_chars;
 1244|     12|	apdu.datalen = datalen + pad_chars;
 1245|       |
 1246|     12|	apdu.data = sbuf;
 1247|     12|	r = sc_transmit_apdu(card, &apdu);
 1248|     12|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     12|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     12|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     12|	int _ret = (r); \
  |  |  |  |  168|     12|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  169|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      4|		return _ret; \
  |  |  |  |  172|      4|	} \
  |  |  |  |  173|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1249|      8|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1250|      8|	LOG_TEST_RET(ctx, r, "compute_signature failed");
  ------------------
  |  |  174|      8|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      8|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      8|	int _ret = (r); \
  |  |  |  |  168|      8|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1251|       |
 1252|      5|	if (priv->sec_env->algorithm == SC_ALGORITHM_EC) {
  ------------------
  |  |   70|      5|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1252:6): [True: 0, False: 5]
  ------------------
 1253|      0|		r = myeid_convert_ec_signature(ctx, priv->sec_env->algorithm_ref, apdu.resp, apdu.resplen);
 1254|      0|		LOG_TEST_RET(ctx, r, "compute_signature convert signature failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1255|      0|		apdu.resplen = r;
 1256|      0|	}
 1257|       |
 1258|      5|	if (apdu.resplen > outlen)
  ------------------
  |  Branch (1258:6): [True: 1, False: 4]
  ------------------
 1259|      5|		LOG_FUNC_RETURN(ctx, SC_ERROR_BUFFER_TOO_SMALL);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1260|       |
 1261|      4|	memcpy(out, apdu.resp, apdu.resplen);
 1262|      4|	LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  164|      4|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      4|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      4|	int _ret = r; \
  |  |  |  |  155|      4|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} else { \
  |  |  |  |  159|      3|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      3|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      3|	} \
  |  |  |  |  162|      4|	return _ret; \
  |  |  |  |  163|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1263|      4|}
card-myeid.c:myeid_compute_raw_2048_signature:
 1135|     27|{
 1136|     27|	int r;
 1137|     27|	struct sc_context *ctx;
 1138|     27|	struct myeid_private_data *priv;
 1139|     27|	struct sc_apdu apdu;
 1140|     27|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1141|     27|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1142|     27|	sc_security_env_t env;
 1143|       |
 1144|     27|	ctx = card->ctx;
 1145|     27|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     27|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     27|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     27|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     27|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1146|       |
 1147|     27|	priv = (myeid_private_data_t *) card->drv_data;
 1148|       |
 1149|       |/* security env change - use DECIPHER operation */
 1150|     27|	memcpy(&env, priv->sec_env, sizeof(sc_security_env_t));
 1151|     27|	env.flags |= SC_SEC_ENV_ALG_REF_PRESENT;
  ------------------
  |  |   56|     27|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
 1152|     27|	env.flags |= SC_SEC_ENV_FILE_REF_PRESENT;
  ------------------
  |  |   57|     27|#define SC_SEC_ENV_FILE_REF_PRESENT	0x0002
  ------------------
 1153|     27|	env.flags |= SC_SEC_ENV_KEY_REF_PRESENT;
  ------------------
  |  |   58|     27|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
 1154|     27|	env.operation = SC_SEC_OPERATION_DECIPHER;
  ------------------
  |  |   47|     27|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
 1155|     27|	myeid_set_security_env_rsa(card, &env, 0);
 1156|       |
 1157|     27|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x2A, 0x80, 0x86);
  ------------------
  |  |  293|     27|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1158|     27|	apdu.resp = rbuf;
 1159|     27|	apdu.resplen = sizeof(rbuf);
 1160|     27|	apdu.le = 0;	/* there is no response to 1st part of data */
 1161|       |
 1162|       |/* prepare 1st part of data */
 1163|     27|	sbuf[0] = 0x81;
 1164|     27|	memcpy(sbuf + 1, data, datalen / 2);
 1165|     27|	apdu.lc = datalen / 2 + 1;
 1166|     27|	apdu.datalen = apdu.lc;
 1167|     27|	apdu.data = sbuf;
 1168|       |
 1169|     27|	r = sc_transmit_apdu(card, &apdu);
 1170|     27|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     27|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     27|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     27|	int _ret = (r); \
  |  |  |  |  168|     27|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1171|     25|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (1171:6): [True: 14, False: 11]
  |  Branch (1171:26): [True: 12, False: 2]
  ------------------
 1172|       |/* prepare 2nd part of data */
 1173|     12|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x80, 0x86);
  ------------------
  |  |  294|     12|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1174|     12|		apdu.resp = rbuf;
 1175|     12|		apdu.resplen = sizeof(rbuf);
 1176|     12|		apdu.le = datalen;
 1177|     12|		sbuf[0] = 0x82;
 1178|     12|		memcpy(sbuf + 1, data + datalen / 2, datalen / 2);
 1179|     12|		apdu.lc = datalen / 2 + 1;
 1180|     12|		apdu.datalen = apdu.lc;
 1181|     12|		apdu.data = sbuf;
 1182|       |
 1183|     12|		r = sc_transmit_apdu(card, &apdu);
 1184|     12|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     12|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     12|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     12|	int _ret = (r); \
  |  |  |  |  168|     12|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1185|       |
 1186|     11|		if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (1186:7): [True: 5, False: 6]
  |  Branch (1186:27): [True: 3, False: 2]
  ------------------
 1187|      3|			size_t len = apdu.resplen > outlen ? outlen : apdu.resplen;
  ------------------
  |  Branch (1187:17): [True: 0, False: 3]
  ------------------
 1188|      3|			memcpy(out, apdu.resp, len);
 1189|      3|			LOG_FUNC_RETURN(card->ctx, (int)len);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} else { \
  |  |  |  |  159|      2|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      2|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      2|	} \
  |  |  |  |  162|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1190|      3|		}
 1191|     11|	}
 1192|     21|	LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|     21|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     21|	int _ret = r; \
  |  |  |  |  155|     21|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     21|	} 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|     21|	return _ret; \
  |  |  |  |  163|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1193|     21|}
card-myeid.c:myeid_decipher:
 1420|     36|{
 1421|     36|	int r;
 1422|     36|	myeid_private_data_t* priv;
 1423|       |
 1424|     36|	if (card == NULL || crgram == NULL || out == NULL)
  ------------------
  |  Branch (1424:6): [True: 0, False: 36]
  |  Branch (1424:22): [True: 0, False: 36]
  |  Branch (1424:40): [True: 0, False: 36]
  ------------------
 1425|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1426|       |
 1427|     36|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     36|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     36|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     36|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     36|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 36]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1428|       |
 1429|     36|	priv = (myeid_private_data_t*)card->drv_data;
 1430|       |
 1431|     36|	if (priv->sec_env && priv->sec_env->algorithm == SC_ALGORITHM_EC
  ------------------
  |  |   70|     72|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1431:6): [True: 36, False: 0]
  |  Branch (1431:23): [True: 0, False: 36]
  ------------------
 1432|      0|		&& priv->sec_env->operation == SC_SEC_OPERATION_DERIVE
  ------------------
  |  |   50|     36|#define SC_SEC_OPERATION_DERIVE         0x0004
  ------------------
  |  Branch (1432:6): [True: 0, False: 0]
  ------------------
 1433|      0|		&& priv->sec_env->algorithm_flags & SC_ALGORITHM_ECDH_CDH_RAW)
  ------------------
  |  |  173|      0|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  |  Branch (1433:6): [True: 0, False: 0]
  ------------------
 1434|      0|	{
 1435|      0|		r = myeid_ecdh_derive(card, crgram, crgram_len, out, outlen);
 1436|      0|		priv->sec_env = NULL; /* clear after operation */
 1437|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1438|      0|	}
 1439|       |
 1440|     36|	r = myeid_transmit_decipher(card, 0x80, 0x86, crgram, crgram_len, out, outlen);
 1441|     36|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     36|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     36|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     36|	int _ret = r; \
  |  |  |  |  155|     36|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 16, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  156|     16|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 15, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|     16|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     20|	} else { \
  |  |  |  |  159|     20|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     20|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     20|	} \
  |  |  |  |  162|     36|	return _ret; \
  |  |  |  |  163|     36|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1442|     36|}
card-myeid.c:myeid_transmit_decipher:
 1365|     36|{
 1366|     36|	myeid_private_data_t *priv = card->drv_data;
 1367|     36|	struct sc_apdu apdu;
 1368|     36|	u8 rbuf[SC_MAX_EXT_APDU_BUFFER_SIZE];
 1369|     36|	u8 sbuf[SC_MAX_EXT_APDU_BUFFER_SIZE];
 1370|     36|	int r;
 1371|       |
 1372|     36|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     36|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     36|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     36|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     36|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 36]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1373|       |
 1374|       |	/* INS: 0x2A  PERFORM SECURITY OPERATION
 1375|       |	 * P1:  0x00  Resp: No response (unwrapping)
 1376|       |	 * P1:  0x80  Resp: Plain value
 1377|       |	 * P2:  0x84  Cmd: Cryptogram (no padding byte)
 1378|       |	 * P2:  0x86  Cmd: Padding indicator byte followed by cryptogram */
 1379|     36|	sc_format_apdu(card, &apdu, p1 ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_3_SHORT, 0x2A, p1, p2);
  ------------------
  |  |  294|     36|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              	sc_format_apdu(card, &apdu, p1 ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_3_SHORT, 0x2A, p1, p2);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (1379:30): [True: 36, False: 0]
  ------------------
 1380|     36|	if (p2 == 0x86) {
  ------------------
  |  Branch (1380:6): [True: 36, False: 0]
  ------------------
 1381|     36|		if (crgram_len+1 > sizeof(sbuf))
  ------------------
  |  Branch (1381:7): [True: 0, False: 36]
  ------------------
 1382|     36|			LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1383|     36|		sbuf[0] = 0; /* Padding indicator: 0x00 = No further indication */
 1384|     36|		memcpy(sbuf + 1, crgram, crgram_len);
 1385|     36|		apdu.data = sbuf;
 1386|     36|		apdu.datalen = apdu.lc = crgram_len + 1;
 1387|     36|	} else {
 1388|      0|		apdu.data = crgram;
 1389|      0|		apdu.datalen = apdu.lc = crgram_len;
 1390|      0|	}
 1391|     36|	if (p1 != 0x00) {
  ------------------
  |  Branch (1391:6): [True: 36, False: 0]
  ------------------
 1392|     36|		apdu.resp = rbuf;
 1393|     36|		apdu.resplen = sizeof(rbuf);
 1394|     36|		apdu.le = MIN(card->max_recv_size, crgram_len);
  ------------------
  |  |   69|     36|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 3, False: 33]
  |  |  ------------------
  ------------------
 1395|     36|	}
 1396|       |
 1397|       |	/* In MyEID 4.5.x, unwrapping with 2K RSA using APDU chaining doesn't work properly. Split the APDU in the old way in this case. */
 1398|     36|	if (p2 == 0x86 && crgram_len == 256 && priv && (!priv->cap_chaining || (card->version.fw_major == 45 && priv->sec_env != NULL && priv->sec_env->operation == SC_SEC_OPERATION_UNWRAP))) {
  ------------------
  |  |   52|      1|#define SC_SEC_OPERATION_UNWRAP		0x0006
  ------------------
  |  Branch (1398:6): [True: 36, False: 0]
  |  Branch (1398:20): [True: 8, False: 28]
  |  Branch (1398:41): [True: 8, False: 0]
  |  Branch (1398:50): [True: 6, False: 2]
  |  Branch (1398:74): [True: 1, False: 1]
  |  Branch (1398:106): [True: 1, False: 0]
  |  Branch (1398:131): [True: 0, False: 1]
  ------------------
 1399|      6|		r = myeid_transmit_decipher_pi_split(card, &apdu, sbuf);
 1400|     30|	} else {
 1401|     30|		apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     30|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 1402|     30|		r = sc_transmit_apdu(card, &apdu);
 1403|     30|	}
 1404|     36|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     36|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     36|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     36|	int _ret = (r); \
  |  |  |  |  168|     36|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|     36|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1405|       |
 1406|     30|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1407|     30|	LOG_TEST_RET(card->ctx, r, "DECIPHER returned error");
  ------------------
  |  |  174|     30|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     30|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     30|	int _ret = (r); \
  |  |  |  |  168|     30|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 21]
  |  |  |  |  ------------------
  |  |  |  |  169|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      9|		return _ret; \
  |  |  |  |  172|      9|	} \
  |  |  |  |  173|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1408|       |
 1409|     21|	if (out && outlen) {
  ------------------
  |  Branch (1409:6): [True: 21, False: 0]
  |  Branch (1409:13): [True: 21, False: 0]
  ------------------
 1410|     21|		outlen = MIN(apdu.resplen, outlen);
  ------------------
  |  |   69|     21|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 3, False: 18]
  |  |  ------------------
  ------------------
 1411|     21|		memcpy(out, apdu.resp, outlen);
 1412|     21|	} else {
 1413|      0|		outlen = 0;
 1414|      0|	}
 1415|     21|	LOG_FUNC_RETURN(card->ctx, (int)outlen);
  ------------------
  |  |  164|     21|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     21|	int _ret = r; \
  |  |  |  |  155|     21|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     20|	} else { \
  |  |  |  |  159|     20|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     20|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     20|	} \
  |  |  |  |  162|     21|	return _ret; \
  |  |  |  |  163|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1416|     21|}
card-myeid.c:myeid_transmit_decipher_pi_split:
 1324|      6|{
 1325|       |	/* MyEID before 4.5.x does not support APDU chaining. The payload
 1326|       |	 * is split to two regular APDUs and Padding Indicator field is used to
 1327|       |	 * describe which slice it is. */
 1328|      6|	size_t crgram_len = apdu->lc - 1;
 1329|      6|	size_t crgram_half = crgram_len / 2;
 1330|      6|	size_t resplen = apdu->resplen;
 1331|      6|	unsigned char *resp = apdu->resp;
 1332|      6|	int r;
 1333|       |
 1334|      6|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      6|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      6|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      6|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      6|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1335|       |
 1336|       |	/* Send 1st part, no response */
 1337|      6|	apdu->cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|      6|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1338|      6|	apdu->data = &sbuf[0];
 1339|      6|	apdu->datalen = apdu->lc = crgram_half + 1;
 1340|      6|	apdu->resp = 0;
 1341|      6|	apdu->resplen = 0;
 1342|      6|	apdu->le = 0;
 1343|      6|	sbuf[0] = 0x81;			/* Padding Indicator, 0x81 = First half */
 1344|       |
 1345|      6|	r = sc_transmit_apdu(card, apdu);
 1346|      6|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1347|      5|	if (apdu->sw1 != 0x90 || apdu->sw2 != 0x00)
  ------------------
  |  Branch (1347:6): [True: 2, False: 3]
  |  Branch (1347:27): [True: 1, False: 2]
  ------------------
 1348|      3|		return 0;
 1349|       |
 1350|       |	/* Send 2nd part, expect response */
 1351|      2|	apdu->cse = resplen ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  294|      2|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              	apdu->cse = resplen ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|      2|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (1351:14): [True: 2, False: 0]
  ------------------
 1352|      2|	apdu->data = &sbuf[crgram_half];
 1353|      2|	apdu->datalen = apdu->lc = crgram_len - crgram_half + 1;
 1354|      2|	apdu->resp = resp;
 1355|      2|	apdu->resplen = resplen;
 1356|      2|	apdu->le = resplen ? MIN(card->max_recv_size, crgram_len) : 0;
  ------------------
  |  |   69|      2|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 1, False: 1]
  |  |  ------------------
  ------------------
  |  Branch (1356:13): [True: 2, False: 0]
  ------------------
 1357|      2|	sbuf[crgram_half] = 0x82;	/* Padding Indicator, 0x82 = Second half */
 1358|       |
 1359|      2|	r = sc_transmit_apdu(card, apdu);
 1360|      2|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1361|      2|}
card-myeid.c:myeid_process_fci:
  442|    162|{
  443|    162|	myeid_private_data_t *priv = (myeid_private_data_t *) card->drv_data;
  444|    162|	size_t taglen = 0;
  445|    162|	const u8 *tag = NULL;
  446|    162|	int r;
  447|       |
  448|    162|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    162|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    162|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    162|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    162|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 162]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  449|    162|	r = iso_ops->process_fci(card, file, buf, buflen);
  450|    162|	if (r < 0)
  ------------------
  |  Branch (450:6): [True: 0, False: 162]
  ------------------
  451|    162|	 LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  452|       |
  453|    162|	if(file->type == SC_FILE_EF_UNKNOWN)
  ------------------
  |  |  220|    162|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  |  Branch (453:5): [True: 97, False: 65]
  ------------------
  454|     97|	{
  455|     97|		tag = sc_asn1_find_tag(NULL, buf, buflen, 0x82, &taglen);
  456|     97|		if (tag != NULL && taglen > 0 && *tag == 17)
  ------------------
  |  Branch (456:7): [True: 55, False: 42]
  |  Branch (456:22): [True: 45, False: 10]
  |  Branch (456:36): [True: 6, False: 39]
  ------------------
  457|      6|		{
  458|      6|			file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|      6|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  459|      6|		}
  460|     97|	}
  461|    162|	if(file->sec_attr_len >= 3)
  ------------------
  |  Branch (461:5): [True: 68, False: 94]
  ------------------
  462|     68|	{
  463|     68|		sc_log(card->ctx, "id (%X) sec_attr (%X %X %X)", file->id,
  ------------------
  |  |   71|     68|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  464|     68|			file->sec_attr[0],file->sec_attr[1],file->sec_attr[2]);
  465|     68|	}
  466|       |
  467|    162|	priv->card_state = file->status;
  468|    162|	switch (file->status) {
  469|      3|		case SC_FILE_STATUS_CREATION:
  ------------------
  |  |  240|      3|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (469:3): [True: 3, False: 159]
  ------------------
  470|      3|			file->acl_inactive = 1;
  471|      3|			sc_log(card->ctx, "File id (%X) status SC_FILE_STATUS_CREATION", file->id);
  ------------------
  |  |   71|      3|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  472|      3|			break;
  473|      1|		case SC_FILE_STATUS_ACTIVATED:
  ------------------
  |  |  236|      1|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  |  Branch (473:3): [True: 1, False: 161]
  ------------------
  474|      1|			sc_log(card->ctx, "File id (%X) status SC_FILE_STATUS_ACTIVATED", file->id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  475|      1|			break;
  476|    158|		default:
  ------------------
  |  Branch (476:3): [True: 158, False: 4]
  ------------------
  477|    158|			sc_log(card->ctx, "File id (%X) unusual status (0x%X)", file->id, file->status);
  ------------------
  |  |   71|    158|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  478|    162|	}
  479|       |
  480|    162|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|    162|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    162|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    162|	int _ret = r; \
  |  |  |  |  155|    162|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 162, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    162|		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: 162]
  |  |  |  |  ------------------
  |  |  |  |  157|    162|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    162|	} 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|    162|	return _ret; \
  |  |  |  |  163|    162|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|    162|}
card-myeid.c:myeid_card_ctl:
 1858|    256|{
 1859|    256|	int r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    256|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1860|    256|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    256|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    256|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    256|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    256|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 256]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1861|       |
 1862|    256|	switch(cmd) {
  ------------------
  |  Branch (1862:9): [True: 119, False: 137]
  ------------------
 1863|      0|	case SC_CARDCTL_MYEID_PUTDATA:
  ------------------
  |  Branch (1863:2): [True: 0, False: 256]
  ------------------
 1864|      0|		r = myeid_putdata(card,
 1865|      0|			(struct sc_cardctl_myeid_data_obj*) ptr);
 1866|      0|		break;
 1867|      0|	case SC_CARDCTL_MYEID_GETDATA:
  ------------------
  |  Branch (1867:2): [True: 0, False: 256]
  ------------------
 1868|      0|		r = myeid_getdata(card,
 1869|      0|			(struct sc_cardctl_myeid_data_obj*) ptr);
 1870|      0|		break;
 1871|      0|	case SC_CARDCTL_MYEID_GENERATE_STORE_KEY:
  ------------------
  |  Branch (1871:2): [True: 0, False: 256]
  ------------------
 1872|      0|		r = myeid_generate_store_key(card,
 1873|      0|			(struct sc_cardctl_myeid_gen_store_key_info *) ptr);
 1874|      0|		break;
 1875|      0|	case SC_CARDCTL_MYEID_ACTIVATE_CARD:
  ------------------
  |  Branch (1875:2): [True: 0, False: 256]
  ------------------
 1876|      0|		r = myeid_activate_card(card);
 1877|      0|		break;
 1878|    115|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1878:2): [True: 115, False: 141]
  ------------------
 1879|    115|		r = myeid_get_serialnr(card, (sc_serial_number_t *)ptr);
 1880|    115|		break;
 1881|      0|	case SC_CARDCTL_GET_CHANGE_COUNTER:
  ------------------
  |  Branch (1881:2): [True: 0, False: 256]
  ------------------
 1882|      0|		r = myeid_get_change_counter(card, (size_t *)ptr);
 1883|      0|		break;
 1884|      0|	case SC_CARDCTL_GET_DEFAULT_KEY:
  ------------------
  |  Branch (1884:2): [True: 0, False: 256]
  ------------------
 1885|      4|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (1885:2): [True: 4, False: 252]
  ------------------
 1886|      4|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1886:2): [True: 0, False: 256]
  ------------------
 1887|      4|		break;
 1888|    256|	}
 1889|    256|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    256|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    256|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    256|	int _ret = r; \
  |  |  |  |  155|    256|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 256, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    256|		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|    254|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 254, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|    256|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    256|	} 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|    256|	return _ret; \
  |  |  |  |  163|    256|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1890|    256|}
card-myeid.c:myeid_get_serialnr:
 1775|    115|{
 1776|    115|	int r;
 1777|    115|	u8  rbuf[256];
 1778|       |
 1779|    115|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    115|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    115|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    115|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    115|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1780|       |
 1781|       |	/* if number cached, get it
 1782|       |	if(card->serialnr.value) {
 1783|       |		memcpy(serial, &card->serialnr, sizeof(*serial));
 1784|       |		LOG_FUNC_RETURN(card->ctx, r);
 1785|       |	}*/
 1786|       |
 1787|       |	/* get number from card */
 1788|    115|	r = myeid_get_info(card, rbuf, sizeof(rbuf));
 1789|    115|	LOG_TEST_RET(card->ctx, r,  "Get applet info failed");
  ------------------
  |  |  174|    115|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    115|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    115|	int _ret = (r); \
  |  |  |  |  168|    115|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 113, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  169|    113|		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|    113|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    113|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    113|		return _ret; \
  |  |  |  |  172|    113|	} \
  |  |  |  |  173|    115|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1790|       |
 1791|       |	/* cache serial number */
 1792|      2|	memcpy(card->serialnr.value, &rbuf[8], 10);
 1793|      2|	card->serialnr.len = 10;
 1794|       |
 1795|       |	/* copy and return serial number */
 1796|      2|	memcpy(serial, &card->serialnr, sizeof(*serial));
 1797|       |
 1798|      2|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1799|      2|}
card-myeid.c:myeid_pin_cmd:
  666|    205|{
  667|    205|	myeid_private_data_t *priv = (myeid_private_data_t *) card->drv_data;
  668|       |
  669|    205|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    205|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    205|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    205|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    205|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 205]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  670|       |
  671|    205|	sc_log(card->ctx, "cmd (%d), ref (%d), pin1 len(%zu), pin2 len (%zu), puk ref (%d)\n",
  ------------------
  |  |   71|    205|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  672|    205|			data->cmd, data->pin_reference, data->pin1.len, data->pin2.len, data->puk_reference);
  673|       |
  674|    205|	if(data->pin1.len > 8 || data->pin2.len > 8)
  ------------------
  |  Branch (674:5): [True: 0, False: 205]
  |  Branch (674:27): [True: 0, False: 205]
  ------------------
  675|    205|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_PIN_LENGTH);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  676|       |
  677|    205|	data->pin1.pad_length = data->pin2.pad_length = 8;
  678|    205|	data->pin1.pad_char = data->pin2.pad_char = 0xFF;
  679|       |
  680|    205|	if (data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  417|    205|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (680:6): [True: 0, False: 205]
  ------------------
  681|       |		/* In case the PUK reference is set, the PIN is being unblocked implicitly using a global unblocker PIN instead of the
  682|       |		directly associated PUK. In this case, we must issue a VERIFY command first and then the RESET RETRY COUNTER command with only
  683|       |		the new PIN in the data field. */
  684|       |
  685|      0|		struct sc_pin_cmd_data global_unblocker_verif_data;
  686|      0|		int r;
  687|       |
  688|      0|		if (data->puk_reference != 0) {
  ------------------
  |  Branch (688:7): [True: 0, False: 0]
  ------------------
  689|       |			/* Call the iso driver to do the VERIFY */
  690|      0|			memset(&global_unblocker_verif_data, 0, sizeof(global_unblocker_verif_data));
  691|      0|			global_unblocker_verif_data.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  692|      0|			global_unblocker_verif_data.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  693|      0|			global_unblocker_verif_data.pin1 = data->pin1;
  694|      0|			global_unblocker_verif_data.pin_reference = data->puk_reference;
  695|      0|			global_unblocker_verif_data.flags = data->flags;
  696|      0|			r = iso_ops->pin_cmd(card, &global_unblocker_verif_data);
  697|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  698|       |
  699|      0|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (699:8): [True: 0, False: 0]
  ------------------
  700|      0|				LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  701|      0|		}
  702|       |
  703|       |		/* In case puk_reference is 0 and pin1 is empty, we may have end up here from a C_InitPIN call and a pin is being unblocked using the
  704|       |		'user_pin_unblock_style = init_pin_in_so_session' workflow. In this case, the SO-PIN, used as the unblocking PIN, should already have been authenticated
  705|       |		in a separate C_Login call and we don't need the PUK here */
  706|       |
  707|      0|		if (data->puk_reference != 0 || data->pin1.len == 0) {
  ------------------
  |  Branch (707:7): [True: 0, False: 0]
  |  Branch (707:35): [True: 0, False: 0]
  ------------------
  708|      0|			memset(&data->pin1, 0, sizeof(struct sc_pin_cmd_pin));
  709|      0|			data->flags |= SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
  710|      0|			data->flags |= SC_PIN_CMD_NEED_PADDING; /* we don't have this set in the C_InitPIN use case. Perhaps should be fixed at higher level */
  ------------------
  |  |  422|      0|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  711|      0|			struct sc_apdu apdu;
  712|      0|			u8 buf[SC_MAX_APDU_BUFFER_SIZE];
  713|       |
  714|       |			/* Let iso driver build the RESET RETRY COUNTER APDU, but we'll have to modify it before transmitting it. */
  715|      0|			r = iso7816_build_pin_apdu(card, &apdu, data, buf, sizeof(buf));
  716|       |
  717|      0|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (717:8): [True: 0, False: 0]
  ------------------
  718|      0|				LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  719|       |
  720|       |			/* MyEID's implementation of unblocking a PIN implicitly contradicts with ISO 7816-4 here. The iso driver properly sets P2=0x02
  721|       |			while MyEID expects 0x00 */
  722|      0|			apdu.p1 = 0x00;
  723|       |
  724|      0|			r = sc_transmit_apdu(card, &apdu);
  725|       |
  726|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  727|      0|			LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  728|      0|		}
  729|      0|	}
  730|       |
  731|    205|	if (data->cmd == SC_PIN_CMD_VERIFY && priv->card_state == SC_FILE_STATUS_CREATION) {
  ------------------
  |  |  415|    410|#define SC_PIN_CMD_VERIFY	0
  ------------------
              	if (data->cmd == SC_PIN_CMD_VERIFY && priv->card_state == SC_FILE_STATUS_CREATION) {
  ------------------
  |  |  240|     36|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (731:6): [True: 36, False: 169]
  |  Branch (731:40): [True: 26, False: 10]
  ------------------
  732|     26|		sc_log(card->ctx, "Card in creation state, no need to verify");
  ------------------
  |  |   71|     26|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  733|     26|		return SC_SUCCESS;
  ------------------
  |  |   28|     26|#define SC_SUCCESS				0
  ------------------
  734|     26|	}
  735|       |
  736|    179|	LOG_FUNC_RETURN(card->ctx, iso_ops->pin_cmd(card, data));
  ------------------
  |  |  164|    179|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    179|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    179|	int _ret = r; \
  |  |  |  |  155|    179|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 179, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    179|		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|     77|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 77, False: 102]
  |  |  |  |  ------------------
  |  |  |  |  157|    179|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    179|	} 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|    179|	return _ret; \
  |  |  |  |  163|    179|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  737|    179|}

sc_get_npa_driver:
  810|  17.0k|{
  811|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  812|       |
  813|  17.0k|	npa_ops = *iso_drv->ops;
  814|  17.0k|	npa_ops.match_card = npa_match_card;
  815|  17.0k|	npa_ops.init = npa_init;
  816|  17.0k|	npa_ops.finish = npa_finish;
  817|  17.0k|	npa_ops.set_security_env = npa_set_security_env;
  818|  17.0k|	npa_ops.pin_cmd = npa_pin_cmd;
  819|  17.0k|	npa_ops.logout = npa_logout;
  820|       |
  821|  17.0k|	return &npa_drv;
  822|  17.0k|}
card-npa.c:npa_match_card:
  153|  2.78k|{
  154|  2.78k|	unsigned char dir_content[sizeof dir_content_ref];
  155|  2.78k|	unsigned char id[] = {0x2F, 0x00};
  156|  2.78k|	sc_apdu_t select_ef_dir;
  157|       |
  158|  2.78k|	sc_format_apdu_ex(&select_ef_dir, 0x00, 0xA4, 0x02, 0x0C, id, sizeof id, NULL, 0);
  159|       |
  160|  2.78k|	if (SC_SUCCESS == sc_select_file(card, sc_get_mf_path(), NULL)
  ------------------
  |  |   28|  2.78k|#define SC_SUCCESS				0
  ------------------
  |  Branch (160:6): [True: 36, False: 2.75k]
  ------------------
  161|     36|			&& SC_SUCCESS == sc_transmit_apdu(card, &select_ef_dir)
  ------------------
  |  |   28|     36|#define SC_SUCCESS				0
  ------------------
  |  Branch (161:7): [True: 35, False: 1]
  ------------------
  162|     35|			&& select_ef_dir.sw1 == 0x90 && select_ef_dir.sw2 == 0x00
  ------------------
  |  Branch (162:7): [True: 26, False: 9]
  |  Branch (162:36): [True: 24, False: 2]
  ------------------
  163|     24|			&& sizeof dir_content == sc_read_binary(card, 0, dir_content, sizeof dir_content, 0)
  ------------------
  |  Branch (163:7): [True: 6, False: 18]
  ------------------
  164|      6|			&& 0 == memcmp(dir_content_ref, dir_content, sizeof dir_content))
  ------------------
  |  Branch (164:7): [True: 0, False: 6]
  ------------------
  165|      0|		return 1;
  166|       |
  167|  2.78k|	return 0;
  168|  2.78k|}

nqapplet_set_security_env:
  259|     53|{
  260|       |	/* Note: the NQ-Applet does not have APDU for SET SECURITY ENV,
  261|       |	this function checks the intended parameters and sets card_data.key_reference */
  262|     53|	nqapplet_driver_data_ptr data;
  263|     53|	u8 key_reference = KEY_REFERENCE_NO_KEY;
  ------------------
  |  |   47|     53|#define KEY_REFERENCE_NO_KEY   0x00
  ------------------
  264|       |
  265|     53|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     53|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     53|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     53|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     53|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  266|       |
  267|     53|	data = (nqapplet_driver_data_ptr)card->drv_data;
  268|     53|	data->key_reference = KEY_REFERENCE_NO_KEY;
  ------------------
  |  |   47|     53|#define KEY_REFERENCE_NO_KEY   0x00
  ------------------
  269|       |
  270|     53|	if (se_num != 0) {
  ------------------
  |  Branch (270:6): [True: 0, False: 53]
  ------------------
  271|      0|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  272|      0|		             "Storing of security environment is not supported");
  273|      0|	}
  274|     53|	if (env->key_ref_len == 1) {
  ------------------
  |  Branch (274:6): [True: 53, False: 0]
  ------------------
  275|     53|		key_reference = env->key_ref[0];
  276|     53|	}
  277|       |
  278|     53|	switch (env->operation) {
  279|     35|	case SC_SEC_OPERATION_DECIPHER:
  ------------------
  |  |   47|     35|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
  |  Branch (279:2): [True: 35, False: 18]
  ------------------
  280|     35|		if (key_reference != KEY_REFERENCE_AUTH_KEY && key_reference != KEY_REFERENCE_ENCR_KEY) {
  ------------------
  |  |   48|     70|#define KEY_REFERENCE_AUTH_KEY 0x01
  ------------------
              		if (key_reference != KEY_REFERENCE_AUTH_KEY && key_reference != KEY_REFERENCE_ENCR_KEY) {
  ------------------
  |  |   49|      1|#define KEY_REFERENCE_ENCR_KEY 0x02
  ------------------
  |  Branch (280:7): [True: 1, False: 34]
  |  Branch (280:50): [True: 0, False: 1]
  ------------------
  281|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INCOMPATIBLE_KEY,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  282|      0|			             "Decipher operation is only supported with AUTH and ENCR keys.");
  283|      0|		}
  284|     35|		data->key_reference = key_reference;
  285|     35|		break;
  286|     18|	case SC_SEC_OPERATION_SIGN:
  ------------------
  |  |   48|     18|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (286:2): [True: 18, False: 35]
  ------------------
  287|     18|		if (key_reference != KEY_REFERENCE_AUTH_KEY) {
  ------------------
  |  |   48|     18|#define KEY_REFERENCE_AUTH_KEY 0x01
  ------------------
  |  Branch (287:7): [True: 0, False: 18]
  ------------------
  288|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INCOMPATIBLE_KEY,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  289|      0|			             "Sign operation is only supported with AUTH key.");
  290|      0|		}
  291|     18|		data->key_reference = key_reference;
  292|     18|		break;
  293|      0|	default:
  ------------------
  |  Branch (293:2): [True: 0, False: 53]
  ------------------
  294|      0|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported sec. operation.");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|     53|	}
  296|       |
  297|     53|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     53|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     53|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     53|	int _ret = r; \
  |  |  |  |  155|     53|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 53, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     53|		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: 53]
  |  |  |  |  ------------------
  |  |  |  |  157|     53|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     53|	} 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|     53|	return _ret; \
  |  |  |  |  163|     53|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|     53|}
sc_get_nqApplet_driver:
  471|  17.0k|{
  472|  17.0k|	sc_card_driver_t *iso_driver = sc_get_iso7816_driver();
  473|       |
  474|  17.0k|	if (iso_operations == NULL) {
  ------------------
  |  Branch (474:6): [True: 1, False: 17.0k]
  ------------------
  475|      1|		iso_operations = iso_driver->ops;
  476|      1|	}
  477|       |
  478|  17.0k|	nqapplet_operations = *iso_driver->ops;
  479|       |
  480|       |	/* supported operations */
  481|  17.0k|	nqapplet_operations.match_card = nqapplet_match_card;
  482|  17.0k|	nqapplet_operations.init = nqapplet_init;
  483|  17.0k|	nqapplet_operations.finish = nqapplet_finish;
  484|  17.0k|	nqapplet_operations.get_response = nqapplet_get_response;
  485|  17.0k|	nqapplet_operations.get_challenge = nqapplet_get_challenge;
  486|  17.0k|	nqapplet_operations.logout = nqapplet_logout;
  487|  17.0k|	nqapplet_operations.set_security_env = nqapplet_set_security_env;
  488|  17.0k|	nqapplet_operations.decipher = nqapplet_decipher;
  489|  17.0k|	nqapplet_operations.compute_signature = nqapplet_compute_signature;
  490|  17.0k|	nqapplet_operations.check_sw = nqapplet_check_sw;
  491|  17.0k|	nqapplet_operations.get_data = nqapplet_get_data;
  492|  17.0k|	nqapplet_operations.select_file = nqapplet_select_file;
  493|  17.0k|	nqapplet_operations.card_ctl = nqapplet_card_ctl;
  494|  17.0k|	nqapplet_operations.pin_cmd = nqapplet_pin_cmd;
  495|       |
  496|       |	/* unsupported operations */
  497|  17.0k|	nqapplet_operations.read_binary = NULL;
  498|  17.0k|	nqapplet_operations.write_binary = NULL;
  499|  17.0k|	nqapplet_operations.update_binary = NULL;
  500|  17.0k|	nqapplet_operations.erase_binary = NULL;
  501|  17.0k|	nqapplet_operations.read_record = NULL;
  502|  17.0k|	nqapplet_operations.write_record = NULL;
  503|  17.0k|	nqapplet_operations.append_record = NULL;
  504|  17.0k|	nqapplet_operations.update_record = NULL;
  505|       |
  506|  17.0k|	nqapplet_operations.verify = NULL;
  507|  17.0k|	nqapplet_operations.restore_security_env = NULL;
  508|  17.0k|	nqapplet_operations.change_reference_data = NULL;
  509|  17.0k|	nqapplet_operations.reset_retry_counter = NULL;
  510|  17.0k|	nqapplet_operations.create_file = NULL;
  511|  17.0k|	nqapplet_operations.delete_file = NULL;
  512|  17.0k|	nqapplet_operations.list_files = NULL;
  513|  17.0k|	nqapplet_operations.process_fci = NULL;
  514|  17.0k|	nqapplet_operations.construct_fci = NULL;
  515|  17.0k|	nqapplet_operations.put_data = NULL;
  516|  17.0k|	nqapplet_operations.delete_record = NULL;
  517|  17.0k|	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|  17.0k|	return &nqapplet_driver;
  526|  17.0k|}
card-nqApplet.c:nqapplet_match_card:
  143|  2.59k|{
  144|  2.59k|	int rv = _sc_match_atr(card, nqapplet_atrs, &card->type);
  145|  2.59k|	return (rv >= 0);
  146|  2.59k|}
card-nqApplet.c:nqapplet_init:
  149|    213|{
  150|    213|	u8 version_major;
  151|    213|	u8 version_minor;
  152|    213|	u8 serial_nr[APPLET_SERIALNR_LEN];
  153|    213|	size_t cb_serial_nr = sizeof(serial_nr);
  154|    213|	unsigned long rsa_flags = 0;
  155|       |
  156|    213|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    213|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    213|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    213|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    213|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 213]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  157|    213|	int rv =
  158|    213|		select_nqapplet(card, &version_major, &version_minor, serial_nr, cb_serial_nr, &cb_serial_nr);
  159|    213|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    213|#define SC_SUCCESS				0
  ------------------
  |  Branch (159:6): [True: 70, False: 143]
  ------------------
  160|     70|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_CARD, "Cannot select NQ-Applet.");
  ------------------
  |  |  174|     70|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     70|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     70|	int _ret = (r); \
  |  |  |  |  168|     70|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 70, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     70|		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|     70|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     70|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     70|		return _ret; \
  |  |  |  |  172|     70|	} \
  |  |  |  |  173|     70|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|     70|	}
  162|       |
  163|    143|	rv = init_driver_data(card, version_major, version_minor);
  164|    143|	LOG_TEST_RET(card->ctx, rv, "Failed to initialize driver data.");
  ------------------
  |  |  174|    143|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    143|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    143|	int _ret = (r); \
  |  |  |  |  168|    143|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 143]
  |  |  |  |  ------------------
  |  |  |  |  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|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 143]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|       |
  166|    143|	card->max_send_size = 255;
  167|    143|	card->max_recv_size = 256;
  168|    143|	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  550|    143|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    143|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  169|    143|	rsa_flags |= SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|    143|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  170|    143|	_sc_card_add_rsa_alg(card, 3072, rsa_flags, 0);
  171|       |
  172|    143|	card->serialnr.len = MIN(sizeof(card->serialnr.value), cb_serial_nr);
  ------------------
  |  |   69|    143|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 143]
  |  |  ------------------
  ------------------
  173|    143|	memcpy(card->serialnr.value, serial_nr, card->serialnr.len);
  174|       |
  175|    143|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    143|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    143|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    143|	int _ret = r; \
  |  |  |  |  155|    143|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 143, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    143|		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: 143]
  |  |  |  |  ------------------
  |  |  |  |  157|    143|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    143|	} 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|    143|	return _ret; \
  |  |  |  |  163|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  176|    143|}
card-nqApplet.c:select_nqapplet:
  110|    228|{
  111|    228|	int rv;
  112|    228|	sc_context_t *ctx = card->ctx;
  113|    228|	u8 buffer[APPLET_VERSION_LEN + APPLET_MEMTYPE_LEN + APPLET_SERIALNR_LEN + 2];
  114|    228|	size_t cb_buffer = sizeof(buffer);
  115|    228|	size_t cb_aid = sizeof(nqapplet_aid);
  116|       |
  117|    228|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    228|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    228|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    228|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    228|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 228]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  118|       |
  119|    228|	rv = iso7816_select_aid(card, nqapplet_aid, cb_aid, buffer, &cb_buffer);
  120|    228|	LOG_TEST_RET(card->ctx, rv, "Failed to select NQ-Applet.");
  ------------------
  |  |  174|    228|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    228|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    228|	int _ret = (r); \
  |  |  |  |  168|    228|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 62, False: 166]
  |  |  |  |  ------------------
  |  |  |  |  169|     62|		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|     62|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     62|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     62|		return _ret; \
  |  |  |  |  172|     62|	} \
  |  |  |  |  173|    228|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 166]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  121|       |
  122|    166|	if (cb_buffer < APPLET_VERSION_LEN + APPLET_MEMTYPE_LEN + APPLET_SERIALNR_LEN) {
  ------------------
  |  |   30|    166|#define APPLET_VERSION_LEN  2
  ------------------
              	if (cb_buffer < APPLET_VERSION_LEN + APPLET_MEMTYPE_LEN + APPLET_SERIALNR_LEN) {
  ------------------
  |  |   31|    166|#define APPLET_MEMTYPE_LEN  1
  ------------------
              	if (cb_buffer < APPLET_VERSION_LEN + APPLET_MEMTYPE_LEN + APPLET_SERIALNR_LEN) {
  ------------------
  |  |   32|    166|#define APPLET_SERIALNR_LEN 8
  ------------------
  |  Branch (122:6): [True: 15, False: 151]
  ------------------
  123|     15|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_NORMAL, SC_ERROR_WRONG_LENGTH);
  ------------------
  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     15|	int _ret = r; \
  |  |  155|     15|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  ------------------
  |  |  156|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 15, False: 0]
  |  |  ------------------
  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     15|	} 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|     15|	return _ret; \
  |  |  163|     15|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  124|     15|	}
  125|       |
  126|    151|	if (version_major != NULL) {
  ------------------
  |  Branch (126:6): [True: 143, False: 8]
  ------------------
  127|    143|		*version_major = buffer[0];
  128|    143|	}
  129|    151|	if (version_minor != NULL) {
  ------------------
  |  Branch (129:6): [True: 143, False: 8]
  ------------------
  130|    143|		*version_minor = buffer[1];
  131|    143|	}
  132|    151|	if (serial_nr != NULL && cb_serial_nr > 0 && serial_nr_len != NULL) {
  ------------------
  |  Branch (132:6): [True: 143, False: 8]
  |  Branch (132:27): [True: 143, False: 0]
  |  Branch (132:47): [True: 143, False: 0]
  ------------------
  133|    143|		size_t cb = MIN(APPLET_SERIALNR_LEN, cb_serial_nr);
  ------------------
  |  |   69|    143|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 143]
  |  |  ------------------
  ------------------
  134|    143|		memcpy(serial_nr, buffer + 3, cb);
  135|    143|		*serial_nr_len = cb;
  136|    143|	}
  137|       |
  138|    151|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    151|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    151|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    151|	int _ret = r; \
  |  |  |  |  155|    151|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 151, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    151|		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: 151]
  |  |  |  |  ------------------
  |  |  |  |  157|    151|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    151|	} 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|    151|	return _ret; \
  |  |  |  |  163|    151|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  139|    151|}
card-nqApplet.c:init_driver_data:
   82|    143|{
   83|    143|	nqapplet_driver_data_ptr data = calloc(1, sizeof(struct nqapplet_driver_data));
   84|    143|	if (data == NULL) {
  ------------------
  |  Branch (84:6): [True: 0, False: 143]
  ------------------
   85|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   86|      0|	}
   87|       |
   88|    143|	data->version_major = version_major;
   89|    143|	data->version_minor = version_minor;
   90|    143|	data->key_reference = KEY_REFERENCE_NO_KEY;
  ------------------
  |  |   47|    143|#define KEY_REFERENCE_NO_KEY   0x00
  ------------------
   91|    143|	card->drv_data = (void *)data;
   92|    143|	return SC_SUCCESS;
  ------------------
  |  |   28|    143|#define SC_SUCCESS				0
  ------------------
   93|    143|}
card-nqApplet.c:nqapplet_finish:
  179|    143|{
  180|    143|	nqapplet_driver_data_ptr data = (nqapplet_driver_data_ptr)card->drv_data;
  181|       |
  182|    143|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    143|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    143|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    143|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    143|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 143]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  183|    143|	if (data != NULL) {
  ------------------
  |  Branch (183:6): [True: 143, False: 0]
  ------------------
  184|    143|		free(data);
  185|    143|		card->drv_data = NULL;
  186|    143|	}
  187|    143|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    143|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    143|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    143|	int _ret = r; \
  |  |  |  |  155|    143|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 143, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    143|		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: 143]
  |  |  |  |  ------------------
  |  |  |  |  157|    143|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    143|	} 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|    143|	return _ret; \
  |  |  |  |  163|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|    143|}
card-nqApplet.c:nqapplet_get_response:
  192|  1.74k|{
  193|  1.74k|	struct sc_apdu apdu = {0};
  194|  1.74k|	int rv;
  195|  1.74k|	size_t resplen;
  196|       |
  197|  1.74k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.74k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.74k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.74k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.74k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|  1.74k|	resplen = MIN(sc_get_max_recv_size(card), *cb_resp);
  ------------------
  |  |   69|  1.74k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 1.74k]
  |  |  ------------------
  ------------------
  199|       |
  200|  1.74k|	sc_format_apdu_ex(&apdu, 0x80, 0xC0, 0x00, 0x00, NULL, 0, resp, resplen);
  201|  1.74k|	apdu.flags |= SC_APDU_FLAGS_NO_GET_RESP;
  ------------------
  |  |  308|  1.74k|#define SC_APDU_FLAGS_NO_GET_RESP	0x00000002UL
  ------------------
  202|       |
  203|  1.74k|	rv = sc_transmit_apdu(card, &apdu);
  204|  1.74k|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  1.74k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.74k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.74k|	int _ret = (r); \
  |  |  |  |  168|  1.74k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 1.74k]
  |  |  |  |  ------------------
  |  |  |  |  169|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      5|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      5|		return _ret; \
  |  |  |  |  172|      5|	} \
  |  |  |  |  173|  1.74k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  205|       |
  206|  1.74k|	*cb_resp = apdu.resplen;
  207|       |
  208|  1.74k|	if (apdu.resplen == 0) {
  ------------------
  |  Branch (208:6): [True: 82, False: 1.65k]
  ------------------
  209|     82|		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|     82|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     82|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     82|	int _ret = r; \
  |  |  |  |  155|     82|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 82, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     82|		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|     51|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 51, False: 31]
  |  |  |  |  ------------------
  |  |  |  |  157|     82|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     82|	} 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|     82|	return _ret; \
  |  |  |  |  163|     82|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|     82|	}
  211|  1.65k|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (211:6): [True: 82, False: 1.57k]
  |  Branch (211:26): [True: 47, False: 35]
  ------------------
  212|     47|		rv = SC_SUCCESS;
  ------------------
  |  |   28|     47|#define SC_SUCCESS				0
  ------------------
  213|  1.61k|	} else if (apdu.sw1 == 0x61) {
  ------------------
  |  Branch (213:13): [True: 1.26k, False: 343]
  ------------------
  214|  1.26k|		rv = apdu.sw2 == 0 ? 256 : apdu.sw2;
  ------------------
  |  Branch (214:8): [True: 536, False: 733]
  ------------------
  215|  1.26k|	} else if (apdu.sw1 == 0x62 && apdu.sw2 == 0x82) {
  ------------------
  |  Branch (215:13): [True: 125, False: 218]
  |  Branch (215:33): [True: 3, False: 122]
  ------------------
  216|      3|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  217|      3|	}
  218|       |
  219|  1.65k|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|  1.65k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.65k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.65k|	int _ret = r; \
  |  |  |  |  155|  1.65k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 390, False: 1.26k]
  |  |  |  |  ------------------
  |  |  |  |  156|    390|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3, False: 387]
  |  |  |  |  ------------------
  |  |  |  |  157|    390|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.26k|	} else { \
  |  |  |  |  159|  1.26k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.26k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.26k|	} \
  |  |  |  |  162|  1.65k|	return _ret; \
  |  |  |  |  163|  1.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  220|  1.65k|}
card-nqApplet.c:nqapplet_get_challenge:
  223|    547|{
  224|    547|	int r;
  225|    547|	struct sc_apdu apdu;
  226|       |
  227|    547|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    547|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    547|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    547|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    547|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 547]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  228|    547|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x84, 0x00, 0x00);
  ------------------
  |  |  301|    547|#define SC_APDU_CASE_2			0x22
  ------------------
  229|    547|	apdu.le = count;
  230|    547|	apdu.resp = buf;
  231|    547|	apdu.resplen = count;
  232|       |
  233|    547|	r = sc_transmit_apdu(card, &apdu);
  234|    547|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    547|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    547|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    547|	int _ret = (r); \
  |  |  |  |  168|    547|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 541]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|    547|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 541]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  235|       |
  236|    541|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  237|    541|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE failed");
  ------------------
  |  |  174|    541|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    541|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    541|	int _ret = (r); \
  |  |  |  |  168|    541|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 44, False: 497]
  |  |  |  |  ------------------
  |  |  |  |  169|     44|		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|     44|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     44|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     44|		return _ret; \
  |  |  |  |  172|     44|	} \
  |  |  |  |  173|    541|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 497]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  238|       |
  239|    497|	if (count < apdu.resplen) {
  ------------------
  |  Branch (239:6): [True: 0, False: 497]
  ------------------
  240|      0|		return (int)count;
  241|      0|	}
  242|       |
  243|    497|	return (int)apdu.resplen;
  244|    497|}
card-nqApplet.c:nqapplet_decipher:
  301|     35|{
  302|     35|	int rv;
  303|     35|	struct sc_apdu apdu;
  304|     35|	u8 p1 = 0x80;
  305|     35|	u8 p2 = 0x86;
  306|     35|	nqapplet_driver_data_ptr drv_data;
  307|       |
  308|     35|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     35|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     35|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     35|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     35|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 35]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  309|       |
  310|     35|	drv_data = (nqapplet_driver_data_ptr)card->drv_data;
  311|       |
  312|     35|	if (drv_data->key_reference == KEY_REFERENCE_AUTH_KEY) {
  ------------------
  |  |   48|     35|#define KEY_REFERENCE_AUTH_KEY 0x01
  ------------------
  |  Branch (312:6): [True: 34, False: 1]
  ------------------
  313|     34|		p1 = 0x9E;
  314|     34|		p2 = 0x9A;
  315|     34|	} else if (drv_data->key_reference != KEY_REFERENCE_ENCR_KEY) {
  ------------------
  |  |   49|      1|#define KEY_REFERENCE_ENCR_KEY 0x02
  ------------------
  |  Branch (315:13): [True: 0, False: 1]
  ------------------
  316|      0|		LOG_TEST_RET(card->ctx, SC_ERROR_INCOMPATIBLE_KEY,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|      0|		             "Decipher operation is only supported with AUTH and ENCR keys.");
  318|      0|	}
  319|       |
  320|       |	/* the applet supports only 3072 RAW RSA, input buffer size must be 384 octets,
  321|       |	output buffer size must be at least 384 octets */
  322|     35|	sc_format_apdu_ex(&apdu, 0x80, 0x2A, p1, p2, data, cb_data, out, outlen);
  323|     35|	apdu.le = 256;
  324|     35|	apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     35|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  325|     35|	rv = sc_transmit_apdu(card, &apdu);
  326|     35|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|     35|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     35|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     35|	int _ret = (r); \
  |  |  |  |  168|     35|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  169|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      9|		return _ret; \
  |  |  |  |  172|      9|	} \
  |  |  |  |  173|     35|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  327|       |
  328|     26|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (328:6): [True: 17, False: 9]
  |  Branch (328:26): [True: 15, False: 2]
  ------------------
  329|     15|		rv = (int)apdu.resplen;
  330|     15|	} else if (apdu.sw1 == 0x61) {
  ------------------
  |  Branch (330:13): [True: 0, False: 11]
  ------------------
  331|      0|		rv = apdu.sw2 == 0 ? 256 : apdu.sw2;
  ------------------
  |  Branch (331:8): [True: 0, False: 0]
  ------------------
  332|     11|	} else {
  333|     11|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  334|     11|	}
  335|       |
  336|     26|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|     26|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     26|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     26|	int _ret = r; \
  |  |  |  |  155|     26|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  156|     12|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 11, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|     12|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} else { \
  |  |  |  |  159|     14|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     14|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     14|	} \
  |  |  |  |  162|     26|	return _ret; \
  |  |  |  |  163|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  337|     26|}
card-nqApplet.c:nqapplet_compute_signature:
  341|     18|{
  342|     18|	int rv;
  343|     18|	struct sc_apdu apdu;
  344|     18|	nqapplet_driver_data_ptr drv_data;
  345|       |
  346|     18|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     18|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     18|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     18|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     18|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|     18|	drv_data = (nqapplet_driver_data_ptr)card->drv_data;
  348|       |
  349|     18|	if (drv_data->key_reference != KEY_REFERENCE_AUTH_KEY) {
  ------------------
  |  |   48|     18|#define KEY_REFERENCE_AUTH_KEY 0x01
  ------------------
  |  Branch (349:6): [True: 0, False: 18]
  ------------------
  350|      0|		LOG_TEST_RET(card->ctx, SC_ERROR_INCOMPATIBLE_KEY,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|      0|		             "Sign operation is only supported with AUTH key.");
  352|      0|	}
  353|       |
  354|       |	/* the applet supports only 3072 RAW RSA, input buffer size must be 384 octets,
  355|       |	output buffer size must be at least 384 octets */
  356|     18|	sc_format_apdu_ex(&apdu, 0x80, 0x2A, 0x9E, 0x9A, data, cb_data, out, outlen);
  357|     18|	apdu.le = 256;
  358|     18|	apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     18|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  359|     18|	rv = sc_transmit_apdu(card, &apdu);
  360|     18|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|     18|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     18|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     18|	int _ret = (r); \
  |  |  |  |  168|     18|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  169|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      9|		return _ret; \
  |  |  |  |  172|      9|	} \
  |  |  |  |  173|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  361|       |
  362|      9|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (362:6): [True: 3, False: 6]
  |  Branch (362:26): [True: 2, False: 1]
  ------------------
  363|      2|		rv = (int)apdu.resplen;
  364|      7|	} else if (apdu.sw1 == 0x61) {
  ------------------
  |  Branch (364:13): [True: 0, False: 7]
  ------------------
  365|      0|		rv = apdu.sw2 == 0 ? 256 : apdu.sw2;
  ------------------
  |  Branch (365:8): [True: 0, False: 0]
  ------------------
  366|      7|	} else {
  367|      7|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  368|      7|	}
  369|       |
  370|      9|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|      9|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      9|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      9|	int _ret = r; \
  |  |  |  |  155|      9|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  156|      8|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      8|	} else { \
  |  |  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      1|	} \
  |  |  |  |  162|      9|	return _ret; \
  |  |  |  |  163|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|      9|}
card-nqApplet.c:nqapplet_check_sw:
  374|    932|{
  375|    932|	const int nqapplet_error_count = sizeof(nqapplet_errors) / sizeof(struct sc_card_error);
  376|    932|	int i;
  377|       |
  378|    932|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    932|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    932|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    932|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    932|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 932]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  379|    932|	sc_log(card->ctx, "Checking sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
  ------------------
  |  |   71|    932|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  380|       |
  381|  9.87k|	for (i = 0; i < nqapplet_error_count; i++) {
  ------------------
  |  Branch (381:14): [True: 9.10k, False: 770]
  ------------------
  382|  9.10k|		if (nqapplet_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (382:7): [True: 162, False: 8.94k]
  ------------------
  383|    162|			LOG_TEST_RET(card->ctx, nqapplet_errors[i].errorno, nqapplet_errors[i].errorstr);
  ------------------
  |  |  174|    162|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    162|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    162|	int _ret = (r); \
  |  |  |  |  168|    162|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 162, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    162|		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|    162|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    162|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    162|		return _ret; \
  |  |  |  |  172|    162|	} \
  |  |  |  |  173|    162|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|    162|		}
  385|  9.10k|	}
  386|       |
  387|    770|	return iso_operations->check_sw(card, sw1, sw2);
  388|    932|}
card-nqApplet.c:nqapplet_get_data:
  391|    257|{
  392|    257|	struct sc_apdu apdu;
  393|    257|	int rv;
  394|       |
  395|    257|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    257|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    257|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    257|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    257|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 257]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  396|       |
  397|    257|	sc_format_apdu_ex(&apdu, 0x80, 0xB0, 0x00, (u8)id, NULL, 0, resp, cb_resp);
  398|    257|	apdu.le = 256;
  399|       |
  400|    257|	rv = sc_transmit_apdu(card, &apdu);
  401|    257|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    257|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    257|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    257|	int _ret = (r); \
  |  |  |  |  168|    257|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 25, False: 232]
  |  |  |  |  ------------------
  |  |  |  |  169|     25|		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|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     25|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     25|		return _ret; \
  |  |  |  |  172|     25|	} \
  |  |  |  |  173|    257|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 232]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  402|       |
  403|    232|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (403:6): [True: 168, False: 64]
  |  Branch (403:26): [True: 154, False: 14]
  ------------------
  404|    154|		rv = (int)apdu.resplen;
  405|    154|	} else if (apdu.sw1 == 0x61) {
  ------------------
  |  Branch (405:13): [True: 0, False: 78]
  ------------------
  406|      0|		rv = apdu.sw2 == 0 ? 256 : apdu.sw2;
  ------------------
  |  Branch (406:8): [True: 0, False: 0]
  ------------------
  407|     78|	} else if (apdu.sw1 == 0x62 && apdu.sw2 == 0x82) {
  ------------------
  |  Branch (407:13): [True: 7, False: 71]
  |  Branch (407:33): [True: 1, False: 6]
  ------------------
  408|      1|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  409|      1|	}
  410|       |
  411|    232|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    232|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    232|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    232|	int _ret = r; \
  |  |  |  |  155|    232|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 79, False: 153]
  |  |  |  |  ------------------
  |  |  |  |  156|     79|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 78]
  |  |  |  |  ------------------
  |  |  |  |  157|     79|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    153|	} else { \
  |  |  |  |  159|    153|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    153|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    153|	} \
  |  |  |  |  162|    232|	return _ret; \
  |  |  |  |  163|    232|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|    232|}
card-nqApplet.c:nqapplet_select_file:
  416|    487|{
  417|    487|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    487|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    487|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    487|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    487|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 487]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  418|       |
  419|       |	/* the applet does not support SELECT EF/DF except for SELECT APPLET.
  420|       |	In order to enable opensc-explorer add support for virtually selecting MF only */
  421|    487|	if (in_path->type == SC_PATH_TYPE_PATH && in_path->len == 2 &&
  ------------------
  |  |  119|    974|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (421:6): [True: 201, False: 286]
  |  Branch (421:44): [True: 0, False: 201]
  ------------------
  422|      0|	    memcmp(in_path->value, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (422:6): [True: 0, False: 0]
  ------------------
  423|      0|		if (file_out != NULL) {
  ------------------
  |  Branch (423:7): [True: 0, False: 0]
  ------------------
  424|      0|			struct sc_file *file = sc_file_new();
  425|      0|			if (file == NULL) {
  ------------------
  |  Branch (425:8): [True: 0, False: 0]
  ------------------
  426|      0|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  427|      0|			}
  428|      0|			file->path = *in_path;
  429|      0|			*file_out = file;
  430|      0|			LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  431|      0|		}
  432|      0|	}
  433|       |	// TODO allow selecting Applet AID
  434|       |
  435|    487|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    487|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    487|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    487|	int _ret = r; \
  |  |  |  |  155|    487|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 487, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    487|		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|    487|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 487, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    487|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    487|	} 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|    487|	return _ret; \
  |  |  |  |  163|    487|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|    487|}
card-nqApplet.c:nqapplet_card_ctl:
  439|    116|{
  440|    116|	switch (cmd) {
  ------------------
  |  Branch (440:10): [True: 0, False: 116]
  ------------------
  441|      0|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (441:2): [True: 0, False: 116]
  ------------------
  442|      0|		if (card->serialnr.len) {
  ------------------
  |  Branch (442:7): [True: 0, False: 0]
  ------------------
  443|      0|			sc_serial_number_t *serial = (sc_serial_number_t *)ptr;
  444|      0|			memcpy(serial->value, card->serialnr.value, card->serialnr.len);
  445|      0|			serial->len = card->serialnr.len;
  446|      0|			return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  447|      0|		}
  448|      0|		break;
  449|    116|	}
  450|    116|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    116|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  451|    116|}
card-nqApplet.c:nqapplet_pin_cmd:
  455|     52|{
  456|     52|	int r;
  457|       |
  458|     52|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     52|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     52|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     52|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     52|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 52]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  459|     52|	r = iso_operations->pin_cmd(card, data);
  460|     52|	if (r == SC_ERROR_OBJECT_NOT_FOUND) {
  ------------------
  |  |   88|     52|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (460:6): [True: 15, False: 37]
  ------------------
  461|       |		/* it is possible that the NQ-Applet is not active, try to activate it */
  462|     15|		r = select_nqapplet(card, NULL, NULL, NULL, 0, NULL);
  463|     15|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|     15|#define SC_SUCCESS				0
  ------------------
  |  Branch (463:7): [True: 8, False: 7]
  ------------------
  464|      8|			r = iso_operations->pin_cmd(card, data);
  465|      8|		}
  466|     15|	}
  467|     52|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|     52|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     52|	int _ret = r; \
  |  |  155|     52|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 52, False: 0]
  |  |  ------------------
  |  |  156|     52|		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|     35|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 35, False: 17]
  |  |  ------------------
  |  |  157|     52|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     52|	} 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|     52|	return _ret; \
  |  |  163|     52|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  468|     52|}

sc_get_oberthur_driver:
 2319|  17.0k|{
 2320|  17.0k|	return sc_get_driver();
 2321|  17.0k|}
card-oberthur.c:sc_get_driver:
 2288|  17.0k|{
 2289|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2289:6): [True: 1, False: 17.0k]
  ------------------
 2290|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 2291|       |
 2292|  17.0k|	auth_ops = *iso_ops;
 2293|  17.0k|	auth_ops.match_card = auth_match_card;
 2294|  17.0k|	auth_ops.init = auth_init;
 2295|  17.0k|	auth_ops.finish = auth_finish;
 2296|  17.0k|	auth_ops.select_file = auth_select_file;
 2297|  17.0k|	auth_ops.list_files = auth_list_files;
 2298|  17.0k|	auth_ops.delete_file = auth_delete_file;
 2299|  17.0k|	auth_ops.create_file = auth_create_file;
 2300|  17.0k|	auth_ops.read_binary = auth_read_binary;
 2301|  17.0k|	auth_ops.update_binary = auth_update_binary;
 2302|  17.0k|	auth_ops.read_record = auth_read_record;
 2303|  17.0k|	auth_ops.delete_record = auth_delete_record;
 2304|  17.0k|	auth_ops.card_ctl = auth_card_ctl;
 2305|  17.0k|	auth_ops.set_security_env = auth_set_security_env;
 2306|  17.0k|	auth_ops.restore_security_env = auth_restore_security_env;
 2307|  17.0k|	auth_ops.compute_signature = auth_compute_signature;
 2308|  17.0k|	auth_ops.decipher = auth_decipher;
 2309|  17.0k|	auth_ops.process_fci = auth_process_fci;
 2310|  17.0k|	auth_ops.pin_cmd = auth_pin_cmd;
 2311|  17.0k|	auth_ops.logout = auth_logout;
 2312|  17.0k|	auth_ops.check_sw = auth_check_sw;
 2313|  17.0k|	return &auth_drv;
 2314|  17.0k|}
card-oberthur.c:auth_match_card:
  204|  13.3k|{
  205|  13.3k|	if (_sc_match_atr(card, oberthur_atrs, &card->type) < 0)
  ------------------
  |  Branch (205:6): [True: 12.5k, False: 804]
  ------------------
  206|  12.5k|		return 0;
  207|    804|	else
  208|    804|		return 1;
  209|  13.3k|}
card-oberthur.c:auth_init:
  214|    804|{
  215|    804|	struct auth_private_data *data;
  216|    804|	struct sc_path path;
  217|    804|	unsigned long flags;
  218|    804|	int rv = 0;
  219|       |
  220|    804|	data = calloc(1, sizeof(struct auth_private_data));
  221|    804|	if (!data)
  ------------------
  |  Branch (221:6): [True: 0, False: 804]
  ------------------
  222|    804|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  223|       |
  224|    804|	card->cla = 0x00;
  225|    804|	card->drv_data = data;
  226|       |
  227|    804|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    804|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  228|    804|	card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  557|    804|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  229|       |
  230|    804|	if (auth_select_aid(card)) {
  ------------------
  |  Branch (230:6): [True: 42, False: 762]
  ------------------
  231|     42|		sc_log(card->ctx, "Failed to initialize %s", card->name);
  ------------------
  |  |   71|     42|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  232|     42|		rv = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     42|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  233|     42|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_CARD, "Failed to initialize");
  ------------------
  |  |  184|     42|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     42|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     42|	int _ret = (r); \
  |  |  |  |  178|     42|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 42, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     42|		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|     42|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     42|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     42|		goto err; \
  |  |  |  |  182|     42|	} \
  |  |  |  |  183|     42|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|     42|	}
  235|       |
  236|    762|	sc_format_path("3F00", &path);
  237|    762|	rv = auth_select_file(card, &path, NULL);
  238|       |
  239|    804|err:
  240|    804|	if (rv == SC_SUCCESS) {
  ------------------
  |  |   28|    804|#define SC_SUCCESS				0
  ------------------
  |  Branch (240:6): [True: 762, False: 42]
  ------------------
  241|    762|		flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ISO9796;
  ------------------
  |  |  111|    762|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    762|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    762|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ISO9796;
  ------------------
  |  |  106|    762|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  242|    762|		flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    762|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  243|    762|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    762|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  244|       |
  245|    762|		_sc_card_add_rsa_alg(card, 512, flags, 0);
  246|    762|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  247|    762|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  248|    762|	} else {
  249|     42|		free(card->drv_data);
  250|     42|		card->drv_data = NULL;
  251|     42|	}
  252|       |
  253|    804|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    804|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    804|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    804|	int _ret = r; \
  |  |  |  |  155|    804|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 804, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    804|		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|     42|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 42, False: 762]
  |  |  |  |  ------------------
  |  |  |  |  157|    804|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    804|	} 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|    804|	return _ret; \
  |  |  |  |  163|    804|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  254|    804|}
card-oberthur.c:auth_select_aid:
  145|    804|{
  146|    804|	struct sc_apdu apdu;
  147|    804|	unsigned char apdu_resp[SC_MAX_APDU_BUFFER_SIZE];
  148|    804|	struct auth_private_data *data = (struct auth_private_data *)card->drv_data;
  149|    804|	int rv, ii;
  150|    804|	struct sc_path tmp_path;
  151|       |
  152|       |	/* Select Card Manager (to deselect previously selected application) */
  153|    804|	rv = gp_select_card_manager(card);
  154|    804|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    804|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    804|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    804|	int _ret = (r); \
  |  |  |  |  168|    804|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 30, False: 774]
  |  |  |  |  ------------------
  |  |  |  |  169|     30|		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|     30|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     30|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     30|		return _ret; \
  |  |  |  |  172|     30|	} \
  |  |  |  |  173|    804|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 774]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  155|       |
  156|       |	/* Get smart card serial number */
  157|    774|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x9F, 0x7F);
  ------------------
  |  |  292|    774|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  158|    774|	apdu.cla = 0x80;
  159|    774|	apdu.le = 0x2D;
  160|    774|	apdu.resplen = 0x30;
  161|    774|	apdu.resp = apdu_resp;
  162|       |
  163|    774|	rv = sc_transmit_apdu(card, &apdu);
  164|    774|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    774|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    774|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    774|	int _ret = (r); \
  |  |  |  |  168|    774|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 772]
  |  |  |  |  ------------------
  |  |  |  |  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|    774|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 772]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|    772|	if (apdu.resplen < 20) {
  ------------------
  |  Branch (165:6): [True: 2, False: 770]
  ------------------
  166|      2|		LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Serial number has incorrect length");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|      2|	}
  168|    770|	card->serialnr.len = 4;
  169|    770|	memcpy(card->serialnr.value, apdu.resp+15, 4);
  170|       |
  171|  3.85k|	for (ii=0, data->sn = 0; ii < 4; ii++)
  ------------------
  |  Branch (171:27): [True: 3.08k, False: 770]
  ------------------
  172|  3.08k|		data->sn += (long int)(*(apdu.resp + 15 + ii)) << (3-ii)*8;
  173|       |
  174|    770|	sc_log(card->ctx, "serial number %li/0x%lX", data->sn, data->sn);
  ------------------
  |  |   71|    770|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  175|       |
  176|    770|	memset(&tmp_path, 0, sizeof(struct sc_path));
  177|    770|	tmp_path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    770|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  178|    770|	memcpy(tmp_path.value, aidAuthentIC_V5, lenAidAuthentIC_V5);
  179|    770|	tmp_path.len = lenAidAuthentIC_V5;
  180|       |
  181|    770|	rv = iso_ops->select_file(card, &tmp_path, NULL);
  182|    770|	LOG_TEST_RET(card->ctx, rv, "select parent failed");
  ------------------
  |  |  174|    770|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    770|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    770|	int _ret = (r); \
  |  |  |  |  168|    770|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 764]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|    770|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 764]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  183|       |
  184|    764|	sc_format_path("3F00", &tmp_path);
  185|    764|	sc_file_free(auth_current_df);
  186|    764|	auth_current_df = NULL;
  187|    764|	rv = iso_ops->select_file(card, &tmp_path, &auth_current_df);
  188|    764|	LOG_TEST_RET(card->ctx, rv, "select parent failed");
  ------------------
  |  |  174|    764|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    764|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    764|	int _ret = (r); \
  |  |  |  |  168|    764|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 762]
  |  |  |  |  ------------------
  |  |  |  |  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|    764|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 762]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|       |
  190|    762|	sc_file_free(auth_current_ef);
  191|    762|	auth_current_ef = NULL;
  192|    762|	sc_file_dup(&auth_current_ef, auth_current_df);
  193|       |
  194|    762|	memcpy(data->aid, aidAuthentIC_V5, lenAidAuthentIC_V5);
  195|    762|	data->aid_len = lenAidAuthentIC_V5;
  196|    762|	card->name = nameAidAuthentIC_V5;
  197|       |
  198|    762|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    762|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    762|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    762|	int _ret = r; \
  |  |  |  |  155|    762|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 762, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    762|		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: 762]
  |  |  |  |  ------------------
  |  |  |  |  157|    762|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    762|	} 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|    762|	return _ret; \
  |  |  |  |  163|    762|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|    762|}
card-oberthur.c:auth_finish:
  137|    762|{
  138|    762|	free(card->drv_data);
  139|    762|	return SC_SUCCESS;
  ------------------
  |  |   28|    762|#define SC_SUCCESS				0
  ------------------
  140|    762|}
card-oberthur.c:auth_select_file:
  443|  14.5k|{
  444|  14.5k|	struct sc_path path;
  445|  14.5k|	struct sc_file *tmp_file = NULL;
  446|  14.5k|	size_t offs, ii;
  447|  14.5k|	int rv;
  448|       |
  449|  14.5k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (449:6): [True: 0, False: 14.5k]
  |  Branch (449:22): [True: 0, False: 14.5k]
  ------------------
  450|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  451|       |
  452|  14.5k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  14.5k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  14.5k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  14.5k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  14.5k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 14.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  453|       |
  454|  14.5k|	memcpy(&path, in_path, sizeof(struct sc_path));
  455|       |
  456|  14.5k|	if (!auth_current_df)
  ------------------
  |  Branch (456:6): [True: 0, False: 14.5k]
  ------------------
  457|      0|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  458|       |
  459|  14.5k|	sc_log(card->ctx, "in_path; type=%d, path=%s, out %p",
  ------------------
  |  |   71|  14.5k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  460|  14.5k|			in_path->type, sc_print_path(in_path), file_out);
  461|  14.5k|	sc_log(card->ctx, "current path; type=%d, path=%s",
  ------------------
  |  |   71|  14.5k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  462|  14.5k|			auth_current_df->path.type, sc_print_path(&auth_current_df->path));
  463|  14.5k|	if (auth_current_ef)
  ------------------
  |  Branch (463:6): [True: 9.30k, False: 5.24k]
  ------------------
  464|  9.30k|		sc_log(card->ctx, "current file; type=%d, path=%s",
  ------------------
  |  |   71|  9.30k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  465|  14.5k|				auth_current_ef->path.type, sc_print_path(&auth_current_ef->path));
  466|       |
  467|  14.5k|	if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID) {
  ------------------
  |  |  123|  29.0k|#define SC_PATH_TYPE_PARENT		5
  ------------------
              	if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID) {
  ------------------
  |  |  117|  14.4k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (467:6): [True: 72, False: 14.4k]
  |  Branch (467:42): [True: 7.20k, False: 7.27k]
  ------------------
  468|  7.27k|		sc_file_free(auth_current_ef);
  469|  7.27k|		auth_current_ef = NULL;
  470|       |
  471|  7.27k|		rv = iso_ops->select_file(card, &path, &tmp_file);
  472|  7.27k|		LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|  7.27k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.27k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.27k|	int _ret = (r); \
  |  |  |  |  168|  7.27k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.37k, False: 4.89k]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.37k|		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.37k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.37k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.37k|		return _ret; \
  |  |  |  |  172|  2.37k|	} \
  |  |  |  |  173|  7.27k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.89k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|  4.89k|		if (!tmp_file)
  ------------------
  |  Branch (473:7): [True: 0, False: 4.89k]
  ------------------
  474|      0|			return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  475|       |
  476|  4.89k|		if (path.type == SC_PATH_TYPE_PARENT) {
  ------------------
  |  |  123|  4.89k|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (476:7): [True: 29, False: 4.86k]
  ------------------
  477|     29|			memcpy(&tmp_file->path, &auth_current_df->path, sizeof(struct sc_path));
  478|     29|			if (tmp_file->path.len > 2)
  ------------------
  |  Branch (478:8): [True: 29, False: 0]
  ------------------
  479|     29|				tmp_file->path.len -= 2;
  480|       |
  481|     29|			sc_file_free(auth_current_df);
  482|     29|			auth_current_df = NULL;
  483|     29|			sc_file_dup(&auth_current_df, tmp_file);
  484|  4.86k|		} else {
  485|  4.86k|			if (tmp_file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|  4.86k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (485:8): [True: 76, False: 4.79k]
  ------------------
  486|     76|				sc_concatenate_path(&tmp_file->path, &auth_current_df->path, &path);
  487|       |
  488|     76|				sc_file_free(auth_current_df);
  489|     76|				auth_current_df = NULL;
  490|     76|				sc_file_dup(&auth_current_df, tmp_file);
  491|  4.79k|			} else {
  492|  4.79k|				sc_file_free(auth_current_ef);
  493|  4.79k|				auth_current_ef = NULL;
  494|       |
  495|  4.79k|				sc_file_dup(&auth_current_ef, tmp_file);
  496|  4.79k|				sc_concatenate_path(&auth_current_ef->path, &auth_current_df->path, &path);
  497|  4.79k|			}
  498|  4.86k|		}
  499|  4.89k|		if (file_out) {
  ------------------
  |  Branch (499:7): [True: 4.32k, False: 570]
  ------------------
  500|  4.32k|			sc_file_free(*file_out);
  501|  4.32k|			sc_file_dup(file_out, tmp_file);
  502|  4.32k|		}
  503|       |
  504|  4.89k|		sc_file_free(tmp_file);
  505|  7.27k|	} else if (path.type == SC_PATH_TYPE_DF_NAME) {
  ------------------
  |  |  118|  7.27k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (505:13): [True: 1.43k, False: 5.84k]
  ------------------
  506|  1.43k|		rv = iso_ops->select_file(card, &path, NULL);
  507|  1.43k|		if (rv) {
  ------------------
  |  Branch (507:7): [True: 1.29k, False: 133]
  ------------------
  508|  1.29k|			sc_file_free(auth_current_ef);
  509|  1.29k|			auth_current_ef = NULL;
  510|  1.29k|		}
  511|  1.43k|		LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|  1.43k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.43k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.43k|	int _ret = (r); \
  |  |  |  |  168|  1.43k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.29k, False: 133]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.29k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.29k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.29k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.29k|		return _ret; \
  |  |  |  |  172|  1.29k|	} \
  |  |  |  |  173|  1.43k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 133]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  512|  5.84k|	} else {
  513|  11.6k|		for (offs = 0; offs < path.len && offs < auth_current_df->path.len; offs += 2)
  ------------------
  |  Branch (513:18): [True: 10.7k, False: 846]
  |  Branch (513:37): [True: 5.96k, False: 4.81k]
  ------------------
  514|  5.96k|			if (path.value[offs] != auth_current_df->path.value[offs] ||
  ------------------
  |  Branch (514:8): [True: 142, False: 5.82k]
  ------------------
  515|  5.82k|					path.value[offs + 1] != auth_current_df->path.value[offs + 1])
  ------------------
  |  Branch (515:6): [True: 41, False: 5.77k]
  ------------------
  516|    183|				break;
  517|       |
  518|  5.84k|		sc_log(card->ctx, "offs %zu", offs);
  ------------------
  |  |   71|  5.84k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  519|  5.84k|		if (offs && offs < auth_current_df->path.len) {
  ------------------
  |  Branch (519:7): [True: 5.68k, False: 158]
  |  Branch (519:15): [True: 67, False: 5.61k]
  ------------------
  520|     67|			size_t deep = auth_current_df->path.len - offs;
  521|       |
  522|     67|			sc_log(card->ctx, "deep %zu", deep);
  ------------------
  |  |   71|     67|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  523|     96|			for (ii = 0; ii < deep; ii += 2) {
  ------------------
  |  Branch (523:17): [True: 72, False: 24]
  ------------------
  524|     72|				struct sc_path tmp_path;
  525|       |
  526|     72|				memcpy(&tmp_path, &auth_current_df->path,  sizeof(struct sc_path));
  527|     72|				tmp_path.type = SC_PATH_TYPE_PARENT;
  ------------------
  |  |  123|     72|#define SC_PATH_TYPE_PARENT		5
  ------------------
  528|       |
  529|     72|				if (file_out) {
  ------------------
  |  Branch (529:9): [True: 11, False: 61]
  ------------------
  530|     11|					sc_file_free(*file_out);
  531|     11|					*file_out = NULL;
  532|     11|				}
  533|       |
  534|     72|				rv = auth_select_file (card, &tmp_path, file_out);
  535|     72|				LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|     72|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     72|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     72|	int _ret = (r); \
  |  |  |  |  168|     72|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 43, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  169|     43|		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|     43|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     43|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     43|		return _ret; \
  |  |  |  |  172|     43|	} \
  |  |  |  |  173|     72|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  536|     72|			}
  537|     67|		}
  538|       |
  539|  5.79k|		if (path.len > offs) {
  ------------------
  |  Branch (539:7): [True: 4.95k, False: 846]
  ------------------
  540|  4.95k|			struct sc_path tmp_path;
  541|       |
  542|  4.95k|			memset(&tmp_path, 0, sizeof(struct sc_path));
  543|  4.95k|			tmp_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  4.95k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  544|  4.95k|			tmp_path.len = 2;
  545|       |
  546|  9.82k|			for (ii = 0; ii < path.len - offs; ii += 2) {
  ------------------
  |  Branch (546:17): [True: 7.20k, False: 2.61k]
  ------------------
  547|  7.20k|				memcpy(tmp_path.value, path.value + offs + ii, 2);
  548|       |
  549|  7.20k|				if (file_out) {
  ------------------
  |  Branch (549:9): [True: 5.70k, False: 1.50k]
  ------------------
  550|  5.70k|					sc_file_free(*file_out);
  551|  5.70k|					*file_out = NULL;
  552|  5.70k|				}
  553|       |
  554|  7.20k|				rv = auth_select_file(card, &tmp_path, file_out);
  555|  7.20k|				LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|  7.20k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.20k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.20k|	int _ret = (r); \
  |  |  |  |  168|  7.20k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.33k, False: 4.86k]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.33k|		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.33k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.33k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.33k|		return _ret; \
  |  |  |  |  172|  2.33k|	} \
  |  |  |  |  173|  7.20k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.86k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|  7.20k|			}
  557|  4.95k|		} else if (path.len - offs == 0 && file_out) {
  ------------------
  |  Branch (557:14): [True: 846, False: 0]
  |  Branch (557:38): [True: 42, False: 804]
  ------------------
  558|     42|			if (sc_compare_path(&path, &auth_current_df->path) && file_out) {
  ------------------
  |  Branch (558:8): [True: 0, False: 42]
  |  Branch (558:58): [True: 0, False: 0]
  ------------------
  559|      0|				sc_file_free(*file_out);
  560|      0|				sc_file_dup(file_out, auth_current_df);
  561|     42|			} else  if (auth_current_ef && file_out) {
  ------------------
  |  Branch (561:16): [True: 31, False: 11]
  |  Branch (561:35): [True: 31, False: 0]
  ------------------
  562|     31|				sc_file_free(*file_out);
  563|     31|				sc_file_dup(file_out, auth_current_ef);
  564|     31|			} else {
  565|     11|				LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "No current EF");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|     11|			}
  567|     42|		}
  568|  5.79k|	}
  569|       |
  570|  8.48k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  8.48k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  8.48k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  8.48k|	int _ret = r; \
  |  |  |  |  155|  8.48k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8.48k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  8.48k|		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: 8.48k]
  |  |  |  |  ------------------
  |  |  |  |  157|  8.48k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  8.48k|	} 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|  8.48k|	return _ret; \
  |  |  |  |  163|  8.48k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  571|  8.48k|}
card-oberthur.c:auth_read_binary:
 2102|  4.16k|{
 2103|  4.16k|	int rv;
 2104|  4.16k|	size_t sz;
 2105|  4.16k|	struct sc_pkcs15_bignum bn[2];
 2106|  4.16k|	unsigned char *out = NULL;
 2107|  4.16k|	bn[0].data = NULL;
 2108|  4.16k|	bn[1].data = NULL;
 2109|       |
 2110|  4.16k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  4.16k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.16k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.16k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.16k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.16k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2111|       |
 2112|  4.16k|	if (!auth_current_ef)
  ------------------
  |  Branch (2112:6): [True: 12, False: 4.14k]
  ------------------
 2113|  4.16k|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid auth_current_ef");
  ------------------
  |  |  174|     12|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     12|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     12|	int _ret = (r); \
  |  |  |  |  168|     12|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     12|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     12|		return _ret; \
  |  |  |  |  172|     12|	} \
  |  |  |  |  173|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2114|       |
 2115|  4.14k|	sc_log(card->ctx, "offset %i; size %zu; flags 0x%lX", offset, count, flags ? *flags : 0);
  ------------------
  |  |   71|  8.29k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 113, False: 4.03k]
  |  |  ------------------
  ------------------
 2116|  4.14k|	sc_log(card->ctx, "last selected : magic %X; ef %X",
  ------------------
  |  |   71|  4.14k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2117|  4.14k|			auth_current_ef->magic, auth_current_ef->ef_structure);
 2118|       |
 2119|  4.14k|	if (offset & ~0x7FFF)
  ------------------
  |  Branch (2119:6): [True: 0, False: 4.14k]
  ------------------
 2120|  4.14k|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid file offset");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2121|       |
 2122|  4.14k|	if (auth_current_ef->magic == SC_FILE_MAGIC &&
  ------------------
  |  |   56|  8.29k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  |  Branch (2122:6): [True: 4.14k, False: 0]
  ------------------
 2123|  4.14k|			auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
  ------------------
  |  Branch (2123:4): [True: 149, False: 3.99k]
  ------------------
 2124|    149|		int jj;
 2125|    149|		unsigned char resp[SC_MAX_APDU_RESP_SIZE];
 2126|    149|		size_t resp_len, out_len;
 2127|    149|		struct sc_pkcs15_pubkey_rsa key;
 2128|       |
 2129|    149|		resp_len = sizeof(resp);
 2130|    149|		rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 2131|    149|				2, resp, resp_len);
 2132|    149|		LOG_TEST_RET(card->ctx, rv, "read component failed");
  ------------------
  |  |  174|    149|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    149|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    149|	int _ret = (r); \
  |  |  |  |  168|    149|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 30, False: 119]
  |  |  |  |  ------------------
  |  |  |  |  169|     30|		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|     30|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     30|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     30|		return _ret; \
  |  |  |  |  172|     30|	} \
  |  |  |  |  173|    149|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 119]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2133|       |
 2134|    555|		for (jj=0; jj<rv && *(resp+jj)==0; jj++)
  ------------------
  |  Branch (2134:14): [True: 545, False: 10]
  |  Branch (2134:23): [True: 436, False: 109]
  ------------------
 2135|    436|			;
 2136|       |
 2137|    119|		if (rv - jj == 0)
  ------------------
  |  Branch (2137:7): [True: 10, False: 109]
  ------------------
 2138|     10|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     10|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2139|    109|		bn[0].data = calloc(1, rv - jj);
 2140|    109|		if (!bn[0].data) {
  ------------------
  |  Branch (2140:7): [True: 0, False: 109]
  ------------------
 2141|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2142|      0|			goto err;
 2143|      0|		}
 2144|    109|		bn[0].len = rv - jj;
 2145|    109|		memcpy(bn[0].data, resp + jj, rv - jj);
 2146|       |
 2147|    109|		rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 2148|    109|				1, resp, resp_len);
 2149|    109|		LOG_TEST_GOTO_ERR(card->ctx, rv, "Cannot read RSA public key component");
  ------------------
  |  |  184|    109|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    109|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    109|	int _ret = (r); \
  |  |  |  |  178|    109|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 17, False: 92]
  |  |  |  |  ------------------
  |  |  |  |  179|     17|		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|     17|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     17|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     17|		goto err; \
  |  |  |  |  182|     17|	} \
  |  |  |  |  183|    109|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 92]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2150|       |
 2151|     92|		bn[1].data = calloc(1, rv);
 2152|     92|		if (!bn[1].data) {
  ------------------
  |  Branch (2152:7): [True: 0, False: 92]
  ------------------
 2153|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2154|      0|			goto err;
 2155|      0|		}
 2156|     92|		bn[1].len = rv;
 2157|     92|		memcpy(bn[1].data, resp, rv);
 2158|       |
 2159|     92|		key.exponent = bn[0];
 2160|     92|		key.modulus = bn[1];
 2161|       |
 2162|     92|		if (sc_pkcs15_encode_pubkey_rsa(card->ctx, &key, &out, &out_len) != SC_SUCCESS) {
  ------------------
  |  |   28|     92|#define SC_SUCCESS				0
  ------------------
  |  Branch (2162:7): [True: 4, False: 88]
  ------------------
 2163|      4|			rv = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      4|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2164|      4|			LOG_TEST_GOTO_ERR(card->ctx, rv, "cannot encode RSA public key");
  ------------------
  |  |  184|      4|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      4|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      4|	int _ret = (r); \
  |  |  |  |  178|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      4|		goto err; \
  |  |  |  |  182|      4|	} \
  |  |  |  |  183|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2165|      4|		}
 2166|     88|		else {
 2167|     88|			if (out_len < offset) {
  ------------------
  |  Branch (2167:8): [True: 13, False: 75]
  ------------------
 2168|     13|				rv = SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     13|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
 2169|     13|				goto err;
 2170|     13|			}
 2171|     75|			sz = MIN(out_len - offset, count);
  ------------------
  |  |   69|     75|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 43, False: 32]
  |  |  ------------------
  ------------------
 2172|     75|			memcpy(buf, out + offset, sz);
 2173|       |
 2174|     75|			sc_log_hex(card->ctx, "write_publickey", buf, sz);
  ------------------
  |  |  129|     75|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     75|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2175|     75|			rv = (int)sz;
 2176|     75|		}
 2177|  3.99k|	} else {
 2178|  3.99k|		rv = iso_ops->read_binary(card, offset, buf, count, 0);
 2179|  3.99k|	}
 2180|       |
 2181|  4.10k|err:
 2182|  4.10k|	free(bn[0].data);
 2183|  4.10k|	free(bn[1].data);
 2184|  4.10k|	free(out);
 2185|       |
 2186|  4.10k|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|  4.10k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.10k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.10k|	int _ret = r; \
  |  |  |  |  155|  4.10k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.32k, False: 2.78k]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.32k|		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|  1.18k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.18k, False: 138]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.32k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.78k|	} else { \
  |  |  |  |  159|  2.78k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  2.78k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  2.78k|	} \
  |  |  |  |  162|  4.10k|	return _ret; \
  |  |  |  |  163|  4.10k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2187|  4.10k|}
card-oberthur.c:auth_read_component:
 1463|    258|{
 1464|    258|	struct sc_apdu apdu;
 1465|    258|	int rv;
 1466|    258|	unsigned char resp[SC_MAX_APDU_RESP_SIZE];
 1467|       |
 1468|    258|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    258|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    258|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    258|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    258|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1469|    258|	sc_log(card->ctx, "num %i, outlen %zu, type %i", num, outlen, type);
  ------------------
  |  |   71|    258|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1470|       |
 1471|    258|	if (!outlen || type!=SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC)
  ------------------
  |  Branch (1471:6): [True: 0, False: 258]
  |  Branch (1471:17): [True: 0, False: 258]
  ------------------
 1472|    258|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1473|       |
 1474|    258|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB4,	num, 0x00);
  ------------------
  |  |  292|    258|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1475|    258|	apdu.cla |= 0x80;
 1476|    258|	apdu.le = outlen;
 1477|    258|	apdu.resp = resp;
 1478|    258|	apdu.resplen = sizeof(resp);
 1479|    258|	rv = sc_transmit_apdu(card, &apdu);
 1480|    258|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    258|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    258|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    258|	int _ret = (r); \
  |  |  |  |  168|    258|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 251]
  |  |  |  |  ------------------
  |  |  |  |  169|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      7|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      7|		return _ret; \
  |  |  |  |  172|      7|	} \
  |  |  |  |  173|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 251]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1481|       |
 1482|    251|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1483|    251|	LOG_TEST_RET(card->ctx, rv, "Card returned error");
  ------------------
  |  |  174|    251|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    251|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    251|	int _ret = (r); \
  |  |  |  |  168|    251|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 40, False: 211]
  |  |  |  |  ------------------
  |  |  |  |  169|     40|		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|     40|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     40|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     40|		return _ret; \
  |  |  |  |  172|     40|	} \
  |  |  |  |  173|    251|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 211]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1484|       |
 1485|    211|	if (outlen < apdu.resplen)
  ------------------
  |  Branch (1485:6): [True: 0, False: 211]
  ------------------
 1486|    211|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1487|       |
 1488|    211|	memcpy(out, apdu.resp, apdu.resplen);
 1489|    211|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|    211|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    211|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    211|	int _ret = r; \
  |  |  |  |  155|    211|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7, False: 204]
  |  |  |  |  ------------------
  |  |  |  |  156|      7|		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: 7]
  |  |  |  |  ------------------
  |  |  |  |  157|      7|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    204|	} else { \
  |  |  |  |  159|    204|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    204|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    204|	} \
  |  |  |  |  162|    211|	return _ret; \
  |  |  |  |  163|    211|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1490|    211|}
card-oberthur.c:auth_read_record:
 2193|    610|{
 2194|    610|	struct sc_apdu apdu;
 2195|    610|	int rv = 0;
 2196|    610|	unsigned char recvbuf[SC_MAX_APDU_BUFFER_SIZE];
 2197|       |
 2198|    610|	sc_log(card->ctx, "auth_read_record(): nr_rec %i; count %zu", nr_rec, count);
  ------------------
  |  |   71|    610|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2199|       |
 2200|    610|	if (nr_rec > 0xFF || idx != 0)
  ------------------
  |  Branch (2200:6): [True: 0, False: 610]
  |  Branch (2200:23): [True: 237, False: 373]
  ------------------
 2201|    610|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|    237|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    237|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    237|	int _ret = r; \
  |  |  |  |  155|    237|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 237, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    237|		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|    237|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 237, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    237|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    237|	} 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|    237|	return _ret; \
  |  |  |  |  163|    237|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2202|       |
 2203|    373|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB2, nr_rec, 0);
  ------------------
  |  |  292|    373|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 2204|    373|	apdu.p2 = (flags & SC_RECORD_EF_ID_MASK) << 3;
  ------------------
  |  | 1293|    373|#define SC_RECORD_EF_ID_MASK		0x0001FUL
  ------------------
 2205|    373|	if (flags & SC_RECORD_BY_REC_NR)
  ------------------
  |  | 1298|    373|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (2205:6): [True: 373, False: 0]
  ------------------
 2206|    373|		apdu.p2 |= 0x04;
 2207|       |
 2208|    373|	apdu.le = MIN(count, SC_MAX_APDU_BUFFER_SIZE);
  ------------------
  |  |   69|    373|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 373, False: 0]
  |  |  ------------------
  ------------------
 2209|    373|	apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|    373|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 2210|    373|	apdu.resp = recvbuf;
 2211|       |
 2212|    373|	rv = sc_transmit_apdu(card, &apdu);
 2213|    373|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    373|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    373|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    373|	int _ret = (r); \
  |  |  |  |  168|    373|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 366]
  |  |  |  |  ------------------
  |  |  |  |  169|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      7|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      7|		return _ret; \
  |  |  |  |  172|      7|	} \
  |  |  |  |  173|    373|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 366]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2214|    366|	if (apdu.resplen == 0)
  ------------------
  |  Branch (2214:6): [True: 88, False: 278]
  ------------------
 2215|    366|		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|     88|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     88|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     88|	int _ret = r; \
  |  |  |  |  155|     88|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 88, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     88|		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|     56|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 56, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  157|     88|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     88|	} 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|     88|	return _ret; \
  |  |  |  |  163|     88|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2216|    278|	if (count < apdu.resplen)
  ------------------
  |  Branch (2216:6): [True: 1, False: 277]
  ------------------
 2217|    278|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_LENGTH);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2218|    277|	memcpy(buf, recvbuf, apdu.resplen);
 2219|       |
 2220|    277|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2221|    277|	LOG_TEST_RET(card->ctx, rv, "Card returned error");
  ------------------
  |  |  174|    277|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    277|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    277|	int _ret = (r); \
  |  |  |  |  168|    277|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 40, False: 237]
  |  |  |  |  ------------------
  |  |  |  |  169|     40|		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|     40|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     40|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     40|		return _ret; \
  |  |  |  |  172|     40|	} \
  |  |  |  |  173|    277|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 237]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2222|       |
 2223|    237|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|    237|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    237|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    237|	int _ret = r; \
  |  |  |  |  155|    237|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 237]
  |  |  |  |  ------------------
  |  |  |  |  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|    237|	} else { \
  |  |  |  |  159|    237|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    237|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    237|	} \
  |  |  |  |  162|    237|	return _ret; \
  |  |  |  |  163|    237|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2224|    237|}
card-oberthur.c:auth_card_ctl:
 1435|     86|{
 1436|     86|	switch (cmd) {
 1437|      0|	case SC_CARDCTL_GET_DEFAULT_KEY:
  ------------------
  |  Branch (1437:2): [True: 0, False: 86]
  ------------------
 1438|      0|		return auth_get_default_key(card,
 1439|      0|				(struct sc_cardctl_default_key *) ptr);
 1440|      0|	case SC_CARDCTL_OBERTHUR_GENERATE_KEY:
  ------------------
  |  Branch (1440:2): [True: 0, False: 86]
  ------------------
 1441|      0|		return auth_generate_key(card, 0,
 1442|      0|				(struct sc_cardctl_oberthur_genkey_info *) ptr);
 1443|      0|	case SC_CARDCTL_OBERTHUR_UPDATE_KEY:
  ------------------
  |  Branch (1443:2): [True: 0, False: 86]
  ------------------
 1444|      0|		return auth_update_key(card,
 1445|      0|				(struct sc_cardctl_oberthur_updatekey_info *) ptr);
 1446|      0|	case SC_CARDCTL_OBERTHUR_CREATE_PIN:
  ------------------
  |  Branch (1446:2): [True: 0, False: 86]
  ------------------
 1447|      0|		return auth_create_reference_data(card,
 1448|      0|				(struct sc_cardctl_oberthur_createpin_info *) ptr);
 1449|     11|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1449:2): [True: 11, False: 75]
  ------------------
 1450|     11|		return auth_get_serialnr(card, (struct sc_serial_number *)ptr);
 1451|      0|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1451:2): [True: 0, False: 86]
  ------------------
 1452|      1|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (1452:2): [True: 1, False: 85]
  ------------------
 1453|      1|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      1|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1454|     74|	default:
  ------------------
  |  Branch (1454:2): [True: 74, False: 12]
  ------------------
 1455|     74|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     74|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     74|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     74|	int _ret = r; \
  |  |  |  |  155|     74|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 74, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     74|		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|     74|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 74, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     74|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     74|	} 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|     74|	return _ret; \
  |  |  |  |  163|     74|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1456|     86|	}
 1457|     86|}
card-oberthur.c:auth_init_pin_info:
 1521|    978|{
 1522|    978|	pin->offset = 0;
 1523|    978|	pin->pad_char   = 0xFF;
 1524|    978|	pin->encoding   = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|    978|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1525|       |
 1526|    978|	if (type == OBERTHUR_AUTH_TYPE_PIN) {
  ------------------
  |  |   92|    978|#define OBERTHUR_AUTH_TYPE_PIN		1
  ------------------
  |  Branch (1526:6): [True: 978, False: 0]
  ------------------
 1527|    978|		pin->max_length = OBERTHUR_AUTH_MAX_LENGTH_PIN;
  ------------------
  |  |   95|    978|#define OBERTHUR_AUTH_MAX_LENGTH_PIN	64
  ------------------
 1528|    978|		pin->pad_length = OBERTHUR_AUTH_MAX_LENGTH_PIN;
  ------------------
  |  |   95|    978|#define OBERTHUR_AUTH_MAX_LENGTH_PIN	64
  ------------------
 1529|    978|	} else {
 1530|      0|		pin->max_length = OBERTHUR_AUTH_MAX_LENGTH_PUK;
  ------------------
  |  |   96|      0|#define OBERTHUR_AUTH_MAX_LENGTH_PUK	16
  ------------------
 1531|      0|		pin->pad_length = OBERTHUR_AUTH_MAX_LENGTH_PUK;
  ------------------
  |  |   96|      0|#define OBERTHUR_AUTH_MAX_LENGTH_PUK	16
  ------------------
 1532|      0|	}
 1533|    978|}
card-oberthur.c:auth_get_serialnr:
 2249|     11|{
 2250|     11|	if (!serial)
  ------------------
  |  Branch (2250:6): [True: 0, False: 11]
  ------------------
 2251|     11|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2252|       |
 2253|     11|	if (card->serialnr.len==0)
  ------------------
  |  Branch (2253:6): [True: 0, False: 11]
  ------------------
 2254|     11|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2255|       |
 2256|     11|	memcpy(serial, &card->serialnr, sizeof(*serial));
 2257|       |
 2258|     11|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     11|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     11|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     11|	int _ret = r; \
  |  |  |  |  155|     11|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     11|		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: 11]
  |  |  |  |  ------------------
  |  |  |  |  157|     11|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     11|	} 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|     11|	return _ret; \
  |  |  |  |  163|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2259|     11|}
card-oberthur.c:auth_process_fci:
  297|  4.94k|{
  298|  4.94k|	unsigned char type;
  299|  4.94k|	const unsigned char *attr;
  300|  4.94k|	size_t attr_len = 0;
  301|       |
  302|  4.94k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  4.94k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.94k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.94k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.94k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.94k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  303|  4.94k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x82, &attr_len);
  304|  4.94k|	if (!attr || attr_len < 1)
  ------------------
  |  Branch (304:6): [True: 2.04k, False: 2.90k]
  |  Branch (304:15): [True: 271, False: 2.63k]
  ------------------
  305|  4.94k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  2.31k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.31k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.31k|	int _ret = r; \
  |  |  |  |  155|  2.31k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.31k|		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|  2.31k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.31k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.31k|	} 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|  2.31k|	return _ret; \
  |  |  |  |  163|  2.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  306|  2.63k|	type = attr[0];
  307|       |
  308|  2.63k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x83, &attr_len);
  309|  2.63k|	if (!attr || attr_len < 2)
  ------------------
  |  Branch (309:6): [True: 326, False: 2.30k]
  |  Branch (309:15): [True: 28, False: 2.28k]
  ------------------
  310|  2.63k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    354|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    354|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    354|	int _ret = r; \
  |  |  |  |  155|    354|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 354, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    354|		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|    354|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 354, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    354|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    354|	} 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|    354|	return _ret; \
  |  |  |  |  163|    354|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  311|  2.28k|	file->id = attr[0]*0x100 + attr[1];
  312|       |
  313|  2.28k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, type==0x01 ? 0x80 : 0x85, &attr_len);
  ------------------
  |  Branch (313:50): [True: 1.75k, False: 522]
  ------------------
  314|  2.28k|	switch (type) {
  315|  1.75k|	case 0x01:
  ------------------
  |  Branch (315:2): [True: 1.75k, False: 522]
  ------------------
  316|  1.75k|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (316:7): [True: 77, False: 1.68k]
  |  Branch (316:16): [True: 10, False: 1.67k]
  ------------------
  317|  1.75k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     87|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     87|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     87|	int _ret = r; \
  |  |  |  |  155|     87|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 87, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     87|		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|     87|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 87, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     87|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     87|	} 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|     87|	return _ret; \
  |  |  |  |  163|     87|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  318|  1.67k|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|  1.67k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  319|  1.67k|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|  1.67k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  320|  1.67k|		file->size = attr[0]*0x100 + attr[1];
  321|  1.67k|		break;
  322|    144|	case 0x04:
  ------------------
  |  Branch (322:2): [True: 144, False: 2.13k]
  ------------------
  323|    144|		if (!attr || attr_len < 1)
  ------------------
  |  Branch (323:7): [True: 12, False: 132]
  |  Branch (323:16): [True: 10, False: 122]
  ------------------
  324|    144|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     22|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     22|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     22|	int _ret = r; \
  |  |  |  |  155|     22|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 22, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     22|		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|     22|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 22, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     22|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     22|	} 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|     22|	return _ret; \
  |  |  |  |  163|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  325|    122|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    122|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  326|    122|		file->ef_structure = SC_FILE_EF_LINEAR_VARIABLE;
  ------------------
  |  |  224|    122|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  327|    122|		file->size = attr[0];
  328|    122|		attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x82, &attr_len);
  329|    122|		if (!attr || attr_len < 5)
  ------------------
  |  Branch (329:7): [True: 0, False: 122]
  |  Branch (329:16): [True: 122, False: 0]
  ------------------
  330|    122|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    122|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    122|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    122|	int _ret = r; \
  |  |  |  |  155|    122|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 122, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    122|		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|    122|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 122, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    122|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    122|	} 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|    122|	return _ret; \
  |  |  |  |  163|    122|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  331|      0|		file->record_length = attr[2]*0x100+attr[3];
  332|      0|		file->record_count = attr[4];
  333|      0|		break;
  334|     37|	case 0x11:
  ------------------
  |  Branch (334:2): [True: 37, False: 2.24k]
  ------------------
  335|     37|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (335:7): [True: 10, False: 27]
  |  Branch (335:16): [True: 10, False: 17]
  ------------------
  336|     37|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     20|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     20|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     20|	int _ret = r; \
  |  |  |  |  155|     20|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     20|		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|     20|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     20|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     20|	} 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|     20|	return _ret; \
  |  |  |  |  163|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  337|     17|		file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     17|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  338|     17|		file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_DES;
  339|     17|		file->size = attr[0]*0x100 + attr[1];
  340|     17|		file->size /= 8;
  341|     17|		break;
  342|    178|	case 0x12:
  ------------------
  |  Branch (342:2): [True: 178, False: 2.10k]
  ------------------
  343|    178|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (343:7): [True: 10, False: 168]
  |  Branch (343:16): [True: 11, False: 157]
  ------------------
  344|    178|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     21|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     21|	int _ret = r; \
  |  |  |  |  155|     21|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     21|	} 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|     21|	return _ret; \
  |  |  |  |  163|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  345|    157|		file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|    157|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  346|    157|		file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
  347|       |
  348|    157|		file->size = attr[0]*0x100 + attr[1];
  349|    157|		if (file->size==512)
  ------------------
  |  Branch (349:7): [True: 21, False: 136]
  ------------------
  350|     21|			file->size = PUBKEY_512_ASN1_SIZE;
  ------------------
  |  |  100|     21|#define PUBKEY_512_ASN1_SIZE	0x4A
  ------------------
  351|    136|		else if (file->size==1024)
  ------------------
  |  Branch (351:12): [True: 46, False: 90]
  ------------------
  352|     46|			file->size = PUBKEY_1024_ASN1_SIZE;
  ------------------
  |  |  101|     46|#define PUBKEY_1024_ASN1_SIZE	0x8C
  ------------------
  353|     90|		else if (file->size==2048)
  ------------------
  |  Branch (353:12): [True: 0, False: 90]
  ------------------
  354|      0|			file->size = PUBKEY_2048_ASN1_SIZE;
  ------------------
  |  |  102|      0|#define PUBKEY_2048_ASN1_SIZE	0x10E
  ------------------
  355|     90|		else {
  356|     90|			sc_log(card->ctx, "Not supported public key size: %zu", file->size);
  ------------------
  |  |   71|     90|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  357|     90|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     90|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     90|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     90|	int _ret = r; \
  |  |  |  |  155|     90|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 90, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     90|		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|     90|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 90, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     90|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     90|	} 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|     90|	return _ret; \
  |  |  |  |  163|     90|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  358|     90|		}
  359|     67|		break;
  360|     67|	case 0x14:
  ------------------
  |  Branch (360:2): [True: 22, False: 2.25k]
  ------------------
  361|     22|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (361:7): [True: 11, False: 11]
  |  Branch (361:16): [True: 10, False: 1]
  ------------------
  362|     22|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     21|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     21|	int _ret = r; \
  |  |  |  |  155|     21|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     21|	} 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|     21|	return _ret; \
  |  |  |  |  163|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|      1|		file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|      1|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  364|      1|		file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_RSA_CRT;
  365|      1|		file->size = attr[0]*0x100 + attr[1];
  366|      1|		break;
  367|    118|	case 0x38:
  ------------------
  |  Branch (367:2): [True: 118, False: 2.16k]
  ------------------
  368|    118|		if (!attr || attr_len < 1)
  ------------------
  |  Branch (368:7): [True: 11, False: 107]
  |  Branch (368:16): [True: 10, False: 97]
  ------------------
  369|    118|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     21|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     21|	int _ret = r; \
  |  |  |  |  155|     21|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     21|	} 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|     21|	return _ret; \
  |  |  |  |  163|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  370|     97|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     97|#define SC_FILE_TYPE_DF			0x04
  ------------------
  371|     97|		file->size = attr[0];
  372|     97|		if (SC_SUCCESS != sc_file_set_type_attr(file,attr,attr_len))
  ------------------
  |  |   28|     97|#define SC_SUCCESS				0
  ------------------
  |  Branch (372:7): [True: 0, False: 97]
  ------------------
  373|     97|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  374|     97|		break;
  375|     97|	default:
  ------------------
  |  Branch (375:2): [True: 23, False: 2.25k]
  ------------------
  376|     23|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     23|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     23|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     23|	int _ret = r; \
  |  |  |  |  155|     23|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     23|		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|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     23|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     23|	} 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|     23|	return _ret; \
  |  |  |  |  163|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  377|  2.28k|	}
  378|       |
  379|  1.85k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x86, &attr_len);
  380|  1.85k|	if (!attr || attr_len < 8)
  ------------------
  |  Branch (380:6): [True: 1.68k, False: 169]
  |  Branch (380:15): [True: 19, False: 150]
  ------------------
  381|  1.85k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  1.70k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.70k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.70k|	int _ret = r; \
  |  |  |  |  155|  1.70k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.70k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.70k|		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|  1.70k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.70k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.70k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.70k|	} 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|  1.70k|	return _ret; \
  |  |  |  |  163|  1.70k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|       |
  383|    150|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|    150|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (383:6): [True: 1, False: 149]
  ------------------
  384|      1|		add_acl_entry(card, file, SC_AC_OP_CREATE, attr[0]);
  ------------------
  |  |  169|      1|#define SC_AC_OP_CREATE			3
  ------------------
  385|      1|		add_acl_entry(card, file, SC_AC_OP_CRYPTO, attr[1]);
  ------------------
  |  |  173|      1|#define SC_AC_OP_CRYPTO			7
  ------------------
  386|      1|		add_acl_entry(card, file, SC_AC_OP_LIST_FILES, attr[2]);
  ------------------
  |  |  172|      1|#define SC_AC_OP_LIST_FILES		6
  ------------------
  387|      1|		add_acl_entry(card, file, SC_AC_OP_DELETE, attr[3]);
  ------------------
  |  |  168|      1|#define SC_AC_OP_DELETE			2
  ------------------
  388|      1|		add_acl_entry(card, file, SC_AC_OP_PIN_DEFINE, attr[4]);
  ------------------
  |  |  183|      1|#define SC_AC_OP_PIN_DEFINE		17
  ------------------
  389|      1|		add_acl_entry(card, file, SC_AC_OP_PIN_CHANGE, attr[5]);
  ------------------
  |  |  184|      1|#define SC_AC_OP_PIN_CHANGE		18
  ------------------
  390|      1|		add_acl_entry(card, file, SC_AC_OP_PIN_RESET, attr[6]);
  ------------------
  |  |  185|      1|#define SC_AC_OP_PIN_RESET		19
  ------------------
  391|      1|		sc_log(card->ctx, "SC_FILE_TYPE_DF:CRYPTO %X", attr[1]);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  392|    149|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) { /* EF */
  ------------------
  |  |  215|    149|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (392:13): [True: 16, False: 133]
  ------------------
  393|     16|		switch (file->ef_structure) {
  ------------------
  |  Branch (393:11): [True: 16, False: 0]
  ------------------
  394|     14|		case SC_CARDCTL_OBERTHUR_KEY_DES:
  ------------------
  |  Branch (394:3): [True: 14, False: 2]
  ------------------
  395|     14|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[0]);
  ------------------
  |  |  189|     14|#define SC_AC_OP_UPDATE			23
  ------------------
  396|     14|			add_acl_entry(card, file, SC_AC_OP_PSO_DECRYPT, attr[1]);
  ------------------
  |  |  175|     14|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  397|     14|			add_acl_entry(card, file, SC_AC_OP_PSO_ENCRYPT, attr[2]);
  ------------------
  |  |  176|     14|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  398|     14|			add_acl_entry(card, file, SC_AC_OP_PSO_COMPUTE_CHECKSUM, attr[3]);
  ------------------
  |  |  179|     14|#define SC_AC_OP_PSO_COMPUTE_CHECKSUM	13
  ------------------
  399|     14|			add_acl_entry(card, file, SC_AC_OP_PSO_VERIFY_CHECKSUM, attr[4]);
  ------------------
  |  |  180|     14|#define SC_AC_OP_PSO_VERIFY_CHECKSUM	14
  ------------------
  400|     14|			add_acl_entry(card, file, SC_AC_OP_INTERNAL_AUTHENTICATE, attr[5]);
  ------------------
  |  |  181|     14|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  401|     14|			add_acl_entry(card, file, SC_AC_OP_EXTERNAL_AUTHENTICATE, attr[6]);
  ------------------
  |  |  182|     14|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  402|     14|			break;
  403|      1|		case SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC:
  ------------------
  |  Branch (403:3): [True: 1, False: 15]
  ------------------
  404|      1|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[0]);
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
  405|      1|			add_acl_entry(card, file, SC_AC_OP_PSO_ENCRYPT, attr[2]);
  ------------------
  |  |  176|      1|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  406|      1|			add_acl_entry(card, file, SC_AC_OP_PSO_VERIFY_SIGNATURE, attr[4]);
  ------------------
  |  |  178|      1|#define SC_AC_OP_PSO_VERIFY_SIGNATURE	12
  ------------------
  407|      1|			add_acl_entry(card, file, SC_AC_OP_EXTERNAL_AUTHENTICATE, attr[6]);
  ------------------
  |  |  182|      1|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  408|      1|			break;
  409|      1|		case SC_CARDCTL_OBERTHUR_KEY_RSA_CRT:
  ------------------
  |  Branch (409:3): [True: 1, False: 15]
  ------------------
  410|      1|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[0]);
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
  411|      1|			add_acl_entry(card, file, SC_AC_OP_PSO_DECRYPT, attr[1]);
  ------------------
  |  |  175|      1|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  412|      1|			add_acl_entry(card, file, SC_AC_OP_PSO_COMPUTE_SIGNATURE, attr[3]);
  ------------------
  |  |  177|      1|#define SC_AC_OP_PSO_COMPUTE_SIGNATURE	11
  ------------------
  413|      1|			add_acl_entry(card, file, SC_AC_OP_INTERNAL_AUTHENTICATE, attr[5]);
  ------------------
  |  |  181|      1|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  414|      1|			break;
  415|     16|		}
  416|    133|	} else {
  417|    133|		switch (file->ef_structure) {
  ------------------
  |  Branch (417:11): [True: 133, False: 0]
  ------------------
  418|    133|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|    133|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (418:3): [True: 133, False: 0]
  ------------------
  419|    133|			add_acl_entry(card, file, SC_AC_OP_WRITE, attr[0]);
  ------------------
  |  |  190|    133|#define SC_AC_OP_WRITE			24
  ------------------
  420|    133|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[1]);
  ------------------
  |  |  189|    133|#define SC_AC_OP_UPDATE			23
  ------------------
  421|    133|			add_acl_entry(card, file, SC_AC_OP_READ, attr[2]);
  ------------------
  |  |  188|    133|#define SC_AC_OP_READ			22
  ------------------
  422|    133|			add_acl_entry(card, file, SC_AC_OP_ERASE, attr[3]);
  ------------------
  |  |  202|    133|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|    133|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  423|    133|			break;
  424|      0|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (424:3): [True: 0, False: 133]
  ------------------
  425|      0|			add_acl_entry(card, file, SC_AC_OP_WRITE, attr[0]);
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
  426|      0|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[1]);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  427|      0|			add_acl_entry(card, file, SC_AC_OP_READ, attr[2]);
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
  428|      0|			add_acl_entry(card, file, SC_AC_OP_ERASE, attr[3]);
  ------------------
  |  |  202|      0|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|      0|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  429|      0|			break;
  430|    133|		}
  431|    133|	}
  432|       |
  433|    150|	file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|    150|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  434|    150|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|    150|#define SC_FILE_MAGIC			0x14426950
  ------------------
  435|       |
  436|    150|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    150|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    150|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    150|	int _ret = r; \
  |  |  |  |  155|    150|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 150, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    150|		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: 150]
  |  |  |  |  ------------------
  |  |  |  |  157|    150|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    150|	} 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|    150|	return _ret; \
  |  |  |  |  163|    150|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  437|    150|}
card-oberthur.c:add_acl_entry:
  260|    645|{
  261|    645|	if ((acl_byte & 0xE0) == 0x60) {
  ------------------
  |  Branch (261:6): [True: 73, False: 572]
  ------------------
  262|     73|		sc_log(card->ctx, "called; op 0x%X; SC_AC_PRO; ref 0x%X", op, acl_byte);
  ------------------
  |  |   71|     73|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  263|     73|		sc_file_add_acl_entry(file, op, SC_AC_PRO, acl_byte);
  ------------------
  |  |  153|     73|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  264|     73|		return;
  265|     73|	}
  266|       |
  267|    572|	switch (acl_byte) {
  268|     94|	case 0x00:
  ------------------
  |  Branch (268:2): [True: 94, False: 478]
  ------------------
  269|     94|		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     94|#define SC_AC_NONE			0x00000000
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     94|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  270|     94|		break;
  271|       |	/* User and OneTime PINs are locals */
  272|     23|	case 0x21:
  ------------------
  |  Branch (272:2): [True: 23, False: 549]
  ------------------
  273|     41|	case 0x22:
  ------------------
  |  Branch (273:2): [True: 18, False: 554]
  ------------------
  274|     41|		sc_file_add_acl_entry(file, op, SC_AC_CHV, (acl_byte & 0x0F) | OBERTHUR_PIN_LOCAL);
  ------------------
  |  |  151|     41|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_CHV, (acl_byte & 0x0F) | OBERTHUR_PIN_LOCAL);
  ------------------
  |  |   41|     41|#define OBERTHUR_PIN_LOCAL	0x80
  ------------------
  275|     41|		break;
  276|       |	/* Local SOPIN is only for the unblocking. */
  277|     17|	case 0x24:
  ------------------
  |  Branch (277:2): [True: 17, False: 555]
  ------------------
  278|     31|	case 0x25:
  ------------------
  |  Branch (278:2): [True: 14, False: 558]
  ------------------
  279|     31|		if (op == SC_AC_OP_PIN_RESET)
  ------------------
  |  |  185|     31|#define SC_AC_OP_PIN_RESET		19
  ------------------
  |  Branch (279:7): [True: 1, False: 30]
  ------------------
  280|      1|			sc_file_add_acl_entry(file, op, SC_AC_CHV, 0x84);
  ------------------
  |  |  151|      1|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  281|     30|		else
  282|     30|			sc_file_add_acl_entry(file, op, SC_AC_CHV, 0x04);
  ------------------
  |  |  151|     30|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  283|     31|		break;
  284|    103|	case 0xFF:
  ------------------
  |  Branch (284:2): [True: 103, False: 469]
  ------------------
  285|    103|		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  163|    103|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    103|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  286|    103|		break;
  287|    303|	default:
  ------------------
  |  Branch (287:2): [True: 303, False: 269]
  ------------------
  288|    303|		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  162|    303|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    303|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  289|    303|		break;
  290|    572|	}
  291|    572|}
card-oberthur.c:auth_pin_cmd:
 1875|    989|{
 1876|    989|	int rv = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    989|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1877|       |
 1878|    989|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    989|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    989|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    989|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    989|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 989]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1879|    989|	if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|    989|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1879:6): [True: 0, False: 989]
  ------------------
 1880|    989|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "auth_pin_cmd() unsupported PIN type");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1881|       |
 1882|    989|	sc_log(card->ctx, "PIN CMD:%i; reference:%i; pin1:%p/%zu, pin2:%p/%zu", data->cmd,
  ------------------
  |  |   71|    989|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1883|    989|			data->pin_reference, data->pin1.data, data->pin1.len,
 1884|    989|			data->pin2.data, data->pin2.len);
 1885|    989|	switch (data->cmd) {
 1886|    978|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|    978|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1886:2): [True: 978, False: 11]
  ------------------
 1887|    978|		rv = auth_pin_verify(card, SC_AC_CHV, data);
  ------------------
  |  |  151|    978|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1888|    978|		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
  ------------------
  |  |  174|    978|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    978|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    978|	int _ret = (r); \
  |  |  |  |  168|    978|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 170, False: 808]
  |  |  |  |  ------------------
  |  |  |  |  169|    170|		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|    170|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    170|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    170|		return _ret; \
  |  |  |  |  172|    170|	} \
  |  |  |  |  173|    978|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 808]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1889|    808|		break;
 1890|    808|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1890:2): [True: 0, False: 989]
  ------------------
 1891|      0|		rv = auth_pin_change(card, SC_AC_CHV, data);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1892|      0|		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1893|      0|		break;
 1894|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1894:2): [True: 0, False: 989]
  ------------------
 1895|      0|		rv = auth_pin_reset(card, SC_AC_CHV, data);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1896|      0|		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1897|      0|		break;
 1898|     11|	default:
  ------------------
  |  Branch (1898:2): [True: 11, False: 978]
  ------------------
 1899|     11|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported PIN operation");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1900|    989|	}
 1901|       |
 1902|    808|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    808|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    808|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    808|	int _ret = r; \
  |  |  |  |  155|    808|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 808, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    808|		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: 808]
  |  |  |  |  ------------------
  |  |  |  |  157|    808|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    808|	} 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|    808|	return _ret; \
  |  |  |  |  163|    808|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1903|    808|}
card-oberthur.c:auth_pin_verify:
 1595|    978|{
 1596|    978|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1597|    978|	int rv;
 1598|       |
 1599|    978|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    978|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    978|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    978|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    978|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 978]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1600|       |
 1601|    978|	if (type != SC_AC_CHV)
  ------------------
  |  |  151|    978|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1601:6): [True: 0, False: 978]
  ------------------
 1602|    978|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "PIN type other then SC_AC_CHV is not supported");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1603|       |
 1604|    978|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|    978|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1605|       |
 1606|    978|	auth_init_pin_info(card, &data->pin1, OBERTHUR_AUTH_TYPE_PIN);
  ------------------
  |  |   92|    978|#define OBERTHUR_AUTH_TYPE_PIN		1
  ------------------
 1607|       |
 1608|       |	/* User PIN is always local. */
 1609|    978|	if (data->pin_reference == OBERTHUR_PIN_REFERENCE_USER
  ------------------
  |  |   42|  1.95k|#define OBERTHUR_PIN_REFERENCE_USER	0x81
  ------------------
  |  Branch (1609:6): [True: 433, False: 545]
  ------------------
 1610|    545|			|| data->pin_reference == OBERTHUR_PIN_REFERENCE_ONETIME)
  ------------------
  |  |   43|    545|#define OBERTHUR_PIN_REFERENCE_ONETIME	0x82
  ------------------
  |  Branch (1610:7): [True: 0, False: 545]
  ------------------
 1611|    433|		data->pin_reference  |= OBERTHUR_PIN_LOCAL;
  ------------------
  |  |   41|    433|#define OBERTHUR_PIN_LOCAL	0x80
  ------------------
 1612|       |
 1613|    978|        rv = auth_pin_is_verified(card, data->pin_reference, &data->pin1.tries_left);
 1614|    978|    	sc_log(card->ctx, "auth_pin_is_verified returned rv %i", rv);
  ------------------
  |  |   71|    978|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1615|       |
 1616|       |	/* Return if only PIN status has been asked. */
 1617|    978|	if (data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1617:6): [True: 978, False: 0]
  |  Branch (1617:25): [True: 974, False: 4]
  ------------------
 1618|    978|		LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    974|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    974|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    974|	int _ret = r; \
  |  |  |  |  155|    974|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 974, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    974|		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|    167|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 167, False: 807]
  |  |  |  |  ------------------
  |  |  |  |  157|    974|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    974|	} 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|    974|	return _ret; \
  |  |  |  |  163|    974|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1619|       |
 1620|       |	/* Return SUCCESS without verifying if
 1621|       |	 * PIN has been already verified and PIN pad has to be used. */
 1622|      4|	if (!rv && !data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1622:6): [True: 2, False: 2]
  |  Branch (1622:13): [True: 0, False: 2]
  |  Branch (1622:33): [True: 0, False: 0]
  ------------------
 1623|      4|		LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1624|       |
 1625|      4|	if (!data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1625:6): [True: 0, False: 4]
  |  Branch (1625:26): [True: 0, False: 0]
  ------------------
 1626|      0|		rv = auth_pin_verify_pinpad(card, data->pin_reference, &data->pin1.tries_left);
 1627|      4|	else
 1628|      4|		rv = iso_drv->ops->pin_cmd(card, data);
 1629|       |
 1630|      4|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|      4|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      4|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      4|	int _ret = r; \
  |  |  |  |  155|      4|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      4|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      4|	} 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|      4|	return _ret; \
  |  |  |  |  163|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1631|      4|}
card-oberthur.c:auth_pin_is_verified:
 1636|    978|{
 1637|    978|	struct sc_apdu apdu;
 1638|    978|	int rv;
 1639|       |
 1640|    978|	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x20, 0, pin_reference);
  ------------------
  |  |  291|    978|#define SC_APDU_CASE_1			0x01
  ------------------
 1641|       |
 1642|    978|	rv = sc_transmit_apdu(card, &apdu);
 1643|    978|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    978|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    978|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    978|	int _ret = (r); \
  |  |  |  |  168|    978|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 968]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|    978|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 968]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1644|       |
 1645|    968|	if (tries_left && apdu.sw1 == 0x63 && (apdu.sw2 & 0xF0) == 0xC0)
  ------------------
  |  Branch (1645:6): [True: 968, False: 0]
  |  Branch (1645:20): [True: 54, False: 914]
  |  Branch (1645:40): [True: 40, False: 14]
  ------------------
 1646|     40|		*tries_left = apdu.sw2 & 0x0F;
 1647|       |
 1648|       |	/* Replace 'no tries left' with 'auth method blocked' */
 1649|    968|	if (apdu.sw1 == 0x63 && apdu.sw2 == 0xC0) {
  ------------------
  |  Branch (1649:6): [True: 54, False: 914]
  |  Branch (1649:26): [True: 4, False: 50]
  ------------------
 1650|      4|		apdu.sw1 = 0x69;
 1651|      4|		apdu.sw2 = 0x83;
 1652|      4|	}
 1653|       |
 1654|    968|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1655|       |
 1656|    968|	return rv;
 1657|    978|}
card-oberthur.c:auth_check_sw:
 2272|  16.8k|{
 2273|  16.8k|	int ii;
 2274|       |
 2275|  33.4k|	for (ii = 0; auth_warnings[ii].SWs; ii++) {
  ------------------
  |  Branch (2275:15): [True: 16.8k, False: 16.6k]
  ------------------
 2276|  16.8k|		if (auth_warnings[ii].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (2276:7): [True: 198, False: 16.6k]
  ------------------
 2277|    198|			sc_log(card->ctx, "%s", auth_warnings[ii].errorstr);
  ------------------
  |  |   71|    198|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2278|    198|			return auth_warnings[ii].errorno;
 2279|    198|		}
 2280|  16.8k|	}
 2281|       |
 2282|  16.6k|	return iso_ops->check_sw(card, sw1, sw2);
 2283|  16.8k|}

populate_blobs_to_mf:
  381|    653|{
  382|    653|	pgp_do_info_t	*info;
  383|       |
  384|    653|	if (priv->mf == NULL)
  ------------------
  |  Branch (384:6): [True: 0, False: 653]
  ------------------
  385|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  386|       |
  387|  38.6k|	for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++) {
  ------------------
  |  Branch (387:33): [True: 38.6k, False: 0]
  |  Branch (387:51): [True: 37.9k, False: 653]
  ------------------
  388|  37.9k|		if (((info->access & READ_MASK) != READ_NEVER) && (info->get_fn != NULL)) {
  ------------------
  |  Branch (388:7): [True: 28.0k, False: 9.89k]
  |  Branch (388:53): [True: 12.2k, False: 15.8k]
  ------------------
  389|  12.2k|			pgp_blob_t *child = NULL;
  390|  12.2k|			sc_file_t *file = sc_file_new();
  391|       |
  392|  12.2k|			child = pgp_new_blob(card, priv->mf, info->id, file);
  393|       |
  394|       |			/* catch out of memory condition */
  395|  12.2k|			if (child == NULL) {
  ------------------
  |  Branch (395:8): [True: 0, False: 12.2k]
  ------------------
  396|      0|				sc_file_free(file);
  397|      0|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|      0|			}
  399|  12.2k|		}
  400|  37.9k|	}
  401|    653|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    653|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    653|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    653|	int _ret = r; \
  |  |  |  |  155|    653|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 653, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    653|		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: 653]
  |  |  |  |  ------------------
  |  |  |  |  157|    653|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    653|	} 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|    653|	return _ret; \
  |  |  |  |  163|    653|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  402|    653|}
_pgp_add_algo:
  740|    852|{
  741|    852|	unsigned long flags = 0, ext_flags = 0;
  742|       |
  743|    852|	if (!card || !key_info)
  ------------------
  |  Branch (743:6): [True: 0, False: 852]
  |  Branch (743:15): [True: 0, False: 852]
  ------------------
  744|      0|		return 0;
  745|       |
  746|       |	/* [RFC 4880], [draft-ietf-openpgp-crypto-refresh] */
  747|    852|	switch (key_info->algorithm) {
  748|    852|	case SC_OPENPGP_KEYALGO_RSA:
  ------------------
  |  |  877|    852|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (748:2): [True: 852, False: 0]
  ------------------
  749|       |		/* OpenPGP card spec 1.1 & 2.x, section 7.2.9 & 7.2.10 /
  750|       |		 * v3.x section 7.2.11 & 7.2.12 */
  751|    852|		flags = SC_ALGORITHM_RSA_PAD_PKCS1 |
  ------------------
  |  |  111|    852|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    852|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    852|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  752|    852|			SC_ALGORITHM_RSA_HASH_NONE |
  ------------------
  |  |  133|    852|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  753|    852|			SC_ALGORITHM_ONBOARD_KEY_GEN;	/* key gen on card */
  ------------------
  |  |   93|    852|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  754|       |
  755|    852|		_sc_card_add_rsa_alg(card, key_info->u.rsa.modulus_len, flags, 0);
  756|    852|		sc_log(card->ctx, "DO %uX: Added RSA algorithm, mod_len = %zu",
  ------------------
  |  |   71|    852|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  757|    852|				do_num, key_info->u.rsa.modulus_len);
  758|    852|		break;
  759|      0|	case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  878|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (759:2): [True: 0, False: 852]
  ------------------
  760|       |		/* The montgomery curve (curve25519) needs to go through
  761|       |		 * different paths, otherwise we handle it as a normal EC key */
  762|      0|		if (_pgp_handle_curve25519(card, key_info, do_num))
  ------------------
  |  Branch (762:7): [True: 0, False: 0]
  ------------------
  763|      0|			break;
  764|       |		/* fall through */
  765|      0|	case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  879|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (765:2): [True: 0, False: 852]
  ------------------
  766|       |		/* v3.0+: ECC [RFC 4880 & 6637] */
  767|       |
  768|       |		/* Allow curve to be used by both ECDH and ECDSA.
  769|       |		 * pgp_init set these flags the same way */
  770|      0|		flags = SC_ALGORITHM_ECDH_CDH_RAW;
  ------------------
  |  |  173|      0|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  771|      0|		flags |= SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|      0|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  772|      0|		flags |= SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|      0|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  773|      0|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|      0|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  774|      0|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE;
  ------------------
  |  |  201|      0|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  775|       |
  776|      0|		_sc_card_add_ec_alg(card, key_info->u.ec.key_length, flags, ext_flags,
  777|      0|			&key_info->u.ec.oid);
  778|      0|		sc_log(card->ctx, "DO %uX: Added EC algorithm (%d), mod_len = %zu" ,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  779|      0|			do_num, key_info->algorithm, key_info->u.ec.key_length);
  780|      0|		break;
  781|      0|	case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  880|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (781:2): [True: 0, False: 852]
  ------------------
  782|       |		/* EdDSA from draft-ietf-openpgp-rfc4880bis-08 */
  783|       |		/* Handle Yubikey bug, that in DO FA curve25519 has EDDSA algo */
  784|      0|		if (_pgp_handle_curve25519(card, key_info, do_num))
  ------------------
  |  Branch (784:7): [True: 0, False: 0]
  ------------------
  785|      0|			break;
  786|      0|		_sc_card_add_eddsa_alg(card, key_info->u.ec.key_length,
  787|      0|				SC_ALGORITHM_EDDSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |  188|      0|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
              				SC_ALGORITHM_EDDSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |   93|      0|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  788|       |
  789|      0|		sc_log(card->ctx, "DO %uX: Added EDDSA algorithm (%d), mod_len = %zu" ,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  790|      0|			do_num, key_info->algorithm, key_info->u.ec.key_length);
  791|      0|		break;
  792|      0|	default:
  ------------------
  |  Branch (792:2): [True: 0, False: 852]
  ------------------
  793|      0|		sc_log(card->ctx, "DO %uX: Unknown algorithm ID (%d)" ,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  794|      0|			do_num, key_info->algorithm);
  795|       |		/* return "false" if we do not understand algo */
  796|      0|		return 0;
  797|    852|	}
  798|       |	/* return true */
  799|    852|	return 1;
  800|    852|}
sc_get_openpgp_driver:
 4209|  17.0k|{
 4210|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 4211|       |
 4212|  17.0k|	iso_ops = iso_drv->ops;
 4213|       |
 4214|  17.0k|	pgp_ops = *iso_ops;
 4215|  17.0k|	pgp_ops.match_card	= pgp_match_card;
 4216|  17.0k|	pgp_ops.init		= pgp_init;
 4217|  17.0k|	pgp_ops.finish		= pgp_finish;
 4218|  17.0k|	pgp_ops.select_file	= pgp_select_file;
 4219|  17.0k|	pgp_ops.list_files	= pgp_list_files;
 4220|  17.0k|	pgp_ops.get_challenge	= pgp_get_challenge;
 4221|  17.0k|	pgp_ops.read_binary	= pgp_read_binary;
 4222|  17.0k|	pgp_ops.write_binary	= NULL;
 4223|  17.0k|	pgp_ops.pin_cmd		= pgp_pin_cmd;
 4224|  17.0k|	pgp_ops.logout		= pgp_logout;
 4225|  17.0k|	pgp_ops.get_data	= pgp_get_data;
 4226|  17.0k|	pgp_ops.put_data	= pgp_put_data;
 4227|  17.0k|	pgp_ops.set_security_env= pgp_set_security_env;
 4228|  17.0k|	pgp_ops.compute_signature= pgp_compute_signature;
 4229|  17.0k|	pgp_ops.decipher	= pgp_decipher;
 4230|  17.0k|	pgp_ops.card_ctl	= pgp_card_ctl;
 4231|  17.0k|	pgp_ops.delete_file	= pgp_delete_file;
 4232|  17.0k|	pgp_ops.update_binary	= pgp_update_binary;
 4233|  17.0k|	pgp_ops.card_reader_lock_obtained = pgp_card_reader_lock_obtained;
 4234|       |
 4235|  17.0k|	return &pgp_drv;
 4236|  17.0k|}
card-openpgp.c:pgp_new_blob:
 1240|  37.6k|{
 1241|  37.6k|	pgp_blob_t *blob = NULL;
 1242|       |
 1243|  37.6k|	if (file == NULL)
  ------------------
  |  Branch (1243:6): [True: 0, False: 37.6k]
  ------------------
 1244|      0|		return NULL;
 1245|       |
 1246|  37.6k|	if ((blob = calloc(1, sizeof(pgp_blob_t))) != NULL) {
  ------------------
  |  Branch (1246:6): [True: 37.6k, False: 0]
  ------------------
 1247|  37.6k|		struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  37.6k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1248|  37.6k|		pgp_do_info_t *info;
 1249|       |
 1250|  37.6k|		blob->file = file;
 1251|       |
 1252|  37.6k|		blob->file->type         = SC_FILE_TYPE_WORKING_EF; /* default */
  ------------------
  |  |  216|  37.6k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 1253|  37.6k|		blob->file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|  37.6k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 1254|  37.6k|		blob->file->id           = file_id;
 1255|       |
 1256|  37.6k|		blob->id     = file_id;
 1257|  37.6k|		blob->parent = parent;
 1258|       |
 1259|  37.6k|		if (parent != NULL) {
  ------------------
  |  Branch (1259:7): [True: 36.9k, False: 653]
  ------------------
 1260|  36.9k|			pgp_blob_t **p;
 1261|       |
 1262|       |			/* set file's path = parent's path + file's id */
 1263|  36.9k|			blob->file->path = parent->file->path;
 1264|  36.9k|			sc_append_file_id(&blob->file->path, file_id);
 1265|       |
 1266|       |			/* append blob to list of parent's children */
 1267|  3.74M|			for (p = &parent->files; *p != NULL; p = &(*p)->next)
  ------------------
  |  Branch (1267:29): [True: 3.70M, False: 36.9k]
  ------------------
 1268|  3.70M|				;
 1269|  36.9k|			*p = blob;
 1270|  36.9k|		}
 1271|    653|		else {
 1272|    653|			char path[10] = "0000";	/* long enough */
 1273|       |
 1274|       |			/* no parent: set file's path = file's id */
 1275|    653|			if (4 != snprintf(path, sizeof(path), "%04X", file_id & 0xFFFF)) {
  ------------------
  |  Branch (1275:8): [True: 0, False: 653]
  ------------------
 1276|      0|				free(blob);
 1277|      0|				return NULL;
 1278|      0|			}
 1279|       |
 1280|    653|			sc_format_path(path, &blob->file->path);
 1281|    653|		}
 1282|       |
 1283|       |		/* find matching DO info: set file type depending on it */
 1284|  1.49M|		for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++) {
  ------------------
  |  Branch (1284:34): [True: 1.49M, False: 0]
  |  Branch (1284:52): [True: 1.48M, False: 10.7k]
  ------------------
 1285|  1.48M|			if (info->id == file_id) {
  ------------------
  |  Branch (1285:8): [True: 26.8k, False: 1.45M]
  ------------------
 1286|  26.8k|				blob->info = info;
 1287|  26.8k|				blob->file->type = blob->info->type;
 1288|  26.8k|				pgp_attach_acl(card, blob->file, info);
 1289|  26.8k|				break;
 1290|  26.8k|			}
 1291|  1.48M|		}
 1292|  37.6k|	}
 1293|       |
 1294|  37.6k|	return blob;
 1295|  37.6k|}
card-openpgp.c:pgp_attach_acl:
 1172|  26.8k|{
 1173|  26.8k|	unsigned int method = SC_AC_NONE;
  ------------------
  |  |  150|  26.8k|#define SC_AC_NONE			0x00000000
  ------------------
 1174|  26.8k|	unsigned long key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  26.8k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 1175|       |
 1176|       |	/* Write access */
 1177|  26.8k|	switch (info->access & WRITE_MASK) {
  ------------------
  |  Branch (1177:10): [True: 26.8k, False: 0]
  ------------------
 1178|  9.08k|	case WRITE_NEVER:
  ------------------
  |  Branch (1178:2): [True: 9.08k, False: 17.7k]
  ------------------
 1179|  9.08k|		method = SC_AC_NEVER;
  ------------------
  |  |  163|  9.08k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1180|  9.08k|		break;
 1181|      0|	case WRITE_PIN1:
  ------------------
  |  Branch (1181:2): [True: 0, False: 26.8k]
  ------------------
 1182|      0|		method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1183|      0|		key_ref = 0x01;
 1184|      0|		break;
 1185|  1.30k|	case WRITE_PIN2:
  ------------------
  |  Branch (1185:2): [True: 1.30k, False: 25.5k]
  ------------------
 1186|  1.30k|		method = SC_AC_CHV;
  ------------------
  |  |  151|  1.30k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1187|  1.30k|		key_ref = 0x02;
 1188|  1.30k|		break;
 1189|  16.4k|	case WRITE_PIN3:
  ------------------
  |  Branch (1189:2): [True: 16.4k, False: 10.3k]
  ------------------
 1190|  16.4k|		method = SC_AC_CHV;
  ------------------
  |  |  151|  16.4k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1191|  16.4k|		key_ref = 0x03;
 1192|  16.4k|		break;
 1193|  26.8k|	}
 1194|       |
 1195|  26.8k|	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  150|  53.7k|#define SC_AC_NONE			0x00000000
  ------------------
              	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  204|      0|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (1195:6): [True: 26.8k, False: 0]
  |  Branch (1195:30): [True: 0, False: 0]
  ------------------
 1196|  26.8k|		sc_file_add_acl_entry(file, SC_AC_OP_WRITE, method, key_ref);
  ------------------
  |  |  190|  26.8k|#define SC_AC_OP_WRITE			24
  ------------------
 1197|  26.8k|		sc_file_add_acl_entry(file, SC_AC_OP_UPDATE, method, key_ref);
  ------------------
  |  |  189|  26.8k|#define SC_AC_OP_UPDATE			23
  ------------------
 1198|  26.8k|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE, method, key_ref);
  ------------------
  |  |  168|  26.8k|#define SC_AC_OP_DELETE			2
  ------------------
 1199|  26.8k|		sc_file_add_acl_entry(file, SC_AC_OP_CREATE, method, key_ref);
  ------------------
  |  |  169|  26.8k|#define SC_AC_OP_CREATE			3
  ------------------
 1200|  26.8k|	}
 1201|      0|	else {
 1202|       |		/* When SC_AC_OP_DELETE is absent, we need to provide
 1203|       |		 * SC_AC_OP_DELETE_SELF for sc_pkcs15init_delete_by_path() */
 1204|      0|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE_SELF, method, key_ref);
  ------------------
  |  |  174|      0|#define SC_AC_OP_DELETE_SELF		8
  ------------------
 1205|      0|	}
 1206|       |
 1207|  26.8k|	method = SC_AC_NONE;
  ------------------
  |  |  150|  26.8k|#define SC_AC_NONE			0x00000000
  ------------------
 1208|  26.8k|	key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  26.8k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 1209|       |	/* Read access */
 1210|  26.8k|	switch (info->access & READ_MASK) {
  ------------------
  |  Branch (1210:10): [True: 2.24k, False: 24.6k]
  ------------------
 1211|    940|	case READ_NEVER:
  ------------------
  |  Branch (1211:2): [True: 940, False: 25.9k]
  ------------------
 1212|    940|		method = SC_AC_NEVER;
  ------------------
  |  |  163|    940|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1213|    940|		break;
 1214|      0|	case READ_PIN1:
  ------------------
  |  Branch (1214:2): [True: 0, False: 26.8k]
  ------------------
 1215|      0|		method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1216|      0|		key_ref = 0x01;
 1217|      0|		break;
 1218|    653|	case READ_PIN2:
  ------------------
  |  Branch (1218:2): [True: 653, False: 26.2k]
  ------------------
 1219|    653|		method = SC_AC_CHV;
  ------------------
  |  |  151|    653|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1220|    653|		key_ref = 0x02;
 1221|    653|		break;
 1222|    653|	case READ_PIN3:
  ------------------
  |  Branch (1222:2): [True: 653, False: 26.2k]
  ------------------
 1223|    653|		method = SC_AC_CHV;
  ------------------
  |  |  151|    653|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1224|    653|		key_ref = 0x03;
 1225|    653|		break;
 1226|  26.8k|	}
 1227|       |
 1228|  26.8k|	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  150|  53.7k|#define SC_AC_NONE			0x00000000
  ------------------
              	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  204|  24.6k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (1228:6): [True: 2.24k, False: 24.6k]
  |  Branch (1228:30): [True: 0, False: 24.6k]
  ------------------
 1229|  2.24k|		sc_file_add_acl_entry(file, SC_AC_OP_READ, method, key_ref);
  ------------------
  |  |  188|  2.24k|#define SC_AC_OP_READ			22
  ------------------
 1230|  2.24k|	}
 1231|  26.8k|}
card-openpgp.c:pgp_match_card:
  326|  3.51k|{
  327|  3.51k|	int i;
  328|       |
  329|  3.51k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.51k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.51k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.51k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.51k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.51k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  330|       |
  331|  3.51k|	i = _sc_match_atr(card, pgp_atrs, &card->type);
  332|  3.51k|	if (i >= 0) {
  ------------------
  |  Branch (332:6): [True: 16, False: 3.49k]
  ------------------
  333|     16|		card->name = pgp_atrs[i].name;
  334|     16|		LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  164|     16|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     16|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     16|	int _ret = r; \
  |  |  |  |  155|     16|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     16|	} else { \
  |  |  |  |  159|     16|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     16|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     16|	} \
  |  |  |  |  162|     16|	return _ret; \
  |  |  |  |  163|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  335|     16|	}
  336|  3.49k|	else {
  337|  3.49k|		sc_path_t	partial_aid;
  338|  3.49k|		sc_file_t *file = NULL;
  339|       |
  340|       |		/* select application "OpenPGP" */
  341|  3.49k|		sc_format_path("D276:0001:2401", &partial_aid);
  342|  3.49k|		partial_aid.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  3.49k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  343|       |		/* OpenPGP card only supports selection *with* requested FCI */
  344|  3.49k|		i = iso_ops->select_file(card, &partial_aid, &file);
  345|  3.49k|		if (SC_SUCCESS == i) {
  ------------------
  |  |   28|  3.49k|#define SC_SUCCESS				0
  ------------------
  |  Branch (345:7): [True: 662, False: 2.83k]
  ------------------
  346|    662|			card->type = SC_CARD_TYPE_OPENPGP_BASE;
  347|    662|			card->name = default_cardname;
  348|       |
  349|    662|			if (file->namelen != 16)
  ------------------
  |  Branch (349:8): [True: 661, False: 1]
  ------------------
  350|    661|				(void) get_full_pgp_aid(card, file);
  351|    662|			if (file->namelen == 16) {
  ------------------
  |  Branch (351:8): [True: 79, False: 583]
  ------------------
  352|     79|				unsigned char major = BCD2UCHAR(file->name[6]);
  ------------------
  |  |  216|     79|#define BCD2UCHAR(x) (((((x) & 0xF0) >> 4) * 10) + ((x) & 0x0F))
  ------------------
  353|       |
  354|     79|				switch (major) {
  355|      3|					case 1:
  ------------------
  |  Branch (355:6): [True: 3, False: 76]
  ------------------
  356|      3|						card->type = SC_CARD_TYPE_OPENPGP_V1;
  357|      3|						card->name = default_cardname_v1;
  358|      3|						break;
  359|      6|					case 2:
  ------------------
  |  Branch (359:6): [True: 6, False: 73]
  ------------------
  360|      6|						card->type = SC_CARD_TYPE_OPENPGP_V2;
  361|      6|						card->name = default_cardname_v2;
  362|      6|						break;
  363|      6|					case 3:
  ------------------
  |  Branch (363:6): [True: 6, False: 73]
  ------------------
  364|      6|						card->type = SC_CARD_TYPE_OPENPGP_V3;
  365|      6|						card->name = default_cardname_v3;
  366|      6|						break;
  367|     64|					default:
  ------------------
  |  Branch (367:6): [True: 64, False: 15]
  ------------------
  368|     64|						break;
  369|     79|				}
  370|     79|			}
  371|    662|			sc_file_free(file);
  372|    662|			LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  164|    662|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    662|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    662|	int _ret = r; \
  |  |  |  |  155|    662|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 662]
  |  |  |  |  ------------------
  |  |  |  |  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|    662|	} else { \
  |  |  |  |  159|    662|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    662|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    662|	} \
  |  |  |  |  162|    662|	return _ret; \
  |  |  |  |  163|    662|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  373|    662|		}
  374|  3.49k|	}
  375|  2.83k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  2.83k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.83k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.83k|	int _ret = r; \
  |  |  |  |  155|  2.83k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.83k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.83k|		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: 2.83k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.83k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.83k|	} 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|  2.83k|	return _ret; \
  |  |  |  |  163|  2.83k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  376|  2.83k|}
card-openpgp.c:get_full_pgp_aid:
  307|  1.32k|{
  308|  1.32k|	int r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  1.32k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  309|       |
  310|  1.32k|	if (file != NULL) {
  ------------------
  |  Branch (310:6): [True: 1.32k, False: 0]
  ------------------
  311|       |		/* explicitly get the full aid */
  312|  1.32k|		r = sc_get_data(card, 0x004F, file->name, sizeof file->name);
  313|  1.32k|		file->namelen = MAX(r, 0);
  ------------------
  |  |   66|  1.32k|#define MAX(x, y) (((x) > (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (66:20): [True: 543, False: 777]
  |  |  ------------------
  ------------------
  314|  1.32k|	}
  315|       |
  316|  1.32k|	return r;
  317|  1.32k|}
card-openpgp.c:pgp_init:
  409|    678|{
  410|    678|	struct pgp_priv_data *priv;
  411|    678|	sc_path_t	path;
  412|    678|	sc_file_t	*file = NULL;
  413|    678|	int		r, i;
  414|       |
  415|    678|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    678|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    678|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    678|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    678|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 678]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|       |
  417|    678|	priv = calloc (1, sizeof *priv);
  418|    678|	if (!priv)
  ------------------
  |  Branch (418:6): [True: 0, False: 678]
  ------------------
  419|    678|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  420|    678|	card->drv_data = priv;
  421|       |
  422|    678|	card->cla = 0x00;
  423|       |
  424|       |	/* select application "OpenPGP" */
  425|    678|	sc_format_path("D276:0001:2401", &path);
  426|    678|	path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    678|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  427|    678|	if ((r = iso_ops->select_file(card, &path, &file)) < 0) {
  ------------------
  |  Branch (427:6): [True: 18, False: 660]
  ------------------
  428|     18|		sc_file_free(file);
  429|     18|		pgp_finish(card);
  430|     18|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|     18|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     18|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     18|	int _ret = r; \
  |  |  |  |  155|     18|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     18|		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|     18|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     18|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     18|	} 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|     18|	return _ret; \
  |  |  |  |  163|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  431|     18|	}
  432|       |
  433|       |	/* defensive programming check */
  434|    660|	if (!file)   {
  ------------------
  |  Branch (434:6): [True: 0, False: 660]
  ------------------
  435|      0|		pgp_finish(card);
  436|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  437|      0|	}
  438|       |
  439|    660|	if (file->namelen != 16) {
  ------------------
  |  Branch (439:6): [True: 659, False: 1]
  ------------------
  440|       |		/* explicitly get the full aid */
  441|    659|		r = get_full_pgp_aid(card, file);
  442|    659|		if (r < 0) {
  ------------------
  |  Branch (442:7): [True: 7, False: 652]
  ------------------
  443|      7|			sc_file_free(file);
  444|      7|			pgp_finish(card);
  445|      7|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|      7|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      7|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      7|	int _ret = r; \
  |  |  |  |  155|      7|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      7|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      7|	} 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|      7|	return _ret; \
  |  |  |  |  163|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|      7|		}
  447|    659|	}
  448|       |
  449|       |	/* read information from AID */
  450|    653|	if (file->namelen == 16) {
  ------------------
  |  Branch (450:6): [True: 435, False: 218]
  ------------------
  451|    435|		static char card_name[SC_MAX_APDU_BUFFER_SIZE] = "OpenPGP card";
  452|       |
  453|       |		/* OpenPGP card spec 1.1, 2.x & 3.x, section 4.2.1 & 4.1.2.1 */
  454|    435|		priv->bcd_version = bebytes2ushort(file->name + 6);
  455|    435|		card->version.fw_major = card->version.hw_major = BCD2UCHAR(file->name[6]);
  ------------------
  |  |  216|    435|#define BCD2UCHAR(x) (((((x) & 0xF0) >> 4) * 10) + ((x) & 0x0F))
  ------------------
  456|    435|		card->version.fw_minor = card->version.hw_minor = BCD2UCHAR(file->name[7]);
  ------------------
  |  |  216|    435|#define BCD2UCHAR(x) (((((x) & 0xF0) >> 4) * 10) + ((x) & 0x0F))
  ------------------
  457|       |
  458|       |		/* for "standard" cards, include detailed card version & serial no. in card name */
  459|    435|		if (card->name == default_cardname_v1 ||
  ------------------
  |  Branch (459:7): [True: 1, False: 434]
  ------------------
  460|    434|		    card->name == default_cardname_v2 ||
  ------------------
  |  Branch (460:7): [True: 3, False: 431]
  ------------------
  461|    431|		    card->name == default_cardname_v3) {
  ------------------
  |  Branch (461:7): [True: 4, False: 427]
  ------------------
  462|      8|			snprintf(card_name, sizeof(card_name),
  463|      8|				 "OpenPGP card v%u.%u (%04X %08lX)",
  464|      8|				 card->version.hw_major, card->version.hw_minor,
  465|      8|				 bebytes2ushort(file->name + 8),
  466|      8|				 bebytes2ulong(file->name + 10));
  467|      8|		}
  468|    427|		else if (card->name != NULL) {
  ------------------
  |  Branch (468:12): [True: 427, False: 0]
  ------------------
  469|       |			/* for other cards, append serial number to the card name */
  470|    427|			snprintf(card_name, sizeof(card_name),
  471|    427|				 "%s (%04X %08lX)",
  472|    427|				 card->name,
  473|    427|				 bebytes2ushort(file->name + 8),
  474|    427|				 bebytes2ulong(file->name + 10));
  475|    427|		}
  476|    435|		card->name = card_name;
  477|       |
  478|       |		/* GPG compatibility: set card's serial number to manufacturer ID + serial number */
  479|    435|		memcpy(card->serialnr.value, file->name + 8, 6);
  480|    435|		card->serialnr.len = 6;
  481|    435|	} else {
  482|       |		/* set detailed card version */
  483|    218|		switch (card->type) {
  484|      5|			case SC_CARD_TYPE_OPENPGP_V3:
  ------------------
  |  Branch (484:4): [True: 5, False: 213]
  ------------------
  485|      5|				priv->bcd_version = OPENPGP_CARD_3_0;
  486|      5|				break;
  487|      1|			case SC_CARD_TYPE_OPENPGP_GNUK:
  ------------------
  |  Branch (487:4): [True: 1, False: 217]
  ------------------
  488|      3|			case SC_CARD_TYPE_OPENPGP_V2:
  ------------------
  |  Branch (488:4): [True: 2, False: 216]
  ------------------
  489|      3|				priv->bcd_version = OPENPGP_CARD_2_0;
  490|      3|				break;
  491|    210|			default:
  ------------------
  |  Branch (491:4): [True: 210, False: 8]
  ------------------
  492|    210|				priv->bcd_version = OPENPGP_CARD_1_1;
  493|    210|				break;
  494|    218|		}
  495|    218|	}
  496|       |
  497|       |	/* set pointer to correct list of card objects */
  498|    653|	priv->pgp_objects = (priv->bcd_version < OPENPGP_CARD_2_0) ? pgp1x_objects
  ------------------
  |  Branch (498:22): [True: 239, False: 414]
  ------------------
  499|    653|			  : (priv->bcd_version < OPENPGP_CARD_2_1) ? pgp20_objects
  ------------------
  |  Branch (499:8): [True: 8, False: 406]
  ------------------
  500|    414|			  : (priv->bcd_version < OPENPGP_CARD_3_0) ? pgp21_objects
  ------------------
  |  Branch (500:8): [True: 21, False: 385]
  ------------------
  501|    406|			  : (priv->bcd_version < OPENPGP_CARD_3_3) ? pgp30_objects
  ------------------
  |  Branch (501:8): [True: 7, False: 378]
  ------------------
  502|    385|			  : (priv->bcd_version < OPENPGP_CARD_3_4) ? pgp33_objects
  ------------------
  |  Branch (502:8): [True: 1, False: 377]
  ------------------
  503|    378|			  :					     pgp34_objects;
  504|       |
  505|       |	/* With gnuk, we use different curves */
  506|    653|	if (card->type == SC_CARD_TYPE_OPENPGP_GNUK) {
  ------------------
  |  Branch (506:6): [True: 7, False: 646]
  ------------------
  507|      7|		priv->ec_curves = ec_curves_gnuk;
  508|    646|	} else if (priv->bcd_version >= OPENPGP_CARD_3_4) {
  ------------------
  |  Branch (508:13): [True: 375, False: 271]
  ------------------
  509|    375|		priv->ec_curves = ec_curves_openpgp34;
  510|    375|	} else {
  511|    271|		priv->ec_curves = ec_curves_openpgp;
  512|    271|	}
  513|       |
  514|       |	/* change file path to MF for reuse in MF */
  515|    653|	sc_format_path("3f00", &file->path);
  516|       |
  517|       |	/* set up the root of our fake file tree */
  518|       |	/* Transfers ownership of the file to the priv->mf structure */
  519|    653|	priv->mf = pgp_new_blob(card, NULL, 0x3f00, file);
  520|    653|	if (!priv->mf) {
  ------------------
  |  Branch (520:6): [True: 0, False: 653]
  ------------------
  521|      0|		sc_file_free(file);
  522|      0|		pgp_finish(card);
  523|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  524|      0|	}
  525|       |
  526|       |	/* select MF */
  527|    653|	priv->current = priv->mf;
  528|       |
  529|    653|	r = populate_blobs_to_mf(card, priv);
  530|    653|	if (r < 0) {
  ------------------
  |  Branch (530:6): [True: 0, False: 653]
  ------------------
  531|      0|		pgp_finish(card);
  532|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  533|      0|	}
  534|       |
  535|       |	/* get card_features from ATR & DOs */
  536|    653|	if (pgp_get_card_features(card)) {
  ------------------
  |  Branch (536:6): [True: 51, False: 602]
  ------------------
  537|     51|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     51|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     51|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     51|	int _ret = r; \
  |  |  |  |  155|     51|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 51, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     51|		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: 51]
  |  |  |  |  ------------------
  |  |  |  |  157|     51|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     51|	} 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|     51|	return _ret; \
  |  |  |  |  163|     51|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  538|     51|	}
  539|       |
  540|       |	/* if algorithm attributes can be changed,
  541|       |	 * add supported algorithms based on specification for pkcs15-init */
  542|    602|	if (priv->ext_caps & EXT_CAP_ALG_ATTR_CHANGEABLE) {
  ------------------
  |  Branch (542:6): [True: 28, False: 574]
  ------------------
  543|     28|		unsigned long flags_rsa, flags_ecc, ext_flags;
  544|     28|		unsigned long flags_eddsa, flags_xeddsa;
  545|       |
  546|       |		/* OpenPGP card spec 1.1 & 2.x, section 7.2.9 & 7.2.10 / v3.x section 7.2.11 & 7.2.12 */
  547|     28|		flags_rsa = SC_ALGORITHM_RSA_PAD_PKCS1|
  ------------------
  |  |  111|     28|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     28|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     28|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  548|     28|			    SC_ALGORITHM_RSA_HASH_NONE|
  ------------------
  |  |  133|     28|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  549|     28|			    SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|     28|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  550|     28|		flags_ecc = SC_ALGORITHM_ECDSA_RAW|
  ------------------
  |  |  174|     28|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  551|     28|			    SC_ALGORITHM_ECDH_CDH_RAW|
  ------------------
  |  |  173|     28|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  552|     28|			    SC_ALGORITHM_ECDSA_HASH_NONE|
  ------------------
  |  |  175|     28|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|     28|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  553|     28|			    SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|     28|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  554|     28|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE;
  ------------------
  |  |  201|     28|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  555|       |
  556|     28|		flags_eddsa = SC_ALGORITHM_EDDSA_RAW |
  ------------------
  |  |  188|     28|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
  557|     28|			      SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|     28|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  558|       |		/* xeddsa may allow signing at some time */
  559|     28|		flags_xeddsa = SC_ALGORITHM_ECDH_CDH_RAW |
  ------------------
  |  |  173|     28|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  560|     28|			       SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|     28|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  561|       |
  562|     28|		switch (card->type) {
  563|      4|			case SC_CARD_TYPE_OPENPGP_V3:
  ------------------
  |  Branch (563:4): [True: 4, False: 24]
  ------------------
  564|       |				/* RSA 1024 was removed for v3+ */
  565|      4|				_sc_card_add_rsa_alg(card, 4096, flags_rsa, 0);
  566|      4|				_sc_card_add_rsa_alg(card, 3072, flags_rsa, 0);
  567|       |				/* fallthrough */
  568|      4|			case SC_CARD_TYPE_OPENPGP_GNUK:
  ------------------
  |  Branch (568:4): [True: 0, False: 28]
  ------------------
  569|      4|				_sc_card_add_rsa_alg(card, 2048, flags_rsa, 0);
  570|     52|				for (i=0; priv->ec_curves[i].oid.value[0] >= 0; i++)
  ------------------
  |  Branch (570:15): [True: 48, False: 4]
  ------------------
  571|     48|				{
  572|     48|					if (priv->ec_curves[i].key_type == SC_ALGORITHM_EC)
  ------------------
  |  |   70|     48|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (572:10): [True: 36, False: 12]
  ------------------
  573|     36|						_sc_card_add_ec_alg(card, priv->ec_curves[i].size,
  574|     36|								flags_ecc, ext_flags, &priv->ec_curves[i].oid);
  575|     12|					else if (priv->ec_curves[i].key_type == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   72|     12|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (575:15): [True: 6, False: 6]
  ------------------
  576|      6|						_sc_card_add_eddsa_alg(card, priv->ec_curves[i].size,
  577|      6|								flags_eddsa, ext_flags, &priv->ec_curves[i].oid);
  578|      6|					else if (priv->ec_curves[i].key_type == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|      6|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (578:15): [True: 6, False: 0]
  ------------------
  579|      6|						_sc_card_add_xeddsa_alg(card, priv->ec_curves[i].size,
  580|      6|								flags_xeddsa, ext_flags, &priv->ec_curves[i].oid);
  581|      0|					else
  582|      0|						LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|     48|				}
  584|      4|				break;
  585|      4|			case SC_CARD_TYPE_OPENPGP_V2:
  ------------------
  |  Branch (585:4): [True: 1, False: 27]
  ------------------
  586|     24|			default:
  ------------------
  |  Branch (586:4): [True: 23, False: 5]
  ------------------
  587|     24|				_sc_card_add_rsa_alg(card, 1024, flags_rsa, 0);
  588|     24|				_sc_card_add_rsa_alg(card, 2048, flags_rsa, 0);
  589|     24|				_sc_card_add_rsa_alg(card, 3072, flags_rsa, 0);
  590|     24|				_sc_card_add_rsa_alg(card, 4096, flags_rsa, 0);
  591|     24|				break;
  592|     28|		}
  593|     28|	}
  594|       |
  595|    602|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    602|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    602|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    602|	int _ret = r; \
  |  |  |  |  155|    602|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 602, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    602|		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: 602]
  |  |  |  |  ------------------
  |  |  |  |  157|    602|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    602|	} 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|    602|	return _ret; \
  |  |  |  |  163|    602|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  596|    602|}
card-openpgp.c:pgp_get_blob:
 1480|  5.43k|{
 1481|  5.43k|	pgp_blob_t		*child;
 1482|  5.43k|	int			r;
 1483|       |
 1484|  5.43k|	if ((r = pgp_enumerate_blob(card, blob)) < 0)
  ------------------
  |  Branch (1484:6): [True: 1.14k, False: 4.28k]
  ------------------
 1485|  1.14k|		return r;
 1486|       |
 1487|  47.5k|	for (child = blob->files; child; child = child->next) {
  ------------------
  |  Branch (1487:28): [True: 45.6k, False: 1.88k]
  ------------------
 1488|  45.6k|		if (child->id == id) {
  ------------------
  |  Branch (1488:7): [True: 2.40k, False: 43.2k]
  ------------------
 1489|  2.40k|			(void) pgp_read_blob(card, child);
 1490|  2.40k|			*ret = child;
 1491|  2.40k|			return SC_SUCCESS;
  ------------------
  |  |   28|  2.40k|#define SC_SUCCESS				0
  ------------------
 1492|  2.40k|		}
 1493|  45.6k|	}
 1494|       |
 1495|       |	/* This part is for "NOT FOUND" cases */
 1496|       |
 1497|       |	/* Special case:
 1498|       |	 * Gnuk does not have default value for children of DO 65 (DOs 5B, 5F2D, 5F35)
 1499|       |	 * So, if these blob was not found, we create it. */
 1500|  1.88k|	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  154|  3.76k|#define DO_CARDHOLDER            0x65
  ------------------
              	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  155|     80|#define DO_NAME                  0x5b
  ------------------
              	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  156|     80|#define DO_LANG_PREF             0x5f2d
  ------------------
              	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  157|      0|#define DO_SEX                   0x5f35
  ------------------
  |  Branch (1500:6): [True: 40, False: 1.84k]
  |  Branch (1500:36): [True: 0, False: 40]
  |  Branch (1500:53): [True: 40, False: 0]
  |  Branch (1500:75): [True: 0, False: 0]
  ------------------
 1501|     40|		sc_log(card->ctx, "Create blob %X under %X", id, blob->id);
  ------------------
  |  |   71|     40|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1502|     40|		child = pgp_new_blob(card, blob, id, sc_file_new());
 1503|     40|		if (child) {
  ------------------
  |  Branch (1503:7): [True: 40, False: 0]
  ------------------
 1504|     40|			pgp_set_blob(child, NULL, 0);
 1505|     40|			*ret = child;
 1506|     40|			return SC_SUCCESS;
  ------------------
  |  |   28|     40|#define SC_SUCCESS				0
  ------------------
 1507|     40|		}
 1508|      0|		else
 1509|      0|			sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1510|     40|			       "Not enough memory to create blob for DO %X",
 1511|     40|			       id);
 1512|     40|	}
 1513|       |
 1514|  1.84k|	return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|  1.84k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 1515|  1.88k|}
card-openpgp.c:pgp_enumerate_blob:
 1398|  5.81k|{
 1399|  5.81k|	const u8	*in;
 1400|  5.81k|	int		r;
 1401|  5.81k|	sc_file_t	*file = NULL;
 1402|       |
 1403|  5.81k|	if (blob->files != NULL)
  ------------------
  |  Branch (1403:6): [True: 3.96k, False: 1.84k]
  ------------------
 1404|  3.96k|		return SC_SUCCESS;
  ------------------
  |  |   28|  3.96k|#define SC_SUCCESS				0
  ------------------
 1405|       |
 1406|  1.84k|	if ((r = pgp_read_blob(card, blob)) < 0)
  ------------------
  |  Branch (1406:6): [True: 1.05k, False: 790]
  ------------------
 1407|  1.05k|		return r;
 1408|       |
 1409|    790|	in = blob->data;
 1410|       |
 1411|  26.0k|	while ((int) blob->len > (in - blob->data)) {
  ------------------
  |  Branch (1411:9): [True: 25.6k, False: 428]
  ------------------
 1412|  25.6k|		unsigned int	cla, tag, tmptag;
 1413|  25.6k|		size_t		len;
 1414|  25.6k|		const u8	*data = in;
 1415|  25.6k|		pgp_blob_t	*new;
 1416|       |
 1417|  25.6k|		if (!in)
  ------------------
  |  Branch (1417:7): [True: 0, False: 25.6k]
  ------------------
 1418|      0|			return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1419|       |
 1420|  25.6k|		r = sc_asn1_read_tag(&data, blob->len - (in - blob->data),
 1421|  25.6k|					&cla, &tag, &len);
 1422|  25.6k|		if (r == SC_ERROR_INVALID_ASN1_OBJECT) {
  ------------------
  |  |   82|  25.6k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  |  Branch (1422:7): [True: 147, False: 25.4k]
  ------------------
 1423|    147|			sc_log(card->ctx, "Invalid ASN.1 object");
  ------------------
  |  |   71|    147|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1424|    147|			return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|    147|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1425|    147|		}
 1426|       |		/* Check for unknown error, or empty data */
 1427|  25.4k|		if (((r < 0) && (r != SC_ERROR_ASN1_END_OF_CONTENTS)) ||
  ------------------
  |  |   84|    452|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (1427:8): [True: 452, False: 25.0k]
  |  Branch (1427:19): [True: 0, False: 452]
  ------------------
 1428|  25.4k|		    (data == NULL)) {
  ------------------
  |  Branch (1428:7): [True: 118, False: 25.3k]
  ------------------
 1429|    118|			sc_log(card->ctx, "Unexpected end of contents");
  ------------------
  |  |   71|    118|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1430|    118|			return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|    118|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1431|    118|		}
 1432|       |
 1433|       |		/* undo ASN1's split of tag & class */
 1434|  26.2k|		for (tmptag = tag; tmptag > 0x0FF; tmptag >>= 8) {
  ------------------
  |  Branch (1434:22): [True: 908, False: 25.3k]
  ------------------
 1435|    908|			cla <<= 8;
 1436|    908|		}
 1437|  25.3k|		tag |= cla;
 1438|       |		/* Check for length mismatch */
 1439|  25.3k|		if ((r == SC_ERROR_ASN1_END_OF_CONTENTS) ||
  ------------------
  |  |   84|  25.3k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (1439:7): [True: 452, False: 24.9k]
  ------------------
 1440|  24.9k|		    (data + len > blob->data + blob->len)) {
  ------------------
  |  Branch (1440:7): [True: 0, False: 24.9k]
  ------------------
 1441|       |			// Check if it is not known Yubikey 5 issue
 1442|    452|			if ((tag != blob->id) || (tag != 0xfa)) {
  ------------------
  |  Branch (1442:8): [True: 88, False: 364]
  |  Branch (1442:29): [True: 9, False: 355]
  ------------------
 1443|     97|				sc_log(card->ctx, "Unexpected end of contents");
  ------------------
  |  |   71|     97|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1444|     97|				return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|     97|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1445|     97|			}
 1446|    452|		}
 1447|       |
 1448|       |		/* Awful hack for composite DOs that have
 1449|       |		 * a TLV with the DO's id encompassing the
 1450|       |		 * entire blob. Example: Yubikey Neo */
 1451|  25.2k|		if (tag == blob->id) {
  ------------------
  |  Branch (1451:7): [True: 575, False: 24.7k]
  ------------------
 1452|    575|			in = data;
 1453|    575|			continue;
 1454|    575|		}
 1455|       |
 1456|       |		/* create fake file system hierarchy by
 1457|       |		 * using constructed DOs as DF */
 1458|  24.7k|		file = sc_file_new();
 1459|  24.7k|		if ((new = pgp_new_blob(card, blob, tag, file)) == NULL) {
  ------------------
  |  Branch (1459:7): [True: 0, False: 24.7k]
  ------------------
 1460|      0|			sc_file_free(file);
 1461|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1462|      0|		}
 1463|  24.7k|		if (pgp_set_blob(new, data, len) != SC_SUCCESS) {
  ------------------
  |  |   28|  24.7k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1463:7): [True: 0, False: 24.7k]
  ------------------
 1464|      0|			sc_file_free(file);
 1465|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1466|      0|		}
 1467|  24.7k|		in = data + len;
 1468|  24.7k|	}
 1469|       |
 1470|    428|	return SC_SUCCESS;
  ------------------
  |  |   28|    428|#define SC_SUCCESS				0
  ------------------
 1471|    790|}
card-openpgp.c:pgp_set_blob:
 1140|  25.4k|{
 1141|  25.4k|	if (blob->data)
  ------------------
  |  Branch (1141:6): [True: 0, False: 25.4k]
  ------------------
 1142|      0|		free(blob->data);
 1143|  25.4k|	blob->data = NULL;
 1144|  25.4k|	blob->len    = 0;
 1145|  25.4k|	blob->status = 0;
 1146|       |
 1147|  25.4k|	if (len > 0) {
  ------------------
  |  Branch (1147:6): [True: 10.5k, False: 14.9k]
  ------------------
 1148|  10.5k|		void *tmp = calloc(1, len);
 1149|       |
 1150|  10.5k|		if (tmp == NULL)
  ------------------
  |  Branch (1150:7): [True: 0, False: 10.5k]
  ------------------
 1151|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1152|       |
 1153|  10.5k|		blob->data = tmp;
 1154|  10.5k|		blob->len  = (unsigned int)len;
 1155|  10.5k|		if (data != NULL)
  ------------------
  |  Branch (1155:7): [True: 10.5k, False: 0]
  ------------------
 1156|  10.5k|			memcpy(blob->data, data, len);
 1157|  10.5k|	}
 1158|       |
 1159|  25.4k|	if (blob->file)
  ------------------
  |  Branch (1159:6): [True: 25.4k, False: 0]
  ------------------
 1160|  25.4k|		blob->file->size = len;
 1161|       |
 1162|  25.4k|	return SC_SUCCESS;
  ------------------
  |  |   28|  25.4k|#define SC_SUCCESS				0
  ------------------
 1163|  25.4k|}
card-openpgp.c:pgp_read_blob:
 1348|  4.27k|{
 1349|  4.27k|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  4.27k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1350|       |
 1351|  4.27k|	if (blob->data != NULL)
  ------------------
  |  Branch (1351:6): [True: 949, False: 3.32k]
  ------------------
 1352|    949|		return SC_SUCCESS;
  ------------------
  |  |   28|    949|#define SC_SUCCESS				0
  ------------------
 1353|  3.32k|	if (blob->info == NULL)
  ------------------
  |  Branch (1353:6): [True: 3, False: 3.32k]
  ------------------
 1354|      3|		return blob->status;
 1355|       |
 1356|  3.32k|	if (blob->info->get_fn) {	/* readable, top-level DO */
  ------------------
  |  Branch (1356:6): [True: 3.27k, False: 45]
  ------------------
 1357|  3.27k|		u8 	buffer[MAX_OPENPGP_DO_SIZE];
 1358|  3.27k|		size_t	buf_len = sizeof(buffer);
 1359|  3.27k|		int r = SC_SUCCESS;
  ------------------
  |  |   28|  3.27k|#define SC_SUCCESS				0
  ------------------
 1360|       |
 1361|       |		/* buffer length for certificate */
 1362|  3.27k|		if (blob->id == DO_CERT && priv->max_cert_size > 0) {
  ------------------
  |  |  138|  6.55k|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (1362:7): [True: 0, False: 3.27k]
  |  Branch (1362:30): [True: 0, False: 0]
  ------------------
 1363|      0|			buf_len = MIN(priv->max_cert_size, sizeof(buffer));
  ------------------
  |  |   69|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1364|      0|		}
 1365|       |
 1366|       |		/* buffer length for Gnuk pubkey */
 1367|  3.27k|		if (card->type == SC_CARD_TYPE_OPENPGP_GNUK &&
  ------------------
  |  Branch (1367:7): [True: 32, False: 3.24k]
  ------------------
 1368|     32|		    (blob->id == DO_AUTH ||
  ------------------
  |  |  143|     64|#define DO_AUTH                  0xa400
  ------------------
  |  Branch (1368:8): [True: 0, False: 32]
  ------------------
 1369|     32|		     blob->id == DO_SIGN ||
  ------------------
  |  |  141|     64|#define DO_SIGN                  0xb600
  ------------------
  |  Branch (1369:8): [True: 0, False: 32]
  ------------------
 1370|     32|		     blob->id == DO_ENCR ||
  ------------------
  |  |  142|     64|#define DO_ENCR                  0xb800
  ------------------
  |  Branch (1370:8): [True: 0, False: 32]
  ------------------
 1371|     32|		     blob->id == DO_AUTH_SYM ||
  ------------------
  |  |  147|     64|#define DO_AUTH_SYM              0xa401
  ------------------
  |  Branch (1371:8): [True: 0, False: 32]
  ------------------
 1372|     32|		     blob->id == DO_SIGN_SYM ||
  ------------------
  |  |  145|     64|#define DO_SIGN_SYM              0xb601
  ------------------
  |  Branch (1372:8): [True: 0, False: 32]
  ------------------
 1373|     32|		     blob->id == DO_ENCR_SYM)) {
  ------------------
  |  |  146|     32|#define DO_ENCR_SYM              0xb801
  ------------------
  |  Branch (1373:8): [True: 0, False: 32]
  ------------------
 1374|      0|			buf_len = MIN(MAXLEN_RESP_PUBKEY_GNUK, sizeof(buffer));
  ------------------
  |  |   69|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, Folded]
  |  |  ------------------
  ------------------
 1375|      0|		}
 1376|       |
 1377|  3.27k|		r = blob->info->get_fn(card, blob->id, buffer, buf_len);
 1378|       |
 1379|  3.27k|		if (r < 0) {	/* an error occurred */
  ------------------
  |  Branch (1379:7): [True: 2.52k, False: 754]
  ------------------
 1380|  2.52k|			blob->status = r;
 1381|  2.52k|			return r;
 1382|  2.52k|		}
 1383|       |
 1384|    754|		return pgp_set_blob(blob, buffer, r);
 1385|  3.27k|	}
 1386|     45|	else {		/* un-readable DO or part of a constructed DO */
 1387|     45|		return SC_SUCCESS;
  ------------------
  |  |   28|     45|#define SC_SUCCESS				0
  ------------------
 1388|     45|	}
 1389|  3.32k|}
card-openpgp.c:pgp_parse_algo_attr_blob:
  634|  9.67k|{
  635|  9.67k|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  9.67k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  636|  9.67k|	struct sc_object_id oid;
  637|  9.67k|	unsigned int j, r;
  638|       |
  639|  9.67k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  9.67k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  9.67k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  9.67k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  9.67k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 9.67k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  640|       |
  641|  9.67k|	if (blob == NULL || blob->data == NULL || blob->len == 0 ||
  ------------------
  |  Branch (641:6): [True: 0, False: 9.67k]
  |  Branch (641:22): [True: 2.47k, False: 7.19k]
  |  Branch (641:44): [True: 0, False: 7.19k]
  ------------------
  642|  7.19k|	    blob->id < 0x00c1 || blob->id > 0x00c3 || key_info == NULL) {
  ------------------
  |  Branch (642:6): [True: 0, False: 7.19k]
  |  Branch (642:27): [True: 0, False: 7.19k]
  |  Branch (642:48): [True: 0, False: 7.19k]
  ------------------
  643|  2.47k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  164|  2.47k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.47k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.47k|	int _ret = r; \
  |  |  |  |  155|  2.47k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.47k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.47k|		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|  2.47k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.47k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.47k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.47k|	} 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|  2.47k|	return _ret; \
  |  |  |  |  163|  2.47k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  644|  2.47k|	}
  645|       |
  646|  7.19k|	key_info->key_id = blob->id - 0x00c0;	/* attribute algorithm blobs are C1 - C3 */
  647|       |
  648|  7.19k|	switch (blob->data[0]) {
  649|  1.28k|		case SC_OPENPGP_KEYALGO_RSA:
  ------------------
  |  |  877|  1.28k|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (649:3): [True: 1.28k, False: 5.91k]
  ------------------
  650|  1.28k|			if (blob->len < 5) {
  ------------------
  |  Branch (650:8): [True: 429, False: 852]
  ------------------
  651|    429|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  164|    429|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    429|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    429|	int _ret = r; \
  |  |  |  |  155|    429|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 429, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    429|		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|    429|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 429, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    429|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    429|	} 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|    429|	return _ret; \
  |  |  |  |  163|    429|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|    429|			}
  653|       |
  654|    852|			key_info->algorithm = SC_OPENPGP_KEYALGO_RSA;
  ------------------
  |  |  877|    852|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  655|    852|			key_info->u.rsa.modulus_len = bebytes2ushort(blob->data + 1);
  656|    852|			key_info->u.rsa.exponent_len = bebytes2ushort(blob->data + 3);
  657|       |
  658|    852|			key_info->u.rsa.keyformat = (blob->len > 5)
  ------------------
  |  Branch (658:32): [True: 405, False: 447]
  ------------------
  659|    852|						  ? blob->data[5]
  660|    852|						  : SC_OPENPGP_KEYFORMAT_RSA_STD;
  ------------------
  |  |  882|  1.29k|#define SC_OPENPGP_KEYFORMAT_RSA_STD	0    /* See 4.3.3.6 Algorithm Attributes */
  ------------------
  661|    852|			break;
  662|    813|		case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  878|    813|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (662:3): [True: 813, False: 6.38k]
  ------------------
  663|  4.86k|		case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  879|  4.86k|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (663:3): [True: 4.05k, False: 3.14k]
  ------------------
  664|  5.25k|		case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  880|  5.25k|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (664:3): [True: 389, False: 6.81k]
  ------------------
  665|       |
  666|       |			/* SC_OPENPGP_KEYALGO_ECDH || SC_OPENPGP_KEYALGO_ECDSA || SC_OPENPGP_KEYALGO_EDDSA */
  667|  5.25k|			key_info->algorithm = blob->data[0];
  668|       |
  669|       |			/* last byte is set to 0xFF if pubkey import is supported */
  670|  5.25k|			if (blob->data[blob->len-1] == SC_OPENPGP_KEYFORMAT_EC_STDPUB){
  ------------------
  |  |  888|  5.25k|#define SC_OPENPGP_KEYFORMAT_EC_STDPUB	0xFF
  ------------------
  |  Branch (670:8): [True: 1.35k, False: 3.90k]
  ------------------
  671|  1.35k|				if (blob->len < 3)
  ------------------
  |  Branch (671:9): [True: 223, False: 1.12k]
  ------------------
  672|    223|					return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|    223|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  673|  1.12k|				key_info->u.ec.oidv_len = blob->len - 2;
  674|  1.12k|				key_info->u.ec.keyformat = SC_OPENPGP_KEYFORMAT_EC_STDPUB;
  ------------------
  |  |  888|  1.12k|#define SC_OPENPGP_KEYFORMAT_EC_STDPUB	0xFF
  ------------------
  675|  1.12k|			}
  676|  3.90k|			else {
  677|       |				/* otherwise, last byte could be 00, so let's ignore it, as
  678|       |				 * it is not part of OID */
  679|  3.90k|				if (blob->len < 2)
  ------------------
  |  Branch (679:9): [True: 278, False: 3.62k]
  ------------------
  680|    278|					return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|    278|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  681|  3.62k|				if (blob->data[blob->len-1] == SC_OPENPGP_KEYFORMAT_EC_STD)
  ------------------
  |  |  887|  3.62k|#define SC_OPENPGP_KEYFORMAT_EC_STD	0
  ------------------
  |  Branch (681:9): [True: 598, False: 3.02k]
  ------------------
  682|    598|					key_info->u.ec.oidv_len = blob->len - 2;
  683|  3.02k|				else
  684|  3.02k|					key_info->u.ec.oidv_len = blob->len - 1;
  685|  3.62k|				key_info->u.ec.keyformat = SC_OPENPGP_KEYFORMAT_EC_STD;
  ------------------
  |  |  887|  3.62k|#define SC_OPENPGP_KEYFORMAT_EC_STD	0
  ------------------
  686|  3.62k|			}
  687|       |
  688|       |			/* Create copy of oid from blob */
  689|  4.75k|			sc_init_oid(&oid);
  690|  4.75k|			r = sc_asn1_decode_object_id(&blob->data[1], key_info->u.ec.oidv_len, &oid);
  691|       |
  692|       |			/* decoding failed, return sc_asn1_decode_object_id error code */
  693|  4.75k|			if (r > 0){
  ------------------
  |  Branch (693:8): [True: 2.85k, False: 1.90k]
  ------------------
  694|  2.85k|				return r;
  695|  2.85k|			}
  696|       |			/* compare with list of supported ec_curves */
  697|  26.6k|			for (j = 0; priv->ec_curves[j].oid.value[0] >= 0; j++) {
  ------------------
  |  Branch (697:16): [True: 24.7k, False: 1.90k]
  ------------------
  698|  24.7k|				if (sc_compare_oid(&priv->ec_curves[j].oid, &oid)) {
  ------------------
  |  Branch (698:9): [True: 0, False: 24.7k]
  ------------------
  699|      0|					sc_log(card->ctx, "Matched EC oid %s (%d)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  700|      0|						sc_dump_oid(&oid), j);
  701|      0|					key_info->u.ec.oid = priv->ec_curves[j].oid;
  702|      0|					key_info->u.ec.key_length = priv->ec_curves[j].size;
  703|      0|					break;
  704|      0|				}
  705|  24.7k|			}
  706|       |			/* We did not match the OID */
  707|  1.90k|			if (priv->ec_curves[j].oid.value[0] < 0) {
  ------------------
  |  Branch (707:8): [True: 1.90k, False: 0]
  ------------------
  708|  1.90k|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  1.90k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.90k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.90k|	int _ret = r; \
  |  |  |  |  155|  1.90k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.90k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.90k|		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|  1.90k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.90k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.90k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.90k|	} 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|  1.90k|	return _ret; \
  |  |  |  |  163|  1.90k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  709|  1.90k|			}
  710|      0|			break;
  711|    661|		default:
  ------------------
  |  Branch (711:3): [True: 661, False: 6.53k]
  ------------------
  712|    661|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    661|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    661|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    661|	int _ret = r; \
  |  |  |  |  155|    661|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 661, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    661|		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|    661|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 661, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    661|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    661|	} 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|    661|	return _ret; \
  |  |  |  |  163|    661|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  713|  7.19k|	}
  714|       |
  715|    852|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    852|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    852|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    852|	int _ret = r; \
  |  |  |  |  155|    852|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 852, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    852|		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: 852]
  |  |  |  |  ------------------
  |  |  |  |  157|    852|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    852|	} 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|    852|	return _ret; \
  |  |  |  |  163|    852|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  716|    852|}
card-openpgp.c:pgp_get_card_features:
  909|    653|{
  910|    653|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    653|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  911|    653|	u8 *hist_bytes = card->reader->atr_info.hist_bytes;
  912|    653|	size_t hist_bytes_len = card->reader->atr_info.hist_bytes_len;
  913|    653|	unsigned int i;
  914|    653|	pgp_blob_t *blob, *blob6e, *blob73, *blobfa;
  915|    653|	int handled_algos = 0;
  916|       |
  917|    653|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    653|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    653|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    653|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    653|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 653]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  918|       |
  919|       |	/* parse card capabilities from historical bytes in ATR */
  920|    653|	if (hist_bytes_len > 0) {
  ------------------
  |  Branch (920:6): [True: 107, False: 546]
  ------------------
  921|       |		/* category indicator 0x00, 0x10 or 0x80 => compact TLV (ISO) */
  922|    107|		switch (hist_bytes[0]) {
  ------------------
  |  Branch (922:11): [True: 53, False: 54]
  ------------------
  923|     32|			case 0x00:
  ------------------
  |  Branch (923:4): [True: 32, False: 75]
  ------------------
  924|     32|				if (hist_bytes_len > 4) {
  ------------------
  |  Branch (924:9): [True: 15, False: 17]
  ------------------
  925|     15|					pgp_parse_hist_bytes(card, hist_bytes+1, hist_bytes_len-4);
  926|     15|				}
  927|     32|				break;
  928|     17|			case 0x80:
  ------------------
  |  Branch (928:4): [True: 17, False: 90]
  ------------------
  929|     17|				if (hist_bytes_len > 1) {
  ------------------
  |  Branch (929:9): [True: 16, False: 1]
  ------------------
  930|     16|					pgp_parse_hist_bytes(card, hist_bytes+1, hist_bytes_len-1);
  931|     16|				}
  932|     17|				break;
  933|      4|			case 0x10:
  ------------------
  |  Branch (933:4): [True: 4, False: 103]
  ------------------
  934|      4|				if (hist_bytes_len > 2) {
  ------------------
  |  Branch (934:9): [True: 2, False: 2]
  ------------------
  935|      2|					pgp_parse_hist_bytes(card, hist_bytes+2, hist_bytes_len-2);
  936|      2|				}
  937|      4|				break;
  938|    107|		}
  939|    107|	}
  940|       |
  941|       |	/* v1.1 does not support lifecycle via ACTIVATE & TERMINATE: set default */
  942|    653|	priv->ext_caps &= ~EXT_CAP_LCS;
  943|       |
  944|    653|	if (priv->bcd_version >= OPENPGP_CARD_2_0) {
  ------------------
  |  Branch (944:6): [True: 414, False: 239]
  ------------------
  945|       |		/* get card capabilities from "historical bytes" DO */
  946|    414|		if ((pgp_get_blob(card, priv->mf, 0x5f52, &blob) >= 0) &&
  ------------------
  |  Branch (946:7): [True: 414, False: 0]
  ------------------
  947|    414|		    (blob->data != NULL) && (blob->data[0] == 0x00)) {
  ------------------
  |  Branch (947:7): [True: 45, False: 369]
  |  Branch (947:31): [True: 43, False: 2]
  ------------------
  948|       |
  949|     43|			if (blob->len > 4) {
  ------------------
  |  Branch (949:8): [True: 33, False: 10]
  ------------------
  950|     33|				pgp_parse_hist_bytes(card, blob->data+1, blob->len-4);
  951|     33|			}
  952|       |
  953|       |			/* get card status from historical bytes status indicator */
  954|     43|			if ((blob->data[0] == 0x00) && (blob->len >= 4)) {
  ------------------
  |  Branch (954:8): [True: 43, False: 0]
  |  Branch (954:35): [True: 34, False: 9]
  ------------------
  955|     34|				priv->state = blob->data[blob->len-3];
  956|       |				/* state not CARD_STATE_UNKNOWN => LCS supported */
  957|     34|				if (priv->state != CARD_STATE_UNKNOWN)
  ------------------
  |  Branch (957:9): [True: 27, False: 7]
  ------------------
  958|     27|					priv->ext_caps |= EXT_CAP_LCS;
  959|     34|			}
  960|     43|		}
  961|    414|	}
  962|       |
  963|    653|	if (priv->bcd_version >= OPENPGP_CARD_3_1) {
  ------------------
  |  Branch (963:6): [True: 379, False: 274]
  ------------------
  964|    379|		card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    379|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  965|    379|	}
  966|       |
  967|    653|	if (priv->bcd_version >= OPENPGP_CARD_3_4) {
  ------------------
  |  Branch (967:6): [True: 377, False: 276]
  ------------------
  968|       |		/* Parse supported algorithms from Algorithm Information DO
  969|       |		 * see OpenPGP card spec 3.4 section 4.4.3.11 */
  970|    377|		if (pgp_get_blob(card, priv->mf, 0x00fa, &blobfa) >= 0) {
  ------------------
  |  Branch (970:7): [True: 377, False: 0]
  ------------------
  971|    377|			pgp_blob_t *child;
  972|    377|			pgp_enumerate_blob(card, blobfa);
  973|       |			/* There will be multiple children with the same ID, but
  974|       |			 * different algos, so we need to iterate over all of them */
  975|  16.7k|			for (child = blobfa->files; child; child = child->next) {
  ------------------
  |  Branch (975:32): [True: 16.3k, False: 377]
  ------------------
  976|  16.3k|				if ((child->id < 0x00c1) || (child->id > 0x00c3))
  ------------------
  |  Branch (976:9): [True: 5.30k, False: 11.0k]
  |  Branch (976:33): [True: 1.42k, False: 9.65k]
  ------------------
  977|  6.72k|					continue;
  978|  9.65k|				sc_cardctl_openpgp_key_gen_store_info_t key_info;
  979|  9.65k|				if (pgp_parse_algo_attr_blob(card, child, &key_info) >= 0)
  ------------------
  |  Branch (979:9): [True: 849, False: 8.80k]
  ------------------
  980|    849|					handled_algos += _pgp_add_algo(card, &key_info, 0x00fa);
  981|  9.65k|			}
  982|    377|		}
  983|    377|	}
  984|       |
  985|       |	/* v1.1 & v2.x: special DOs are limited to 254 bytes */
  986|    653|	priv->max_specialDO_size = 254;
  987|       |
  988|    653|	if ((pgp_get_blob(card, priv->mf, 0x006e, &blob6e) >= 0) &&
  ------------------
  |  Branch (988:6): [True: 653, False: 0]
  ------------------
  989|    653|	    (pgp_get_blob(card, blob6e, 0x0073, &blob73) >= 0)) {
  ------------------
  |  Branch (989:6): [True: 97, False: 556]
  ------------------
  990|       |
  991|       |		/* get "extended capabilities" DO */
  992|     97|		if ((pgp_get_blob(card, blob73, 0x00c0, &blob) >= 0) &&
  ------------------
  |  Branch (992:7): [True: 55, False: 42]
  ------------------
  993|     55|		    (blob->data != NULL) && (blob->len > 0)) {
  ------------------
  |  Branch (993:7): [True: 53, False: 2]
  |  Branch (993:31): [True: 53, False: 0]
  ------------------
  994|     53|			if ((blob->data[0] & 0x01) && (priv->bcd_version >= OPENPGP_CARD_3_3)) {
  ------------------
  |  Branch (994:8): [True: 36, False: 17]
  |  Branch (994:34): [True: 29, False: 7]
  ------------------
  995|     29|				priv->ext_caps |= EXT_CAP_KDF_DO;
  996|     29|			}
  997|       |			/* v2.0+: bit 0x04 in first byte means "algorithm attributes changeable" */
  998|     53|			if ((blob->data[0] & 0x04) &&
  ------------------
  |  Branch (998:8): [True: 41, False: 12]
  ------------------
  999|     41|					(priv->bcd_version >= OPENPGP_CARD_2_0))
  ------------------
  |  Branch (999:6): [True: 28, False: 13]
  ------------------
 1000|     28|				priv->ext_caps |= EXT_CAP_ALG_ATTR_CHANGEABLE;
 1001|       |			/* bit 0x08 in first byte means "support for private use DOs" */
 1002|     53|			if (blob->data[0] & 0x08)
  ------------------
  |  Branch (1002:8): [True: 27, False: 26]
  ------------------
 1003|     27|				priv->ext_caps |= EXT_CAP_PRIVATE_DO;
 1004|       |			/* bit 0x10 in first byte means "support for CHV status byte changeable" */
 1005|     53|			if (blob->data[0] & 0x10)
  ------------------
  |  Branch (1005:8): [True: 30, False: 23]
  ------------------
 1006|     30|				priv->ext_caps |= EXT_CAP_C4_CHANGEABLE;
 1007|       |			/* bit 0x20 in first byte means "support for Key Import" */
 1008|     53|			if (blob->data[0] & 0x20)
  ------------------
  |  Branch (1008:8): [True: 26, False: 27]
  ------------------
 1009|     26|				priv->ext_caps |= EXT_CAP_KEY_IMPORT;
 1010|       |			/* bit 0x40 in first byte means "support for Get Challenge" */
 1011|     53|			if (blob->data[0] & 0x40) {
  ------------------
  |  Branch (1011:8): [True: 34, False: 19]
  ------------------
 1012|     34|				card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|     34|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
 1013|     34|				priv->ext_caps |= EXT_CAP_GET_CHALLENGE;
 1014|     34|			}
 1015|       |			/* v2.0+: bit 0x80 in first byte means "support Secure Messaging" */
 1016|     53|			if ((blob->data[0] & 0x80) &&
  ------------------
  |  Branch (1016:8): [True: 35, False: 18]
  ------------------
 1017|     35|					(priv->bcd_version >= OPENPGP_CARD_2_0))
  ------------------
  |  Branch (1017:6): [True: 22, False: 13]
  ------------------
 1018|     22|				priv->ext_caps |= EXT_CAP_SM;
 1019|       |
 1020|     53|			if ((priv->bcd_version >= OPENPGP_CARD_2_0) && (blob->len >= 10)) {
  ------------------
  |  Branch (1020:8): [True: 39, False: 14]
  |  Branch (1020:51): [True: 18, False: 21]
  ------------------
 1021|       |				/* v2.0+: max. challenge size is at bytes 3-4 */
 1022|     18|				priv->max_challenge_size = bebytes2ushort(blob->data + 2);
 1023|       |				/* v2.0+: max. cert size it at bytes 5-6 */
 1024|     18|				priv->max_cert_size = bebytes2ushort(blob->data + 4);
 1025|       |
 1026|     18|				if (priv->bcd_version < OPENPGP_CARD_3_0) {
  ------------------
  |  Branch (1026:9): [True: 6, False: 12]
  ------------------
 1027|       |					/* v2.x: SM algorithm is at byte 2: 0 == 3DES */
 1028|      6|					priv->sm_algo = blob->data[1];
 1029|      6|					if ((priv->sm_algo == SM_ALGO_NONE) && (priv->ext_caps & EXT_CAP_SM))
  ------------------
  |  Branch (1029:10): [True: 3, False: 3]
  |  Branch (1029:45): [True: 1, False: 2]
  ------------------
 1030|      1|						priv->sm_algo = SM_ALGO_3DES;
 1031|       |
 1032|       |					/* v2.x: max. send/receive sizes are at bytes 7-8 resp. 9-10 */
 1033|      6|					card->max_send_size = bebytes2ushort(blob->data + 6);
 1034|      6|					card->max_recv_size = bebytes2ushort(blob->data + 8);
 1035|      6|				}
 1036|     12|				else {
 1037|       |					/* v3.0+: SM algorithm is at byte 2: 0 == UNKNOWN */
 1038|     12|					priv->sm_algo = blob->data[1];
 1039|     12|					if ((priv->sm_algo == SM_ALGO_NONE) && (priv->ext_caps & EXT_CAP_SM))
  ------------------
  |  Branch (1039:10): [True: 6, False: 6]
  |  Branch (1039:45): [True: 5, False: 1]
  ------------------
 1040|      5|						priv->sm_algo = SM_ALGO_UNKNOWN;
 1041|       |
 1042|       |					/* v3.0+: max. size of special DOs is at bytes 7-8 */
 1043|     12|					priv->max_specialDO_size = bebytes2ushort(blob->data + 6);
 1044|     12|				}
 1045|     18|				if (priv->bcd_version >= OPENPGP_CARD_3_3 && (blob->len >= 10)) {
  ------------------
  |  Branch (1045:9): [True: 12, False: 6]
  |  Branch (1045:50): [True: 12, False: 0]
  ------------------
 1046|       |					/* v3.3+: MSE for key numbers 2(DEC) and 3(AUT) supported */
 1047|     12|					if (blob->data[9])
  ------------------
  |  Branch (1047:10): [True: 9, False: 3]
  ------------------
 1048|      9|						priv->ext_caps |= EXT_CAP_MSE;
 1049|     12|				}
 1050|     18|			}
 1051|     53|		}
 1052|       |
 1053|       |		/* get max. PIN length from "CHV status bytes" DO */
 1054|     97|		if ((pgp_get_blob(card, blob73, 0x00c4, &blob) >= 0) &&
  ------------------
  |  Branch (1054:7): [True: 24, False: 73]
  ------------------
 1055|     24|			(blob->data != NULL) && (blob->len > 1)) {
  ------------------
  |  Branch (1055:4): [True: 6, False: 18]
  |  Branch (1055:28): [True: 5, False: 1]
  ------------------
 1056|       |			/* 2nd byte in "CHV status bytes" DO means "max. PIN length" */
 1057|      5|			card->max_pin_len = blob->data[1];
 1058|      5|		}
 1059|       |
 1060|     97|		if (priv->bcd_version >= OPENPGP_CARD_3_0) {
  ------------------
  |  Branch (1060:7): [True: 54, False: 43]
  ------------------
 1061|       |			/* v3.0+: get length info from "extended length information" DO */
 1062|     54|			if ((pgp_get_blob(card, blob6e, 0x7f66, &blob) >= 0) &&
  ------------------
  |  Branch (1062:8): [True: 0, False: 54]
  ------------------
 1063|      0|				(blob->data != NULL) && (blob->len >= 8)) {
  ------------------
  |  Branch (1063:5): [True: 0, False: 0]
  |  Branch (1063:29): [True: 0, False: 0]
  ------------------
 1064|       |				/* kludge: treat as SIMPLE DO and use appropriate offsets */
 1065|      0|				card->max_send_size = bebytes2ushort(blob->data + 2);
 1066|      0|				card->max_recv_size = bebytes2ushort(blob->data + 6);
 1067|      0|			}
 1068|     54|		}
 1069|       |
 1070|     97|#ifdef ENABLE_OPENSSL
 1071|     97|		if (priv->ext_caps & EXT_CAP_KDF_DO) {
  ------------------
  |  Branch (1071:7): [True: 29, False: 68]
  ------------------
 1072|     29|			int r = pgp_decode_kdf_do(card, priv);
 1073|     29|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     29|#define SC_SUCCESS				0
  ------------------
  |  Branch (1073:8): [True: 27, False: 2]
  ------------------
 1074|     27|				sc_log(card->ctx, "Failed to decode KDF DO: %s", sc_strerror(r));
  ------------------
  |  |   71|     27|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1075|     27|			}
 1076|     29|		}
 1077|     97|#endif /* ENABLE_OPENSSL */
 1078|       |
 1079|       |		/* if we found at least one usable algo, let's skip other ways to find them */
 1080|     97|		if (handled_algos) {
  ------------------
  |  Branch (1080:7): [True: 1, False: 96]
  ------------------
 1081|      1|			sc_log(card->ctx, "Algo list populated from Algorithm Information DO");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1082|      1|			LOG_FUNC_RETURN(card->ctx, handled_algos);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|      1|	} else { \
  |  |  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      1|	} \
  |  |  |  |  162|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1083|      1|		}
 1084|       |
 1085|       |		/* get _current_ algorithms & key lengths from "algorithm attributes" DOs
 1086|       |		 *
 1087|       |		 * All available algorithms should be already provided by pgp_init. However, if another
 1088|       |		 * algorithm is found in the "algorithm attributes" DOs, it is supported by the card as
 1089|       |		 * well and therefore added
 1090|       |		 * see OpenPGP card spec 1.1 & 2.x section 4.3.3.6 / v3.x section 4.4.3.7 */
 1091|    384|		for (i = 0x00c1; i <= 0x00c3; i++) {
  ------------------
  |  Branch (1091:20): [True: 288, False: 96]
  ------------------
 1092|    288|			sc_cardctl_openpgp_key_gen_store_info_t key_info;
 1093|       |
 1094|    288|			sc_log(card->ctx, "Parsing algorithm attributes DO %uX" , i);
  ------------------
  |  |   71|    288|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1095|       |
 1096|       |			/* OpenPGP card spec 1.1 & 2.x section 4.3.3.6 / v3.x section 4.4.3.7 */
 1097|    288|			if ((pgp_get_blob(card, blob73, i, &blob) >= 0) &&
  ------------------
  |  Branch (1097:8): [True: 14, False: 274]
  ------------------
 1098|     14|			    (pgp_parse_algo_attr_blob(card, blob, &key_info) >= 0)) {
  ------------------
  |  Branch (1098:8): [True: 3, False: 11]
  ------------------
 1099|      3|				if (!_pgp_add_algo(card, &key_info, i))
  ------------------
  |  Branch (1099:9): [True: 0, False: 3]
  ------------------
 1100|      3|					LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "Cannot add algorithm");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1101|      3|			}
 1102|    288|		}
 1103|       |
 1104|     96|	}
 1105|       |
 1106|    652|	LOG_FUNC_RETURN(card->ctx, handled_algos);
  ------------------
  |  |  164|    652|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    652|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    652|	int _ret = r; \
  |  |  |  |  155|    652|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 602, False: 50]
  |  |  |  |  ------------------
  |  |  |  |  156|    602|		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: 602]
  |  |  |  |  ------------------
  |  |  |  |  157|    602|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    602|	} else { \
  |  |  |  |  159|     50|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     50|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     50|	} \
  |  |  |  |  162|    652|	return _ret; \
  |  |  |  |  163|    652|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1107|    652|}
card-openpgp.c:pgp_parse_hist_bytes:
  604|     66|{
  605|     66|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|     66|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  606|     66|	const u8 *ptr;
  607|       |
  608|       |	/* IS07816-4 hist bytes: 3rd function table */
  609|     66|	if ((ptr = sc_compacttlv_find_tag(ctlv, ctlv_len, 0x73, NULL)) != NULL) {
  ------------------
  |  Branch (609:6): [True: 25, False: 41]
  ------------------
  610|       |		/* bit 0x40 in byte 3 of TL 0x73 means "extended Le/Lc" */
  611|     25|		if (ptr[2] & 0x40) {
  ------------------
  |  Branch (611:7): [True: 15, False: 10]
  ------------------
  612|     15|			card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|     15|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  613|     15|			priv->ext_caps |= EXT_CAP_APDU_EXT;
  614|     15|		}
  615|       |		/* bit 0x80 in byte 3 of TL 0x73 means "Command chaining" */
  616|     25|		if (ptr[2] & 0x80) {
  ------------------
  |  Branch (616:7): [True: 17, False: 8]
  ------------------
  617|     17|			priv->ext_caps |= EXT_CAP_CHAINING;
  618|     17|		}
  619|     25|	}
  620|       |
  621|     66|	if ((priv->bcd_version >= OPENPGP_CARD_3_0) &&
  ------------------
  |  Branch (621:6): [True: 39, False: 27]
  ------------------
  622|     39|	    ((ptr = sc_compacttlv_find_tag(ctlv, ctlv_len, 0x31, NULL)) != NULL)) {
  ------------------
  |  Branch (622:6): [True: 12, False: 27]
  ------------------
  623|       |		// ToDo ...
  624|     12|	}
  625|     66|}
card-openpgp.c:pgp_decode_kdf_do:
  805|     29|{
  806|     29|	pgp_pin_kdf_info_t *pin_kdf_info = (pgp_pin_kdf_info_t *)calloc(1, sizeof(pgp_pin_kdf_info_t));
  807|     29|	int r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|     29|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  808|     29|	pgp_blob_t *kdf_blob;
  809|     29|	const uint8_t *data;
  810|     29|	size_t data_len;
  811|     29|	size_t tag_len;
  812|     29|	const uint8_t *p;
  813|     29|	pgp_blob_t *blob;
  814|       |
  815|     29|	if (!pin_kdf_info) {
  ------------------
  |  Branch (815:6): [True: 0, False: 29]
  ------------------
  816|      0|		return r;
  817|      0|	}
  818|       |
  819|     29|	r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     29|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  820|     29|	priv->pin_kdf_info = NULL;
  821|     29|	if ((pgp_get_blob(card, priv->mf, DO_KDF, &kdf_blob) != SC_SUCCESS) || (kdf_blob->len < 3)) {
  ------------------
  |  |  159|     29|#define DO_KDF                   0xf9
  ------------------
              	if ((pgp_get_blob(card, priv->mf, DO_KDF, &kdf_blob) != SC_SUCCESS) || (kdf_blob->len < 3)) {
  ------------------
  |  |   28|     29|#define SC_SUCCESS				0
  ------------------
  |  Branch (821:6): [True: 0, False: 29]
  |  Branch (821:73): [True: 15, False: 14]
  ------------------
  822|     15|		sc_log(card->ctx, "KDF DO does not exists or contains invalid data but card claims to support it");
  ------------------
  |  |   71|     15|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  823|     15|		goto out;
  824|     15|	}
  825|       |
  826|     14|	data = kdf_blob->data;
  827|     14|	data_len = kdf_blob->len;
  828|     14|	p = sc_asn1_find_tag(card->ctx, data, data_len, 0x81, &tag_len);
  829|     14|	if (!p) {
  ------------------
  |  Branch (829:6): [True: 1, False: 13]
  ------------------
  830|      1|		sc_log(card->ctx, "KDF algorithm byte not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  831|      1|		goto out;
  832|      1|	}
  833|     13|	if (tag_len != 1) {
  ------------------
  |  Branch (833:6): [True: 1, False: 12]
  ------------------
  834|      1|		sc_log(card->ctx, "Unexpected KDF algorithm byte length, expects 1, got %zu", tag_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  835|      1|		goto out;
  836|      1|	}
  837|       |
  838|     12|	if (*p != 0x3) {
  ------------------
  |  Branch (838:6): [True: 2, False: 10]
  ------------------
  839|      2|		if (*p == 0x0) {
  ------------------
  |  Branch (839:7): [True: 1, False: 1]
  ------------------
  840|      1|			r = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  841|      1|			sc_log(card->ctx, "KDF derived PIN format disabled");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  842|      1|		} else {
  843|      1|			sc_log(card->ctx, "Unknown KDF algorithm ID %x", *p);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  844|      1|		}
  845|      2|		goto out;
  846|      2|	}
  847|       |
  848|     10|	p = sc_asn1_find_tag(card->ctx, data, data_len, 0x82, &tag_len);
  849|     10|	if (!p) {
  ------------------
  |  Branch (849:6): [True: 1, False: 9]
  ------------------
  850|      1|		sc_log(card->ctx, "KDF hash algorithm byte not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  851|      1|		goto out;
  852|      1|	}
  853|      9|	if (tag_len != 1) {
  ------------------
  |  Branch (853:6): [True: 1, False: 8]
  ------------------
  854|      1|		sc_log(card->ctx, "Unexpected KDF hash algorithm byte length, expects 1, got %zu", tag_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  855|      1|		goto out;
  856|      1|	}
  857|       |
  858|      8|	switch (*p) {
  859|      6|	case 0x08:
  ------------------
  |  Branch (859:2): [True: 6, False: 2]
  ------------------
  860|      6|		pin_kdf_info->hash_algo = "SHA256";
  861|      6|		break;
  862|      1|	case 0x0A:
  ------------------
  |  Branch (862:2): [True: 1, False: 7]
  ------------------
  863|      1|		pin_kdf_info->hash_algo = "SHA512";
  864|      1|		break;
  865|      1|	default:
  ------------------
  |  Branch (865:2): [True: 1, False: 7]
  ------------------
  866|      1|		sc_log(card->ctx, "Unknown KDF hash algorithm ID %x", *p);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  867|      1|		goto out;
  868|      8|	}
  869|       |
  870|      7|	p = sc_asn1_find_tag(card->ctx, data, data_len, 0x83, &tag_len);
  871|      7|	if (!p) {
  ------------------
  |  Branch (871:6): [True: 2, False: 5]
  ------------------
  872|      2|		sc_log(card->ctx, "KDF iteration count not found");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  873|      2|		goto out;
  874|      2|	}
  875|      5|	if (tag_len != 4) {
  ------------------
  |  Branch (875:6): [True: 1, False: 4]
  ------------------
  876|      1|		sc_log(card->ctx, "Unexpected KDF iteration count length, expects 4, got %zu", tag_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  877|      1|		goto out;
  878|      1|	}
  879|      4|	pin_kdf_info->iterations = (uint32_t)bebytes2ulong(p);
  880|       |
  881|      4|	r = pgp_get_blob(card, kdf_blob, 0x84, &blob);
  882|      4|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  |  Branch (882:6): [True: 2, False: 2]
  ------------------
  883|      2|		sc_log(card->ctx, "Failed to get salt bytes of user password");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  884|      2|		goto out;
  885|      2|	}
  886|      2|	pin_kdf_info->userpw_salt = blob;
  887|       |
  888|      2|	r = pgp_get_blob(card, kdf_blob, 0x86, &blob);
  889|      2|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
  |  Branch (889:6): [True: 1, False: 1]
  ------------------
  890|      1|		sc_log(card->ctx, "Failed to get salt bytes of admin password");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  891|      1|		goto out;
  892|      1|	}
  893|      1|	pin_kdf_info->adminpw_salt = blob;
  894|       |
  895|      1|	sc_log(card->ctx, "KDF derived PIN format enabled");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  896|      1|	priv->pin_kdf_info = pin_kdf_info;
  897|      1|	return r;
  898|     28|out:
  899|     28|	free(pin_kdf_info);
  900|     28|	return r;
  901|      2|}
card-openpgp.c:pgp_finish:
 1115|    678|{
 1116|    678|	if (card != NULL) {
  ------------------
  |  Branch (1116:6): [True: 678, False: 0]
  ------------------
 1117|    678|		struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    678|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1118|       |
 1119|    678|		if (priv != NULL) {
  ------------------
  |  Branch (1119:7): [True: 678, False: 0]
  ------------------
 1120|       |			/* delete fake file hierarchy */
 1121|    678|			pgp_free_blobs(priv->mf);
 1122|       |
 1123|       |			/* delete kdf do related data if exists */
 1124|    678|			free(priv->pin_kdf_info);
 1125|       |
 1126|       |			/* delete private data */
 1127|    678|			free(priv);
 1128|    678|		}
 1129|    678|		card->drv_data = NULL;
 1130|    678|	}
 1131|    678|	return SC_SUCCESS;
  ------------------
  |  |   28|    678|#define SC_SUCCESS				0
  ------------------
 1132|    678|}
card-openpgp.c:pgp_free_blobs:
 1328|  37.6k|{
 1329|  37.6k|	if (blob) {
  ------------------
  |  Branch (1329:6): [True: 37.6k, False: 25]
  ------------------
 1330|  37.6k|		pgp_blob_t *child = blob->files;
 1331|       |
 1332|  74.5k|		while (child != NULL) {
  ------------------
  |  Branch (1332:10): [True: 36.9k, False: 37.6k]
  ------------------
 1333|  36.9k|			pgp_blob_t *next = child->next;
 1334|       |
 1335|  36.9k|			pgp_free_blobs(child);
 1336|  36.9k|			child = next;
 1337|  36.9k|		}
 1338|  37.6k|		pgp_free_blob(blob);
 1339|  37.6k|	}
 1340|  37.6k|}
card-openpgp.c:pgp_free_blob:
 1303|  37.6k|{
 1304|  37.6k|	if (blob) {
  ------------------
  |  Branch (1304:6): [True: 37.6k, False: 0]
  ------------------
 1305|  37.6k|		if (blob->parent) {
  ------------------
  |  Branch (1305:7): [True: 36.9k, False: 653]
  ------------------
 1306|  36.9k|			pgp_blob_t **p;
 1307|       |
 1308|       |			/* remove blob from list of parent's children */
 1309|  36.9k|			for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next)
  ------------------
  |  Branch (1309:35): [True: 36.9k, False: 0]
  |  Branch (1309:49): [True: 0, False: 36.9k]
  ------------------
 1310|      0|				;
 1311|  36.9k|			if (*p == blob)
  ------------------
  |  Branch (1311:8): [True: 36.9k, False: 0]
  ------------------
 1312|  36.9k|				*p = blob->next;
 1313|  36.9k|		}
 1314|       |
 1315|  37.6k|		sc_file_free(blob->file);
 1316|  37.6k|		if (blob->data)
  ------------------
  |  Branch (1316:7): [True: 10.5k, False: 27.0k]
  ------------------
 1317|  10.5k|			free(blob->data);
 1318|  37.6k|		free(blob);
 1319|  37.6k|	}
 1320|  37.6k|}
card-openpgp.c:pgp_select_file:
 1614|  4.06k|{
 1615|  4.06k|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  4.06k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1616|  4.06k|	pgp_blob_t	*blob;
 1617|  4.06k|	unsigned int	path_start = 0;
 1618|  4.06k|	unsigned int	n;
 1619|  4.06k|	sc_path_t dummy_path;
 1620|       |
 1621|  4.06k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  4.06k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.06k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.06k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.06k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1622|       |
 1623|  4.06k|	if (path->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  4.06k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1623:6): [True: 1.36k, False: 2.69k]
  ------------------
 1624|  4.06k|		LOG_FUNC_RETURN(card->ctx, iso_ops->select_file(card, path, ret));
  ------------------
  |  |  164|  1.36k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.36k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.36k|	int _ret = r; \
  |  |  |  |  155|  1.36k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.36k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.36k|		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|  1.23k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.23k, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.36k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.36k|	} 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|  1.36k|	return _ret; \
  |  |  |  |  163|  1.36k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1625|       |
 1626|  2.69k|	if (path->len < 2 || (path->len & 1))
  ------------------
  |  Branch (1626:6): [True: 0, False: 2.69k]
  |  Branch (1626:23): [True: 0, False: 2.69k]
  ------------------
 1627|  2.69k|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|  2.69k|				"invalid path length");
 1629|       |
 1630|  2.69k|	if (path->type == SC_PATH_TYPE_FILE_ID && path->len != 2)
  ------------------
  |  |  117|  5.39k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1630:6): [True: 0, False: 2.69k]
  |  Branch (1630:44): [True: 0, False: 0]
  ------------------
 1631|  2.69k|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1632|  2.69k|				"invalid path type");
 1633|       |
 1634|       |	/* Due to pkcs15init implementation, sometimes a file at path "11001101"
 1635|       |	 * need to be written (one use case is when importing key&cert from p12 file).
 1636|       |	 * This file does not exist in OpenPGP but pkcs15 requires that
 1637|       |	 * writing this file must be successful.
 1638|       |	 * So, we pretend that selecting & writing this file is successful.
 1639|       |	 * The "11001101"is defined in sc_pkcs15emu_get_df() function, pkcs15-sync.c file. */
 1640|  2.69k|	sc_format_path("11001101", &dummy_path);
 1641|  2.69k|	if (sc_compare_path(path, &dummy_path)) {
  ------------------
  |  Branch (1641:6): [True: 0, False: 2.69k]
  ------------------
 1642|      0|		if (ret != NULL) {
  ------------------
  |  Branch (1642:7): [True: 0, False: 0]
  ------------------
 1643|      0|			*ret = sc_file_new();
 1644|       |			/* One use case of this dummy file is after writing certificate in pkcs15init.
 1645|       |			 * So we set its size to be the same as max certificate size the card supports. */
 1646|      0|			(*ret)->size = priv->max_cert_size;
 1647|      0|		}
 1648|      0|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1649|      0|	}
 1650|       |
 1651|       |	/* ignore explicitly mentioned MF at the path's beginning */
 1652|  2.69k|	path_start = pgp_strip_path(card, path);
 1653|       |
 1654|       |	/* starting with the MF ... */
 1655|  2.69k|	blob = priv->mf;
 1656|       |	/* ... recurse through the tree following the path */
 1657|  3.47k|	for (n = path_start; n < path->len; n += 2) {
  ------------------
  |  Branch (1657:23): [True: 2.76k, False: 707]
  ------------------
 1658|  2.76k|		unsigned int	id = bebytes2ushort(path->value + n);
 1659|  2.76k|		int		r = pgp_get_blob(card, blob, id, &blob);
 1660|       |
 1661|       |		/* This file ID is referred when importing key&certificate via pkcs15init, like above.
 1662|       |		 * We pretend to successfully find this inexistent file. */
 1663|  2.76k|		if (id == 0x4402 || id == 0x5f48) {
  ------------------
  |  Branch (1663:7): [True: 0, False: 2.76k]
  |  Branch (1663:23): [True: 0, False: 2.76k]
  ------------------
 1664|      0|			if (ret == NULL)
  ------------------
  |  Branch (1664:8): [True: 0, False: 0]
  ------------------
 1665|       |				/* No need to return file */
 1666|      0|				LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1667|       |
 1668|       |			/* Else, need to return file */
 1669|      0|			*ret = sc_file_new();
 1670|      0|			(*ret)->size = priv->max_cert_size;
 1671|      0|			LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1672|      0|		}
 1673|       |
 1674|  2.76k|		if (r < 0) {	/* failure */
  ------------------
  |  Branch (1674:7): [True: 1.98k, False: 777]
  ------------------
 1675|  1.98k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.98k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.98k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.98k|	int _ret = r; \
  |  |  |  |  155|  1.98k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.98k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.98k|		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|  1.98k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.98k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.98k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.98k|	} 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|  1.98k|	return _ret; \
  |  |  |  |  163|  1.98k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1676|  1.98k|		}
 1677|  2.76k|	}
 1678|       |
 1679|       |	/* success: select file = set "current" pointer to blob found */
 1680|    707|	priv->current = blob;
 1681|       |
 1682|    707|	if (ret)
  ------------------
  |  Branch (1682:6): [True: 60, False: 647]
  ------------------
 1683|     60|		sc_file_dup(ret, blob->file);
 1684|       |
 1685|    707|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    707|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    707|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    707|	int _ret = r; \
  |  |  |  |  155|    707|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 707, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    707|		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: 707]
  |  |  |  |  ------------------
  |  |  |  |  157|    707|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    707|	} 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|    707|	return _ret; \
  |  |  |  |  163|    707|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1686|    707|}
card-openpgp.c:pgp_strip_path:
 1595|  2.69k|{
 1596|  2.69k|	unsigned int start_point = 0;
 1597|       |	/* start_point will move through the path string */
 1598|  2.69k|	if (path->len == 0)
  ------------------
  |  Branch (1598:6): [True: 0, False: 2.69k]
  ------------------
 1599|      0|		return 0;
 1600|       |
 1601|       |	/* ignore 3F00 (MF) at the beginning */
 1602|  2.69k|	start_point = (memcmp(path->value, "\x3f\x00", 2) == 0) ? 2 : 0;
  ------------------
  |  Branch (1602:16): [True: 1.96k, False: 735]
  ------------------
 1603|       |	/* strip path of PKCS15-App DF (5015) */
 1604|  2.69k|	start_point += (memcmp(path->value + start_point, "\x50\x15", 2) == 0) ? 2 : 0;
  ------------------
  |  Branch (1604:17): [True: 1.30k, False: 1.38k]
  ------------------
 1605|  2.69k|	return start_point;
 1606|  2.69k|}
card-openpgp.c:pgp_get_challenge:
 1731|    242|{
 1732|    242|	struct pgp_priv_data *priv;
 1733|       |
 1734|    242|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    242|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    242|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    242|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    242|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 242]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1735|       |
 1736|    242|	priv = DRVDATA(card);
  ------------------
  |  |  189|    242|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1737|    242|	if (0 == (priv->ext_caps & EXT_CAP_GET_CHALLENGE)) {
  ------------------
  |  Branch (1737:6): [True: 22, False: 220]
  ------------------
 1738|     22|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     22|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     22|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     22|	int _ret = r; \
  |  |  |  |  155|     22|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 22, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     22|		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|     22|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 22, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     22|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     22|	} 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|     22|	return _ret; \
  |  |  |  |  163|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1739|     22|	}
 1740|       |
 1741|    220|	if (priv->max_challenge_size > 0 && len > priv->max_challenge_size) {
  ------------------
  |  Branch (1741:6): [True: 0, False: 220]
  |  Branch (1741:38): [True: 0, False: 0]
  ------------------
 1742|      0|		len = priv->max_challenge_size;
 1743|      0|	}
 1744|       |
 1745|    220|	LOG_FUNC_RETURN(card->ctx, iso_ops->get_challenge(card, rnd, len));
  ------------------
  |  |  164|    220|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    220|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    220|	int _ret = r; \
  |  |  |  |  155|    220|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11, False: 209]
  |  |  |  |  ------------------
  |  |  |  |  156|     11|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|     11|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    209|	} else { \
  |  |  |  |  159|    209|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    209|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    209|	} \
  |  |  |  |  162|    220|	return _ret; \
  |  |  |  |  163|    220|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1746|    220|}
card-openpgp.c:pgp_read_binary:
 1755|     20|{
 1756|     20|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|     20|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1757|     20|	pgp_blob_t	*blob;
 1758|     20|	int		r;
 1759|       |
 1760|     20|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     20|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     20|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     20|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     20|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1761|       |
 1762|       |	/* jump to selected file */
 1763|     20|	blob = priv->current;
 1764|       |
 1765|     20|	if (blob == NULL)
  ------------------
  |  Branch (1765:6): [True: 0, False: 20]
  ------------------
 1766|     20|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1767|       |
 1768|     20|	if (blob->file->type != SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|     20|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (1768:6): [True: 0, False: 20]
  ------------------
 1769|     20|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1770|       |
 1771|     20|	if ((r = pgp_read_blob(card, blob)) < 0)
  ------------------
  |  Branch (1771:6): [True: 0, False: 20]
  ------------------
 1772|     20|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1773|       |
 1774|     20|	if (idx > blob->len)
  ------------------
  |  Branch (1774:6): [True: 0, False: 20]
  ------------------
 1775|     20|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1776|       |
 1777|     20|	if (idx + count > blob->len)
  ------------------
  |  Branch (1777:6): [True: 0, False: 20]
  ------------------
 1778|      0|		count = blob->len - idx;
 1779|     20|	memcpy(buf, blob->data + idx, count);
 1780|       |
 1781|     20|	LOG_FUNC_RETURN(card->ctx, (int)count);
  ------------------
  |  |  164|     20|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     20|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     20|	int _ret = r; \
  |  |  |  |  155|     20|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  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|     20|	} else { \
  |  |  |  |  159|     20|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     20|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     20|	} \
  |  |  |  |  162|     20|	return _ret; \
  |  |  |  |  163|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1782|     20|}
card-openpgp.c:pgp_pin_cmd:
 2388|     96|{
 2389|     96|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|     96|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 2390|     96|	struct sc_card_operations ops = {.pin_cmd = iso_ops->pin_cmd};
 2391|       |
 2392|     96|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     96|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     96|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     96|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     96|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2393|       |
 2394|     96|	if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|     96|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (2394:6): [True: 0, False: 96]
  ------------------
 2395|     96|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2396|     96|				"invalid PIN type");
 2397|       |
 2398|       |	/* In general, the PIN Reference is extracted from the key-id,
 2399|       |	 * for example, CHV0 -> Ref=0, CHV1 -> Ref=1.
 2400|       |	 * However, in the case of OpenPGP, the PIN Ref to compose APDU
 2401|       |	 * must be 81, 82, 83.
 2402|       |	 * So, if we receive Ref=1, Ref=2, we must convert to 81, 82...
 2403|       |	 * In OpenPGP v1, the PINs are named CHV1, CHV2, CHV3.
 2404|       |	 * In v2, they are named PW1, PW3 (PW1 operates in 2 modes).
 2405|       |	 *
 2406|       |	 * The PIN references (P2 in APDU) for "VERIFY" are the same in both versions:
 2407|       |	 * 81 (CHV1 or PW1), 82 (CHV2 or PW1-mode 2), 83 (CHV3 or PW3),
 2408|       |	 * On the other hand from version 2.0 "CHANGE REFERENCE DATA" and
 2409|       |	 * "RESET RETRY COUNTER" don't support PW1-mode 2 (82) and need this
 2410|       |	 * value changed to PW1 (81).
 2411|       |	 * Both of these commands also differ between card versions in that
 2412|       |	 * v1 cards can use only implicit old PIN or CHV3 test for both commands
 2413|       |	 * whereas v2 can use both implicit (for PW3) and explicit
 2414|       |	 * (for special "Resetting Code") PIN test for "RESET RETRY COUNTER"
 2415|       |	 * and only explicit test for "CHANGE REFERENCE DATA".
 2416|       |	 *
 2417|       |	 * Note that if this function is called from sc_pkcs15_verify_pin() in pkcs15-pin.c,
 2418|       |	 * the Ref is already 81, 82, 83.
 2419|       |	 */
 2420|       |
 2421|       |	/* convert the PIN Reference if needed */
 2422|     96|	data->pin_reference |= 0x80;
 2423|       |
 2424|       |	/* check version-dependent constraints */
 2425|     96|	if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  416|    192|#define SC_PIN_CMD_CHANGE	1
  ------------------
              	if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  417|     86|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2425:6): [True: 10, False: 86]
  |  Branch (2425:40): [True: 0, False: 86]
  ------------------
 2426|     10|		if (priv->bcd_version >= OPENPGP_CARD_2_0) {
  ------------------
  |  Branch (2426:7): [True: 9, False: 1]
  ------------------
 2427|      9|			if (data->pin_reference == 0x82)
  ------------------
  |  Branch (2427:8): [True: 9, False: 0]
  ------------------
 2428|      9|				data->pin_reference = 0x81;
 2429|       |
 2430|      9|			if (data->cmd == SC_PIN_CMD_CHANGE) {
  ------------------
  |  |  416|      9|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (2430:8): [True: 9, False: 0]
  ------------------
 2431|      9|				if (data->pin1.len == 0 &&
  ------------------
  |  Branch (2431:9): [True: 0, False: 9]
  ------------------
 2432|      0|				    !(data->flags & SC_PIN_CMD_USE_PINPAD))
  ------------------
  |  |  421|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (2432:9): [True: 0, False: 0]
  ------------------
 2433|      9|					LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2434|      9|							"v2 cards don't support implicit old PIN for PIN change");
 2435|       |
 2436|      9|				data->flags &= ~SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  423|      9|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
 2437|      9|			}
 2438|      9|		} else {
 2439|      1|			if (data->pin1.len != 0) {
  ------------------
  |  Branch (2439:8): [True: 1, False: 0]
  ------------------
 2440|      1|				sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2441|      1|				       "v1 cards don't support explicit old or CHV3 PIN, PIN ignored.");
 2442|      1|				sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2443|      1|				       "please make sure that you have verified the relevant PIN first.");
 2444|      1|				data->pin1.len = 0;
 2445|      1|			}
 2446|       |
 2447|      1|			data->flags |= SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  423|      1|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
 2448|      1|		}
 2449|     10|	}
 2450|       |
 2451|     96|	if (data->cmd == SC_PIN_CMD_UNBLOCK && data->pin2.len == 0 &&
  ------------------
  |  |  417|    192|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2451:6): [True: 0, False: 96]
  |  Branch (2451:41): [True: 0, False: 0]
  ------------------
 2452|      0|	    !(data->flags & SC_PIN_CMD_USE_PINPAD))
  ------------------
  |  |  421|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (2452:6): [True: 0, False: 0]
  ------------------
 2453|     96|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2454|     96|				"new PIN must be provided for unblock operation");
 2455|       |
 2456|       |	/* ensure pin_reference is 81, 82, 83 */
 2457|     96|	if (data->pin_reference < 0x81 || data->pin_reference > 0x83)
  ------------------
  |  Branch (2457:6): [True: 0, False: 96]
  |  Branch (2457:36): [True: 0, False: 96]
  ------------------
 2458|     96|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2459|     96|				"Invalid key ID; must be 1, 2, or 3");
 2460|       |
 2461|       |	/* emulate SC_PIN_CMD_GET_INFO command for cards not supporting it */
 2462|     96|	if (data->cmd == SC_PIN_CMD_GET_INFO && (card->caps & SC_CARD_CAP_ISO7816_PIN_INFO) == 0) {
  ------------------
  |  |  418|    192|#define SC_PIN_CMD_GET_INFO	3
  ------------------
              	if (data->cmd == SC_PIN_CMD_GET_INFO && (card->caps & SC_CARD_CAP_ISO7816_PIN_INFO) == 0) {
  ------------------
  |  |  553|     77|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  |  Branch (2462:6): [True: 77, False: 19]
  |  Branch (2462:42): [True: 26, False: 51]
  ------------------
 2463|     26|		u8 c4data[10];
 2464|     26|		int r;
 2465|       |
 2466|     26|		r = sc_get_data(card, 0x00c4, c4data, sizeof(c4data));
 2467|     26|		LOG_TEST_RET(card->ctx, r, "reading CHV status bytes failed");
  ------------------
  |  |  174|     26|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     26|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     26|	int _ret = (r); \
  |  |  |  |  168|     26|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2468|       |
 2469|     16|		if (r != 7)
  ------------------
  |  Branch (2469:7): [True: 10, False: 6]
  ------------------
 2470|     16|			LOG_TEST_RET(card->ctx, SC_ERROR_OBJECT_NOT_VALID,
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2471|      6|				"CHV status bytes have unexpected length");
 2472|       |
 2473|       |		/* The definition of fields of DO C4 changed between OpenPGP
 2474|       |		 * card specification v1.1 and v2.0. There is no longer a separate
 2475|       |		 * CHV2 retry counter but only one retry counter for both PW1 mode 1
 2476|       |		 * and mode 2 at byte 5 (count from 1) of the DO.
 2477|       |		 */
 2478|      6|		if (priv->bcd_version >= OPENPGP_CARD_2_0 && data->pin_reference == 0x82)
  ------------------
  |  Branch (2478:7): [True: 1, False: 5]
  |  Branch (2478:48): [True: 1, False: 0]
  ------------------
 2479|      1|			data->pin_reference = 0x81;
 2480|       |
 2481|      6|		data->pin1.tries_left = c4data[3 + (data->pin_reference & 0x0F)];
 2482|      6|		data->pin1.max_tries = 3;
 2483|      6|		data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|      6|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 2484|       |
 2485|      6|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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: 6]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2486|      6|	}
 2487|       |
 2488|     70|#ifdef ENABLE_OPENSSL
 2489|     70|	if (priv->pin_kdf_info) {
  ------------------
  |  Branch (2489:6): [True: 0, False: 70]
  ------------------
 2490|      0|		ops.pin_cmd = &pgp_kdf_do_pin_cmd;
 2491|      0|	}
 2492|     70|#endif /* ENABLE_OPENSSL */
 2493|       |
 2494|     70|	LOG_FUNC_RETURN(card->ctx, ops.pin_cmd(card, data));
  ------------------
  |  |  164|     70|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     70|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     70|	int _ret = r; \
  |  |  |  |  155|     70|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 70, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     70|		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|     57|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 57, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  157|     70|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     70|	} 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|     70|	return _ret; \
  |  |  |  |  163|     70|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2495|     70|}
card-openpgp.c:pgp_get_data:
 1994|  4.62k|{
 1995|  4.62k|	sc_apdu_t	apdu;
 1996|  4.62k|	int		r;
 1997|       |
 1998|  4.62k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  4.62k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.62k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.62k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.62k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.62k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1999|       |
 2000|  4.62k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xCA, tag >> 8, tag);
  ------------------
  |  |  301|  4.62k|#define SC_APDU_CASE_2			0x22
  ------------------
 2001|  4.62k|	apdu.le = ((buf_len >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : buf_len;
  ------------------
  |  |  547|  3.27k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (2001:13): [True: 3.27k, False: 1.34k]
  |  Branch (2001:33): [True: 3.21k, False: 60]
  ------------------
 2002|  4.62k|	apdu.resp = buf;
 2003|  4.62k|	apdu.resplen = buf_len;
 2004|       |
 2005|  4.62k|	r = sc_transmit_apdu(card, &apdu);
 2006|  4.62k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  4.62k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.62k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.62k|	int _ret = (r); \
  |  |  |  |  168|  4.62k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 44, False: 4.57k]
  |  |  |  |  ------------------
  |  |  |  |  169|     44|		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|     44|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     44|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     44|		return _ret; \
  |  |  |  |  172|     44|	} \
  |  |  |  |  173|  4.62k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.57k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2007|       |
 2008|  4.57k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2009|       |
 2010|       |	/* Gnuk returns an error instead of empty data if there is no certificate or private DO.
 2011|       |	 * So, for this case, we ignore error and consider success */
 2012|  4.57k|	if (card->type == SC_CARD_TYPE_OPENPGP_GNUK &&
  ------------------
  |  Branch (2012:6): [True: 39, False: 4.53k]
  ------------------
 2013|     39|	    (tag == DO_CERT  ||
  ------------------
  |  |  138|     78|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (2013:7): [True: 0, False: 39]
  ------------------
 2014|     39|	     tag == DO_PRIV1 ||
  ------------------
  |  |  149|     78|#define DO_PRIV1                 0x0101
  ------------------
  |  Branch (2014:7): [True: 0, False: 39]
  ------------------
 2015|     39|	     tag == DO_PRIV2 ||
  ------------------
  |  |  150|     78|#define DO_PRIV2                 0x0102
  ------------------
  |  Branch (2015:7): [True: 0, False: 39]
  ------------------
 2016|     39|	     tag == DO_PRIV3 ||
  ------------------
  |  |  151|     78|#define DO_PRIV3                 0x0103
  ------------------
  |  Branch (2016:7): [True: 0, False: 39]
  ------------------
 2017|     39|	     tag == DO_PRIV4)) {
  ------------------
  |  |  152|     39|#define DO_PRIV4                 0x0104
  ------------------
  |  Branch (2017:7): [True: 0, False: 39]
  ------------------
 2018|      0|		if (r == SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (2018:7): [True: 0, False: 0]
  ------------------
 2019|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2020|      0|			apdu.resplen = 0;
 2021|      0|		}
 2022|      0|	}
 2023|  4.57k|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|  4.57k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.57k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.57k|	int _ret = (r); \
  |  |  |  |  168|  4.57k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3.06k, False: 1.51k]
  |  |  |  |  ------------------
  |  |  |  |  169|  3.06k|		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|  3.06k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  3.06k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  3.06k|		return _ret; \
  |  |  |  |  172|  3.06k|	} \
  |  |  |  |  173|  4.57k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.51k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2024|       |
 2025|  1.51k|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|  1.51k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.51k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.51k|	int _ret = r; \
  |  |  |  |  155|  1.51k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 272, False: 1.24k]
  |  |  |  |  ------------------
  |  |  |  |  156|    272|		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: 272]
  |  |  |  |  ------------------
  |  |  |  |  157|    272|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.24k|	} else { \
  |  |  |  |  159|  1.24k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.24k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.24k|	} \
  |  |  |  |  162|  1.51k|	return _ret; \
  |  |  |  |  163|  1.51k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2026|  1.51k|}
card-openpgp.c:pgp_card_ctl:
 4009|    140|{
 4010|    140|	int r;
 4011|       |
 4012|    140|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    140|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    140|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    140|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    140|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 140]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4013|       |
 4014|    140|	switch(cmd) {
  ------------------
  |  Branch (4014:9): [True: 63, False: 77]
  ------------------
 4015|     63|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (4015:2): [True: 63, False: 77]
  ------------------
 4016|     63|		memmove((sc_serial_number_t *) ptr, &card->serialnr, sizeof(card->serialnr));
 4017|     63|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     63|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     63|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     63|	int _ret = r; \
  |  |  |  |  155|     63|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 63, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     63|		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: 63]
  |  |  |  |  ------------------
  |  |  |  |  157|     63|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     63|	} 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|     63|	return _ret; \
  |  |  |  |  163|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4018|      0|		break;
 4019|      0|	case SC_CARDCTL_OPENPGP_SELECT_DATA:
  ------------------
  |  Branch (4019:2): [True: 0, False: 140]
  ------------------
 4020|      0|		r = pgp_select_data(card, *((u8 *) ptr));
 4021|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4022|      0|		break;
 4023|      0|#ifdef ENABLE_OPENSSL
 4024|      0|	case SC_CARDCTL_OPENPGP_GENERATE_KEY:
  ------------------
  |  Branch (4024:2): [True: 0, False: 140]
  ------------------
 4025|      0|		r = pgp_gen_key(card, (sc_cardctl_openpgp_key_gen_store_info_t *)ptr);
 4026|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4027|      0|		break;
 4028|      0|	case SC_CARDCTL_OPENPGP_STORE_KEY:
  ------------------
  |  Branch (4028:2): [True: 0, False: 140]
  ------------------
 4029|      0|		r = pgp_store_key(card, (sc_cardctl_openpgp_key_gen_store_info_t *)ptr);
 4030|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4031|      0|		break;
 4032|      0|#endif /* ENABLE_OPENSSL */
 4033|      0|	case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (4033:2): [True: 0, False: 140]
  ------------------
 4034|      0|		r = pgp_erase_card(card);
 4035|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4036|      0|		break;
 4037|    140|	}
 4038|       |
 4039|     77|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     77|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     77|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     77|	int _ret = r; \
  |  |  |  |  155|     77|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 77, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     77|		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|     77|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 77, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     77|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     77|	} 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|     77|	return _ret; \
  |  |  |  |  163|     77|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4040|     77|}
card-openpgp.c:pgp_card_reader_lock_obtained:
 4169|  8.22k|{
 4170|  8.22k|	struct pgp_priv_data *priv = DRVDATA(card); /* may be null during initialization */
  ------------------
  |  |  189|  8.22k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 4171|  8.22k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  8.22k|#define SC_SUCCESS				0
  ------------------
 4172|       |
 4173|  8.22k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  8.22k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  8.22k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  8.22k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 8.22k]
  |  |  ------------------
  ------------------
 4174|       |
 4175|  8.22k|	if (card->flags & SC_CARD_FLAG_KEEP_ALIVE
  ------------------
  |  |  537|  16.4k|#define SC_CARD_FLAG_KEEP_ALIVE	0x00000004
  ------------------
  |  Branch (4175:6): [True: 0, False: 8.22k]
  ------------------
 4176|      0|			&& was_reset <= 0
  ------------------
  |  Branch (4176:7): [True: 0, False: 0]
  ------------------
 4177|      0|			&& priv != NULL && priv->mf && priv->mf->file) {
  ------------------
  |  Branch (4177:7): [True: 0, False: 0]
  |  Branch (4177:23): [True: 0, False: 0]
  |  Branch (4177:35): [True: 0, False: 0]
  ------------------
 4178|       |		/* check whether applet is still selected */
 4179|      0|		unsigned char aid[16];
 4180|       |
 4181|      0|		r = sc_get_data(card, 0x004F, aid, sizeof aid);
 4182|      0|		if ((size_t) r != priv->mf->file->namelen
  ------------------
  |  Branch (4182:7): [True: 0, False: 0]
  ------------------
 4183|      0|				|| 0 != memcmp(aid, priv->mf->file->name, r)) {
  ------------------
  |  Branch (4183:8): [True: 0, False: 0]
  ------------------
 4184|       |			/* reselect is required */
 4185|      0|			was_reset = 1;
 4186|      0|		}
 4187|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 4188|      0|	}
 4189|       |
 4190|  8.22k|	if (was_reset > 0) {
  ------------------
  |  Branch (4190:6): [True: 0, False: 8.22k]
  ------------------
 4191|      0|		sc_file_t	*file = NULL;
 4192|      0|		sc_path_t	path;
 4193|       |		/* select application "OpenPGP" */
 4194|      0|		sc_format_path("D276:0001:2401", &path);
 4195|      0|		path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 4196|      0|		r = iso_ops->select_file(card, &path, &file);
 4197|      0|		sc_file_free(file);
 4198|      0|	}
 4199|       |
 4200|  8.22k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  8.22k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  8.22k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  8.22k|	int _ret = r; \
  |  |  |  |  155|  8.22k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8.22k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  8.22k|		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: 8.22k]
  |  |  |  |  ------------------
  |  |  |  |  157|  8.22k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  8.22k|	} 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|  8.22k|	return _ret; \
  |  |  |  |  163|  8.22k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4201|  8.22k|}

sc_get_piv_driver:
 6708|  17.0k|{
 6709|  17.0k|	return sc_get_driver();
 6710|  17.0k|}
card-piv.c:sc_get_driver:
 6681|  17.0k|{
 6682|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 6683|       |
 6684|  17.0k|	piv_ops = *iso_drv->ops;
 6685|  17.0k|	piv_ops.match_card = piv_match_card;
 6686|  17.0k|	piv_ops.init = piv_init;
 6687|  17.0k|	piv_ops.finish = piv_finish;
 6688|       |
 6689|  17.0k|	piv_ops.select_file = piv_select_file; /* must use get/put, could emulate? */
 6690|  17.0k|	piv_ops.get_challenge = piv_get_challenge;
 6691|  17.0k|	piv_ops.logout = piv_logout;
 6692|  17.0k|	piv_ops.read_binary = piv_read_binary;
 6693|  17.0k|	piv_ops.write_binary = piv_write_binary;
 6694|  17.0k|	piv_ops.set_security_env = piv_set_security_env;
 6695|  17.0k|	piv_ops.restore_security_env = piv_restore_security_env;
 6696|  17.0k|	piv_ops.compute_signature = piv_compute_signature;
 6697|  17.0k|	piv_ops.decipher = piv_decipher;
 6698|  17.0k|	piv_ops.check_sw = piv_check_sw;
 6699|  17.0k|	piv_ops.card_ctl = piv_card_ctl;
 6700|  17.0k|	piv_ops.pin_cmd = piv_pin_cmd;
 6701|  17.0k|	piv_ops.card_reader_lock_obtained = piv_card_reader_lock_obtained;
 6702|       |
 6703|  17.0k|	return &piv_drv;
 6704|  17.0k|}
card-piv.c:piv_match_card:
 5629|  6.06k|{
 5630|  6.06k|	int r = 0;
 5631|       |
 5632|  6.06k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d\n", card->type);
  ------------------
  |  |   70|  6.06k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5633|       |	/* piv_match_card may be called with card->type, set by opensc.conf */
 5634|       |	/* user provided card type must be one we know */
 5635|  6.06k|	switch (card->type) {
 5636|  6.06k|	case -1:
  ------------------
  |  Branch (5636:2): [True: 6.06k, False: 0]
  ------------------
 5637|  6.06k|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5637:2): [True: 0, False: 6.06k]
  ------------------
 5638|  6.06k|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5638:2): [True: 0, False: 6.06k]
  ------------------
 5639|  6.06k|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5639:2): [True: 0, False: 6.06k]
  ------------------
 5640|  6.06k|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5640:2): [True: 0, False: 6.06k]
  ------------------
 5641|  6.06k|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5641:2): [True: 0, False: 6.06k]
  ------------------
 5642|  6.06k|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5642:2): [True: 0, False: 6.06k]
  ------------------
 5643|  6.06k|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5643:2): [True: 0, False: 6.06k]
  ------------------
 5644|  6.06k|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5644:2): [True: 0, False: 6.06k]
  ------------------
 5645|  6.06k|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5645:2): [True: 0, False: 6.06k]
  ------------------
 5646|  6.06k|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5646:2): [True: 0, False: 6.06k]
  ------------------
 5647|  6.06k|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5647:2): [True: 0, False: 6.06k]
  ------------------
 5648|  6.06k|	case SC_CARD_TYPE_PIV_II_PIVKEY:
  ------------------
  |  Branch (5648:2): [True: 0, False: 6.06k]
  ------------------
 5649|  6.06k|	case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (5649:2): [True: 0, False: 6.06k]
  ------------------
 5650|  6.06k|	case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5650:2): [True: 0, False: 6.06k]
  ------------------
 5651|  6.06k|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5651:2): [True: 0, False: 6.06k]
  ------------------
 5652|  6.06k|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5652:2): [True: 0, False: 6.06k]
  ------------------
 5653|  6.06k|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5653:2): [True: 0, False: 6.06k]
  ------------------
 5654|  6.06k|	case SC_CARD_TYPE_PIV_II_OPENFIPS201:
  ------------------
  |  Branch (5654:2): [True: 0, False: 6.06k]
  ------------------
 5655|  6.06k|		break;
 5656|      0|	default:
  ------------------
  |  Branch (5656:2): [True: 0, False: 6.06k]
  ------------------
 5657|      0|		return 0; /* can not handle the card */
 5658|  6.06k|	}
 5659|       |
 5660|  6.06k|	r = sc_lock(card);
 5661|  6.06k|	if (r < 0)
  ------------------
  |  Branch (5661:6): [True: 0, False: 6.06k]
  ------------------
 5662|      0|		return 0;
 5663|       |	/* its one we know, or we can test for it in piv_init */
 5664|  6.06k|	r = piv_match_card_continued(card);
 5665|  6.06k|	sc_unlock(card);
 5666|       |
 5667|  6.06k|	if (r < 0 || !card->drv_data) {
  ------------------
  |  Branch (5667:6): [True: 4.83k, False: 1.23k]
  |  Branch (5667:15): [True: 0, False: 1.23k]
  ------------------
 5668|       |		/* clean up what we left in card */
 5669|  4.83k|		piv_finish(card);
 5670|  4.83k|		return 0; /* match failed */
 5671|  4.83k|	}
 5672|       |
 5673|  1.23k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r:%d\n", card->type, r);
  ------------------
  |  |   70|  1.23k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5674|  1.23k|	return 1; /* matched */
 5675|  6.06k|}
card-piv.c:piv_match_card_continued:
 5679|  6.06k|{
 5680|  6.06k|	int i, r = 0, r2 = 0;
 5681|  6.06k|	int type = -1;
 5682|  6.06k|	piv_private_data_t *priv = NULL;
 5683|  6.06k|	int saved_type = card->type;
 5684|  6.06k|	sc_apdu_t apdu;
 5685|  6.06k|	u8 yubico_version_buf[3] = {0};
 5686|       |
 5687|       |	/* piv_match_card may be called with card->type, set by opensc.conf */
 5688|       |	/* User provided card type must be one we know */
 5689|       |
 5690|  6.06k|	switch (card->type) {
 5691|  6.06k|	case -1:
  ------------------
  |  Branch (5691:2): [True: 6.06k, False: 0]
  ------------------
 5692|  6.06k|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5692:2): [True: 0, False: 6.06k]
  ------------------
 5693|  6.06k|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5693:2): [True: 0, False: 6.06k]
  ------------------
 5694|  6.06k|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5694:2): [True: 0, False: 6.06k]
  ------------------
 5695|  6.06k|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5695:2): [True: 0, False: 6.06k]
  ------------------
 5696|  6.06k|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5696:2): [True: 0, False: 6.06k]
  ------------------
 5697|  6.06k|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5697:2): [True: 0, False: 6.06k]
  ------------------
 5698|  6.06k|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5698:2): [True: 0, False: 6.06k]
  ------------------
 5699|  6.06k|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5699:2): [True: 0, False: 6.06k]
  ------------------
 5700|  6.06k|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5700:2): [True: 0, False: 6.06k]
  ------------------
 5701|  6.06k|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5701:2): [True: 0, False: 6.06k]
  ------------------
 5702|  6.06k|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5702:2): [True: 0, False: 6.06k]
  ------------------
 5703|  6.06k|	case SC_CARD_TYPE_PIV_II_PIVKEY:
  ------------------
  |  Branch (5703:2): [True: 0, False: 6.06k]
  ------------------
 5704|  6.06k|	case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (5704:2): [True: 0, False: 6.06k]
  ------------------
 5705|  6.06k|	case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5705:2): [True: 0, False: 6.06k]
  ------------------
 5706|  6.06k|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5706:2): [True: 0, False: 6.06k]
  ------------------
 5707|  6.06k|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5707:2): [True: 0, False: 6.06k]
  ------------------
 5708|  6.06k|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5708:2): [True: 0, False: 6.06k]
  ------------------
 5709|  6.06k|	case SC_CARD_TYPE_PIV_II_OPENFIPS201:
  ------------------
  |  Branch (5709:2): [True: 0, False: 6.06k]
  ------------------
 5710|       |
 5711|  6.06k|		type = card->type;
 5712|  6.06k|		break;
 5713|      0|	default:
  ------------------
  |  Branch (5713:2): [True: 0, False: 6.06k]
  ------------------
 5714|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5715|  6.06k|	}
 5716|  6.06k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d type:%d r:%d\n", card->type, type, r);
  ------------------
  |  |   70|  6.06k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5717|  6.06k|	if (type == -1) {
  ------------------
  |  Branch (5717:6): [True: 6.06k, False: 0]
  ------------------
 5718|       |		/*
 5719|       |		 * Try to identify card by ATR or historical data in ATR
 5720|       |		 * currently all PIV card will respond to piv_find_aid
 5721|       |		 * the same. But in future may need to know card type first,
 5722|       |		 * so do it here.
 5723|       |		 */
 5724|       |
 5725|  6.06k|		if (card->reader->atr_info.hist_bytes != NULL) {
  ------------------
  |  Branch (5725:7): [True: 1.61k, False: 4.45k]
  ------------------
 5726|  1.61k|			if (card->reader->atr_info.hist_bytes_len == 8 &&
  ------------------
  |  Branch (5726:8): [True: 127, False: 1.48k]
  ------------------
 5727|    127|					!(memcmp(card->reader->atr_info.hist_bytes, "Yubikey4", 8))) {
  ------------------
  |  Branch (5727:6): [True: 25, False: 102]
  ------------------
 5728|     25|				type = SC_CARD_TYPE_PIV_II_YUBIKEY4;
 5729|  1.58k|			} else if (card->reader->atr_info.hist_bytes_len >= 7 &&
  ------------------
  |  Branch (5729:15): [True: 980, False: 607]
  ------------------
 5730|    980|					!(memcmp(card->reader->atr_info.hist_bytes, "Yubikey", 7))) {
  ------------------
  |  Branch (5730:6): [True: 87, False: 893]
  ------------------
 5731|     87|				type = SC_CARD_TYPE_PIV_II_NEO;
 5732|  1.50k|			} else if (card->reader->atr_info.hist_bytes_len >= 6 &&
  ------------------
  |  Branch (5732:15): [True: 915, False: 585]
  ------------------
 5733|    915|					!(memcmp(card->reader->atr_info.hist_bytes, "PIVKEY", 6))) {
  ------------------
  |  Branch (5733:6): [True: 72, False: 843]
  ------------------
 5734|     72|				type = SC_CARD_TYPE_PIV_II_PIVKEY;
 5735|  1.42k|			} else if (card->reader->atr_info.hist_bytes_len >= 6 &&
  ------------------
  |  Branch (5735:15): [True: 843, False: 585]
  ------------------
 5736|    843|					!(memcmp(card->reader->atr_info.hist_bytes, (u8 *)"TK\x00PIV", 6))) {
  ------------------
  |  Branch (5736:6): [True: 12, False: 831]
  ------------------
 5737|     12|				type = SC_CARD_TYPE_PIV_II_TOKEN2;
 5738|     12|			}
 5739|       |			/* look for TLV historic data */
 5740|  1.41k|			else if (card->reader->atr_info.hist_bytes_len > 0 &&
  ------------------
  |  Branch (5740:13): [True: 1.39k, False: 22]
  ------------------
 5741|  1.39k|					card->reader->atr_info.hist_bytes[0] == 0x80u) { /* compact TLV */
  ------------------
  |  Branch (5741:6): [True: 534, False: 860]
  ------------------
 5742|    534|				size_t datalen;
 5743|    534|				const u8 *data;
 5744|       |
 5745|       |				/* look for card issuer's data:  tag 5X where X is datalen */
 5746|    534|				if ((data = sc_compacttlv_find_tag(card->reader->atr_info.hist_bytes + 1,
  ------------------
  |  Branch (5746:9): [True: 224, False: 310]
  ------------------
 5747|    534|						     card->reader->atr_info.hist_bytes_len - 1, 0x50, &datalen))) {
 5748|    224|					if (datalen >= 8 && !(memcmp(data, "Nitrokey", 8))) { /* first 8 are Nitrokey */
  ------------------
  |  Branch (5748:10): [True: 40, False: 184]
  |  Branch (5748:26): [True: 22, False: 18]
  ------------------
 5749|     22|						type = SC_CARD_TYPE_PIV_II_NITROKEY;
 5750|    202|					} else if (datalen == 7 && !(memcmp(data, "YubiKey", 7))) {
  ------------------
  |  Branch (5750:17): [True: 174, False: 28]
  |  Branch (5750:33): [True: 157, False: 17]
  ------------------
 5751|    157|						type = SC_CARD_TYPE_PIV_II_YUBIKEY4; /* reader says 4  really 5 */
 5752|    157|					}
 5753|       |					/* Yubikey 5 NFC ATR using ACR122 contactless reader does not match
 5754|       |					 * https://developers.yubico.com/PIV/Introduction/Yubico_extensions.html
 5755|       |					 * On Windows 10, using Omnikey 5021, the ATR is correct
 5756|       |					 * will look at only 6 bytes that do match
 5757|       |					 */
 5758|     45|					else if (datalen == 7 && !(memcmp(data, "YubiKe", 6))) {
  ------------------
  |  Branch (5758:15): [True: 17, False: 28]
  |  Branch (5758:31): [True: 12, False: 5]
  ------------------
 5759|     12|						type = SC_CARD_TYPE_PIV_II_YUBIKEY4; /* reader says 4 really 5 */
 5760|     12|					}
 5761|    310|				} else if ((data = sc_compacttlv_find_tag(card->reader->atr_info.hist_bytes + 1,
  ------------------
  |  Branch (5761:16): [True: 44, False: 266]
  ------------------
 5762|    310|							    card->reader->atr_info.hist_bytes_len - 1, 0xF0, &datalen))) {
 5763|     44|					int k;
 5764|       |
 5765|    129|					for (k = 0; piv_aids[k].len_long != 0; k++) {
  ------------------
  |  Branch (5765:18): [True: 88, False: 41]
  ------------------
 5766|     88|						if (datalen == piv_aids[k].len_long &&
  ------------------
  |  Branch (5766:11): [True: 84, False: 4]
  ------------------
 5767|     84|								!memcmp(data, piv_aids[k].value, datalen)) {
  ------------------
  |  Branch (5767:9): [True: 3, False: 81]
  ------------------
 5768|      3|							type = SC_CARD_TYPE_PIV_II_HIST;
 5769|      3|							break;
 5770|      3|						}
 5771|     88|					}
 5772|     44|				}
 5773|    534|			}
 5774|  1.61k|		}
 5775|       |
 5776|  6.06k|		sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d type:%d r:%d\n", card->type, type, r);
  ------------------
  |  |   70|  6.06k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5777|       |
 5778|  6.06k|		if (type == -1) {
  ------------------
  |  Branch (5778:7): [True: 5.67k, False: 390]
  ------------------
 5779|       |			/* use known ATRs  which changes the type */
 5780|  5.67k|			i = _sc_match_atr(card, piv_atrs, &type);
 5781|  5.67k|			if (i < 0)
  ------------------
  |  Branch (5781:8): [True: 5.67k, False: 5]
  ------------------
 5782|  5.67k|				type = SC_CARD_TYPE_PIV_II_BASE; /* May be some newer unknown card including CAC or PIV-like card */
 5783|  5.67k|		}
 5784|  6.06k|	}
 5785|       |
 5786|  6.06k|	card->type = type;
 5787|       |
 5788|       |	/* we either found via ATR historic bytes or ATR directly */
 5789|  6.06k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d type:%d r:%d\n", card->type, type, r);
  ------------------
  |  |   70|  6.06k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5790|       |
 5791|       |	/* allocate and init basic fields */
 5792|  6.06k|	priv = calloc(1, sizeof(piv_private_data_t));
 5793|       |
 5794|  6.06k|	if (!priv)
  ------------------
  |  Branch (5794:6): [True: 0, False: 6.06k]
  ------------------
 5795|  6.06k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5796|       |
 5797|  6.06k|	card->drv_data = priv; /* will free if no match, or pass on to piv_init */
 5798|       |	/*
 5799|       |	 * Largest object defined in NIST sp800-73-3 and sp800-73-4 is 12710 bytes
 5800|       |	 * If for some reason future cards have larger objects, this value needs to
 5801|       |	 * be increased here.
 5802|       |	 */
 5803|  6.06k|	priv->max_object_size = MAX_FILE_SIZE - 256; /* fix SM apdu resplen issue */
  ------------------
  |  |  220|  6.06k|#define MAX_FILE_SIZE 65535
  ------------------
 5804|  6.06k|	priv->selected_obj = -1;
 5805|  6.06k|	priv->pin_preference = 0x80; /* 800-73-3 part 1, table 3 */
 5806|  6.06k|	priv->logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|  6.06k|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 5807|  6.06k|	priv->pstate = PIV_STATE_MATCH;
 5808|       |
 5809|       |#ifdef ENABLE_PIV_SM
 5810|       |	memset(&card->sm_ctx, 0, sizeof card->sm_ctx);
 5811|       |	card->sm_ctx.ops.open = piv_sm_open;
 5812|       |	card->sm_ctx.ops.get_sm_apdu = piv_get_sm_apdu;
 5813|       |	card->sm_ctx.ops.free_sm_apdu = piv_free_sm_apdu;
 5814|       |	card->sm_ctx.ops.close = piv_sm_close;
 5815|       |#endif /* ENABLE_PIV_SM */
 5816|       |
 5817|       |	/* See if contactless  or run as virtual card */
 5818|       |	/* PivApplet in .github/test_piv.sh for example */
 5819|  6.06k|	if (card->reader->atr.len >= 4 &&
  ------------------
  |  Branch (5819:6): [True: 1.83k, False: 4.23k]
  ------------------
 5820|  1.83k|			card->reader->atr.value[0] == 0x3b &&
  ------------------
  |  Branch (5820:4): [True: 1.64k, False: 193]
  ------------------
 5821|  1.64k|			(card->reader->atr.value[1] & 0xF0) == 0x80 &&
  ------------------
  |  Branch (5821:4): [True: 166, False: 1.47k]
  ------------------
 5822|    166|			card->reader->atr.value[2] == 0x80 &&
  ------------------
  |  Branch (5822:4): [True: 126, False: 40]
  ------------------
 5823|    126|			card->reader->atr.value[3] == 0x01) {
  ------------------
  |  Branch (5823:4): [True: 100, False: 26]
  ------------------
 5824|    100|		priv->init_flags |= PIV_INIT_CONTACTLESS;
  ------------------
  |  |  385|    100|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
 5825|    100|	}
 5826|       |
 5827|   370k|	for (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++)
  ------------------
  |  Branch (5827:14): [True: 364k, False: 6.06k]
  ------------------
 5828|   364k|		if (piv_objects[i].flags & PIV_OBJECT_NOT_PRESENT)
  ------------------
  |  |  655|   364k|#define PIV_OBJECT_NOT_PRESENT		0x04
  ------------------
  |  Branch (5828:7): [True: 121k, False: 242k]
  ------------------
 5829|   121k|			priv->obj_cache[i].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|   127k|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5830|       |	/*
 5831|       |	 * Detect if active AID is PIV. NIST 800-73 says only one PIV application per card
 5832|       |	 * and PIV must be the default application.
 5833|       |	 * Try to avoid doing a select_aid and losing the login state on some cards.
 5834|       |	 * We may get interference on some cards by other drivers trying SELECT_AID before
 5835|       |	 * we get to see if PIV application is still active. Putting PIV driver first might help.
 5836|       |	 *
 5837|       |	 * Discovery Object introduced in 800-73-3 so will return OK if found and PIV applet active.
 5838|       |	 * Will fail with SC_ERROR_FILE_NOT_FOUND if 800-73-3 and no Discovery object.
 5839|       |	 * But some other card could also return SC_ERROR_FILE_NOT_FOUND.
 5840|       |	 * Will fail for other reasons if wrong applet is selected or bad PIV implementation.
 5841|       |	 */
 5842|       |
 5843|       |	/*
 5844|       |	 * if ATR matched or user forced card type
 5845|       |	 * test if PIV is active applet without using AID If fails try AID
 5846|       |	 */
 5847|       |
 5848|  6.06k|	if (card->type > SC_CARD_TYPE_PIV_II_BASE &&
  ------------------
  |  Branch (5848:6): [True: 395, False: 5.67k]
  ------------------
 5849|    395|			!(priv->init_flags & PIV_INIT_CONTACTLESS)) {
  ------------------
  |  |  385|    395|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
  |  Branch (5849:4): [True: 391, False: 4]
  ------------------
 5850|    391|		r = piv_find_discovery(card);
 5851|    391|		if (r < 0) {
  ------------------
  |  Branch (5851:7): [True: 305, False: 86]
  ------------------
 5852|    305|			piv_obj_cache_free_entry(card, PIV_OBJ_DISCOVERY, 0); /* don't cache  on failure */
 5853|    305|			r = piv_find_aid(card);
 5854|    305|			LOG_TEST_GOTO_ERR(card->ctx, r, "Not a PIV card");
  ------------------
  |  |  184|    305|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    305|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    305|	int _ret = (r); \
  |  |  |  |  178|    305|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 93, False: 212]
  |  |  |  |  ------------------
  |  |  |  |  179|     93|		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|     93|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     93|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     93|		goto err; \
  |  |  |  |  182|     93|	} \
  |  |  |  |  183|    305|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 212]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5855|    305|		}
 5856|  5.67k|	} else {
 5857|       |		/* piv_find_aid saves al_label from response */
 5858|  5.67k|		r = piv_find_aid(card);
 5859|  5.67k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Not a PIV card");
  ------------------
  |  |  184|  5.67k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  5.67k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  5.67k|	int _ret = (r); \
  |  |  |  |  178|  5.67k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 4.74k, False: 932]
  |  |  |  |  ------------------
  |  |  |  |  179|  4.74k|		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|  4.74k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  4.74k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  4.74k|		goto err; \
  |  |  |  |  182|  4.74k|	} \
  |  |  |  |  183|  5.67k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 932]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5860|  5.67k|	}
 5861|       |
 5862|       |	/* Know to be PIV card but not the type */
 5863|       |
 5864|       |	/* If card type still unknown, see if Application Label is known and set card->type */
 5865|  1.23k|	if (priv->al_label && priv->al_labellen) {
  ------------------
  |  Branch (5865:6): [True: 15, False: 1.21k]
  |  Branch (5865:24): [True: 12, False: 3]
  ------------------
 5866|     12|		switch (card->type) {
  ------------------
  |  Branch (5866:11): [True: 11, False: 1]
  ------------------
 5867|     11|		case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5867:3): [True: 11, False: 1]
  ------------------
 5868|     11|		case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5868:3): [True: 0, False: 12]
  ------------------
 5869|     30|			for (i = 0; al_map[i].al_label; i++) {
  ------------------
  |  Branch (5869:16): [True: 21, False: 9]
  ------------------
 5870|     21|				if ((priv->al_labellen >= al_map[i].al_labellen) &&
  ------------------
  |  Branch (5870:9): [True: 19, False: 2]
  ------------------
 5871|     19|						(!memcmp(priv->al_label, al_map[i].al_label, al_map[i].al_labellen))) {
  ------------------
  |  Branch (5871:7): [True: 2, False: 17]
  ------------------
 5872|      2|					sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "AL match i:%d type:%d", i, al_map[i].al_type);
  ------------------
  |  |   70|      2|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5873|      2|					card->type = al_map[i].al_type;
 5874|      2|					break;
 5875|      2|				}
 5876|     21|			}
 5877|     11|			break;
 5878|     12|		}
 5879|     12|	}
 5880|       |
 5881|  1.23k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d  CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|  1.23k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5882|  1.23k|			card->type, priv->card_issues, r, priv->alg_ids);
 5883|       |
 5884|       |	/*
 5885|       |	 * Assumes all Yubikey/Nitrokey/Token2/PivApplet cards are all "Yubico like"
 5886|       |	 * via ATR, ATR Historic bytes or Application Label
 5887|       |	 * Will also check if BASE cards are Yubikey like card and return a version number
 5888|       |	 * SC_CARD_TYPE_PIV_II_GENERIC can be set by user to not test for Yubico version
 5889|       |	 */
 5890|  1.23k|	switch (card->type) {
  ------------------
  |  Branch (5890:10): [True: 1.20k, False: 21]
  ------------------
 5891|     74|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5891:2): [True: 74, False: 1.15k]
  ------------------
 5892|    254|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5892:2): [True: 180, False: 1.05k]
  ------------------
 5893|    274|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5893:2): [True: 20, False: 1.21k]
  ------------------
 5894|    277|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5894:2): [True: 3, False: 1.22k]
  ------------------
 5895|    278|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5895:2): [True: 1, False: 1.22k]
  ------------------
 5896|    279|	case SC_CARD_TYPE_PIV_II_OPENFIPS201:
  ------------------
  |  Branch (5896:2): [True: 1, False: 1.22k]
  ------------------
 5897|    279|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5897:2): [True: 0, False: 1.23k]
  ------------------
 5898|  1.20k|	case SC_CARD_TYPE_PIV_II_BASE: /* unknown PIV card */
  ------------------
  |  Branch (5898:2): [True: 930, False: 300]
  ------------------
 5899|  1.20k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xFD, 0x00, 0x00);
  ------------------
  |  |  292|  1.20k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 5900|  1.20k|		apdu.lc = 0;
 5901|  1.20k|		apdu.data = NULL;
 5902|  1.20k|		apdu.datalen = 0;
 5903|  1.20k|		apdu.resp = yubico_version_buf;
 5904|  1.20k|		apdu.resplen = sizeof(yubico_version_buf);
 5905|  1.20k|		apdu.le = apdu.resplen;
 5906|  1.20k|		r2 = sc_transmit_apdu(card, &apdu); /* if not supported yubico_version == 0 */
 5907|  1.20k|		if (r2 == SC_SUCCESS && apdu.resplen == 3) {
  ------------------
  |  |   28|  2.41k|#define SC_SUCCESS				0
  ------------------
  |  Branch (5907:7): [True: 1.20k, False: 5]
  |  Branch (5907:27): [True: 535, False: 669]
  ------------------
 5908|    535|			priv->yubico_version = (yubico_version_buf[0] << 16) | (yubico_version_buf[1] << 8) | yubico_version_buf[2];
 5909|    535|			sc_log(card->ctx, "Yubikey version test card->type=%d, r=0x%08x version=0x%08x", card->type, r, priv->yubico_version);
  ------------------
  |  |   71|    535|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5910|    535|			if (priv->yubico_version == 1) {
  ------------------
  |  Branch (5910:8): [True: 1, False: 534]
  ------------------
 5911|      1|				sc_log(card->ctx, "Detected Alpha/development version of yubikey. Assuming v6");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5912|      1|				priv->yubico_version = 0x060000;
 5913|      1|			}
 5914|    535|		}
 5915|  1.20k|		break;
 5916|  1.23k|	}
 5917|       |
 5918|  1.23k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|  1.23k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5919|  1.23k|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5920|       |
 5921|       |	/* We now know PIV AID is active, test CCC object. 800-73-* say CCC is required */
 5922|       |	/* CCC not readable over contactless, unless using VCI. but dont need CCC for SC_CARD_TYPE_PIV_II_800_73_4 */
 5923|  1.23k|	switch (card->type) {
  ------------------
  |  Branch (5923:10): [True: 931, False: 299]
  ------------------
 5924|       |	/*
 5925|       |	 * For cards that may also be CAC, try and read the CCC
 5926|       |	 * CCC is required and all Dual PIV/CAC will have a CCC
 5927|       |	 * Currently Dual PIV/CAC are based on NIST 800-73-1 which does not have Discovery or History
 5928|       |	 */
 5929|    930|	case SC_CARD_TYPE_PIV_II_BASE: /* i.e. really dont know what this is */
  ------------------
  |  Branch (5929:2): [True: 930, False: 300]
  ------------------
 5930|    930|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5930:2): [True: 0, False: 1.23k]
  ------------------
 5931|    931|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5931:2): [True: 1, False: 1.22k]
  ------------------
 5932|    931|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5932:2): [True: 0, False: 1.23k]
  ------------------
 5933|    931|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5933:2): [True: 0, False: 1.23k]
  ------------------
 5934|    931|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5934:2): [True: 0, False: 1.23k]
  ------------------
 5935|    931|		r2 = piv_process_ccc(card);
 5936|    931|		sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|    931|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5937|    931|				card->type, r2, priv->card_issues, r, priv->alg_ids);
 5938|       |		/* Ignore any error. */
 5939|       |		/* If CCC says it has CAC with PKI on card set to one of the SC_CARD_TYPE_PIV_II_*_DUAL_CAC */
 5940|    931|		if (priv->ccc_flags & PIV_CCC_F3_CAC_PKI) {
  ------------------
  |  |  174|    931|#define PIV_CCC_F3_CAC_PKI	0x00000010
  ------------------
  |  Branch (5940:7): [True: 4, False: 927]
  ------------------
 5941|      4|			switch (card->type) {
  ------------------
  |  Branch (5941:12): [True: 4, False: 0]
  ------------------
 5942|      4|			case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5942:4): [True: 4, False: 0]
  ------------------
 5943|      4|			case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5943:4): [True: 0, False: 4]
  ------------------
 5944|      4|			case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5944:4): [True: 0, False: 4]
  ------------------
 5945|      4|			case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5945:4): [True: 0, False: 4]
  ------------------
 5946|      4|				card->type = SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC;
 5947|      4|				priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  597|      4|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5948|      4|				priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      4|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5949|      4|				break;
 5950|      0|			case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5950:4): [True: 0, False: 4]
  ------------------
 5951|      0|				card->type = SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC;
 5952|      0|				priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  597|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5953|      0|				priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5954|      0|				break;
 5955|      0|			case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5955:4): [True: 0, False: 4]
  ------------------
 5956|      0|				card->type = SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC;
 5957|      0|				priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  597|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5958|      0|				priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5959|      0|				break;
 5960|      4|			}
 5961|      4|		}
 5962|    931|		break;
 5963|       |
 5964|    931|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5964:2): [True: 0, False: 1.23k]
  ------------------
 5965|      0|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5965:2): [True: 0, False: 1.23k]
  ------------------
 5966|      0|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5966:2): [True: 0, False: 1.23k]
  ------------------
 5967|      0|		priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  597|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5968|      0|		priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5969|      0|		break;
 5970|  1.23k|	}
 5971|  1.23k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|  1.23k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5972|  1.23k|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5973|       |
 5974|       |	/* If contactless or run as virtual card try to get alg refs from AC entries in response to SELECT AID */
 5975|  1.23k|	if (!(priv->init_flags & PIV_INIT_AID_PARSED) && priv->init_flags & PIV_INIT_CONTACTLESS) {
  ------------------
  |  |  380|  1.23k|#define PIV_INIT_AID_PARSED			0x00000001u
  ------------------
              	if (!(priv->init_flags & PIV_INIT_AID_PARSED) && priv->init_flags & PIV_INIT_CONTACTLESS) {
  ------------------
  |  |  385|     86|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
  |  Branch (5975:6): [True: 86, False: 1.14k]
  |  Branch (5975:51): [True: 0, False: 86]
  ------------------
 5976|      0|		r2 = piv_find_aid(card);
 5977|      0|	}
 5978|       |
 5979|       |	/* Read AID if needed for these cards types */
 5980|  1.23k|	if (!(priv->init_flags & PIV_INIT_AID_PARSED)) {
  ------------------
  |  |  380|  1.23k|#define PIV_INIT_AID_PARSED			0x00000001u
  ------------------
  |  Branch (5980:6): [True: 86, False: 1.14k]
  ------------------
 5981|     86|		switch (card->type) {
  ------------------
  |  Branch (5981:11): [True: 23, False: 63]
  ------------------
 5982|      0|		case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5982:3): [True: 0, False: 86]
  ------------------
 5983|      0|		case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5983:3): [True: 0, False: 86]
  ------------------
 5984|      1|		case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5984:3): [True: 1, False: 85]
  ------------------
 5985|     21|		case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5985:3): [True: 20, False: 66]
  ------------------
 5986|     23|		case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5986:3): [True: 2, False: 84]
  ------------------
 5987|     23|		case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5987:3): [True: 0, False: 86]
  ------------------
 5988|     23|		case SC_CARD_TYPE_PIV_II_OPENFIPS201:
  ------------------
  |  Branch (5988:3): [True: 0, False: 86]
  ------------------
 5989|       |
 5990|     23|			r2 = piv_find_aid(card);
 5991|     86|		}
 5992|     86|	}
 5993|       |
 5994|  1.23k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|  1.23k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5995|  1.23k|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5996|       |
 5997|       |	/* if card did not specify any of the NIST basic alg_ids add them */
 5998|  1.23k|	if ((priv->alg_ids & AI_NIST) == 0) {
  ------------------
  |  |  617|  1.23k|#define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  608|  1.23k|#define AI_RSA_1024			    0x00000001U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  609|  1.23k|#define AI_RSA_2048			    0x00000002U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  610|  1.23k|#define AI_RSA_3072			    0x00000004U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  612|  1.23k|#define AI_EC_256			    0x00000100U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  613|  1.23k|#define AI_EC_384			    0x00000200U
  |  |  ------------------
  ------------------
  |  Branch (5998:6): [True: 1.22k, False: 3]
  ------------------
 5999|  1.22k|		priv->alg_ids |= AI_NIST;
  ------------------
  |  |  617|  1.22k|#define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  608|  1.22k|#define AI_RSA_1024			    0x00000001U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  609|  1.22k|#define AI_RSA_2048			    0x00000002U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  610|  1.22k|#define AI_RSA_3072			    0x00000004U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  612|  1.22k|#define AI_EC_256			    0x00000100U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  613|  1.22k|#define AI_EC_384			    0x00000200U
  |  |  ------------------
  ------------------
 6000|  1.22k|	}
 6001|       |
 6002|       |	/* If unknown card has 800-73-4 features, it must be based on 800-73-4 or above */
 6003|  1.23k|	switch (card->type) {
  ------------------
  |  Branch (6003:10): [True: 926, False: 304]
  ------------------
 6004|    926|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (6004:2): [True: 926, False: 304]
  ------------------
 6005|    926|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (6005:2): [True: 0, False: 1.23k]
  ------------------
 6006|    926|		if (priv->init_flags & PIV_INIT_AID_AC_SM) {
  ------------------
  |  |  381|    926|#define PIV_INIT_AID_AC_SM			0x00000002u
  ------------------
  |  Branch (6006:7): [True: 0, False: 926]
  ------------------
 6007|      0|			card->type = SC_CARD_TYPE_PIV_II_800_73_4;
 6008|      0|		}
 6009|       |
 6010|       |#ifdef ENABLE_PIV_SM
 6011|       |		/* Discovery object has pin policy. 800-74-4 bits, its at least SC_CARD_TYPE_PIV_II_800_73_4 */
 6012|       |		if ((priv->pin_policy & (PIV_PP_OCC | PIV_PP_VCI_IMPL | PIV_PP_VCI_WITHOUT_PC)) != 0) {
 6013|       |			card->type = SC_CARD_TYPE_PIV_II_800_73_4;
 6014|       |		}
 6015|       |#endif
 6016|    926|		break;
 6017|  1.23k|	}
 6018|       |
 6019|  1.23k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|  1.23k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6020|  1.23k|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 6021|       |
 6022|       |	/*
 6023|       |	 * Set card_issues flags based card->type and version numbers if available.
 6024|       |	 *
 6025|       |	 * YubiKey NEO, Yubikey 4 and other devices with PIV applets, have compliance
 6026|       |	 * issues with the NIST 800-73-3 specs. The OpenSC developers do not have
 6027|       |	 * access to all the different devices or versions of the devices.
 6028|       |	 * Vendor and user input is welcome on any compliance issues.
 6029|       |	 *
 6030|       |	 * For the Yubico devices The assumption is also made that if a bug is
 6031|       |	 * fixed in a Yubico version that means it is fixed on both NEO and Yubikey 4.
 6032|       |	 *
 6033|       |	 * The flags CI_CANT_USE_GETDATA_FOR_STATE and CI_DISCOVERY_USELESS
 6034|       |	 * may be set earlier or later then in the following code.
 6035|       |	 */
 6036|       |
 6037|  1.23k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|  1.23k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6038|  1.23k|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 6039|  1.23k|	switch (card->type) {
 6040|     74|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (6040:2): [True: 74, False: 1.15k]
  ------------------
 6041|     74|		priv->card_issues |= CI_NO_EC384 |
  ------------------
  |  |  603|     74|#define CI_NO_EC384			    0x00000400U /* does not have EC 384 */
  ------------------
 6042|     74|				     CI_VERIFY_630X |
  ------------------
  |  |  591|     74|#define CI_VERIFY_630X			    0x00000001U /* VERIFY tries left returns 630X rather then 63CX */
  ------------------
 6043|     74|				     CI_OTHER_AID_LOSE_STATE |
  ------------------
  |  |  600|     74|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 6044|     74|				     CI_LEAKS_FILE_NOT_FOUND |
  ------------------
  |  |  596|     74|#define CI_LEAKS_FILE_NOT_FOUND		    0x00000010U /* GET DATA of empty object returns 6A 82 even if PIN not verified */
  ------------------
 6045|     74|				     CI_NFC_EXPOSE_TOO_MUCH;
  ------------------
  |  |  601|     74|#define CI_NFC_EXPOSE_TOO_MUCH		    0x00000200U /* PIN, crypto and objects exposed over NFS in violation of 800-73-3 */
  ------------------
 6046|     74|		if (priv->yubico_version < 0x00040302)
  ------------------
  |  Branch (6046:7): [True: 53, False: 21]
  ------------------
 6047|     53|			priv->card_issues |= CI_VERIFY_LC0_FAIL;
  ------------------
  |  |  592|     53|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 6048|     74|		break;
 6049|       |
 6050|      1|	case SC_CARD_TYPE_PIV_II_OPENFIPS201:
  ------------------
  |  Branch (6050:2): [True: 1, False: 1.22k]
  ------------------
 6051|       |		/* also supports using yubico-piv-tool */
 6052|      1|		priv->card_issues |= CI_ENFORCES_EC_HASH_EQ_KEYSIZE |
  ------------------
  |  |  605|      1|#define CI_ENFORCES_EC_HASH_EQ_KEYSIZE	    0x00001000U /* Applet enforces hash size == EC field size for ECDSA. Windows issue */
  ------------------
 6053|      1|				     CI_OTHER_AID_LOSE_STATE |
  ------------------
  |  |  600|      1|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 6054|      1|				     CI_LEAKS_FILE_NOT_FOUND;
  ------------------
  |  |  596|      1|#define CI_LEAKS_FILE_NOT_FOUND		    0x00000010U /* GET DATA of empty object returns 6A 82 even if PIN not verified */
  ------------------
 6055|      1|		break;
 6056|       |
 6057|    180|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (6057:2): [True: 180, False: 1.05k]
  ------------------
 6058|    181|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (6058:2): [True: 1, False: 1.22k]
  ------------------
 6059|    184|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (6059:2): [True: 3, False: 1.22k]
  ------------------
 6060|    184|		priv->card_issues |= CI_OTHER_AID_LOSE_STATE |
  ------------------
  |  |  600|    184|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 6061|    184|				     CI_LEAKS_FILE_NOT_FOUND;
  ------------------
  |  |  596|    184|#define CI_LEAKS_FILE_NOT_FOUND		    0x00000010U /* GET DATA of empty object returns 6A 82 even if PIN not verified */
  ------------------
 6062|    184|		if (priv->yubico_version < 0x00040302)
  ------------------
  |  Branch (6062:7): [True: 67, False: 117]
  ------------------
 6063|     67|			priv->card_issues |= CI_VERIFY_LC0_FAIL;
  ------------------
  |  |  592|     67|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 6064|    184|		if (priv->yubico_version >= 0x00050700) /* Also used by Token2 */
  ------------------
  |  Branch (6064:7): [True: 95, False: 89]
  ------------------
 6065|     95|			priv->alg_ids |= AI_RSA_4096 | AI_25519 | AI_X25519;
  ------------------
  |  |  611|     95|#define AI_RSA_4096			    0x00000008U
  ------------------
              			priv->alg_ids |= AI_RSA_4096 | AI_25519 | AI_X25519;
  ------------------
  |  |  614|     95|#define AI_25519			    0x00100000U
  ------------------
              			priv->alg_ids |= AI_RSA_4096 | AI_25519 | AI_X25519;
  ------------------
  |  |  615|     95|#define AI_X25519			    0x00200000U
  ------------------
 6066|    184|		break;
 6067|       |
 6068|     20|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (6068:2): [True: 20, False: 1.21k]
  ------------------
 6069|     20|		priv->card_issues |= CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  600|     20|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 6070|     20|		if (priv->yubico_version >= 0x00010802) /* use for NitroKey too */
  ------------------
  |  Branch (6070:7): [True: 14, False: 6]
  ------------------
 6071|     14|			priv->alg_ids |= AI_RSA_4096;
  ------------------
  |  |  611|     14|#define AI_RSA_4096			    0x00000008U
  ------------------
 6072|     20|		break;
 6073|       |
 6074|      0|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (6074:2): [True: 0, False: 1.23k]
  ------------------
 6075|      0|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (6075:2): [True: 0, False: 1.23k]
  ------------------
 6076|      0|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (6076:2): [True: 0, False: 1.23k]
  ------------------
 6077|      0|	case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (6077:2): [True: 0, False: 1.23k]
  ------------------
 6078|      0|		priv->card_issues |= 0; /* could add others here */
 6079|      0|		break;
 6080|       |
 6081|    926|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (6081:2): [True: 926, False: 304]
  ------------------
 6082|    927|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (6082:2): [True: 1, False: 1.22k]
  ------------------
 6083|    929|	case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (6083:2): [True: 2, False: 1.22k]
  ------------------
 6084|    929|		priv->card_issues |= 0; /* could add others here */
 6085|    929|		break;
 6086|       |
 6087|      4|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (6087:2): [True: 4, False: 1.22k]
  ------------------
 6088|      4|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (6088:2): [True: 0, False: 1.23k]
  ------------------
 6089|      4|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (6089:2): [True: 0, False: 1.23k]
  ------------------
 6090|      4|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  592|      4|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 6091|      4|				     CI_PIV_AID_LOSE_STATE |
  ------------------
  |  |  598|      4|#define CI_PIV_AID_LOSE_STATE		    0x00000040U /* PIV AID can lose the login state run with out it*/
  ------------------
 6092|      4|				     CI_NO_RANDOM |
  ------------------
  |  |  594|      4|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
 6093|      4|				     CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  600|      4|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 6094|      4|		break;
 6095|       |
 6096|      0|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (6096:2): [True: 0, False: 1.23k]
  ------------------
 6097|      0|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  592|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 6098|      0|				     CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  600|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 6099|      0|		break;
 6100|       |
 6101|     18|	case SC_CARD_TYPE_PIV_II_PIVKEY:
  ------------------
  |  Branch (6101:2): [True: 18, False: 1.21k]
  ------------------
 6102|     18|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  592|     18|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 6103|     18|				     CI_PIV_AID_LOSE_STATE | /* be conservative */
  ------------------
  |  |  598|     18|#define CI_PIV_AID_LOSE_STATE		    0x00000040U /* PIV AID can lose the login state run with out it*/
  ------------------
 6104|     18|				     CI_NO_RANDOM;	     /* does not have 9B key */
  ------------------
  |  |  594|     18|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
 6105|       |							     /* Discovery object returns 6A 82 so is not on card by default */
 6106|     18|		break;
 6107|       |
 6108|      0|	default:
  ------------------
  |  Branch (6108:2): [True: 0, False: 1.23k]
  ------------------
 6109|      0|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  592|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 6110|      0|				     CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  600|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 6111|       |		/* opensc.conf may have it wrong, continue anyway */
 6112|      0|		sc_log(card->ctx, "Unknown PIV card->type %d", card->type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 6113|      0|		card->type = SC_CARD_TYPE_PIV_II_GENERIC;
 6114|  1.23k|	}
 6115|  1.23k|	sc_log(card->ctx, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6116|  1.23k|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 6117|       |
 6118|  1.23k|	if (!(priv->card_issues & CI_DISCOVERY_USELESS) && !(priv->init_flags & PIV_INIT_DISCOVERY_PARSED)) {
  ------------------
  |  |  597|  1.23k|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
              	if (!(priv->card_issues & CI_DISCOVERY_USELESS) && !(priv->init_flags & PIV_INIT_DISCOVERY_PARSED)) {
  ------------------
  |  |  382|  1.22k|#define PIV_INIT_DISCOVERY_PARSED		0x00000004u
  ------------------
  |  Branch (6118:6): [True: 1.22k, False: 4]
  |  Branch (6118:53): [True: 1.14k, False: 86]
  ------------------
 6119|       |		/*
 6120|       |		 * We now know PIV AID is active, test DISCOVERY object again
 6121|       |		 * Some PIV don't support DISCOVERY and return
 6122|       |		 * SC_ERROR_INCORRECT_PARAMETERS. Any error
 6123|       |		 * including SC_ERROR_FILE_NOT_FOUND means we cannot use discovery
 6124|       |		 * to test for active AID.
 6125|       |		 */
 6126|  1.14k|		r2 = piv_find_discovery(card);
 6127|       |
 6128|  1.14k|		if (r2 < 0) {
  ------------------
  |  Branch (6128:7): [True: 1.13k, False: 1]
  ------------------
 6129|  1.13k|			priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  597|  1.13k|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 6130|  1.13k|			piv_obj_cache_free_entry(card, PIV_OBJ_DISCOVERY, PIV_OBJ_CACHE_NOT_PRESENT);
  ------------------
  |  |  153|  1.13k|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 6131|  1.13k|		}
 6132|  1.14k|	}
 6133|       |
 6134|  1.23k|	sc_log(card->ctx, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6135|  1.23k|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 6136|       |	/* Matched, caller will use or free priv and sc_lock as needed */
 6137|  1.23k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.23k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.23k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.23k|	int _ret = r; \
  |  |  |  |  155|  1.23k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.23k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.23k|		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: 1.23k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.23k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.23k|	} 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|  1.23k|	return _ret; \
  |  |  |  |  163|  1.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6138|       |
 6139|  4.83k|err:
 6140|  4.83k|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH failed card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|  4.83k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6141|  4.83k|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 6142|       |	/* don't match. Does not have a PIV applet. */
 6143|  4.83k|	piv_finish(card);
 6144|  4.83k|	card->type = saved_type;
 6145|  4.83k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  4.83k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.83k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.83k|	int _ret = r; \
  |  |  |  |  155|  4.83k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.83k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.83k|		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|  4.83k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.83k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.83k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.83k|	} 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|  4.83k|	return _ret; \
  |  |  |  |  163|  4.83k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6146|  4.83k|}
card-piv.c:piv_find_discovery:
 5276|  1.73k|{
 5277|  1.73k|	int r = 0;
 5278|  1.73k|	size_t rbuflen;
 5279|  1.73k|	u8 *rbuf = NULL;
 5280|  1.73k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  1.73k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5281|       |
 5282|  1.73k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.73k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.73k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.73k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.73k]
  |  |  ------------------
  ------------------
 5283|       |
 5284|       |	/*
 5285|       |	 * During piv_card_reader_lock_obtained,
 5286|       |	 * we use the discovery object to test if card present, and
 5287|       |	 * if PIV AID is active.
 5288|       |	 */
 5289|  1.73k|	if (priv->obj_cache[PIV_OBJ_DISCOVERY].flags & PIV_OBJ_CACHE_NOT_PRESENT) {
  ------------------
  |  |  153|  1.73k|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
  |  Branch (5289:6): [True: 0, False: 1.73k]
  ------------------
 5290|      0|		r = SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
 5291|      0|		goto end;
 5292|      0|	}
 5293|       |
 5294|       |	/* If not valid: read, test,  cache */
 5295|  1.73k|	if (!(priv->obj_cache[PIV_OBJ_DISCOVERY].flags & PIV_OBJ_CACHE_VALID)) {
  ------------------
  |  |  151|  1.73k|#define PIV_OBJ_CACHE_VALID		1
  ------------------
  |  Branch (5295:6): [True: 1.53k, False: 205]
  ------------------
 5296|  1.53k|		r = piv_process_discovery(card);
 5297|  1.53k|	} else {
 5298|       |		/* if already in cache,force read */
 5299|    205|		rbuflen = 1;
 5300|    205|		r = piv_get_data(card, PIV_OBJ_DISCOVERY, &rbuf, &rbuflen);
 5301|       |		/* if same response as last, no need to parse */
 5302|    205|		if (r == 0 && priv->obj_cache[PIV_OBJ_DISCOVERY].obj_len == 0)
  ------------------
  |  Branch (5302:7): [True: 0, False: 205]
  |  Branch (5302:17): [True: 0, False: 0]
  ------------------
 5303|      0|			goto end;
 5304|       |
 5305|    205|		if (r >= 0 && priv->obj_cache[PIV_OBJ_DISCOVERY].obj_len == rbuflen &&
  ------------------
  |  Branch (5305:7): [True: 38, False: 167]
  |  Branch (5305:17): [True: 34, False: 4]
  ------------------
 5306|     34|				priv->obj_cache[PIV_OBJ_DISCOVERY].obj_data &&
  ------------------
  |  Branch (5306:5): [True: 34, False: 0]
  ------------------
 5307|     34|				!memcmp(rbuf, priv->obj_cache[PIV_OBJ_DISCOVERY].obj_data, rbuflen)) {
  ------------------
  |  Branch (5307:5): [True: 19, False: 15]
  ------------------
 5308|     19|			goto end;
 5309|     19|		}
 5310|       |		/* This should not happen  bad card */
 5311|    186|		sc_log(card->ctx, "Discovery not the same as previously read object");
  ------------------
  |  |   71|    186|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5312|    186|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|    186|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 5313|    186|		goto end;
 5314|    205|	}
 5315|       |
 5316|  1.73k|end:
 5317|  1.73k|	free(rbuf);
 5318|  1.73k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.73k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.73k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.73k|	int _ret = r; \
  |  |  |  |  155|  1.73k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.71k, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.71k|		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|  1.63k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.63k, False: 87]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.71k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.71k|	} else { \
  |  |  |  |  159|     19|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     19|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     19|	} \
  |  |  |  |  162|  1.73k|	return _ret; \
  |  |  |  |  163|  1.73k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5319|  1.73k|}
card-piv.c:piv_process_discovery:
 5169|  1.53k|{
 5170|  1.53k|	int r;
 5171|  1.53k|	u8 *rbuf = NULL;
 5172|  1.53k|	size_t rbuflen = 0;
 5173|       |
 5174|  1.53k|	r = piv_get_cached_data(card, PIV_OBJ_DISCOVERY, &rbuf, &rbuflen);
 5175|       |	/* Note rbuf and rbuflen are now pointers into cache */
 5176|  1.53k|	if (r < 0)
  ------------------
  |  Branch (5176:6): [True: 1.41k, False: 119]
  ------------------
 5177|  1.41k|		goto err;
 5178|       |
 5179|       |	/* the object is now cached, see what we have */
 5180|    119|	r = piv_parse_discovery(card, rbuf, rbuflen, 0);
 5181|       |
 5182|  1.53k|err:
 5183|  1.53k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.53k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.53k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.53k|	int _ret = r; \
  |  |  |  |  155|  1.53k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.53k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.53k|		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|  1.44k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.44k, False: 87]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.53k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.53k|	} 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|  1.53k|	return _ret; \
  |  |  |  |  163|  1.53k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5184|  1.53k|}
card-piv.c:piv_get_cached_data:
 3214|  15.2k|{
 3215|       |
 3216|  15.2k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  15.2k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 3217|  15.2k|	int r;
 3218|  15.2k|	u8 *rbuf = NULL;
 3219|  15.2k|	size_t rbuflen;
 3220|       |
 3221|  15.2k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  15.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  15.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  15.2k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 15.2k]
  |  |  ------------------
  ------------------
 3222|       |
 3223|  15.2k|	if (enumtag < 0 || enumtag >= PIV_OBJ_LAST_ENUM)
  ------------------
  |  Branch (3223:6): [True: 0, False: 15.2k]
  |  Branch (3223:21): [True: 0, False: 15.2k]
  ------------------
 3224|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3225|       |
 3226|  15.2k|	sc_log(card->ctx, "#%d, %s", enumtag, piv_objects[enumtag].name);
  ------------------
  |  |   71|  15.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3227|       |
 3228|       |	/* see if we have it cached */
 3229|  15.2k|	if (priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_VALID) {
  ------------------
  |  |  151|  15.2k|#define PIV_OBJ_CACHE_VALID		1
  ------------------
  |  Branch (3229:6): [True: 1.79k, False: 13.4k]
  ------------------
 3230|       |
 3231|  1.79k|		sc_log(card->ctx, "found #%d %p:%zu %p:%zu",
  ------------------
  |  |   71|  1.79k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3232|  1.79k|				enumtag,
 3233|  1.79k|				priv->obj_cache[enumtag].obj_data,
 3234|  1.79k|				priv->obj_cache[enumtag].obj_len,
 3235|  1.79k|				priv->obj_cache[enumtag].internal_obj_data,
 3236|  1.79k|				priv->obj_cache[enumtag].internal_obj_len);
 3237|       |
 3238|  1.79k|		if (priv->obj_cache[enumtag].obj_len == 0) {
  ------------------
  |  Branch (3238:7): [True: 0, False: 1.79k]
  ------------------
 3239|      0|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3240|      0|			sc_log(card->ctx, "#%d found but len=0", enumtag);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3241|      0|			goto err;
 3242|      0|		}
 3243|  1.79k|		*buf = priv->obj_cache[enumtag].obj_data;
 3244|  1.79k|		*buf_len = priv->obj_cache[enumtag].obj_len;
 3245|  1.79k|		r = (int)*buf_len;
 3246|  1.79k|		goto ok;
 3247|  1.79k|	}
 3248|       |
 3249|       |	/*
 3250|       |	 * If we know it can not be on the card  i.e. History object
 3251|       |	 * has been read, and we know what other certs may or
 3252|       |	 * may not be on the card. We can avoid extra overhead
 3253|       |	 * Also used if object on card was not parsable
 3254|       |	 */
 3255|       |
 3256|  13.4k|	if (priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_NOT_PRESENT) {
  ------------------
  |  |  153|  13.4k|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
  |  Branch (3256:6): [True: 0, False: 13.4k]
  ------------------
 3257|      0|		sc_log(card->ctx, "no_obj #%d", enumtag);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3258|      0|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3259|      0|		goto err;
 3260|      0|	}
 3261|       |
 3262|       |	/* Not cached, try to get it, piv_get_data will allocate a buf */
 3263|  13.4k|	sc_log(card->ctx, "get #%d", enumtag);
  ------------------
  |  |   71|  13.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3264|  13.4k|	rbuflen = 1;
 3265|  13.4k|	r = piv_get_data(card, enumtag, &rbuf, &rbuflen);
 3266|  13.4k|	if (r > 0) {
  ------------------
  |  Branch (3266:6): [True: 2.51k, False: 10.9k]
  ------------------
 3267|  2.51k|		priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
  ------------------
  |  |  151|  2.51k|#define PIV_OBJ_CACHE_VALID		1
  ------------------
 3268|  2.51k|		priv->obj_cache[enumtag].obj_len = r;
 3269|  2.51k|		priv->obj_cache[enumtag].obj_data = rbuf;
 3270|  2.51k|		*buf = rbuf;
 3271|  2.51k|		*buf_len = r;
 3272|       |
 3273|  2.51k|		sc_log(card->ctx, "added #%d  %p:%zu %p:%zu",
  ------------------
  |  |   71|  2.51k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3274|  2.51k|				enumtag,
 3275|  2.51k|				priv->obj_cache[enumtag].obj_data,
 3276|  2.51k|				priv->obj_cache[enumtag].obj_len,
 3277|  2.51k|				priv->obj_cache[enumtag].internal_obj_data,
 3278|  2.51k|				priv->obj_cache[enumtag].internal_obj_len);
 3279|       |
 3280|  10.9k|	} else {
 3281|  10.9k|		free(rbuf);
 3282|  10.9k|		if (r == 0 || r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|  10.9k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (3282:7): [True: 0, False: 10.9k]
  |  Branch (3282:17): [True: 1.26k, False: 9.67k]
  ------------------
 3283|  1.26k|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|  1.26k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3284|  1.26k|			priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
  ------------------
  |  |  151|  1.26k|#define PIV_OBJ_CACHE_VALID		1
  ------------------
 3285|  1.26k|			priv->obj_cache[enumtag].obj_len = 0;
 3286|  9.67k|		} else {
 3287|  9.67k|			goto err;
 3288|  9.67k|		}
 3289|  10.9k|	}
 3290|  5.57k|ok:
 3291|       |
 3292|  15.2k|err:
 3293|  15.2k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  15.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  15.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  15.2k|	int _ret = r; \
  |  |  |  |  155|  15.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10.9k, False: 4.30k]
  |  |  |  |  ------------------
  |  |  |  |  156|  10.9k|		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|  10.9k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  10.9k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  10.9k|	} else { \
  |  |  |  |  159|  4.30k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  4.30k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  4.30k|	} \
  |  |  |  |  162|  15.2k|	return _ret; \
  |  |  |  |  163|  15.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3294|  15.2k|}
card-piv.c:piv_parse_discovery:
 5113|    119|{
 5114|    119|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|    119|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5115|    119|	int r = 0;
 5116|    119|	const u8 *body;
 5117|    119|	size_t bodylen;
 5118|    119|	const u8 *aid;
 5119|    119|	size_t aidlen;
 5120|    119|	const u8 *pinp;
 5121|    119|	size_t pinplen;
 5122|    119|	unsigned int cla_out, tag_out;
 5123|       |
 5124|    119|	if (rbuflen != 0) {
  ------------------
  |  Branch (5124:6): [True: 119, False: 0]
  ------------------
 5125|    119|		body = rbuf;
 5126|    119|		if ((r = sc_asn1_read_tag(&body, rbuflen, &cla_out, &tag_out, &bodylen)) != SC_SUCCESS ||
  ------------------
  |  |   28|    238|#define SC_SUCCESS				0
  ------------------
  |  Branch (5126:7): [True: 0, False: 119]
  ------------------
 5127|    119|				body == NULL ||
  ------------------
  |  Branch (5127:5): [True: 0, False: 119]
  ------------------
 5128|    119|				bodylen == 0 ||
  ------------------
  |  Branch (5128:5): [True: 2, False: 117]
  ------------------
 5129|    117|				((cla_out | tag_out) != 0x7E)) {
  ------------------
  |  Branch (5129:5): [True: 0, False: 117]
  ------------------
 5130|      2|			sc_log(card->ctx, "DER problem %d", r);
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5131|      2|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      2|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5132|      2|			goto err;
 5133|      2|		}
 5134|       |
 5135|    117|		sc_log(card->ctx, "Discovery 0x%2.2x 0x%2.2x %p:%zu",
  ------------------
  |  |   71|    117|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5136|    117|				cla_out, tag_out, body, bodylen);
 5137|    117|		aidlen = 0;
 5138|    117|		aid = sc_asn1_find_tag(card->ctx, body, bodylen, 0x4F, &aidlen);
 5139|    117|		if (aid == NULL || aidlen < piv_aids[0].len_short ||
  ------------------
  |  Branch (5139:7): [True: 13, False: 104]
  |  Branch (5139:22): [True: 2, False: 102]
  ------------------
 5140|    102|				memcmp(aid, piv_aids[0].value, piv_aids[0].len_short) != 0) {
  ------------------
  |  Branch (5140:5): [True: 15, False: 87]
  ------------------
 5141|     30|			sc_log(card->ctx, "Discovery object not PIV");
  ------------------
  |  |   71|     30|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5142|     30|			r = SC_ERROR_INVALID_CARD; /* This is an error */
  ------------------
  |  |   60|     30|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 5143|     30|			goto err;
 5144|     30|		}
 5145|     87|		if (aid_only == 0) {
  ------------------
  |  Branch (5145:7): [True: 87, False: 0]
  ------------------
 5146|     87|			pinp = sc_asn1_find_tag(card->ctx, body, bodylen, 0x5F2F, &pinplen);
 5147|     87|			if (pinp && pinplen == 2) {
  ------------------
  |  Branch (5147:8): [True: 17, False: 70]
  |  Branch (5147:16): [True: 15, False: 2]
  ------------------
 5148|     15|				priv->init_flags |= PIV_INIT_DISCOVERY_PP;
  ------------------
  |  |  383|     15|#define PIV_INIT_DISCOVERY_PP			0x00000008u
  ------------------
 5149|     15|				priv->pin_policy = (*pinp << 8) + *(pinp + 1);
 5150|     15|				sc_log(card->ctx, "Discovery pinp flags=0x%2.2x 0x%2.2x", *pinp, *(pinp + 1));
  ------------------
  |  |   71|     15|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5151|     15|				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  371|     15|#define PIV_PP_PIN		0x00004000u
  ------------------
              				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  372|     15|#define PIV_PP_GLOBAL		0x00002000u
  ------------------
              				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  371|     15|#define PIV_PP_PIN		0x00004000u
  ------------------
              				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  372|     15|#define PIV_PP_GLOBAL		0x00002000u
  ------------------
  |  Branch (5151:9): [True: 5, False: 10]
  ------------------
 5152|      5|						priv->pin_policy & PIV_PP_GLOBAL_PRIMARY) {
  ------------------
  |  |  377|      5|#define PIV_PP_GLOBAL_PRIMARY	0x00000020u
  ------------------
  |  Branch (5152:7): [True: 1, False: 4]
  ------------------
 5153|      1|					sc_log(card->ctx, "Pin Preference - Global");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5154|      1|					priv->pin_preference = 0x00;
 5155|      1|				}
 5156|     15|			}
 5157|     87|		}
 5158|     87|		r = SC_SUCCESS;
  ------------------
  |  |   28|     87|#define SC_SUCCESS				0
  ------------------
 5159|     87|		priv->init_flags |= PIV_INIT_DISCOVERY_PARSED;
  ------------------
  |  |  382|     87|#define PIV_INIT_DISCOVERY_PARSED		0x00000004u
  ------------------
 5160|     87|	}
 5161|       |
 5162|    119|err:
 5163|    119|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    119|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    119|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    119|	int _ret = r; \
  |  |  |  |  155|    119|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 119, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    119|		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|     32|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 32, False: 87]
  |  |  |  |  ------------------
  |  |  |  |  157|    119|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    119|	} 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|    119|	return _ret; \
  |  |  |  |  163|    119|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5164|    119|}
card-piv.c:piv_get_data:
 3104|  13.6k|{
 3105|  13.6k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  13.6k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 3106|  13.6k|	u8 *p;
 3107|  13.6k|	u8 *tbuf;
 3108|  13.6k|	int r = 0;
 3109|  13.6k|	u8 tagbuf[8];
 3110|  13.6k|	size_t tag_len;
 3111|  13.6k|	int alloc_buf = 0;
 3112|       |
 3113|  13.6k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  13.6k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  13.6k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  13.6k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 13.6k]
  |  |  ------------------
  ------------------
 3114|       |
 3115|  13.6k|	sc_log(card->ctx, "#%d, %s", enumtag, piv_objects[enumtag].name);
  ------------------
  |  |   71|  13.6k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3116|       |
 3117|  13.6k|	r = sc_lock(card); /* do check len and get data in same transaction */
 3118|  13.6k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  13.6k|#define SC_SUCCESS				0
  ------------------
  |  Branch (3118:6): [True: 0, False: 13.6k]
  ------------------
 3119|      0|		sc_log(card->ctx, "sc_lock failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3120|      0|		return r;
 3121|      0|	}
 3122|       |
 3123|  13.6k|	tag_len = piv_objects[enumtag].tag_len;
 3124|       |
 3125|  13.6k|	p = tagbuf;
 3126|  13.6k|	r = sc_asn1_put_tag(0x5c, piv_objects[enumtag].tag_value, tag_len, tagbuf, sizeof(tagbuf), &p);
 3127|  13.6k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  13.6k|#define SC_SUCCESS				0
  ------------------
  |  Branch (3127:6): [True: 0, False: 13.6k]
  ------------------
 3128|      0|		sc_log(card->ctx, "Failed to encode ASN1 tag");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3129|      0|		goto err;
 3130|      0|	}
 3131|       |
 3132|  13.6k|	if (*buf_len == 1 && *buf == NULL) {
  ------------------
  |  Branch (3132:6): [True: 13.6k, False: 13]
  |  Branch (3132:23): [True: 13.6k, False: 0]
  ------------------
 3133|  13.6k|		*buf_len = priv->max_object_size; /* will allocate below */
 3134|  13.6k|		alloc_buf = 1;
 3135|  13.6k|	}
 3136|       |
 3137|  13.6k|	sc_log(card->ctx, "buffer for #%d *buf=0x%p len=%zu", enumtag, *buf, *buf_len);
  ------------------
  |  |   71|  13.6k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3138|  13.6k|	if (*buf == NULL && *buf_len > 0) {
  ------------------
  |  Branch (3138:6): [True: 13.6k, False: 13]
  |  Branch (3138:22): [True: 13.6k, False: 0]
  ------------------
 3139|  13.6k|		if (*buf_len > MAX_FILE_SIZE) {
  ------------------
  |  |  220|  13.6k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (3139:7): [True: 0, False: 13.6k]
  ------------------
 3140|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3141|      0|			goto err;
 3142|      0|		}
 3143|  13.6k|		*buf = malloc(*buf_len);
 3144|  13.6k|		if (*buf == NULL) {
  ------------------
  |  Branch (3144:7): [True: 0, False: 13.6k]
  ------------------
 3145|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3146|      0|			goto err;
 3147|      0|		}
 3148|  13.6k|	}
 3149|       |
 3150|       |#ifdef ENABLE_PIV_SM
 3151|       |	/*
 3152|       |	 * Over contact reader, OK to read non sensitive object in clear even when SM is active
 3153|       |	 * but only if using default policy and we are not in reader_lock_obtained
 3154|       |	 * Discovery object will use SM from reader_lock_obtained to catch if SM is still valid
 3155|       |	 * i.e. no interference from other applications
 3156|       |	 */
 3157|       |	sc_log(card->ctx, "enumtag:%d sm_ctx.sm_mode:%d piv_objects[enumtag].flags:0x%8.8x sm_flags:0x%8.8lx it_flags:0x%8.8x",
 3158|       |			enumtag, card->sm_ctx.sm_mode, piv_objects[enumtag].flags, priv->sm_flags, priv->init_flags);
 3159|       |	if (priv->sm_flags & PIV_SM_FLAGS_SM_IS_ACTIVE &&
 3160|       |			enumtag != PIV_OBJ_DISCOVERY &&
 3161|       |			card->sm_ctx.sm_mode == SM_MODE_TRANSMIT &&
 3162|       |			!(piv_objects[enumtag].flags & PIV_OBJECT_NEEDS_PIN) &&
 3163|       |			!(priv->sm_flags & (PIV_SM_FLAGS_NEVER | PIV_SM_FLAGS_ALWAYS)) &&
 3164|       |			!(priv->init_flags & (PIV_INIT_CONTACTLESS | PIV_INIT_IN_READER_LOCK_OBTAINED))) {
 3165|       |		sc_log(card->ctx, "Set PIV_SM_GET_DATA_IN_CLEAR");
 3166|       |		priv->sm_flags |= PIV_SM_GET_DATA_IN_CLEAR;
 3167|       |	}
 3168|       |
 3169|       |#endif /* ENABLE_PIV_SM */
 3170|  13.6k|	r = piv_general_io(card, 0xCB, 0x3F, 0xFF, tagbuf, p - tagbuf, *buf, *buf_len);
 3171|  13.6k|	if (r > 0) {
  ------------------
  |  Branch (3171:6): [True: 3.30k, False: 10.3k]
  ------------------
 3172|  3.30k|		int r_tag;
 3173|  3.30k|		unsigned int cla_out, tag_out;
 3174|  3.30k|		size_t bodylen = 0;
 3175|  3.30k|		const u8 *body = *buf;
 3176|  3.30k|		r_tag = sc_asn1_read_tag(&body, r, &cla_out, &tag_out, &bodylen);
 3177|  3.30k|		if (r_tag != SC_SUCCESS || body == NULL ||
  ------------------
  |  |   28|  6.60k|#define SC_SUCCESS				0
  ------------------
  |  Branch (3177:7): [True: 226, False: 3.07k]
  |  Branch (3177:30): [True: 151, False: 2.92k]
  ------------------
 3178|  2.92k|				((cla_out << 24 | tag_out) != piv_objects[enumtag].resp_tag)) {
  ------------------
  |  Branch (3178:5): [True: 373, False: 2.55k]
  ------------------
 3179|    750|			sc_log(card->ctx, "invalid tag or length r_tag:%d body:%p", r_tag, body);
  ------------------
  |  |   71|    750|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3180|    750|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|    750|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3181|    750|			goto err;
 3182|    750|		}
 3183|  2.55k|		*buf_len = (body - *buf) + bodylen;
 3184|  10.3k|	} else if (r == 0) {
  ------------------
  |  Branch (3184:13): [True: 194, False: 10.1k]
  ------------------
 3185|    194|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|    194|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3186|    194|		goto err;
 3187|  10.1k|	} else {
 3188|  10.1k|		goto err;
 3189|  10.1k|	}
 3190|       |
 3191|  2.55k|	if (alloc_buf && *buf) {
  ------------------
  |  Branch (3191:6): [True: 2.55k, False: 1]
  |  Branch (3191:19): [True: 2.55k, False: 0]
  ------------------
 3192|  2.55k|		tbuf = malloc(r);
 3193|  2.55k|		if (tbuf == NULL) {
  ------------------
  |  Branch (3193:7): [True: 0, False: 2.55k]
  ------------------
 3194|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3195|      0|			goto err;
 3196|      0|		}
 3197|  2.55k|		memcpy(tbuf, *buf, r);
 3198|  2.55k|		free(*buf);
 3199|  2.55k|		alloc_buf = 0;
 3200|  2.55k|		*buf = tbuf;
 3201|  2.55k|	}
 3202|       |
 3203|  13.6k|err:
 3204|  13.6k|	if (alloc_buf) {
  ------------------
  |  Branch (3204:6): [True: 11.1k, False: 2.56k]
  ------------------
 3205|  11.1k|		free(*buf);
 3206|  11.1k|		*buf = NULL;
 3207|  11.1k|	}
 3208|  13.6k|	sc_unlock(card);
 3209|  13.6k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  13.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  13.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  13.6k|	int _ret = r; \
  |  |  |  |  155|  13.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11.1k, False: 2.55k]
  |  |  |  |  ------------------
  |  |  |  |  156|  11.1k|		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|  11.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 11.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  11.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  11.1k|	} else { \
  |  |  |  |  159|  2.55k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  2.55k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  2.55k|	} \
  |  |  |  |  162|  13.6k|	return _ret; \
  |  |  |  |  163|  13.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3210|  13.6k|}
card-piv.c:piv_general_io:
 1803|  23.7k|{
 1804|  23.7k|	int r, cse;
 1805|  23.7k|	sc_apdu_t apdu;
 1806|       |
 1807|  23.7k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  23.7k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  23.7k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  23.7k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 23.7k]
  |  |  ------------------
  ------------------
 1808|       |
 1809|  23.7k|	r = sc_lock(card);
 1810|  23.7k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|  23.7k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1810:6): [True: 0, False: 23.7k]
  ------------------
 1811|  23.7k|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1812|       |
 1813|  23.7k|	cse = recvbuf ? (sendbuf ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_2_SHORT) :
  ------------------
  |  |  294|  14.1k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              	cse = recvbuf ? (sendbuf ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_2_SHORT) :
  ------------------
  |  |  292|  9.63k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  |  Branch (1813:8): [True: 23.7k, False: 0]
  |  Branch (1813:19): [True: 14.1k, False: 9.63k]
  ------------------
 1814|  23.7k|			(sendbuf ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_1);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
              			(sendbuf ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_1);
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  |  Branch (1814:5): [True: 0, False: 0]
  ------------------
 1815|       |
 1816|  23.7k|	sc_format_apdu(card, &apdu, cse, ins, p1, p2);
 1817|  23.7k|	if (sendbuflen > 255) {
  ------------------
  |  Branch (1817:6): [True: 0, False: 23.7k]
  ------------------
 1818|      0|		apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|      0|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 1819|       |#ifdef ENABLE_PIV_SM
 1820|       |		if (card->sm_ctx.sm_mode != SM_MODE_NONE) {
 1821|       |			/* tell apdu.c to not do the chaining, let the SM get_apdu do it */
 1822|       |			apdu.flags |= SC_APDU_FLAGS_SM_CHAINING;
 1823|       |		}
 1824|       |#endif
 1825|      0|	}
 1826|  23.7k|	apdu.lc = sendbuflen;
 1827|  23.7k|	apdu.datalen = sendbuflen;
 1828|  23.7k|	apdu.data = sendbuf;
 1829|       |
 1830|  23.7k|	if (recvbuf && recvbuflen) {
  ------------------
  |  Branch (1830:6): [True: 23.7k, False: 0]
  |  Branch (1830:17): [True: 23.7k, False: 0]
  ------------------
 1831|  23.7k|		apdu.le = (recvbuflen > 256) ? 256 : recvbuflen;
  ------------------
  |  Branch (1831:13): [True: 23.7k, False: 13]
  ------------------
 1832|  23.7k|		apdu.resplen = recvbuflen;
 1833|  23.7k|	} else {
 1834|      0|		apdu.le = 0;
 1835|      0|		apdu.resplen = 0;
 1836|      0|	}
 1837|  23.7k|	apdu.resp = recvbuf;
 1838|       |
 1839|       |	/* with new adpu.c and chaining, this actually reads the whole object */
 1840|  23.7k|	r = sc_transmit_apdu(card, &apdu);
 1841|       |
 1842|       |	/* adpu will not have sw1,sw2 set because sc_sm_single_transmit called sc_sm_stop, */
 1843|  23.7k|	if (r < 0) {
  ------------------
  |  Branch (1843:6): [True: 258, False: 23.5k]
  ------------------
 1844|    258|		sc_log(card->ctx, "Transmit failed");
  ------------------
  |  |   71|    258|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1845|    258|		goto err;
 1846|    258|	}
 1847|       |
 1848|  23.5k|	if (apdu.sw1 == 0x69 && apdu.sw2 == 0x88)
  ------------------
  |  Branch (1848:6): [True: 147, False: 23.3k]
  |  Branch (1848:26): [True: 56, False: 91]
  ------------------
 1849|     56|		r = SC_ERROR_SM_INVALID_SESSION_KEY;
  ------------------
  |  |  119|     56|#define SC_ERROR_SM_INVALID_SESSION_KEY		-1604
  ------------------
 1850|  23.4k|	else
 1851|  23.4k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1852|       |
 1853|  23.5k|	if (r < 0) {
  ------------------
  |  Branch (1853:6): [True: 19.2k, False: 4.25k]
  ------------------
 1854|  19.2k|		sc_log(card->ctx, "Card returned error ");
  ------------------
  |  |   71|  19.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1855|  19.2k|		goto err;
 1856|  19.2k|	}
 1857|       |
 1858|  4.25k|	r = (int)apdu.resplen;
 1859|       |
 1860|  23.7k|err:
 1861|  23.7k|	sc_unlock(card);
 1862|  23.7k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  23.7k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  23.7k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  23.7k|	int _ret = r; \
  |  |  |  |  155|  23.7k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 19.7k, False: 3.98k]
  |  |  |  |  ------------------
  |  |  |  |  156|  19.7k|		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|  19.5k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 19.5k, False: 265]
  |  |  |  |  ------------------
  |  |  |  |  157|  19.7k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  19.7k|	} else { \
  |  |  |  |  159|  3.98k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  3.98k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  3.98k|	} \
  |  |  |  |  162|  23.7k|	return _ret; \
  |  |  |  |  163|  23.7k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1863|  23.7k|}
card-piv.c:piv_obj_cache_free_entry:
 5573|   365k|{
 5574|   365k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|   365k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5575|       |
 5576|   365k|	if (priv->obj_cache[enumtag].obj_data)
  ------------------
  |  Branch (5576:6): [True: 2.51k, False: 363k]
  ------------------
 5577|  2.51k|		free(priv->obj_cache[enumtag].obj_data);
 5578|   365k|	priv->obj_cache[enumtag].obj_data = NULL;
 5579|   365k|	priv->obj_cache[enumtag].obj_len = 0;
 5580|       |
 5581|   365k|	if (priv->obj_cache[enumtag].internal_obj_data)
  ------------------
  |  Branch (5581:6): [True: 1.79k, False: 363k]
  ------------------
 5582|  1.79k|		free(priv->obj_cache[enumtag].internal_obj_data);
 5583|   365k|	priv->obj_cache[enumtag].internal_obj_data = NULL;
 5584|   365k|	priv->obj_cache[enumtag].internal_obj_len = 0;
 5585|   365k|	priv->obj_cache[enumtag].flags = flags;
 5586|       |
 5587|   365k|	return SC_SUCCESS;
  ------------------
  |  |   28|   365k|#define SC_SUCCESS				0
  ------------------
 5588|   365k|}
card-piv.c:piv_find_aid:
 2915|  6.19k|{
 2916|  6.19k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  6.19k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 2917|  6.19k|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 2918|  6.19k|	int r, i, j;
 2919|  6.19k|	const u8 *tag;
 2920|  6.19k|	size_t taglen;
 2921|  6.19k|	const u8 *nextac;
 2922|  6.19k|	const u8 *next80;
 2923|  6.19k|	const u8 *pix;
 2924|  6.19k|	size_t pixlen;
 2925|  6.19k|	const u8 *al_label;
 2926|  6.19k|	size_t al_labellen;
 2927|  6.19k|	const u8 *actag; /* Cipher Suite */
 2928|  6.19k|	size_t actaglen;
 2929|  6.19k|	const u8 *csai; /* Cipher Suite Algorithm Identifier */
 2930|  6.19k|	size_t csailen;
 2931|  6.19k|	size_t resplen = sizeof(rbuf);
 2932|       |#ifdef ENABLE_PIV_SM
 2933|       |	int found_csai = 0;
 2934|       |#endif
 2935|       |
 2936|  6.19k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  6.19k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  6.19k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  6.19k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 6.19k]
  |  |  ------------------
  ------------------
 2937|       |
 2938|       |	/* first  see if the default application will return a template
 2939|       |	 * that we know about.
 2940|       |	 */
 2941|       |
 2942|  6.19k|	r = iso7816_select_aid(card, piv_aids[0].value, piv_aids[0].len_short, rbuf, &resplen);
 2943|  6.19k|	if (r > 0 && priv->aid_der.value && resplen == priv->aid_der.len && !memcmp(priv->aid_der.value, rbuf, resplen)) {
  ------------------
  |  Branch (2943:6): [True: 0, False: 6.19k]
  |  Branch (2943:15): [True: 0, False: 0]
  |  Branch (2943:38): [True: 0, False: 0]
  |  Branch (2943:70): [True: 0, False: 0]
  ------------------
 2944|      0|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2945|       |		/* no need to parse again, same as last time */
 2946|      0|	}
 2947|  6.19k|	if (r >= 0 && resplen > 2) {
  ------------------
  |  Branch (2947:6): [True: 1.32k, False: 4.87k]
  |  Branch (2947:16): [True: 1.27k, False: 43]
  ------------------
 2948|  1.27k|		tag = sc_asn1_find_tag(card->ctx, rbuf, resplen, 0x61, &taglen);
 2949|  1.27k|		if (tag != NULL) {
  ------------------
  |  Branch (2949:7): [True: 1.22k, False: 51]
  ------------------
 2950|  1.22k|			priv->init_flags |= PIV_INIT_AID_PARSED;
  ------------------
  |  |  380|  1.22k|#define PIV_INIT_AID_PARSED			0x00000001u
  ------------------
 2951|       |			/* look for 800-73-4 0xAC for Cipher Suite Algorithm Identifier Table 14 */
 2952|       |			/* 800-73-4 only expects 1 0xAC tag len 6 with a 80 01 xx 06 01 00
 2953|       |			 * where xx is the SM csID either 27 or 2E.
 2954|       |			 * Some vendors may include entries for supported Algorithms even when
 2955|       |			 * not required. We will use these if possible
 2956|       |			 * Will look for multiple 0x80 with in 0xAC value too.
 2957|       |			 */
 2958|  1.22k|			nextac = tag;
 2959|  1.34k|			while ((actag = sc_asn1_find_tag(card->ctx, nextac, taglen - (nextac - tag),
  ------------------
  |  Branch (2959:11): [True: 119, False: 1.22k]
  ------------------
 2960|  1.34k|						0xAC, &actaglen)) != NULL) {
 2961|    119|				nextac = actag + actaglen;
 2962|       |
 2963|    119|				next80 = actag;
 2964|    230|				while ((csai = sc_asn1_find_tag(card->ctx, next80, actaglen - (next80 - actag),
  ------------------
  |  Branch (2964:12): [True: 111, False: 119]
  ------------------
 2965|    230|							0x80, &csailen)) != NULL) {
 2966|    111|					next80 = csai + csailen;
 2967|    111|					if (csailen == 1) {
  ------------------
  |  Branch (2967:10): [True: 72, False: 39]
  ------------------
 2968|     72|						sc_log(card->ctx, "0xAC 0x80 entry:0x%2.2x found", *csai);
  ------------------
  |  |   71|     72|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2969|     72|						j = piv_ai_map_find_by_id(card, *csai);
 2970|     72|						if (j >= 0) {
  ------------------
  |  Branch (2970:11): [True: 46, False: 26]
  ------------------
 2971|     46|							priv->alg_ids |= ai_map[j].ai_flag;
 2972|     46|							continue;
 2973|     46|						}
 2974|       |#ifdef ENABLE_PIV_SM
 2975|       |						/* check if id is NIST SM */
 2976|       |						for (i = 0; i < PIV_CSS_SIZE; i++) {
 2977|       |							if (*csai != css[i].id)
 2978|       |								continue;
 2979|       |							if (found_csai) {
 2980|       |								sc_log(card->ctx, "found multiple csIDs, using first");
 2981|       |							} else {
 2982|       |								priv->cs = &css[i];
 2983|       |								priv->csID = *csai;
 2984|       |								found_csai++;
 2985|       |								priv->init_flags |= PIV_INIT_AID_AC_SM;
 2986|       |							}
 2987|       |						}
 2988|       |#endif /* ENABLE_PIV_SM */
 2989|     72|					}
 2990|    111|				}
 2991|    119|			}
 2992|       |
 2993|       |			/* Last chance to distinguish card type based on Application Label '50' */
 2994|  1.22k|			al_label = sc_asn1_find_tag(card->ctx, tag, taglen, 0x50, &al_labellen);
 2995|  1.22k|			if (al_label != NULL) {
  ------------------
  |  Branch (2995:8): [True: 16, False: 1.21k]
  ------------------
 2996|     16|				sc_log_hex(card->ctx, "Application Label", al_label, al_labellen);
  ------------------
  |  |  129|     16|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     16|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2997|     16|				free(priv->al_label);
 2998|     16|				if ((priv->al_label = malloc(al_labellen)) == NULL) {
  ------------------
  |  Branch (2998:9): [True: 0, False: 16]
  ------------------
 2999|      0|					LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3000|      0|				}
 3001|     16|				memcpy(priv->al_label, al_label, al_labellen);
 3002|     16|				priv->al_labellen = (int)al_labellen;
 3003|     16|			}
 3004|       |
 3005|  1.22k|			pix = sc_asn1_find_tag(card->ctx, tag, taglen, 0x4F, &pixlen);
 3006|  1.22k|			if (pix != NULL) {
  ------------------
  |  Branch (3006:8): [True: 1.17k, False: 54]
  ------------------
 3007|  1.17k|				sc_log(card->ctx, "found PIX");
  ------------------
  |  |   71|  1.17k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3008|       |
 3009|       |				/* early cards returned full AID, rather then just the pix */
 3010|  1.24k|				for (i = 0; piv_aids[i].len_long != 0; i++) {
  ------------------
  |  Branch (3010:17): [True: 1.21k, False: 27]
  ------------------
 3011|  1.21k|					if ((pixlen >= piv_aids[i].len_long - 5 &&
  ------------------
  |  Branch (3011:11): [True: 1.21k, False: 2]
  ------------------
 3012|  1.21k|							    memcmp(pix, piv_aids[i].value + 5, piv_aids[i].len_long - 5) == 0) ||
  ------------------
  |  Branch (3012:12): [True: 1.13k, False: 78]
  ------------------
 3013|     80|							((pixlen >= piv_aids[i].len_short && memcmp(pix, piv_aids[i].value,
  ------------------
  |  Branch (3013:10): [True: 52, False: 28]
  |  Branch (3013:45): [True: 11, False: 41]
  ------------------
 3014|  1.14k|													     piv_aids[i].len_short) == 0))) {
 3015|  1.14k|						free(priv->aid_der.value); /* free previous value if any */
 3016|  1.14k|						if ((priv->aid_der.value = malloc(resplen)) == NULL) {
  ------------------
  |  Branch (3016:11): [True: 0, False: 1.14k]
  ------------------
 3017|      0|							LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3018|      0|						}
 3019|  1.14k|						memcpy(priv->aid_der.value, rbuf, resplen);
 3020|  1.14k|						priv->aid_der.len = resplen;
 3021|  1.14k|						LOG_FUNC_RETURN(card->ctx, i);
  ------------------
  |  |  164|  1.14k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.14k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.14k|	int _ret = r; \
  |  |  |  |  155|  1.14k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.13k, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.13k|		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: 1.13k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.13k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.13k|	} else { \
  |  |  |  |  159|     15|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     15|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     15|	} \
  |  |  |  |  162|  1.14k|	return _ret; \
  |  |  |  |  163|  1.14k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3022|  1.14k|					}
 3023|  1.21k|				}
 3024|  1.17k|			}
 3025|  1.22k|		}
 3026|  1.27k|	}
 3027|       |
 3028|  5.05k|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NO_CARD_SUPPORT);
  ------------------
  |  |  164|  5.05k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.05k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.05k|	int _ret = r; \
  |  |  |  |  155|  5.05k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5.05k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  5.05k|		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|  5.05k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5.05k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  5.05k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  5.05k|	} 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|  5.05k|	return _ret; \
  |  |  |  |  163|  5.05k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3029|  5.05k|}
card-piv.c:piv_ai_map_find_by_id:
 2898|     72|{
 2899|       |	/* piv_private_data_t * priv = PIV_DATA(card); */
 2900|     72|	int i;
 2901|       |
 2902|    350|	for (i = 0; ai_map[i].ai_id != 0; i++) {
  ------------------
  |  Branch (2902:14): [True: 324, False: 26]
  ------------------
 2903|    324|		if (ai_map[i].ai_id == id)
  ------------------
  |  Branch (2903:7): [True: 46, False: 278]
  ------------------
 2904|     46|			return i;
 2905|    324|	}
 2906|     26|	return -1;
 2907|     72|}
card-piv.c:piv_process_ccc:
 5257|    931|{
 5258|    931|	int r = 0;
 5259|    931|	u8 *rbuf = NULL;
 5260|    931|	size_t rbuflen = 0;
 5261|       |
 5262|    931|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    931|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    931|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    931|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 931]
  |  |  ------------------
  ------------------
 5263|    931|	r = piv_get_cached_data(card, PIV_OBJ_CCC, &rbuf, &rbuflen);
 5264|       |
 5265|    931|	if (r < 0)
  ------------------
  |  Branch (5265:6): [True: 873, False: 58]
  ------------------
 5266|    873|		goto err;
 5267|       |
 5268|       |	/* the object is now cached, see what we have */
 5269|     58|	r = piv_parse_ccc(card, rbuf, rbuflen);
 5270|    931|err:
 5271|    931|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    931|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    931|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    931|	int _ret = r; \
  |  |  |  |  155|    931|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 931, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    931|		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|    917|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 917, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|    931|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    931|	} 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|    931|	return _ret; \
  |  |  |  |  163|    931|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5272|    931|}
card-piv.c:piv_parse_ccc:
 5193|     58|{
 5194|     58|	int r = 0;
 5195|     58|	const u8 *body;
 5196|     58|	size_t bodylen;
 5197|     58|	unsigned int cla_out, tag_out;
 5198|       |
 5199|     58|	u8 tag;
 5200|     58|	const u8 *end;
 5201|     58|	size_t len;
 5202|       |
 5203|     58|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|     58|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5204|       |
 5205|     58|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     58|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     58|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     58|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 58]
  |  |  ------------------
  ------------------
 5206|       |
 5207|     58|	if (rbuf == NULL || rbuflen == 0) {
  ------------------
  |  Branch (5207:6): [True: 0, False: 58]
  |  Branch (5207:22): [True: 0, False: 58]
  ------------------
 5208|      0|		r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 5209|      0|		goto err;
 5210|      0|	}
 5211|       |
 5212|       |	/* Outer layer is a DER tlv */
 5213|     58|	body = rbuf;
 5214|     58|	if ((r = sc_asn1_read_tag(&body, rbuflen, &cla_out, &tag_out, &bodylen)) != SC_SUCCESS ||
  ------------------
  |  |   28|    116|#define SC_SUCCESS				0
  ------------------
  |  Branch (5214:6): [True: 0, False: 58]
  ------------------
 5215|     58|			body == NULL ||
  ------------------
  |  Branch (5215:4): [True: 0, False: 58]
  ------------------
 5216|     58|			bodylen == 0 ||
  ------------------
  |  Branch (5216:4): [True: 1, False: 57]
  ------------------
 5217|     57|			((cla_out << 24 | tag_out) != piv_objects[PIV_OBJ_CCC].resp_tag)) {
  ------------------
  |  Branch (5217:4): [True: 0, False: 57]
  ------------------
 5218|      1|		sc_log(card->ctx, "DER problem %d", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5219|      1|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      1|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5220|      1|		goto err;
 5221|      1|	}
 5222|       |
 5223|     57|	priv->ccc_flags |= PIV_CCC_FOUND;
  ------------------
  |  |  170|     57|#define PIV_CCC_FOUND		0x00000001
  ------------------
 5224|       |
 5225|       |	/* CCC  entries are simple tlv */
 5226|     57|	end = body + bodylen;
 5227|  1.03k|	for (; (body < end); body += len) {
  ------------------
  |  Branch (5227:9): [True: 1.02k, False: 14]
  ------------------
 5228|  1.02k|		r = sc_simpletlv_read_tag(&body, end - body, &tag, &len);
 5229|  1.02k|		if (r < 0)
  ------------------
  |  Branch (5229:7): [True: 43, False: 981]
  ------------------
 5230|     43|			goto err;
 5231|    981|		switch (tag) {
  ------------------
  |  Branch (5231:11): [True: 280, False: 701]
  ------------------
 5232|    233|		case PIV_CCC_TAG_F0:
  ------------------
  |  |  176|    233|#define PIV_CCC_TAG_F0		0xF0
  ------------------
  |  Branch (5232:3): [True: 233, False: 748]
  ------------------
 5233|    233|			if (len == 0x15) {
  ------------------
  |  Branch (5233:8): [True: 30, False: 203]
  ------------------
 5234|     30|				if (memcmp(body, "\xA0\x00\x00\x03\08", 5) == 0)
  ------------------
  |  Branch (5234:9): [True: 3, False: 27]
  ------------------
 5235|      3|					priv->ccc_flags |= PIV_CCC_F0_PIV;
  ------------------
  |  |  171|      3|#define PIV_CCC_F0_PIV		0x00000002
  ------------------
 5236|     27|				else if (memcmp(body, "\xA0\x00\x00\x00\x79", 5) == 0)
  ------------------
  |  Branch (5236:14): [True: 12, False: 15]
  ------------------
 5237|     12|					priv->ccc_flags |= PIV_CCC_F0_CAC;
  ------------------
  |  |  172|     12|#define PIV_CCC_F0_CAC		0x00000004
  ------------------
 5238|     30|				if (*(body + 6) == 0x02)
  ------------------
  |  Branch (5238:9): [True: 10, False: 20]
  ------------------
 5239|     10|					priv->ccc_flags |= PIV_CCC_F0_JAVA;
  ------------------
  |  |  173|     10|#define PIV_CCC_F0_JAVA		0x00000008
  ------------------
 5240|     30|			}
 5241|    233|			break;
 5242|     47|		case PIV_CCC_TAG_F3:
  ------------------
  |  |  177|     47|#define PIV_CCC_TAG_F3		0xF3
  ------------------
  |  Branch (5242:3): [True: 47, False: 934]
  ------------------
 5243|     47|			if (len == 0x10) {
  ------------------
  |  Branch (5243:8): [True: 27, False: 20]
  ------------------
 5244|     27|				if (memcmp(body, "\xA0\x00\x00\x00\x79\x04", 6) == 0)
  ------------------
  |  Branch (5244:9): [True: 10, False: 17]
  ------------------
 5245|     10|					priv->ccc_flags |= PIV_CCC_F3_CAC_PKI;
  ------------------
  |  |  174|     10|#define PIV_CCC_F3_CAC_PKI	0x00000010
  ------------------
 5246|     27|			}
 5247|     47|			break;
 5248|    981|		}
 5249|    981|	}
 5250|       |
 5251|     58|err:
 5252|     58|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     58|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     58|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     58|	int _ret = r; \
  |  |  |  |  155|     58|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 58, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     58|		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|     44|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 44, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     58|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     58|	} 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|     58|	return _ret; \
  |  |  |  |  163|     58|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5253|     58|}
card-piv.c:piv_init:
 6150|  1.23k|{
 6151|  1.23k|	int r = 0;
 6152|  1.23k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  1.23k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6153|  1.23k|	unsigned long flags;
 6154|  1.23k|	unsigned long flags_eddsa;
 6155|  1.23k|	unsigned long flags_xeddsa;
 6156|  1.23k|	unsigned long ext_flags;
 6157|       |
 6158|  1.23k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.23k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.23k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.23k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
 6159|       |
 6160|  1.23k|	r = sc_lock(card); /* hold until match or init is complete */
 6161|  1.23k|	LOG_TEST_RET(card->ctx, r, "sc_lock failed");
  ------------------
  |  |  174|  1.23k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.23k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.23k|	int _ret = (r); \
  |  |  |  |  168|  1.23k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 1.23k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6162|       |
 6163|       |	/* piv_match_card_continued called from card match should have left card->drv_data */
 6164|  1.23k|	if (priv == NULL) {
  ------------------
  |  Branch (6164:6): [True: 0, False: 1.23k]
  ------------------
 6165|      0|		r = piv_match_card_continued(card);
 6166|      0|		priv = PIV_DATA(card);
  ------------------
  |  |  447|      0|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6167|      0|		if (r < 0 || !priv) {
  ------------------
  |  Branch (6167:7): [True: 0, False: 0]
  |  Branch (6167:16): [True: 0, False: 0]
  ------------------
 6168|      0|			sc_log(card->ctx, "piv_match_card_continued failed card->type:%d", card->type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 6169|      0|			sc_unlock(card);
 6170|      0|			piv_finish(card);
 6171|       |			/* tell sc_connect_card to try other driver */
 6172|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6173|      0|		}
 6174|      0|	}
 6175|       |
 6176|       |	/* read "card_driver PIV-II" opensc.conf options, and env parameters */
 6177|  1.23k|	piv_load_options(card);
 6178|       |
 6179|  1.23k|	priv->pstate = PIV_STATE_INIT;
 6180|       |
 6181|  1.23k|	sc_log(card->ctx, "Max send = %zu recv = %zu card->type:%d, CI:%08x AI:%08x",
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6182|  1.23k|			card->max_send_size, card->max_recv_size, card->type, priv->card_issues, priv->alg_ids);
 6183|  1.23k|	card->cla = 0x00;
 6184|  1.23k|	if (card->name == NULL)
  ------------------
  |  Branch (6184:6): [True: 1.23k, False: 0]
  ------------------
 6185|  1.23k|		card->name = card->driver->name;
 6186|       |
 6187|  1.23k|	priv->enumtag = piv_aids[0].enumtag;
 6188|       |
 6189|       |	/* PKCS#11 may try to generate session keys, and get confused
 6190|       |	 * if SC_ALGORITHM_ONBOARD_KEY_GEN is present
 6191|       |	 * piv-tool can still do this, just don't tell PKCS#11
 6192|       |	 */
 6193|       |
 6194|  1.23k|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|  1.23k|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
 6195|       |
 6196|  1.23k|	if (card->type == SC_CARD_TYPE_PIV_II_SWISSBIT) {
  ------------------
  |  Branch (6196:6): [True: 0, False: 1.23k]
  ------------------
 6197|      0|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|      0|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
 6198|      0|	}
 6199|       |
 6200|  1.23k|	if (priv->alg_ids & AI_RSA_1024)
  ------------------
  |  |  608|  1.23k|#define AI_RSA_1024			    0x00000001U
  ------------------
  |  Branch (6200:6): [True: 1.22k, False: 2]
  ------------------
 6201|  1.22k|		_sc_card_add_rsa_alg(card, 1024, flags, 0); /* mandatory */
 6202|       |
 6203|  1.23k|	if (priv->alg_ids & AI_RSA_2048)
  ------------------
  |  |  609|  1.23k|#define AI_RSA_2048			    0x00000002U
  ------------------
  |  Branch (6203:6): [True: 1.22k, False: 1]
  ------------------
 6204|  1.22k|		_sc_card_add_rsa_alg(card, 2048, flags, 0); /* optional */
 6205|       |
 6206|  1.23k|	if (priv->alg_ids & AI_RSA_3072)
  ------------------
  |  |  610|  1.23k|#define AI_RSA_3072			    0x00000004U
  ------------------
  |  Branch (6206:6): [True: 1.22k, False: 3]
  ------------------
 6207|  1.22k|		_sc_card_add_rsa_alg(card, 3072, flags, 0); /* optional */
 6208|       |
 6209|  1.23k|	if (priv->alg_ids & AI_RSA_4096)
  ------------------
  |  |  611|  1.23k|#define AI_RSA_4096			    0x00000008U
  ------------------
  |  Branch (6209:6): [True: 109, False: 1.12k]
  ------------------
 6210|    109|		_sc_card_add_rsa_alg(card, 4096, flags, 0); /* non standard */
 6211|       |
 6212|  1.23k|	if (!(priv->card_issues & CI_NO_EC)) {
  ------------------
  |  |  604|  1.23k|#define CI_NO_EC			    0x00000800U /* No EC at all */
  ------------------
  |  Branch (6212:6): [True: 1.23k, False: 0]
  ------------------
 6213|  1.23k|		int i;
 6214|  1.23k|		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  174|  1.23k|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  173|  1.23k|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|  1.23k|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|  1.23k|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
 6215|  1.23k|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  201|  1.23k|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  202|  1.23k|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
 6216|  1.23k|		flags_eddsa = SC_ALGORITHM_EDDSA_RAW;
  ------------------
  |  |  188|  1.23k|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
 6217|  1.23k|		flags_xeddsa = SC_ALGORITHM_XEDDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW;
  ------------------
  |  |  189|  1.23k|#define SC_ALGORITHM_XEDDSA_RAW		0x00800000
  ------------------
              		flags_xeddsa = SC_ALGORITHM_XEDDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW;
  ------------------
  |  |  173|  1.23k|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
 6218|       |
 6219|  6.15k|		for (i = 0; ec_curves[i].oid.value[0] >= 0; i++) {
  ------------------
  |  Branch (6219:15): [True: 4.92k, False: 1.23k]
  ------------------
 6220|  4.92k|			if (ec_curves[i].key_type == SC_ALGORITHM_EC) {
  ------------------
  |  |   70|  4.92k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (6220:8): [True: 2.46k, False: 2.46k]
  ------------------
 6221|  2.46k|				if (!(priv->card_issues & CI_NO_EC384 && ec_curves[i].size == 384))
  ------------------
  |  |  603|  4.92k|#define CI_NO_EC384			    0x00000400U /* does not have EC 384 */
  ------------------
  |  Branch (6221:11): [True: 148, False: 2.31k]
  |  Branch (6221:46): [True: 74, False: 74]
  ------------------
 6222|  2.38k|					_sc_card_add_ec_alg(card, ec_curves[i].size, flags, ext_flags, &ec_curves[i].oid);
 6223|  2.46k|			}
 6224|       |
 6225|  2.46k|			else if (priv->alg_ids & AI_25519 && ec_curves[i].key_type == SC_ALGORITHM_EDDSA)
  ------------------
  |  |  614|  4.92k|#define AI_25519			    0x00100000U
  ------------------
              			else if (priv->alg_ids & AI_25519 && ec_curves[i].key_type == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   72|    192|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (6225:13): [True: 192, False: 2.26k]
  |  Branch (6225:41): [True: 96, False: 96]
  ------------------
 6226|     96|				_sc_card_add_eddsa_alg(card, ec_curves[i].size, flags_eddsa, ext_flags, &ec_curves[i].oid);
 6227|       |
 6228|  2.36k|			else if (priv->alg_ids & AI_X25519 && ec_curves[i].key_type == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |  615|  4.72k|#define AI_X25519			    0x00200000U
  ------------------
              			else if (priv->alg_ids & AI_X25519 && ec_curves[i].key_type == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|     97|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (6228:13): [True: 97, False: 2.26k]
  |  Branch (6228:42): [True: 96, False: 1]
  ------------------
 6229|     96|				_sc_card_add_xeddsa_alg(card, ec_curves[i].size, flags_xeddsa, ext_flags, &ec_curves[i].oid);
 6230|  4.92k|		}
 6231|  1.23k|	}
 6232|       |
 6233|  1.23k|	if (!(priv->card_issues & CI_NO_RANDOM))
  ------------------
  |  |  594|  1.23k|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
  |  Branch (6233:6): [True: 1.20k, False: 22]
  ------------------
 6234|  1.20k|		card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|  1.20k|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
 6235|       |
 6236|       |	/* May turn off SC_CARD_CAP_ISO7816_PIN_INFO later */
 6237|  1.23k|	card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|  1.23k|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
 6238|       |
 6239|       |	/*
 6240|       |	 * 800-73-3 cards may have discovery. "piv-like cards may or may not.
 6241|       |	 * 800-73-4 with VCI must have it as it has the pin policy needed for VCI .
 6242|       |	 */
 6243|       |
 6244|       |#ifdef ENABLE_PIV_SM
 6245|       |	/*
 6246|       |	 * 800-73-4
 6247|       |	 * Response of AID says if SM is supported. Look for Cipher Suite
 6248|       |	 */
 6249|       |	if (priv->csID && priv->cs != NULL) {
 6250|       |		/*
 6251|       |		 * Main point in SM and VCI is to allow contactless access
 6252|       |		 */
 6253|       |		/* Only piv_init and piv_reader_lock_obtained should call piv_sm_open */
 6254|       |
 6255|       |		/* If user said PIV_SM_FLAGS_NEVER, dont start SM; implies limited contatless access */
 6256|       |		if (priv->sm_flags & PIV_SM_FLAGS_NEVER) {
 6257|       |			sc_log(card->ctx, "User has requested PIV_SM_FLAGS_NEVER");
 6258|       |			r = SC_SUCCESS; /* Users choice */
 6259|       |
 6260|       |		} else if ((priv->init_flags & PIV_INIT_CONTACTLESS) &&
 6261|       |				!(priv->pin_policy & PIV_PP_VCI_IMPL)) {
 6262|       |			sc_log(card->ctx, "Contactless and no card support for VCI");
 6263|       |			r = SC_SUCCESS; /* User should know VCI is not possible with their card; use like 800-73-3 contactless  */
 6264|       |
 6265|       |		} else if ((priv->init_flags & PIV_INIT_CONTACTLESS) &&
 6266|       |				!(priv->pin_policy & PIV_PP_VCI_WITHOUT_PC) &&
 6267|       |				(priv->pairing_code[0] == 0x00)) {
 6268|       |			sc_log(card->ctx, "Contactless, pairing_code required and no pairing code");
 6269|       |			r = SC_ERROR_PIN_CODE_INCORRECT; /* User should know they need to set pairing code */
 6270|       |
 6271|       |		} else {
 6272|       |			priv->sm_flags |= PIV_SM_FLAGS_DEFER_OPEN; /* tell priv_sm_open, OK to open */
 6273|       |			r = piv_sm_open(card);
 6274|       |			sc_log(card->ctx, "piv_sm_open returned:%d", r);
 6275|       |		}
 6276|       |
 6277|       |		/* If failed, and user said PIV_SM_FLAGS_ALWAYS quit */
 6278|       |		if (priv->sm_flags & PIV_SM_FLAGS_ALWAYS && r < 0) {
 6279|       |			sc_log(card->ctx, "User has requested PIV_SM_FLAGS_ALWAYS, SM has failed to start, don't use the card");
 6280|       |			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_ALLOWED);
 6281|       |		}
 6282|       |
 6283|       |		/* user has wrong or no required pairing code */
 6284|       |		if (r == SC_ERROR_PIN_CODE_INCORRECT)
 6285|       |			LOG_FUNC_RETURN(card->ctx, r);
 6286|       |
 6287|       |		/* If SM did not start, or is not expected to start, continue on without it */
 6288|       |	}
 6289|       |#endif /* ENABLE_PIV_SM */
 6290|       |
 6291|       |	/*
 6292|       |	 * 800-73-3 cards may have a history object
 6293|       |	 * We want to process it now as this has information on what
 6294|       |	 * keys and certs. "piv like" cards may or may not have history
 6295|       |	 */
 6296|  1.23k|	piv_process_history(card);
 6297|       |
 6298|  1.23k|	priv->pstate = PIV_STATE_NORMAL;
 6299|  1.23k|	sc_unlock(card);
 6300|  1.23k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.23k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.23k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.23k|	int _ret = r; \
  |  |  |  |  155|  1.23k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.23k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.23k|		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: 1.23k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.23k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.23k|	} 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|  1.23k|	return _ret; \
  |  |  |  |  163|  1.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6301|  1.23k|}
card-piv.c:piv_load_options:
 1695|  1.23k|{
 1696|  1.23k|	int r;
 1697|  1.23k|	size_t i, j;
 1698|  1.23k|	scconf_block **found_blocks, *block;
 1699|       |
 1700|       |#ifdef ENABLE_PIV_SM
 1701|       |	piv_private_data_t *priv = PIV_DATA(card);
 1702|       |	const char *option = NULL;
 1703|       |	int piv_pairing_code_found = 0;
 1704|       |	int piv_use_sm_found = 0;
 1705|       |
 1706|       |	/* pairing code is 8 decimal digits and is card specific */
 1707|       |	if ((option = getenv("PIV_PAIRING_CODE")) != NULL) {
 1708|       |		sc_log(card->ctx, "getenv(\"PIV_PAIRING_CODE\") found");
 1709|       |		if (piv_parse_pairing_code(card, option) == SC_SUCCESS) {
 1710|       |			memcpy(priv->pairing_code, option, PIV_PAIRING_CODE_LEN);
 1711|       |			piv_pairing_code_found = 1;
 1712|       |		}
 1713|       |	}
 1714|       |
 1715|       |	if ((option = getenv("PIV_USE_SM")) != NULL) {
 1716|       |		sc_log(card->ctx, "getenv(\"PIV_USE_SM\")=\"%s\"", option);
 1717|       |		if (!strcmp(option, "never")) {
 1718|       |			priv->sm_flags |= PIV_SM_FLAGS_NEVER;
 1719|       |			piv_use_sm_found = 1;
 1720|       |		} else if (!strcmp(option, "always")) {
 1721|       |			priv->sm_flags |= PIV_SM_FLAGS_ALWAYS;
 1722|       |			piv_use_sm_found = 1;
 1723|       |		} else {
 1724|       |			sc_log(card->ctx, "Invalid piv_use_sm: \"%s\"", option);
 1725|       |		}
 1726|       |	}
 1727|       |#endif
 1728|       |
 1729|  2.46k|	for (i = 0; card->ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (1729:14): [True: 1.23k, False: 1.23k]
  ------------------
 1730|  1.23k|		found_blocks = scconf_find_blocks(card->ctx->conf, card->ctx->conf_blocks[i],
 1731|  1.23k|				"card_driver", "PIV-II");
 1732|  1.23k|		if (!found_blocks)
  ------------------
  |  Branch (1732:7): [True: 0, False: 1.23k]
  ------------------
 1733|      0|			continue;
 1734|       |
 1735|  1.23k|		for (j = 0, block = found_blocks[j]; block; j++, block = found_blocks[j]) {
  ------------------
  |  Branch (1735:40): [True: 0, False: 1.23k]
  ------------------
 1736|       |
 1737|       |#ifdef ENABLE_PIV_SM
 1738|       |			/*
 1739|       |			 * "piv_use_sm" if card supports NIST sp800-73-4 sm, when should it be used
 1740|       |			 * never - use card like 800-73-3, i.e. contactless is very limited on
 1741|       |			 * true PIV cards. Some  PIV-like" card may allow this.
 1742|       |			 * this security risk
 1743|       |			 * always - Use even for contact interface.
 1744|       |			 * PINS, crypto and reading of object will not show up in logs
 1745|       |			 * or over network.
 1746|       |			 */
 1747|       |
 1748|       |			if (piv_use_sm_found == 0) {
 1749|       |				option = scconf_get_str(block, "piv_use_sm", "default");
 1750|       |				sc_log(card->ctx, "conf: \"piv_use_sm\"=\"%s\"", option);
 1751|       |				if (!strcmp(option, "default")) {
 1752|       |					/* no new flags */
 1753|       |				} else if (!strcmp(option, "never")) {
 1754|       |					priv->sm_flags |= PIV_SM_FLAGS_NEVER;
 1755|       |				} else if (!strcmp(option, "always")) {
 1756|       |					priv->sm_flags |= PIV_SM_FLAGS_ALWAYS;
 1757|       |				} else {
 1758|       |					sc_log(card->ctx, "Invalid piv_use_sm: \"%s\"", option);
 1759|       |				}
 1760|       |			}
 1761|       |
 1762|       |			/* This is really a card specific value and should not be in the conf file */
 1763|       |			if (piv_pairing_code_found == 0) {
 1764|       |				option = scconf_get_str(block, "piv_pairing_code", NULL);
 1765|       |				if (option && piv_parse_pairing_code(card, option) == SC_SUCCESS) {
 1766|       |					memcpy(priv->pairing_code, option, PIV_PAIRING_CODE_LEN);
 1767|       |				}
 1768|       |			}
 1769|       |#endif
 1770|      0|		}
 1771|  1.23k|		free(found_blocks);
 1772|  1.23k|	}
 1773|  1.23k|	r = SC_SUCCESS;
  ------------------
  |  |   28|  1.23k|#define SC_SUCCESS				0
  ------------------
 1774|  1.23k|	return r;
 1775|  1.23k|}
card-piv.c:piv_process_history:
 5329|  1.23k|{
 5330|  1.23k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  1.23k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5331|  1.23k|	int r;
 5332|  1.23k|	int i, tmplen, tmplen2, tmplen3;
 5333|  1.23k|	int enumtag;
 5334|  1.23k|	u8 *rbuf = NULL;
 5335|  1.23k|	size_t rbuflen = 0;
 5336|  1.23k|	const u8 *body;
 5337|  1.23k|	size_t bodylen;
 5338|  1.23k|	const u8 *num;
 5339|  1.23k|	size_t numlen;
 5340|  1.23k|	const u8 *url = NULL;
 5341|  1.23k|	size_t urllen;
 5342|  1.23k|	u8 *ocfhfbuf = NULL;
 5343|  1.23k|	unsigned int cla_out, tag_out;
 5344|  1.23k|	size_t ocfhflen;
 5345|  1.23k|	const u8 *seq;
 5346|  1.23k|	const u8 *seqtag;
 5347|  1.23k|	size_t seqlen;
 5348|  1.23k|	const u8 *keyref;
 5349|  1.23k|	size_t keyreflen;
 5350|  1.23k|	const u8 *cert;
 5351|  1.23k|	size_t certlen;
 5352|  1.23k|	size_t certobjlen, i2;
 5353|  1.23k|	u8 *certobj;
 5354|  1.23k|	u8 *cp;
 5355|       |
 5356|  1.23k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.23k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.23k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.23k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
 5357|       |
 5358|  1.23k|	r = piv_get_cached_data(card, PIV_OBJ_HISTORY, &rbuf, &rbuflen);
 5359|  1.23k|	if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|  1.23k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (5359:6): [True: 220, False: 1.01k]
  ------------------
 5360|    220|		r = 0; /* OK if not found */
 5361|  1.23k|	if (r <= 0) {
  ------------------
  |  Branch (5361:6): [True: 1.01k, False: 216]
  ------------------
 5362|  1.01k|		priv->obj_cache[PIV_OBJ_HISTORY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|  1.01k|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5363|  1.01k|		goto err; /* no file, must be pre 800-73-3 card and not on card */
 5364|  1.01k|	}
 5365|       |
 5366|       |	/* the object is now cached, see what we have */
 5367|    216|	if (rbuflen != 0) {
  ------------------
  |  Branch (5367:6): [True: 216, False: 0]
  ------------------
 5368|    216|		body = rbuf;
 5369|    216|		if ((r = sc_asn1_read_tag(&body, rbuflen, &cla_out, &tag_out, &bodylen)) != SC_SUCCESS ||
  ------------------
  |  |   28|    432|#define SC_SUCCESS				0
  ------------------
  |  Branch (5369:7): [True: 0, False: 216]
  ------------------
 5370|    216|				((cla_out << 24 | tag_out) != piv_objects[PIV_OBJ_HISTORY].resp_tag)) {
  ------------------
  |  Branch (5370:5): [True: 0, False: 216]
  ------------------
 5371|      0|			sc_log(card->ctx, "DER problem %d", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5372|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5373|      0|			goto err;
 5374|      0|		}
 5375|       |
 5376|    216|		if (body != NULL && bodylen != 0) {
  ------------------
  |  Branch (5376:7): [True: 216, False: 0]
  |  Branch (5376:23): [True: 213, False: 3]
  ------------------
 5377|    213|			numlen = 0;
 5378|    213|			num = sc_asn1_find_tag(card->ctx, body, bodylen, 0xC1, &numlen);
 5379|    213|			if (num) {
  ------------------
  |  Branch (5379:8): [True: 130, False: 83]
  ------------------
 5380|    130|				if (numlen != 1 || *num > PIV_OBJ_RETIRED_X509_20 - PIV_OBJ_RETIRED_X509_1 + 1) {
  ------------------
  |  Branch (5380:9): [True: 1, False: 129]
  |  Branch (5380:24): [True: 1, False: 128]
  ------------------
 5381|      2|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      2|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5382|      2|					goto err;
 5383|      2|				}
 5384|       |
 5385|    128|				priv->keysWithOnCardCerts = *num;
 5386|    128|			}
 5387|       |
 5388|    211|			numlen = 0;
 5389|    211|			num = sc_asn1_find_tag(card->ctx, body, bodylen, 0xC2, &numlen);
 5390|    211|			if (num) {
  ------------------
  |  Branch (5390:8): [True: 3, False: 208]
  ------------------
 5391|      3|				if (numlen != 1 || *num > PIV_OBJ_RETIRED_X509_20 - PIV_OBJ_RETIRED_X509_1 + 1) {
  ------------------
  |  Branch (5391:9): [True: 1, False: 2]
  |  Branch (5391:24): [True: 1, False: 1]
  ------------------
 5392|      2|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      2|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5393|      2|					goto err;
 5394|      2|				}
 5395|       |
 5396|      1|				priv->keysWithOffCardCerts = *num;
 5397|      1|			}
 5398|       |
 5399|    209|			url = sc_asn1_find_tag(card->ctx, body, bodylen, 0xF3, &urllen);
 5400|    209|			if (url) {
  ------------------
  |  Branch (5400:8): [True: 63, False: 146]
  ------------------
 5401|     63|				if (urllen > 118) {
  ------------------
  |  Branch (5401:9): [True: 0, False: 63]
  ------------------
 5402|      0|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5403|      0|					goto err;
 5404|      0|				}
 5405|     63|				priv->offCardCertURL = calloc(1, urllen + 1);
 5406|     63|				if (priv->offCardCertURL == NULL)
  ------------------
  |  Branch (5406:9): [True: 0, False: 63]
  ------------------
 5407|     63|					LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5408|     63|				memcpy(priv->offCardCertURL, url, urllen);
 5409|     63|			}
 5410|    209|		} else {
 5411|      3|			sc_log(card->ctx, "Problem with History object\n");
  ------------------
  |  |   71|      3|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5412|      3|			r = SC_SUCCESS; /* OK if not found */
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
 5413|      3|			goto err;
 5414|      3|		}
 5415|    216|	}
 5416|    209|	sc_log(card->ctx, "History on=%d off=%d URL=%s",
  ------------------
  |  |   71|    418|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 63, False: 146]
  |  |  ------------------
  ------------------
 5417|    209|			priv->keysWithOnCardCerts, priv->keysWithOffCardCerts,
 5418|    209|			priv->offCardCertURL ? priv->offCardCertURL : "NONE");
 5419|       |
 5420|       |	/* now mark what objects are on the card */
 5421|  2.58k|	for (i = 0; i < priv->keysWithOnCardCerts; i++)
  ------------------
  |  Branch (5421:14): [True: 2.37k, False: 209]
  ------------------
 5422|  2.37k|		priv->obj_cache[PIV_OBJ_RETIRED_X509_1 + i].flags &= ~PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|  2.58k|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5423|       |
 5424|       |	/*
 5425|       |	 * If user has gotten copy of the file from the offCardCertsURL,
 5426|       |	 * we will read in and add the certs to the cache as listed on
 5427|       |	 * the card. some of the certs may be on the card as well.
 5428|       |	 *
 5429|       |	 * Get file name from url. verify that the filename is valid
 5430|       |	 * The URL ends in a SHA-256 string. We will use this as the filename
 5431|       |	 * in the directory used for the  PKCS15 cache
 5432|       |	 * "http://" <DNS name> "/" <ASCII-HEX encoded SHA-256 hash of OffCardKeyHistoryFile>
 5433|       |	 */
 5434|       |
 5435|    209|	r = 0;
 5436|    209|	if (priv->offCardCertURL) {
  ------------------
  |  Branch (5436:6): [True: 63, False: 146]
  ------------------
 5437|     63|		char *fp;
 5438|     63|		char filename[PATH_MAX];
 5439|       |
 5440|     63|		if (strncmp("http://", priv->offCardCertURL, 7)) {
  ------------------
  |  Branch (5440:7): [True: 57, False: 6]
  ------------------
 5441|     57|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     57|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5442|     57|			goto err;
 5443|     57|		}
 5444|       |		/* find the last /  so we have the filename part */
 5445|      6|		fp = strrchr(priv->offCardCertURL + 7, '/');
 5446|      6|		if (fp == NULL) {
  ------------------
  |  Branch (5446:7): [True: 4, False: 2]
  ------------------
 5447|      4|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      4|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5448|      4|			goto err;
 5449|      4|		}
 5450|      2|		fp++;
 5451|      2|		if (strlen(fp) != 64) { /* ASCII-HEX encoded SHA-256 */
  ------------------
  |  Branch (5451:7): [True: 2, False: 0]
  ------------------
 5452|      2|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      2|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5453|      2|			goto err;
 5454|      2|		}
 5455|      0|		for (i = 0; i < 64; i++) {
  ------------------
  |  Branch (5455:15): [True: 0, False: 0]
  ------------------
 5456|      0|			if (isxdigit((unsigned char)fp[i]) == 0) {
  ------------------
  |  Branch (5456:8): [True: 0, False: 0]
  ------------------
 5457|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5458|      0|				goto err;
 5459|      0|			}
 5460|      0|		}
 5461|       |
 5462|       |		/* Use the same directory as used for other OpenSC cached items */
 5463|      0|		r = sc_get_cache_dir(card->ctx, filename, sizeof(filename) - strlen(fp) - 2);
 5464|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5464:7): [True: 0, False: 0]
  ------------------
 5465|      0|			goto err;
 5466|       |#ifdef _WIN32
 5467|       |		strlcat(filename, "\\", PATH_MAX);
 5468|       |#else
 5469|      0|		strlcat(filename, "/", PATH_MAX);
 5470|      0|#endif
 5471|      0|		strlcat(filename, fp, PATH_MAX);
 5472|       |
 5473|      0|		r = piv_read_obj_from_file(card, filename,
 5474|      0|				&ocfhfbuf, &ocfhflen);
 5475|      0|		if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (5475:7): [True: 0, False: 0]
  ------------------
 5476|      0|			r = 0;
 5477|      0|			goto err;
 5478|      0|		}
 5479|       |
 5480|       |		/*
 5481|       |		 * Its a seq of seq of a key ref and cert
 5482|       |		 */
 5483|       |
 5484|      0|		body = ocfhfbuf;
 5485|      0|		if (sc_asn1_read_tag(&body, ocfhflen, &cla_out, &tag_out, &bodylen) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5485:7): [True: 0, False: 0]
  ------------------
 5486|      0|				body == NULL ||
  ------------------
  |  Branch (5486:5): [True: 0, False: 0]
  ------------------
 5487|      0|				bodylen == 0 ||
  ------------------
  |  Branch (5487:5): [True: 0, False: 0]
  ------------------
 5488|      0|				(cla_out | tag_out) != 0x30) {
  ------------------
  |  Branch (5488:5): [True: 0, False: 0]
  ------------------
 5489|      0|			sc_log(card->ctx, "DER problem");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5490|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5491|      0|			goto err;
 5492|      0|		}
 5493|      0|		seq = body;
 5494|      0|		while (bodylen > 0) {
  ------------------
  |  Branch (5494:10): [True: 0, False: 0]
  ------------------
 5495|      0|			seqtag = seq;
 5496|      0|			if (sc_asn1_read_tag(&seq, bodylen, &cla_out, &tag_out, &seqlen) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5496:8): [True: 0, False: 0]
  ------------------
 5497|      0|					seq == 0 ||
  ------------------
  |  Branch (5497:6): [True: 0, False: 0]
  ------------------
 5498|      0|					seqlen == 0 ||
  ------------------
  |  Branch (5498:6): [True: 0, False: 0]
  ------------------
 5499|      0|					(cla_out | tag_out) != 0x30) {
  ------------------
  |  Branch (5499:6): [True: 0, False: 0]
  ------------------
 5500|      0|				sc_log(card->ctx, "DER problem");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5501|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5502|      0|				goto err;
 5503|      0|			}
 5504|      0|			keyref = sc_asn1_find_tag(card->ctx, seq, seqlen, 0x04, &keyreflen);
 5505|      0|			if (!keyref || keyreflen != 1 ||
  ------------------
  |  Branch (5505:8): [True: 0, False: 0]
  |  Branch (5505:19): [True: 0, False: 0]
  ------------------
 5506|      0|					(*keyref < 0x82 || *keyref > 0x95)) {
  ------------------
  |  Branch (5506:7): [True: 0, False: 0]
  |  Branch (5506:25): [True: 0, False: 0]
  ------------------
 5507|      0|				sc_log(card->ctx, "DER problem");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5508|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5509|      0|				goto err;
 5510|      0|			}
 5511|      0|			cert = keyref + keyreflen;
 5512|      0|			certlen = seqlen - (cert - seq);
 5513|       |
 5514|      0|			enumtag = PIV_OBJ_RETIRED_X509_1 + *keyref - 0x82;
 5515|       |			/* now add the cert like another object */
 5516|       |
 5517|      0|			if ((tmplen = sc_asn1_put_tag(0x70, NULL, certlen, NULL, 0, NULL)) <= 0 ||
  ------------------
  |  Branch (5517:8): [True: 0, False: 0]
  ------------------
 5518|      0|					(tmplen2 = sc_asn1_put_tag(0x71, NULL, 1, NULL, 0, NULL)) <= 0 ||
  ------------------
  |  Branch (5518:6): [True: 0, False: 0]
  ------------------
 5519|      0|					(tmplen3 = sc_asn1_put_tag(0xFE, NULL, 0, NULL, 0, NULL)) <= 0) {
  ------------------
  |  Branch (5519:6): [True: 0, False: 0]
  ------------------
 5520|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5521|      0|				goto err;
 5522|      0|			}
 5523|      0|			i2 = tmplen + tmplen2 + tmplen3;
 5524|      0|			tmplen = sc_asn1_put_tag(0x53, NULL, i2, NULL, 0, NULL);
 5525|      0|			if (tmplen <= 0) {
  ------------------
  |  Branch (5525:8): [True: 0, False: 0]
  ------------------
 5526|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5527|      0|				goto err;
 5528|      0|			}
 5529|       |
 5530|      0|			certobjlen = tmplen;
 5531|      0|			certobj = malloc(certobjlen);
 5532|      0|			if (certobj == NULL) {
  ------------------
  |  Branch (5532:8): [True: 0, False: 0]
  ------------------
 5533|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 5534|      0|				goto err;
 5535|      0|			}
 5536|      0|			cp = certobj;
 5537|      0|			if ((r = sc_asn1_put_tag(0x53, NULL, i2, cp, certobjlen, &cp)) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5537:8): [True: 0, False: 0]
  ------------------
 5538|      0|					(r = sc_asn1_put_tag(0x70, cert, certlen, cp, certobjlen - (cp - certobj), &cp)) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5538:6): [True: 0, False: 0]
  ------------------
 5539|      0|					(r = sc_asn1_put_tag(0x71, NULL, 1, cp, certobjlen - (cp - certobj), &cp)) != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5539:6): [True: 0, False: 0]
  ------------------
 5540|      0|				goto err;
 5541|      0|			}
 5542|      0|			*cp++ = 0x00;
 5543|      0|			r = sc_asn1_put_tag(0xFE, NULL, 0, cp, certobjlen - (cp - certobj), &cp);
 5544|      0|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5544:8): [True: 0, False: 0]
  ------------------
 5545|      0|				goto err;
 5546|      0|			}
 5547|       |
 5548|      0|			priv->obj_cache[enumtag].obj_data = certobj;
 5549|      0|			priv->obj_cache[enumtag].obj_len = certobjlen;
 5550|      0|			priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
  ------------------
  |  |  151|      0|#define PIV_OBJ_CACHE_VALID		1
  ------------------
 5551|      0|			priv->obj_cache[enumtag].flags &= ~PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  153|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5552|       |
 5553|      0|			r = piv_cache_internal_data(card, enumtag);
 5554|      0|			sc_log(card->ctx, "got internal r=%d", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5555|       |
 5556|      0|			sc_log(card->ctx, "Added from off card file #%d %p:%zu 0x%02X",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5557|      0|					enumtag,
 5558|      0|					priv->obj_cache[enumtag].obj_data,
 5559|      0|					priv->obj_cache[enumtag].obj_len, *keyref);
 5560|       |
 5561|      0|			bodylen -= (seqlen + seq - seqtag);
 5562|      0|			seq += seqlen;
 5563|      0|		}
 5564|      0|	}
 5565|  1.23k|err:
 5566|  1.23k|	if (ocfhfbuf)
  ------------------
  |  Branch (5566:6): [True: 0, False: 1.23k]
  ------------------
 5567|      0|		free(ocfhfbuf);
 5568|  1.23k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.23k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.23k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.23k|	int _ret = r; \
  |  |  |  |  155|  1.23k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.23k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.23k|		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|    861|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 861, False: 369]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.23k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.23k|	} 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|  1.23k|	return _ret; \
  |  |  |  |  163|  1.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5569|  1.23k|}
card-piv.c:piv_cache_internal_data:
 3298|  3.78k|{
 3299|  3.78k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  3.78k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 3300|  3.78k|	const u8 *tag;
 3301|  3.78k|	const u8 *body;
 3302|  3.78k|	size_t taglen;
 3303|  3.78k|	size_t bodylen;
 3304|  3.78k|	int compressed = 0;
 3305|  3.78k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  3.78k|#define SC_SUCCESS				0
  ------------------
 3306|       |#ifdef ENABLE_PIV_SM
 3307|       |	u8 *cvc_start = NULL;
 3308|       |	size_t cvc_len = 0;
 3309|       |#endif
 3310|       |
 3311|       |	/* if already cached */
 3312|  3.78k|	if (priv->obj_cache[enumtag].internal_obj_data && priv->obj_cache[enumtag].internal_obj_len) {
  ------------------
  |  Branch (3312:6): [True: 1.79k, False: 1.98k]
  |  Branch (3312:52): [True: 1.79k, False: 0]
  ------------------
 3313|  1.79k|		sc_log(card->ctx, "#%d found internal %p:%zu",
  ------------------
  |  |   71|  1.79k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3314|  1.79k|				enumtag,
 3315|  1.79k|				priv->obj_cache[enumtag].internal_obj_data,
 3316|  1.79k|				priv->obj_cache[enumtag].internal_obj_len);
 3317|  1.79k|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.79k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.79k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.79k|	int _ret = r; \
  |  |  |  |  155|  1.79k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.79k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.79k|		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: 1.79k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.79k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.79k|	} 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|  1.79k|	return _ret; \
  |  |  |  |  163|  1.79k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3318|  1.79k|	}
 3319|       |
 3320|  1.98k|	body = sc_asn1_find_tag(card->ctx,
 3321|  1.98k|			priv->obj_cache[enumtag].obj_data,
 3322|  1.98k|			priv->obj_cache[enumtag].obj_len,
 3323|  1.98k|			0x53, &bodylen);
 3324|       |
 3325|  1.98k|	if (body == NULL || priv->obj_cache[enumtag].obj_data[0] != 0x53)
  ------------------
  |  Branch (3325:6): [True: 0, False: 1.98k]
  |  Branch (3325:22): [True: 0, False: 1.98k]
  ------------------
 3326|  1.98k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_VALID);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3327|       |
 3328|       |	/* get the certificate out */
 3329|  1.98k|	if (piv_objects[enumtag].flags & PIV_OBJECT_TYPE_CERT) {
  ------------------
  |  |  653|  1.98k|#define PIV_OBJECT_TYPE_CERT		0x01
  ------------------
  |  Branch (3329:6): [True: 1.98k, False: 0]
  ------------------
 3330|       |
 3331|  1.98k|		tag = sc_asn1_find_tag(card->ctx, body, bodylen, 0x71, &taglen);
 3332|       |		/* 800-72-1 not clear if this is 80 or 01 Sent comment to NIST for 800-72-2 */
 3333|       |		/* 800-73-3 says it is 01, keep dual test so old cards still work */
 3334|  1.98k|		if (tag && taglen > 0 && (((*tag) & 0x80) || ((*tag) & 0x01)))
  ------------------
  |  Branch (3334:7): [True: 1.23k, False: 754]
  |  Branch (3334:14): [True: 1.20k, False: 28]
  |  Branch (3334:29): [True: 39, False: 1.16k]
  |  Branch (3334:48): [True: 16, False: 1.15k]
  ------------------
 3335|     55|			compressed = 1;
 3336|       |
 3337|       |#ifdef ENABLE_PIV_SM
 3338|       |		cvc_start = (u8 *)tag + taglen; /* save for later as cvs (if present) follows  0x71 */
 3339|       |#endif
 3340|       |
 3341|  1.98k|		tag = sc_asn1_find_tag(card->ctx, body, bodylen, 0x70, &taglen);
 3342|  1.98k|		if (tag == NULL)
  ------------------
  |  Branch (3342:7): [True: 183, False: 1.80k]
  ------------------
 3343|  1.98k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_VALID);
  ------------------
  |  |  164|    183|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    183|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    183|	int _ret = r; \
  |  |  |  |  155|    183|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    183|		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|    183|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 183, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    183|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    183|	} 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|    183|	return _ret; \
  |  |  |  |  163|    183|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3344|       |
 3345|  1.80k|		if (taglen == 0)
  ------------------
  |  Branch (3345:7): [True: 11, False: 1.79k]
  ------------------
 3346|  1.80k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|     11|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     11|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     11|	int _ret = r; \
  |  |  |  |  155|     11|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     11|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     11|	} 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|     11|	return _ret; \
  |  |  |  |  163|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3347|       |
 3348|  1.79k|		if (compressed) {
  ------------------
  |  Branch (3348:7): [True: 21, False: 1.77k]
  ------------------
 3349|     21|			priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_COMPRESSED;
  ------------------
  |  |  152|     21|#define PIV_OBJ_CACHE_COMPRESSED	2
  ------------------
 3350|     21|		}
 3351|       |		/* internal certificate remains compressed */
 3352|  1.79k|		if (!(priv->obj_cache[enumtag].internal_obj_data = malloc(taglen)))
  ------------------
  |  Branch (3352:7): [True: 0, False: 1.79k]
  ------------------
 3353|  1.79k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3354|       |
 3355|  1.79k|		memcpy(priv->obj_cache[enumtag].internal_obj_data, tag, taglen);
 3356|  1.79k|		priv->obj_cache[enumtag].internal_obj_len = taglen;
 3357|       |
 3358|       |#ifdef ENABLE_PIV_SM
 3359|       |		/* PIV_OBJ_SM_CERT_SIGNER  CERT OBJECT may also have a intermediate CVC */
 3360|       |		if (piv_objects[enumtag].flags & PIV_OBJECT_TYPE_CVC) {
 3361|       |			/* cvc if present should be at cvc_start.
 3362|       |			 * find the tag(T) and get value(V) and len(L) from TLV.
 3363|       |			 * Could reconstruct ASN1 of (T)(L) stating location from length and known tag.
 3364|       |			 * as the size of (L) depends on the length of value
 3365|       |			 */
 3366|       |			if ((tag = sc_asn1_find_tag(card->ctx, body, bodylen, 0x7F21, &taglen)) != NULL &&
 3367|       |					cvc_start &&
 3368|       |					cvc_start < tag &&
 3369|       |					cvc_start[0] == 0x7f && cvc_start[1] == 0x21) {
 3370|       |				cvc_len = tag - cvc_start + taglen;
 3371|       |				/* decode the intermediate CVC */
 3372|       |				r = piv_decode_cvc(card, &cvc_start, &cvc_len, &priv->sm_in_cvc);
 3373|       |				if (r < 0) {
 3374|       |					sc_log(card->ctx, "unable to parse intermediate CVC: %d skipping", r);
 3375|       |				}
 3376|       |				priv->sm_flags |= PIV_SM_FLAGS_SM_IN_CVC_PRESENT;
 3377|       |			}
 3378|       |		}
 3379|       |#endif /* ENABLE_PIV_SM */
 3380|       |
 3381|       |		/* convert pub key to internal */
 3382|  1.79k|	} else if (piv_objects[enumtag].flags & PIV_OBJECT_TYPE_PUBKEY) {
  ------------------
  |  |  654|      0|#define PIV_OBJECT_TYPE_PUBKEY		0x02
  ------------------
  |  Branch (3382:13): [True: 0, False: 0]
  ------------------
 3383|      0|		tag = sc_asn1_find_tag(card->ctx, body, bodylen, *body, &taglen);
 3384|      0|		if (tag == NULL)
  ------------------
  |  Branch (3384:7): [True: 0, False: 0]
  ------------------
 3385|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_VALID);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3386|       |
 3387|      0|		if (taglen == 0)
  ------------------
  |  Branch (3387:7): [True: 0, False: 0]
  ------------------
 3388|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3389|       |
 3390|      0|		if (!(priv->obj_cache[enumtag].internal_obj_data = malloc(taglen)))
  ------------------
  |  Branch (3390:7): [True: 0, False: 0]
  ------------------
 3391|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3392|       |
 3393|      0|		memcpy(priv->obj_cache[enumtag].internal_obj_data, tag, taglen);
 3394|      0|		priv->obj_cache[enumtag].internal_obj_len = taglen;
 3395|      0|	} else {
 3396|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3397|      0|	}
 3398|       |
 3399|  1.79k|	sc_log(card->ctx, "added #%d internal %p:%zu",
  ------------------
  |  |   71|  1.79k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3400|  1.79k|			enumtag,
 3401|  1.79k|			priv->obj_cache[enumtag].internal_obj_data,
 3402|  1.79k|			priv->obj_cache[enumtag].internal_obj_len);
 3403|       |
 3404|  1.79k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.79k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.79k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.79k|	int _ret = r; \
  |  |  |  |  155|  1.79k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.79k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.79k|		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: 1.79k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.79k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.79k|	} 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|  1.79k|	return _ret; \
  |  |  |  |  163|  1.79k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3405|  1.79k|}
card-piv.c:piv_finish:
 5592|  10.9k|{
 5593|  10.9k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  10.9k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5594|  10.9k|	int i;
 5595|       |
 5596|  10.9k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  10.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  10.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  10.9k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 10.9k]
  |  |  ------------------
  ------------------
 5597|  10.9k|	if (priv) {
  ------------------
  |  Branch (5597:6): [True: 6.06k, False: 4.83k]
  ------------------
 5598|  6.06k|		if (priv->context_specific) {
  ------------------
  |  Branch (5598:7): [True: 1, False: 6.06k]
  ------------------
 5599|      1|			sc_log(card->ctx, "Clearing CONTEXT_SPECIFIC lock");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5600|      1|			priv->context_specific = 0;
 5601|      1|			sc_unlock(card);
 5602|      1|		}
 5603|  6.06k|		free(priv->aid_der.value);
 5604|  6.06k|		free(priv->al_label);
 5605|  6.06k|		if (priv->w_buf)
  ------------------
  |  Branch (5605:7): [True: 0, False: 6.06k]
  ------------------
 5606|      0|			free(priv->w_buf);
 5607|  6.06k|		if (priv->offCardCertURL)
  ------------------
  |  Branch (5607:7): [True: 63, False: 6.00k]
  ------------------
 5608|     63|			free(priv->offCardCertURL);
 5609|   370k|		for (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++) {
  ------------------
  |  Branch (5609:15): [True: 364k, False: 6.06k]
  ------------------
 5610|   364k|			piv_obj_cache_free_entry(card, i, 0);
 5611|   364k|		}
 5612|   163k|		for (i = 0; i < PIV_NUM_YK_SLOT_INFO; i++) {
  ------------------
  |  |  389|   163k|#define PIV_NUM_YK_SLOT_INFO 26
  ------------------
  |  Branch (5612:15): [True: 157k, False: 6.06k]
  ------------------
 5613|   157k|			free(priv->yk_slot_info[i].pubkey.value);
 5614|   157k|		}
 5615|       |#ifdef ENABLE_PIV_SM
 5616|       |		piv_clear_cvc_content(&priv->sm_cvc);
 5617|       |		piv_clear_cvc_content(&priv->sm_in_cvc);
 5618|       |		piv_clear_sm_session(&priv->sm_session);
 5619|       |#endif /* ENABLE_PIV_SM */
 5620|       |
 5621|  6.06k|		free(priv);
 5622|       |		card->drv_data = NULL; /* priv */
 5623|  6.06k|	}
 5624|  10.9k|	return 0;
 5625|  10.9k|}
card-piv.c:piv_select_file:
 5026|  11.7k|{
 5027|  11.7k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  11.7k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5028|  11.7k|	int r;
 5029|  11.7k|	int i;
 5030|  11.7k|	const u8 *path;
 5031|  11.7k|	size_t pathlen;
 5032|  11.7k|	sc_file_t *file = NULL;
 5033|  11.7k|	u8 *rbuf = NULL;
 5034|  11.7k|	size_t rbuflen = 0;
 5035|       |
 5036|  11.7k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  11.7k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  11.7k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  11.7k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 11.7k]
  |  |  ------------------
  ------------------
 5037|       |
 5038|  11.7k|	path = in_path->value;
 5039|  11.7k|	pathlen = in_path->len;
 5040|       |
 5041|       |	/* only support single EF in current application */
 5042|       |	/*
 5043|       |	 * PIV emulates files, and only does so because sc_pkcs15_* uses
 5044|       |	 * select_file and read_binary. The emulation adds path emulated structures
 5045|       |	 * so piv_select_file will find it.
 5046|       |	 * there is no dir. Only direct access to emulated files
 5047|       |	 * thus opensc-tool and opensc-explorer can not read the emulated files
 5048|       |	 */
 5049|       |
 5050|  11.7k|	if (memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (5050:6): [True: 3.19k, False: 8.56k]
  ------------------
 5051|  3.19k|		if (pathlen > 2) {
  ------------------
  |  Branch (5051:7): [True: 3.19k, False: 0]
  ------------------
 5052|  3.19k|			path += 2;
 5053|  3.19k|			pathlen -= 2;
 5054|  3.19k|		}
 5055|  3.19k|	}
 5056|       |
 5057|  11.7k|	i = piv_find_obj_by_containerid(card, path);
 5058|       |
 5059|  11.7k|	if (i < 0)
  ------------------
  |  Branch (5059:6): [True: 3.23k, False: 8.52k]
  ------------------
 5060|  11.7k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|  3.23k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.23k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.23k|	int _ret = r; \
  |  |  |  |  155|  3.23k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.23k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.23k|		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|  3.23k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.23k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.23k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.23k|	} 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|  3.23k|	return _ret; \
  |  |  |  |  163|  3.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5061|       |
 5062|       |	/*
 5063|       |	 * pkcs15 will use a 2 byte path or a 4 byte path
 5064|       |	 * with cece added to path to request only the cert from the cert obj
 5065|       |	 * PIV "Container ID" is used as the path, and are two bytes long
 5066|       |	 */
 5067|  8.52k|	priv->return_only_cert = (pathlen == 4 && path[2] == 0xce && path[3] == 0xce);
  ------------------
  |  Branch (5067:28): [True: 8.52k, False: 0]
  |  Branch (5067:44): [True: 8.52k, False: 0]
  |  Branch (5067:63): [True: 8.52k, False: 0]
  ------------------
 5068|       |
 5069|  8.52k|	priv->selected_obj = i;
 5070|  8.52k|	priv->rwb_state = -1;
 5071|       |
 5072|       |	/* make it look like the file was found. */
 5073|       |	/* We don't want to read it now  unless we need the length */
 5074|       |
 5075|  8.52k|	if (file_out) {
  ------------------
  |  Branch (5075:6): [True: 8.52k, False: 0]
  ------------------
 5076|       |		/* we need to read it now, to get length into cache */
 5077|  8.52k|		r = piv_get_cached_data(card, i, &rbuf, &rbuflen);
 5078|       |
 5079|  8.52k|		if (r < 0)
  ------------------
  |  Branch (5079:7): [True: 6.53k, False: 1.98k]
  ------------------
 5080|  8.52k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|  6.53k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.53k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.53k|	int _ret = r; \
  |  |  |  |  155|  6.53k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6.53k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  6.53k|		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|  6.53k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6.53k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  6.53k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.53k|	} 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|  6.53k|	return _ret; \
  |  |  |  |  163|  6.53k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5081|       |
 5082|       |		/* get the cert or the pub key out and into the cache too */
 5083|  1.98k|		if (priv->return_only_cert || piv_objects[i].flags & PIV_OBJECT_TYPE_PUBKEY) {
  ------------------
  |  |  654|      0|#define PIV_OBJECT_TYPE_PUBKEY		0x02
  ------------------
  |  Branch (5083:7): [True: 1.98k, False: 0]
  |  Branch (5083:33): [True: 0, False: 0]
  ------------------
 5084|  1.98k|			r = piv_cache_internal_data(card, i);
 5085|  1.98k|			if (r < 0)
  ------------------
  |  Branch (5085:8): [True: 194, False: 1.79k]
  ------------------
 5086|  1.98k|				LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    194|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    194|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    194|	int _ret = r; \
  |  |  |  |  155|    194|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 194, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    194|		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|    194|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 194, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    194|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    194|	} 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|    194|	return _ret; \
  |  |  |  |  163|    194|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5087|  1.98k|		}
 5088|       |
 5089|  1.79k|		file = sc_file_new();
 5090|  1.79k|		if (file == NULL)
  ------------------
  |  Branch (5090:7): [True: 0, False: 1.79k]
  ------------------
 5091|  1.79k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5092|       |
 5093|  1.79k|		file->path = *in_path;
 5094|       |		/* this could be like the FCI */
 5095|  1.79k|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|  1.79k|#define SC_FILE_TYPE_DF			0x04
  ------------------
 5096|  1.79k|		file->shareable = 0;
 5097|  1.79k|		file->ef_structure = 0;
 5098|  1.79k|		if (priv->return_only_cert)
  ------------------
  |  Branch (5098:7): [True: 1.79k, False: 0]
  ------------------
 5099|  1.79k|			file->size = priv->obj_cache[i].internal_obj_len;
 5100|      0|		else
 5101|      0|			file->size = priv->obj_cache[i].obj_len;
 5102|       |
 5103|  1.79k|		file->id = (piv_objects[i].containerid[0] << 8) + piv_objects[i].containerid[1];
 5104|       |
 5105|  1.79k|		*file_out = file;
 5106|  1.79k|	}
 5107|       |
 5108|  1.79k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.79k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.79k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.79k|	int _ret = r; \
  |  |  |  |  155|  1.79k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.79k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.79k|		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: 1.79k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.79k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.79k|	} 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|  1.79k|	return _ret; \
  |  |  |  |  163|  1.79k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5109|  1.79k|}
card-piv.c:piv_find_obj_by_containerid:
 1779|  88.0k|{
 1780|  88.0k|	int i;
 1781|       |
 1782|  88.0k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  88.0k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  88.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  88.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  88.0k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 88.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1783|  88.0k|	sc_log(card->ctx, "str=0x%02X%02X\n", str[0], str[1]);
  ------------------
  |  |   71|  88.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1784|       |
 1785|  1.85M|	for (i = 0; piv_objects[i].enumtag < PIV_OBJ_LAST_ENUM; i++) {
  ------------------
  |  Branch (1785:14): [True: 1.85M, False: 4.46k]
  ------------------
 1786|  1.85M|		if (str[0] == piv_objects[i].containerid[0] && str[1] == piv_objects[i].containerid[1])
  ------------------
  |  Branch (1786:7): [True: 754k, False: 1.09M]
  |  Branch (1786:50): [True: 83.5k, False: 671k]
  ------------------
 1787|  1.85M|			LOG_FUNC_RETURN(card->ctx, i);
  ------------------
  |  |  164|  83.5k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  83.5k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  83.5k|	int _ret = r; \
  |  |  |  |  155|  83.5k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.23k, False: 82.3k]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.23k|		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: 1.23k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.23k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  82.3k|	} else { \
  |  |  |  |  159|  82.3k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  82.3k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  82.3k|	} \
  |  |  |  |  162|  83.5k|	return _ret; \
  |  |  |  |  163|  83.5k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1788|  1.85M|	}
 1789|       |
 1790|  4.46k|	LOG_FUNC_RETURN(card->ctx, -1);
  ------------------
  |  |  164|  4.46k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.46k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.46k|	int _ret = r; \
  |  |  |  |  155|  4.46k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.46k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.46k|		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|  4.46k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.46k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.46k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.46k|	} 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|  4.46k|	return _ret; \
  |  |  |  |  163|  4.46k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1791|  4.46k|}
card-piv.c:piv_get_challenge:
 4703|    402|{
 4704|       |	/* Dynamic Authentication Template (Challenge) */
 4705|    402|	u8 sbuf[] = {0x7c, 0x02, 0x81, 0x00};
 4706|    402|	u8 rbuf[4096];
 4707|    402|	const u8 *p;
 4708|    402|	size_t out_len = 0;
 4709|    402|	int r;
 4710|    402|	unsigned int tag_out = 0, cla_out = 0;
 4711|    402|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|    402|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4712|       |
 4713|    402|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    402|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    402|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    402|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    402|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 402]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4714|       |
 4715|    402|	if (priv->card_issues & CI_NO_RANDOM) {
  ------------------
  |  |  594|    402|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
  |  Branch (4715:6): [True: 3, False: 399]
  ------------------
 4716|      3|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      3|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 4717|      3|		LOG_TEST_GOTO_ERR(card->ctx, r, "No support for random data");
  ------------------
  |  |  184|      3|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      3|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      3|	int _ret = (r); \
  |  |  |  |  178|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      3|		goto err; \
  |  |  |  |  182|      3|	} \
  |  |  |  |  183|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4718|      3|	}
 4719|       |
 4720|       |	/* NIST 800-73-3 says use 9B, previous versions used 00 */
 4721|    399|	r = piv_general_io(card, 0x87, 0x00, 0x9B, sbuf, sizeof sbuf, rbuf, sizeof rbuf);
 4722|       |	/*
 4723|       |	 * piv_get_challenge is called in a loop.
 4724|       |	 * some cards may allow 1 challenge expecting it to be part of
 4725|       |	 * NIST 800-73-3 part 2 "Authentication of PIV Card Application Administrator"
 4726|       |	 * and return "6A 80" if last command was a get_challenge.
 4727|       |	 * Now that the card returned error, we can try one more time.
 4728|       |	 */
 4729|    399|	if (r == SC_ERROR_INCORRECT_PARAMETERS) {
  ------------------
  |  |   55|    399|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (4729:6): [True: 47, False: 352]
  ------------------
 4730|     47|		r = piv_general_io(card, 0x87, 0x00, 0x9B, sbuf, sizeof sbuf, rbuf, sizeof rbuf);
 4731|     47|		if (r == SC_ERROR_INCORRECT_PARAMETERS) {
  ------------------
  |  |   55|     47|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (4731:7): [True: 1, False: 46]
  ------------------
 4732|      1|			r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      1|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 4733|      1|		}
 4734|     47|	}
 4735|    399|	LOG_TEST_GOTO_ERR(card->ctx, r, "GENERAL AUTHENTICATE failed");
  ------------------
  |  |  184|    399|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    399|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    399|	int _ret = (r); \
  |  |  |  |  178|    399|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 225, False: 174]
  |  |  |  |  ------------------
  |  |  |  |  179|    225|		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|    225|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    225|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    225|		goto err; \
  |  |  |  |  182|    225|	} \
  |  |  |  |  183|    399|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 174]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4736|       |
 4737|    174|	p = rbuf;
 4738|    174|	r = sc_asn1_read_tag(&p, r, &cla_out, &tag_out, &out_len);
 4739|    174|	if (r < 0 || (cla_out | tag_out) != 0x7C) {
  ------------------
  |  Branch (4739:6): [True: 8, False: 166]
  |  Branch (4739:15): [True: 14, False: 152]
  ------------------
 4740|     22|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_DATA, "Can't find Dynamic Authentication Template");
  ------------------
  |  |  184|     22|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     22|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     22|	int _ret = (r); \
  |  |  |  |  178|     22|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 22, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     22|		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|     22|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     22|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     22|		goto err; \
  |  |  |  |  182|     22|	} \
  |  |  |  |  183|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4741|     22|	}
 4742|       |
 4743|    152|	r = sc_asn1_read_tag(&p, out_len, &cla_out, &tag_out, &out_len);
 4744|    152|	if (r < 0 || (cla_out | tag_out) != 0x81) {
  ------------------
  |  Branch (4744:6): [True: 2, False: 150]
  |  Branch (4744:15): [True: 13, False: 137]
  ------------------
 4745|     15|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_DATA, "Can't find Challenge");
  ------------------
  |  |  184|     15|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     15|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     15|	int _ret = (r); \
  |  |  |  |  178|     15|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     15|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     15|		goto err; \
  |  |  |  |  182|     15|	} \
  |  |  |  |  183|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4746|     15|	}
 4747|       |
 4748|    137|	if (len < out_len) {
  ------------------
  |  Branch (4748:6): [True: 1, False: 136]
  ------------------
 4749|      1|		out_len = len;
 4750|      1|	}
 4751|    137|	memcpy(rnd, p, out_len);
 4752|       |
 4753|    137|	r = (int)out_len;
 4754|       |
 4755|    402|err:
 4756|    402|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    402|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    402|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    402|	int _ret = r; \
  |  |  |  |  155|    402|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 265, False: 137]
  |  |  |  |  ------------------
  |  |  |  |  156|    265|		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|    238|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 238, False: 27]
  |  |  |  |  ------------------
  |  |  |  |  157|    265|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    265|	} else { \
  |  |  |  |  159|    137|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    137|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    137|	} \
  |  |  |  |  162|    402|	return _ret; \
  |  |  |  |  163|    402|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4757|    402|}
card-piv.c:piv_read_binary:
 3414|  3.62k|{
 3415|  3.62k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  3.62k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 3416|  3.62k|	int enumtag;
 3417|  3.62k|	int r;
 3418|  3.62k|	u8 *rbuf = NULL;
 3419|  3.62k|	size_t rbuflen = 0;
 3420|  3.62k|	const u8 *body;
 3421|  3.62k|	size_t bodylen;
 3422|       |
 3423|  3.62k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.62k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.62k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.62k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.62k]
  |  |  ------------------
  ------------------
 3424|  3.62k|	if (priv->selected_obj < 0)
  ------------------
  |  Branch (3424:6): [True: 0, False: 3.62k]
  ------------------
 3425|  3.62k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3426|  3.62k|	enumtag = piv_objects[priv->selected_obj].enumtag;
 3427|       |
 3428|  3.62k|	if (priv->rwb_state == -1) {
  ------------------
  |  Branch (3428:6): [True: 1.79k, False: 1.83k]
  ------------------
 3429|  1.79k|		r = piv_get_cached_data(card, enumtag, &rbuf, &rbuflen);
 3430|       |
 3431|  1.79k|		if (r >= 0) {
  ------------------
  |  Branch (3431:7): [True: 1.79k, False: 0]
  ------------------
 3432|       |			/* an object with no data will be considered not found */
 3433|       |			/* Discovery tag = 0x73, all others are 0x53 */
 3434|  1.79k|			if (!rbuf || rbuf[0] == 0x00 || ((rbuf[0] & 0xDF) == 0x53 && rbuf[1] == 0x00)) {
  ------------------
  |  Branch (3434:8): [True: 0, False: 1.79k]
  |  Branch (3434:17): [True: 0, False: 1.79k]
  |  Branch (3434:37): [True: 1.79k, False: 0]
  |  Branch (3434:65): [True: 0, False: 1.79k]
  ------------------
 3435|      0|				r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3436|      0|				goto err;
 3437|      0|			}
 3438|       |
 3439|  1.79k|			body = sc_asn1_find_tag(card->ctx, rbuf, rbuflen, rbuf[0], &bodylen);
 3440|  1.79k|			if (body == NULL) {
  ------------------
  |  Branch (3440:8): [True: 0, False: 1.79k]
  ------------------
 3441|       |				/* if missing, assume its the body */
 3442|       |				/* DEE bug in the beta card */
 3443|      0|				sc_log(card->ctx, " ***** tag 0x53 MISSING");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3444|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 3445|      0|				goto err;
 3446|      0|			}
 3447|  1.79k|			if (bodylen > body - rbuf + rbuflen) {
  ------------------
  |  Branch (3447:8): [True: 0, False: 1.79k]
  ------------------
 3448|      0|				sc_log(card->ctx, " ***** tag length > then data: %zu>%zu+%zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3449|      0|						bodylen, body - rbuf, rbuflen);
 3450|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 3451|      0|				goto err;
 3452|      0|			}
 3453|       |			/* if cached obj has internal interesting data (cert or pub key) */
 3454|  1.79k|			if (priv->return_only_cert || piv_objects[enumtag].flags & PIV_OBJECT_TYPE_PUBKEY) {
  ------------------
  |  |  654|      0|#define PIV_OBJECT_TYPE_PUBKEY		0x02
  ------------------
  |  Branch (3454:8): [True: 1.79k, False: 0]
  |  Branch (3454:34): [True: 0, False: 0]
  ------------------
 3455|  1.79k|				r = piv_cache_internal_data(card, enumtag);
 3456|  1.79k|				if (r < 0)
  ------------------
  |  Branch (3456:9): [True: 0, False: 1.79k]
  ------------------
 3457|      0|					goto err;
 3458|  1.79k|			}
 3459|  1.79k|		}
 3460|  1.79k|		priv->rwb_state = 0;
 3461|  1.79k|	}
 3462|       |
 3463|  3.62k|	if (priv->return_only_cert || piv_objects[enumtag].flags & PIV_OBJECT_TYPE_PUBKEY) {
  ------------------
  |  |  654|      0|#define PIV_OBJECT_TYPE_PUBKEY		0x02
  ------------------
  |  Branch (3463:6): [True: 3.62k, False: 0]
  |  Branch (3463:32): [True: 0, False: 0]
  ------------------
 3464|  3.62k|		rbuf = priv->obj_cache[enumtag].internal_obj_data;
 3465|  3.62k|		rbuflen = priv->obj_cache[enumtag].internal_obj_len;
 3466|  3.62k|		if ((priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_COMPRESSED) && flags) {
  ------------------
  |  |  152|  3.62k|#define PIV_OBJ_CACHE_COMPRESSED	2
  ------------------
  |  Branch (3466:7): [True: 57, False: 3.57k]
  |  Branch (3466:70): [True: 57, False: 0]
  ------------------
 3467|     57|			*flags |= SC_FILE_FLAG_COMPRESSED_AUTO;
  ------------------
  |  |  230|     57|#define SC_FILE_FLAG_COMPRESSED_AUTO		0x01
  ------------------
 3468|     57|		}
 3469|  3.62k|	} else {
 3470|      0|		rbuf = priv->obj_cache[enumtag].obj_data;
 3471|      0|		rbuflen = priv->obj_cache[enumtag].obj_len;
 3472|      0|	}
 3473|       |	/* rbuf rbuflen has pointer and length to cached data */
 3474|       |
 3475|  3.62k|	if (rbuflen < idx + count)
  ------------------
  |  Branch (3475:6): [True: 0, False: 3.62k]
  ------------------
 3476|      0|		count = rbuflen - idx;
 3477|  3.62k|	if (count <= 0) {
  ------------------
  |  Branch (3477:6): [True: 0, False: 3.62k]
  ------------------
 3478|      0|		r = 0;
 3479|      0|		priv->rwb_state = 1;
 3480|  3.62k|	} else {
 3481|  3.62k|		memcpy(buf, rbuf + idx, count);
 3482|  3.62k|		r = (int)count;
 3483|  3.62k|	}
 3484|       |
 3485|  3.62k|err:
 3486|  3.62k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  3.62k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.62k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.62k|	int _ret = r; \
  |  |  |  |  155|  3.62k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 3.62k]
  |  |  |  |  ------------------
  |  |  |  |  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|  3.62k|	} else { \
  |  |  |  |  159|  3.62k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  3.62k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  3.62k|	} \
  |  |  |  |  162|  3.62k|	return _ret; \
  |  |  |  |  163|  3.62k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3487|  3.62k|}
card-piv.c:piv_set_security_env:
 4761|     29|{
 4762|     29|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|     29|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4763|     29|	int r = 0;
 4764|       |
 4765|     29|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     29|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     29|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     29|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 29]
  |  |  ------------------
  ------------------
 4766|       |
 4767|     29|	sc_log(card->ctx, "flags=%08lx op=%d alg=%lu algf=%08lx algr=%08lx kr0=%02x, krfl=%zu",
  ------------------
  |  |   71|     29|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4768|     29|			env->flags, env->operation, env->algorithm, env->algorithm_flags,
 4769|     29|			env->algorithm_ref, env->key_ref[0], env->key_ref_len);
 4770|       |
 4771|     29|	priv->operation = env->operation;
 4772|     29|	priv->algorithm = env->algorithm;
 4773|       |
 4774|     29|	if (env->algorithm == SC_ALGORITHM_RSA) {
  ------------------
  |  |   69|     29|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (4774:6): [True: 0, False: 29]
  ------------------
 4775|      0|		priv->alg_id = 0x06; /* Say it is RSA, set 5, 6, 7 later */
 4776|     29|	} else if (env->algorithm == SC_ALGORITHM_EC) {
  ------------------
  |  |   70|     29|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (4776:13): [True: 29, False: 0]
  ------------------
 4777|     29|		if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT) {
  ------------------
  |  |   56|     29|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
  |  Branch (4777:7): [True: 29, False: 0]
  ------------------
 4778|     29|			switch (env->algorithm_ref) {
 4779|     29|			case 256:
  ------------------
  |  Branch (4779:4): [True: 29, False: 0]
  ------------------
 4780|     29|				priv->alg_id = 0x11; /* Say it is EC 256 */
 4781|     29|				priv->key_size = 256;
 4782|     29|				break;
 4783|      0|			case 384:
  ------------------
  |  Branch (4783:4): [True: 0, False: 29]
  ------------------
 4784|      0|				priv->alg_id = 0x14;
 4785|      0|				priv->key_size = 384;
 4786|      0|				break;
 4787|      0|			default:
  ------------------
  |  Branch (4787:4): [True: 0, False: 29]
  ------------------
 4788|      0|				r = SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|      0|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
 4789|     29|			}
 4790|     29|		} else
 4791|      0|			r = SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|      0|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
 4792|     29|	} else if (env->algorithm == SC_ALGORITHM_EDDSA) {
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (4792:13): [True: 0, False: 0]
  ------------------
 4793|      0|		priv->alg_id = 0xE0;
 4794|      0|		priv->key_size = 255;
 4795|      0|	} else if (env->algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (4795:13): [True: 0, False: 0]
  ------------------
 4796|      0|		priv->alg_id = 0xE1;
 4797|      0|		priv->key_size = 255;
 4798|      0|	} else
 4799|      0|		r = SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|      0|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
 4800|     29|	priv->key_ref = env->key_ref[0];
 4801|       |
 4802|     29|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     29|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     29|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     29|	int _ret = r; \
  |  |  |  |  155|     29|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     29|		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: 29]
  |  |  |  |  ------------------
  |  |  |  |  157|     29|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     29|	} 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|     29|	return _ret; \
  |  |  |  |  163|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4803|     29|}
card-piv.c:piv_compute_signature:
 4931|     29|{
 4932|     29|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|     29|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4933|     29|	int r;
 4934|     29|	u8 *ecdata = NULL;
 4935|     29|	size_t ecdatalen = 0;
 4936|     29|	size_t ecpadlen = 0;
 4937|     29|	size_t nLen;
 4938|     29|	u8 rbuf[128]; /* For EC conversions  384 will fit */
 4939|       |
 4940|     29|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     29|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     29|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     29|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 29]
  |  |  ------------------
  ------------------
 4941|       |
 4942|       |	/* The PIV returns a DER SEQUENCE{INTEGER, INTEGER}
 4943|       |	 * Which may have leading 00 to force a positive integer
 4944|       |	 * But PKCS11 just wants 2* field_length in bytes
 4945|       |	 * So we have to strip out the integers
 4946|       |	 * and pad on left if too short.
 4947|       |	 */
 4948|       |
 4949|     29|	if (priv->alg_id == 0x11 || priv->alg_id == 0x14) {
  ------------------
  |  Branch (4949:6): [True: 29, False: 0]
  |  Branch (4949:30): [True: 0, False: 0]
  ------------------
 4950|     29|		nLen = BYTES4BITS(priv->key_size);
  ------------------
  |  |  145|     29|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 4951|       |
 4952|       |		/* One applet is known to enforce the hash size
 4953|       |		 * must match the field_length in bytes. But Windows
 4954|       |		 * may try ECDSA without a hash when offline
 4955|       |		 * So we will pad input to hash size.
 4956|       |		 */
 4957|     29|		if (priv->card_issues & CI_ENFORCES_EC_HASH_EQ_KEYSIZE &&
  ------------------
  |  |  605|     58|#define CI_ENFORCES_EC_HASH_EQ_KEYSIZE	    0x00001000U /* Applet enforces hash size == EC field size for ECDSA. Windows issue */
  ------------------
  |  Branch (4957:7): [True: 0, False: 29]
  ------------------
 4958|      0|				!strcmp(card->ctx->app_name, "cardmod") &&
  ------------------
  |  Branch (4958:5): [True: 0, False: 0]
  ------------------
 4959|      0|				(datalen < nLen)) {
  ------------------
  |  Branch (4959:5): [True: 0, False: 0]
  ------------------
 4960|      0|			ecpadlen = nLen - datalen;
 4961|     29|		} else {
 4962|     29|			ecpadlen = 0;
 4963|     29|		}
 4964|       |
 4965|     29|		ecdatalen = datalen + ecpadlen;
 4966|     29|		ecdata = calloc(ecdatalen, sizeof(u8));
 4967|     29|		if (ecdata == NULL) {
  ------------------
  |  Branch (4967:7): [True: 0, False: 29]
  ------------------
 4968|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 4969|      0|			goto err;
 4970|      0|		}
 4971|     29|		memcpy(ecdata + ecpadlen, data, datalen);
 4972|       |
 4973|     29|		if (outlen < 2 * nLen) {
  ------------------
  |  Branch (4973:7): [True: 0, False: 29]
  ------------------
 4974|      0|			sc_log(card->ctx, " output too small for EC signature %zu < %zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4975|      0|					outlen, 2 * nLen);
 4976|      0|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 4977|      0|			goto err;
 4978|      0|		}
 4979|       |
 4980|     29|		r = piv_validate_general_authentication(card, ecdata, ecdatalen, rbuf, sizeof rbuf);
 4981|     29|		if (r < 0)
  ------------------
  |  Branch (4981:7): [True: 17, False: 12]
  ------------------
 4982|     17|			goto err;
 4983|       |
 4984|     12|		r = sc_asn1_decode_ecdsa_signature(card->ctx, rbuf, r, nLen, &out, outlen);
 4985|       |		/* Yubikey 5.7.x supports ED25519 */
 4986|     12|	} else if (priv->alg_id == 0xE0) {
  ------------------
  |  Branch (4986:13): [True: 0, False: 0]
  ------------------
 4987|      0|		nLen = BYTES4BITS(priv->key_size);
  ------------------
  |  |  145|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 4988|      0|		if (outlen < nLen) {
  ------------------
  |  Branch (4988:7): [True: 0, False: 0]
  ------------------
 4989|      0|			sc_log(card->ctx, " output too small for ED signature %zu < %zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4990|      0|					outlen, nLen);
 4991|      0|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 4992|      0|			goto err;
 4993|      0|		}
 4994|      0|		r = piv_validate_general_authentication(card, data, datalen, out, outlen);
 4995|       |
 4996|      0|	} else { /* RSA is all set */
 4997|      0|		r = piv_validate_general_authentication(card, data, datalen, out, outlen);
 4998|      0|	}
 4999|       |
 5000|     29|err:
 5001|     29|	free(ecdata);
 5002|     29|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|     29|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     29|	int _ret = r; \
  |  |  155|     29|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 29, False: 0]
  |  |  ------------------
  |  |  156|     29|		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|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 29, False: 0]
  |  |  ------------------
  |  |  157|     29|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     29|	} 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|     29|	return _ret; \
  |  |  163|     29|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 5003|     29|}
card-piv.c:piv_validate_general_authentication:
 4834|     29|{
 4835|     29|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|     29|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4836|     29|	int r, tmplen, tmplen2;
 4837|     29|	u8 *p;
 4838|     29|	const unsigned char *p2;
 4839|     29|	size_t taglen;
 4840|     29|	size_t bodylen;
 4841|     29|	unsigned int cla, tag;
 4842|     29|	unsigned int real_alg_id, op_tag;
 4843|       |
 4844|     29|	u8 sbuf[4096]; /* needs work. for 4096 needs 512+10 or so */
 4845|     29|	size_t sbuflen = sizeof(sbuf);
 4846|     29|	u8 rbuf[4096];
 4847|       |
 4848|     29|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     29|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     29|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     29|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 29]
  |  |  ------------------
  ------------------
 4849|       |
 4850|       |	/* should assume large send data */
 4851|     29|	p = sbuf;
 4852|     29|	tmplen = sc_asn1_put_tag(0xff, NULL, datalen, NULL, 0, NULL);
 4853|     29|	tmplen2 = sc_asn1_put_tag(0x82, NULL, 0, NULL, 0, NULL);
 4854|     29|	if (tmplen <= 0 || tmplen2 <= 0) {
  ------------------
  |  Branch (4854:6): [True: 0, False: 29]
  |  Branch (4854:21): [True: 0, False: 29]
  ------------------
 4855|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4856|      0|	}
 4857|     29|	tmplen += tmplen2;
 4858|     29|	if ((r = sc_asn1_put_tag(0x7c, NULL, tmplen, p, sbuflen, &p)) != SC_SUCCESS ||
  ------------------
  |  |   28|     58|#define SC_SUCCESS				0
  ------------------
  |  Branch (4858:6): [True: 0, False: 29]
  ------------------
 4859|     29|			(r = sc_asn1_put_tag(0x82, NULL, 0, p, sbuflen - (p - sbuf), &p)) != SC_SUCCESS) {
  ------------------
  |  |   28|     29|#define SC_SUCCESS				0
  ------------------
  |  Branch (4859:4): [True: 0, False: 29]
  ------------------
 4860|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4861|      0|	}
 4862|     29|	if (priv->operation == SC_SEC_OPERATION_DERIVE && (priv->algorithm == SC_ALGORITHM_EC || priv->algorithm == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   50|     58|#define SC_SEC_OPERATION_DERIVE         0x0004
  ------------------
              	if (priv->operation == SC_SEC_OPERATION_DERIVE && (priv->algorithm == SC_ALGORITHM_EC || priv->algorithm == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
              	if (priv->operation == SC_SEC_OPERATION_DERIVE && (priv->algorithm == SC_ALGORITHM_EC || priv->algorithm == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (4862:6): [True: 0, False: 29]
  |  Branch (4862:53): [True: 0, False: 0]
  |  Branch (4862:91): [True: 0, False: 0]
  ------------------
 4863|      0|		op_tag = 0x85;
 4864|     29|	} else {
 4865|     29|		op_tag = 0x81;
 4866|     29|	}
 4867|     29|	r = sc_asn1_put_tag(op_tag, data, datalen, p, sbuflen - (p - sbuf), &p);
 4868|     29|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     29|#define SC_SUCCESS				0
  ------------------
  |  Branch (4868:6): [True: 0, False: 29]
  ------------------
 4869|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4870|      0|	}
 4871|       |
 4872|       |	/*
 4873|       |	 * alg_id=06 is a place holder for all RSA keys.
 4874|       |	 * Derive the real alg_id based on the size of the
 4875|       |	 * the data, as we are always using raw mode.
 4876|       |	 * Non RSA keys needs some work in this area.
 4877|       |	 */
 4878|       |
 4879|     29|	real_alg_id = priv->alg_id;
 4880|     29|	if (priv->alg_id == 0x06) {
  ------------------
  |  Branch (4880:6): [True: 0, False: 29]
  ------------------
 4881|      0|		switch (datalen) {
 4882|      0|		case 128:
  ------------------
  |  Branch (4882:3): [True: 0, False: 0]
  ------------------
 4883|      0|			real_alg_id = 0x06;
 4884|      0|			break;
 4885|      0|		case 256:
  ------------------
  |  Branch (4885:3): [True: 0, False: 0]
  ------------------
 4886|      0|			real_alg_id = 0x07;
 4887|      0|			break;
 4888|      0|		case 384:
  ------------------
  |  Branch (4888:3): [True: 0, False: 0]
  ------------------
 4889|      0|			real_alg_id = 0x05;
 4890|      0|			break;
 4891|      0|		case 512:
  ------------------
  |  Branch (4891:3): [True: 0, False: 0]
  ------------------
 4892|      0|			real_alg_id = 0x16;
 4893|      0|			break;
 4894|      0|		default:
  ------------------
  |  Branch (4894:3): [True: 0, False: 0]
  ------------------
 4895|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NO_CARD_SUPPORT);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 4896|      0|		}
 4897|      0|	}
 4898|       |	/* EC and ED alg_id was already set */
 4899|       |
 4900|     29|	piv_yk_notify_touch_policy(card, priv->key_ref);
 4901|     29|	r = piv_general_io(card, 0x87, real_alg_id, priv->key_ref,
 4902|     29|			sbuf, p - sbuf, rbuf, sizeof rbuf);
 4903|     29|	if (r < 0)
  ------------------
  |  Branch (4903:6): [True: 14, False: 15]
  ------------------
 4904|     14|		goto err;
 4905|       |
 4906|     15|	p2 = rbuf;
 4907|     15|	r = sc_asn1_read_tag(&p2, r, &cla, &tag, &bodylen);
 4908|     15|	if (p2 == NULL || r < 0 || bodylen == 0 || (cla | tag) != 0x7C) {
  ------------------
  |  Branch (4908:6): [True: 1, False: 14]
  |  Branch (4908:20): [True: 1, False: 13]
  |  Branch (4908:29): [True: 1, False: 12]
  |  Branch (4908:45): [True: 1, False: 11]
  ------------------
 4909|      4|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_DATA, "Can't find 0x7C");
  ------------------
  |  |  184|      4|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      4|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      4|	int _ret = (r); \
  |  |  |  |  178|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      4|		goto err; \
  |  |  |  |  182|      4|	} \
  |  |  |  |  183|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4910|      4|	}
 4911|       |
 4912|     11|	r = sc_asn1_read_tag(&p2, bodylen, &cla, &tag, &taglen);
 4913|     11|	if (p2 == NULL || r < 0 || taglen == 0 || (cla | tag) != 0x82) {
  ------------------
  |  Branch (4913:6): [True: 1, False: 10]
  |  Branch (4913:20): [True: 1, False: 9]
  |  Branch (4913:29): [True: 1, False: 8]
  |  Branch (4913:44): [True: 1, False: 7]
  ------------------
 4914|      4|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_DATA, "Can't find 0x82");
  ------------------
  |  |  184|      4|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      4|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      4|	int _ret = (r); \
  |  |  |  |  178|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      4|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      4|		goto err; \
  |  |  |  |  182|      4|	} \
  |  |  |  |  183|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4915|      4|	}
 4916|       |
 4917|      7|	if (taglen > outlen) {
  ------------------
  |  Branch (4917:6): [True: 0, False: 7]
  ------------------
 4918|      0|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_DATA, "data read longer then buffer");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4919|      0|	}
 4920|       |
 4921|      7|	memcpy(out, p2, taglen);
 4922|      7|	r = (int)taglen;
 4923|       |
 4924|     29|err:
 4925|     29|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     29|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     29|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     29|	int _ret = r; \
  |  |  |  |  155|     29|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 22, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  156|     22|		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|     17|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 17, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  157|     22|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     22|	} else { \
  |  |  |  |  159|      7|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      7|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      7|	} \
  |  |  |  |  162|     29|	return _ret; \
  |  |  |  |  163|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4926|     29|}
card-piv.c:piv_yk_notify_touch_policy:
 4815|     29|{
 4816|     29|	u8 touch_policy;
 4817|     29|	const char *title = "Touch your Yubikey to continue";
 4818|       |
 4819|     29|	piv_yk_get_metadata(card, key_ref, NULL, &touch_policy, NULL);
 4820|     29|	switch (touch_policy) {
  ------------------
  |  Branch (4820:10): [True: 2, False: 27]
  ------------------
 4821|      1|	case 0x02:
  ------------------
  |  Branch (4821:2): [True: 1, False: 28]
  ------------------
 4822|      1|		sc_notify(title, "Touching the token is required for unlocking the key");
 4823|      1|		break;
 4824|      1|	case 0x03:
  ------------------
  |  Branch (4824:2): [True: 1, False: 28]
  ------------------
 4825|      1|		sc_notify(title, "Touching the token is required unlocking the key (needed again after 15 seconds)");
 4826|      1|		break;
 4827|     29|	}
 4828|     29|}
card-piv.c:piv_yk_get_metadata:
 4549|  29.1k|{
 4550|  29.1k|	u8 resp[3072]; /* Should be enough to fit ML-DSA-87 key */
 4551|  29.1k|	int resplen = 0;
 4552|  29.1k|	size_t i;
 4553|  29.1k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  29.1k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4554|  29.1k|	int rc;
 4555|       |
 4556|       |	/* initialize with the default behaviour */
 4557|  29.1k|	if (pin_policy)
  ------------------
  |  Branch (4557:6): [True: 1.69k, False: 27.4k]
  ------------------
 4558|  1.69k|		*pin_policy = 0x00; /* i.e. use NIST defined */
 4559|  29.1k|	if (touch_policy)
  ------------------
  |  Branch (4559:6): [True: 29, False: 29.1k]
  ------------------
 4560|     29|		*touch_policy = 0x00;
 4561|  29.1k|	if (info) {
  ------------------
  |  Branch (4561:6): [True: 27.4k, False: 1.72k]
  ------------------
 4562|  27.4k|		info->algorithm = 0;
 4563|  27.4k|		info->pubkey.value = NULL;
 4564|  27.4k|		info->pubkey.len = 0;
 4565|  27.4k|	}
 4566|       |
 4567|  29.1k|	if (priv->yubico_version < 0x00050300) {
  ------------------
  |  Branch (4567:6): [True: 19.4k, False: 9.64k]
  ------------------
 4568|  19.4k|		if (priv->yubico_version != 0)
  ------------------
  |  Branch (4568:7): [True: 2.80k, False: 16.6k]
  ------------------
 4569|  2.80k|			sc_log(card->ctx, "Yubikey's Get metadata extension not available");
  ------------------
  |  |   71|  2.80k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4570|  19.4k|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  19.4k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 4571|  19.4k|	}
 4572|       |
 4573|  18.0k|	for (i = 0; i < (PIV_NUM_YK_SLOT_INFO - 1); i++) {
  ------------------
  |  |  389|  18.0k|#define PIV_NUM_YK_SLOT_INFO 26
  ------------------
  |  Branch (4573:14): [True: 18.0k, False: 0]
  ------------------
 4574|  18.0k|		if (priv->yk_slot_info[i].slot == 0x00)
  ------------------
  |  Branch (4574:7): [True: 9.63k, False: 8.38k]
  ------------------
 4575|       |			/* reached the last initialized entry */
 4576|  9.63k|			break;
 4577|       |
 4578|  8.38k|		if (priv->yk_slot_info[i].slot == slot) {
  ------------------
  |  Branch (4578:7): [True: 5, False: 8.38k]
  ------------------
 4579|       |			/* metadata already initialized */
 4580|      5|			if (priv->yk_slot_info[i].invalid)
  ------------------
  |  Branch (4580:8): [True: 3, False: 2]
  ------------------
 4581|       |				/* already failed don't try again */
 4582|      3|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      3|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 4583|      2|			break;
 4584|      5|		}
 4585|  8.38k|	}
 4586|       |
 4587|  9.63k|	if (priv->yk_slot_info[i].slot == 0x00) {
  ------------------
  |  Branch (4587:6): [True: 9.63k, False: 2]
  ------------------
 4588|       |		/* initialize this entry */
 4589|  9.63k|		rc = piv_general_io(card, 0xF7, 0x00, slot, NULL, 0, resp, sizeof(resp));
 4590|       |
 4591|  9.63k|		if (rc >= 0) { /* set defaults */
  ------------------
  |  Branch (4591:7): [True: 566, False: 9.06k]
  ------------------
 4592|    566|			priv->yk_slot_info[i].slot = slot;
 4593|    566|		}
 4594|       |
 4595|  9.63k|		if (rc > 2) { /* at least 1 TLV */
  ------------------
  |  Branch (4595:7): [True: 335, False: 9.30k]
  ------------------
 4596|    335|			resplen = rc;
 4597|    335|			rc = piv_yk_metadata_get_policy(card->ctx, resp, resplen,
 4598|    335|					&priv->yk_slot_info[i].policy, &priv->yk_slot_info[i].touch);
 4599|    335|			if (SC_SUCCESS == rc) {
  ------------------
  |  |   28|    335|#define SC_SUCCESS				0
  ------------------
  |  Branch (4599:8): [True: 34, False: 301]
  ------------------
 4600|     34|				sc_log(card->ctx, "PIN policy for slot 0x%02X: 0x%02X (touch 0x%02X)",
  ------------------
  |  |   71|     34|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4601|     34|						slot, priv->yk_slot_info[i].policy, priv->yk_slot_info[i].touch);
 4602|     34|			}
 4603|    335|			rc = piv_yk_metadata_get_pubkey_info(card->ctx, resp, resplen, &priv->yk_slot_info[i]);
 4604|    335|			if (SC_SUCCESS == rc) {
  ------------------
  |  |   28|    335|#define SC_SUCCESS				0
  ------------------
  |  Branch (4604:8): [True: 50, False: 285]
  ------------------
 4605|     50|				sc_log(card->ctx, "Public key for slot 0x%02X: present", slot);
  ------------------
  |  |   71|     50|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4606|     50|			}
 4607|  9.30k|		} else {
 4608|  9.30k|			sc_log(card->ctx, "Could not get Yubikey's PIN and touch policy");
  ------------------
  |  |   71|  9.30k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4609|  9.30k|			priv->yk_slot_info[i].invalid = 1;
 4610|  9.30k|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  9.30k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 4611|  9.30k|		}
 4612|  9.63k|	} else if (priv->yk_slot_info[i].slot != slot) {
  ------------------
  |  Branch (4612:13): [True: 0, False: 2]
  ------------------
 4613|      0|		sc_log(card->ctx, "No free slot found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4614|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4615|      0|	}
 4616|       |
 4617|    337|	if (pin_policy)
  ------------------
  |  Branch (4617:6): [True: 16, False: 321]
  ------------------
 4618|     16|		*pin_policy = priv->yk_slot_info[i].policy;
 4619|    337|	if (touch_policy)
  ------------------
  |  Branch (4619:6): [True: 3, False: 334]
  ------------------
 4620|      3|		*touch_policy = priv->yk_slot_info[i].touch;
 4621|    337|	if (info) {
  ------------------
  |  Branch (4621:6): [True: 318, False: 19]
  ------------------
 4622|    318|		info->algorithm = priv->yk_slot_info[i].algorithm;
 4623|    318|		info->pubkey.value = priv->yk_slot_info[i].pubkey.value;
 4624|    318|		info->pubkey.len = priv->yk_slot_info[i].pubkey.len;
 4625|    318|	}
 4626|       |
 4627|    337|	return SC_SUCCESS;
  ------------------
  |  |   28|    337|#define SC_SUCCESS				0
  ------------------
 4628|  9.63k|}
card-piv.c:piv_yk_metadata_get_policy:
 4502|    335|{
 4503|    335|	size_t policylen;
 4504|    335|	const u8 *policy = sc_asn1_find_tag(ctx, buf, buflen, 0x02, &policylen);
 4505|    335|	if (policy && policylen == 2) {
  ------------------
  |  Branch (4505:6): [True: 75, False: 260]
  |  Branch (4505:16): [True: 34, False: 41]
  ------------------
 4506|     34|		*pin = policy[0];
 4507|     34|		*touch = policy[1];
 4508|     34|		return SC_SUCCESS;
  ------------------
  |  |   28|     34|#define SC_SUCCESS				0
  ------------------
 4509|    301|	} else {
 4510|    301|		sc_log(ctx, "Yubikey PIN policy not found");
  ------------------
  |  |   71|    301|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4511|    301|		return SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|    301|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
 4512|    301|	}
 4513|    335|}
card-piv.c:piv_yk_metadata_get_pubkey_info:
 4517|    335|{
 4518|    335|	size_t tag_len = 0;
 4519|    335|	const u8 *pk = NULL;
 4520|       |
 4521|       |	/*  Tag 0x01: Algorithm/type of key */
 4522|    335|	pk = sc_asn1_find_tag(ctx, buf, buflen, 0x01, &tag_len);
 4523|    335|	if (pk && tag_len == 1) {
  ------------------
  |  Branch (4523:6): [True: 82, False: 253]
  |  Branch (4523:12): [True: 71, False: 11]
  ------------------
 4524|     71|		info->algorithm = pk[0];
 4525|    264|	} else {
 4526|    264|		sc_log(ctx, "Yubikey algorithm not found");
  ------------------
  |  |   71|    264|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4527|    264|		return SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|    264|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
 4528|    264|	}
 4529|       |
 4530|       |	/*  Tag 0x04: Public key */
 4531|     71|	pk = sc_asn1_find_tag(ctx, buf, buflen, 0x04, &tag_len);
 4532|     71|	if (pk && tag_len > 0) {
  ------------------
  |  Branch (4532:6): [True: 53, False: 18]
  |  Branch (4532:12): [True: 50, False: 3]
  ------------------
 4533|     50|		info->pubkey.value = malloc(tag_len);
 4534|     50|		if (info->pubkey.value == NULL) {
  ------------------
  |  Branch (4534:7): [True: 0, False: 50]
  ------------------
 4535|      0|			return SC_ERROR_MEMORY_FAILURE;
  ------------------
  |  |   57|      0|#define SC_ERROR_MEMORY_FAILURE			-1207
  ------------------
 4536|      0|		}
 4537|     50|		memcpy(info->pubkey.value, pk, tag_len);
 4538|     50|		info->pubkey.len = tag_len;
 4539|     50|	} else {
 4540|     21|		sc_log(ctx, "Yubikey public key not found");
  ------------------
  |  |   71|     21|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4541|     21|		return SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|     21|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
 4542|     21|	}
 4543|       |
 4544|     50|	return SC_SUCCESS;
  ------------------
  |  |   28|     50|#define SC_SUCCESS				0
  ------------------
 4545|     71|}
card-piv.c:piv_check_sw:
 6305|  32.3k|{
 6306|  32.3k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 6307|       |
 6308|  32.3k|	int r;
 6309|       |#ifdef ENABLE_PIV_SM
 6310|       |	int i;
 6311|       |#endif
 6312|  32.3k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  32.3k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6313|       |
 6314|  32.3k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  32.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  32.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  32.3k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 32.3k]
  |  |  ------------------
  ------------------
 6315|       |
 6316|       |	/* may be called before piv_init has allocated priv */
 6317|  32.3k|	if (priv) {
  ------------------
  |  Branch (6317:6): [True: 32.3k, False: 0]
  ------------------
 6318|       |		/* need to save sw1 and sw2 if trying to determine card_state from pin_cmd */
 6319|       |
 6320|  32.3k|		if (priv->pin_cmd_verify) {
  ------------------
  |  Branch (6320:7): [True: 591, False: 31.7k]
  ------------------
 6321|    591|			priv->pin_cmd_verify_sw1 = sw1;
 6322|    591|			priv->pin_cmd_verify_sw2 = sw2;
 6323|  31.7k|		} else {
 6324|       |			/* a command has completed and it is not verify
 6325|       |			 * If we are in a context_specific sequence, unlock
 6326|       |			 * This just decrements the extra lock count
 6327|       |			 */
 6328|  31.7k|			if (priv->context_specific) {
  ------------------
  |  Branch (6328:8): [True: 2, False: 31.7k]
  ------------------
 6329|      2|				sc_log(card->ctx, "Clearing CONTEXT_SPECIFIC lock");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6330|      2|				priv->context_specific = 0;
 6331|      2|				sc_unlock(card);
 6332|      2|			}
 6333|  31.7k|		}
 6334|       |
 6335|  32.3k|		if (priv->card_issues & CI_VERIFY_630X) {
  ------------------
  |  |  591|  32.3k|#define CI_VERIFY_630X			    0x00000001U /* VERIFY tries left returns 630X rather then 63CX */
  ------------------
  |  Branch (6335:7): [True: 1.45k, False: 30.9k]
  ------------------
 6336|       |
 6337|       |			/* Handle the Yubikey NEO or any other PIV card which returns in response to a verify
 6338|       |			 * 63 0X rather than 63 CX indicate the number of remaining PIN retries.
 6339|       |			 * Perhaps they misread the spec and thought 0xCX meant "clear" or "don't care", not a literal 0xC!
 6340|       |			 */
 6341|  1.45k|			if (priv->pin_cmd_verify && sw1 == 0x63U) {
  ------------------
  |  Branch (6341:8): [True: 63, False: 1.39k]
  |  Branch (6341:32): [True: 10, False: 53]
  ------------------
 6342|     10|				priv->pin_cmd_verify_sw2 |= 0xC0U; /* make it easier to test in other code */
 6343|     10|				if ((sw2 & ~0x0fU) == 0x00U) {
  ------------------
  |  Branch (6343:9): [True: 4, False: 6]
  ------------------
 6344|      4|					sc_log(card->ctx, "Verification failed (remaining tries: %d)", (sw2 & 0x0f));
  ------------------
  |  |   71|      4|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6345|      4|					return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|      4|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
 6346|       |					/* this is what the iso_check_sw returns for 63 C0 */
 6347|      4|				}
 6348|     10|			}
 6349|  1.45k|		}
 6350|  32.3k|	}
 6351|       |#ifdef ENABLE_PIV_SM
 6352|       |	/* Note 6982 is map to SC_ERROR_SM_NO_SESSION_KEYS but iso maps it to SC_ERROR_SECURITY_STATUS_NOT_SATISFIED */
 6353|       |	/* we do this because 6982 could also mean a verify is not allowed over contactless without VCI */
 6354|       |	/* we stashed the sw1 and sw2 above for verify */
 6355|       |	/* Check specific NIST sp800-73-4 SM  errors */
 6356|       |	for (i = 0; piv_sm_errors[i].SWs != 0; i++) {
 6357|       |		if (piv_sm_errors[i].SWs == ((sw1 << 8) | sw2)) {
 6358|       |			sc_log(card->ctx, "%s", piv_sm_errors[i].errorstr);
 6359|       |			return piv_sm_errors[i].errorno;
 6360|       |		}
 6361|       |	}
 6362|       |#endif
 6363|  32.3k|	r = iso_drv->ops->check_sw(card, sw1, sw2);
 6364|  32.3k|	return r;
 6365|  32.3k|}
card-piv.c:piv_card_ctl:
 4654|   109k|{
 4655|   109k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|   109k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4656|   109k|	u8 *opts; /*  A or M, key_ref, alg_id */
 4657|       |
 4658|   109k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|   109k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   109k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   109k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   109k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 109k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4659|       |
 4660|   109k|	if (priv == NULL) {
  ------------------
  |  Branch (4660:6): [True: 0, False: 109k]
  ------------------
 4661|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4662|      0|	}
 4663|   109k|	switch (cmd) {
  ------------------
  |  Branch (4663:10): [True: 107k, False: 1.21k]
  ------------------
 4664|      0|	case SC_CARDCTL_PIV_AUTHENTICATE:
  ------------------
  |  Branch (4664:2): [True: 0, False: 109k]
  ------------------
 4665|      0|		opts = (u8 *)ptr;
 4666|      0|		switch (*opts) {
  ------------------
  |  Branch (4666:11): [True: 0, False: 0]
  ------------------
 4667|      0|		case 'A':
  ------------------
  |  Branch (4667:3): [True: 0, False: 0]
  ------------------
 4668|      0|			return piv_general_external_authenticate(card,
 4669|      0|					*(opts + 1), *(opts + 2));
 4670|      0|			break;
 4671|      0|		case 'M':
  ------------------
  |  Branch (4671:3): [True: 0, False: 0]
  ------------------
 4672|      0|			return piv_general_mutual_authenticate(card,
 4673|      0|					*(opts + 1), *(opts + 2));
 4674|      0|			break;
 4675|      0|		}
 4676|      0|		break;
 4677|      0|	case SC_CARDCTL_PIV_GENERATE_KEY:
  ------------------
  |  Branch (4677:2): [True: 0, False: 109k]
  ------------------
 4678|      0|		return piv_generate_key(card,
 4679|      0|				(sc_cardctl_piv_genkey_info_t *)ptr);
 4680|      0|		break;
 4681|  1.23k|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (4681:2): [True: 1.23k, False: 107k]
  ------------------
 4682|  1.23k|		return piv_get_serial_nr_from_CHUI(card, (sc_serial_number_t *)ptr);
 4683|      0|		break;
 4684|  1.23k|	case SC_CARDCTL_PIV_PIN_PREFERENCE:
  ------------------
  |  Branch (4684:2): [True: 1.23k, False: 107k]
  ------------------
 4685|  1.23k|		return piv_get_pin_preference(card, ptr);
 4686|      0|		break;
 4687|  76.2k|	case SC_CARDCTL_PIV_OBJECT_PRESENT:
  ------------------
  |  Branch (4687:2): [True: 76.2k, False: 32.7k]
  ------------------
 4688|  76.2k|		return piv_is_object_present(card, ptr);
 4689|      0|		break;
 4690|  1.69k|	case SC_CARDCTL_PIV_YK_PIN_POLICY:
  ------------------
  |  Branch (4690:2): [True: 1.69k, False: 107k]
  ------------------
 4691|  1.69k|		return piv_yk_pin_policy(card, ptr);
 4692|      0|		break;
 4693|  27.4k|	case SC_CARDCTL_PIV_YK_GET_PUBKEY_INFO:
  ------------------
  |  Branch (4693:2): [True: 27.4k, False: 81.6k]
  ------------------
 4694|  27.4k|		return piv_yk_get_pubkey(card, ptr);
 4695|      0|		break;
 4696|   109k|	}
 4697|       |
 4698|  1.21k|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|  1.21k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.21k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.21k|	int _ret = r; \
  |  |  |  |  155|  1.21k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.21k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.21k|		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|  1.21k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.21k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.21k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.21k|	} 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|  1.21k|	return _ret; \
  |  |  |  |  163|  1.21k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4699|  1.21k|}
card-piv.c:piv_get_serial_nr_from_CHUI:
 4382|  1.23k|{
 4383|  1.23k|	int r;
 4384|  1.23k|	int i;
 4385|  1.23k|	u8 gbits = 0; /* 0 not present or wrong length or all zeros */
 4386|  1.23k|	u8 fbits = 0; /* 0 not present or wrong length or all zeros */
 4387|  1.23k|	u8 *rbuf = NULL;
 4388|  1.23k|	const u8 *body;
 4389|  1.23k|	const u8 *fascn;
 4390|  1.23k|	const u8 *guid;
 4391|  1.23k|	size_t rbuflen = 0, bodylen, fascnlen, guidlen;
 4392|       |
 4393|  1.23k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.23k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.23k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.23k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
 4394|  1.23k|	if (card->serialnr.len) {
  ------------------
  |  Branch (4394:6): [True: 0, False: 1.23k]
  ------------------
 4395|      0|		*serial = card->serialnr;
 4396|      0|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4397|      0|	}
 4398|       |
 4399|       |	/*
 4400|       |	 * 800-73-3 Part 1 and CIO Council docs say for PIV Compatible cards
 4401|       |	 * the FASC-N Agency code should be 9999 and there should be a GUID
 4402|       |	 * based on RFC 4122. If GUID present and not zero
 4403|       |	 * we will use the GUID as the serial number.
 4404|       |	 */
 4405|       |
 4406|  1.23k|	r = piv_get_cached_data(card, PIV_OBJ_CHUI, &rbuf, &rbuflen);
 4407|  1.23k|	LOG_TEST_RET(card->ctx, r, "Failure retrieving CHUI");
  ------------------
  |  |  174|  1.23k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.23k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.23k|	int _ret = (r); \
  |  |  |  |  168|  1.23k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.09k, False: 132]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.09k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.09k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.09k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.09k|		return _ret; \
  |  |  |  |  172|  1.09k|	} \
  |  |  |  |  173|  1.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 132]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4408|       |
 4409|    132|	r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    132|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4410|    132|	if (rbuflen != 0) {
  ------------------
  |  Branch (4410:6): [True: 132, False: 0]
  ------------------
 4411|    132|		body = sc_asn1_find_tag(card->ctx, rbuf, rbuflen, 0x53, &bodylen); /* Pass the outer wrapper asn1 */
 4412|    132|		if (body != NULL && bodylen != 0 && rbuf[0] == 0x53) {
  ------------------
  |  Branch (4412:7): [True: 132, False: 0]
  |  Branch (4412:23): [True: 120, False: 12]
  |  Branch (4412:39): [True: 120, False: 0]
  ------------------
 4413|    120|			fascn = sc_asn1_find_tag(card->ctx, body, bodylen, 0x30, &fascnlen); /* Find the FASC-N data */
 4414|       |
 4415|    120|			if (fascn && fascnlen == 25) {
  ------------------
  |  Branch (4415:8): [True: 46, False: 74]
  |  Branch (4415:17): [True: 33, False: 13]
  ------------------
 4416|    858|				for (i = 0; i < 25; i++) {
  ------------------
  |  Branch (4416:17): [True: 825, False: 33]
  ------------------
 4417|    825|					fbits = fbits || fascn[i]; /* if all are zero, gbits will be zero */
  ------------------
  |  Branch (4417:14): [True: 660, False: 165]
  |  Branch (4417:23): [True: 32, False: 133]
  ------------------
 4418|    825|				}
 4419|     33|			}
 4420|       |
 4421|    120|			guid = sc_asn1_find_tag(card->ctx, body, bodylen, 0x34, &guidlen);
 4422|       |
 4423|    120|			if (guid && guidlen == 16) {
  ------------------
  |  Branch (4423:8): [True: 22, False: 98]
  |  Branch (4423:16): [True: 17, False: 5]
  ------------------
 4424|    289|				for (i = 0; i < 16; i++) {
  ------------------
  |  Branch (4424:17): [True: 272, False: 17]
  ------------------
 4425|    272|					gbits = gbits | guid[i]; /* if all are zero, gbits will be zero */
 4426|    272|				}
 4427|     17|			}
 4428|    120|			sc_log(card->ctx, "fascn=%p,fascnlen=%zu,guid=%p,guidlen=%zu,gbits=%2.2x",
  ------------------
  |  |   71|    120|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4429|    120|					fascn, fascnlen, guid, guidlen, gbits);
 4430|       |
 4431|    120|			if (fascn && fascnlen == 25 && fbits) {
  ------------------
  |  Branch (4431:8): [True: 46, False: 74]
  |  Branch (4431:17): [True: 33, False: 13]
  |  Branch (4431:35): [True: 32, False: 1]
  ------------------
 4432|       |				/* test if guid and the fascn starts with ;9999 (in ISO 4bit + parity code) */
 4433|       |				/* ;9999 is non-gov issued FASC-N, will use FASC-N for gov issued if no guid */
 4434|     32|				if (!(gbits && fascn[0] == 0xD4 && fascn[1] == 0xE7 &&
  ------------------
  |  Branch (4434:11): [True: 15, False: 17]
  |  Branch (4434:20): [True: 12, False: 3]
  |  Branch (4434:40): [True: 7, False: 5]
  ------------------
 4435|     31|						    fascn[2] == 0x39 && (fascn[3] | 0x7F) == 0xFF)) {
  ------------------
  |  Branch (4435:11): [True: 2, False: 5]
  |  Branch (4435:31): [True: 1, False: 1]
  ------------------
 4436|       |					/* fascnlen is 25 */
 4437|     31|					serial->len = fascnlen;
 4438|     31|					memcpy(serial->value, fascn, serial->len);
 4439|     31|					r = SC_SUCCESS;
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
 4440|     31|					gbits = 0; /* set to skip using guid below */
 4441|     31|				}
 4442|     32|			}
 4443|    120|			if (guid && guidlen == 16 && gbits) {
  ------------------
  |  Branch (4443:8): [True: 22, False: 98]
  |  Branch (4443:16): [True: 17, False: 5]
  |  Branch (4443:33): [True: 2, False: 15]
  ------------------
 4444|      2|				serial->len = guidlen;
 4445|      2|				memcpy(serial->value, guid, serial->len);
 4446|      2|				r = SC_SUCCESS;
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
 4447|      2|			}
 4448|    120|		}
 4449|    132|	}
 4450|       |
 4451|    132|	if (fbits == 0 && gbits == 0) { /* were not able to set the serial number */
  ------------------
  |  Branch (4451:6): [True: 100, False: 32]
  |  Branch (4451:20): [True: 99, False: 1]
  ------------------
 4452|     99|		serial->len = 16;
 4453|     99|		memset(serial->value, 0x00, serial->len);
 4454|     99|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     99|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4455|     99|	}
 4456|       |
 4457|    132|	card->serialnr = *serial;
 4458|    132|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    132|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    132|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    132|	int _ret = r; \
  |  |  |  |  155|    132|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 132, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    132|		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|     99|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 99, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  157|    132|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    132|	} 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|    132|	return _ret; \
  |  |  |  |  163|    132|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4459|    132|}
card-piv.c:piv_get_pin_preference:
 4493|  1.23k|{
 4494|  1.23k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  1.23k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4495|       |
 4496|  1.23k|	*pin_ref = priv->pin_preference;
 4497|  1.23k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.23k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.23k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.23k|	int _ret = r; \
  |  |  |  |  155|  1.23k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.23k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.23k|		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: 1.23k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.23k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.23k|	} 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|  1.23k|	return _ret; \
  |  |  |  |  163|  1.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4498|  1.23k|}
card-piv.c:piv_is_object_present:
 4474|  76.2k|{
 4475|  76.2k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|  76.2k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4476|  76.2k|	int r = 0;
 4477|  76.2k|	int enumtag;
 4478|       |
 4479|  76.2k|	enumtag = piv_find_obj_by_containerid(card, ptr);
 4480|  76.2k|	if (enumtag >= 0 && priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_NOT_PRESENT)
  ------------------
  |  |  153|  75.0k|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
  |  Branch (4480:6): [True: 75.0k, False: 1.23k]
  |  Branch (4480:22): [True: 46.6k, False: 28.4k]
  ------------------
 4481|  46.6k|		r = 1;
 4482|       |
 4483|  76.2k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  76.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  76.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  76.2k|	int _ret = r; \
  |  |  |  |  155|  76.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 29.6k, False: 46.6k]
  |  |  |  |  ------------------
  |  |  |  |  156|  29.6k|		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: 29.6k]
  |  |  |  |  ------------------
  |  |  |  |  157|  29.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  46.6k|	} else { \
  |  |  |  |  159|  46.6k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  46.6k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  46.6k|	} \
  |  |  |  |  162|  76.2k|	return _ret; \
  |  |  |  |  163|  76.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4484|  76.2k|}
card-piv.c:piv_yk_pin_policy:
 4632|  1.69k|{
 4633|  1.69k|	u8 slot = *ptr;
 4634|  1.69k|	LOG_FUNC_RETURN(card->ctx, piv_yk_get_metadata(card, slot, ptr, NULL, NULL));
  ------------------
  |  |  164|  1.69k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.69k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.69k|	int _ret = r; \
  |  |  |  |  155|  1.69k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.69k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.69k|		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|  1.68k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.68k, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.69k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.69k|	} 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|  1.69k|	return _ret; \
  |  |  |  |  163|  1.69k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4635|  1.69k|}
card-piv.c:piv_yk_get_pubkey:
 4639|  27.4k|{
 4640|  27.4k|	int rc;
 4641|  27.4k|	u8 slot = info->slot;
 4642|       |
 4643|  27.4k|	rc = piv_yk_get_metadata(card, slot, NULL, NULL, info);
 4644|  27.4k|	LOG_TEST_RET(card->ctx, rc, "piv_yk_get_metadata failed");
  ------------------
  |  |  174|  27.4k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  27.4k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  27.4k|	int _ret = (r); \
  |  |  |  |  168|  27.4k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 27.0k, False: 318]
  |  |  |  |  ------------------
  |  |  |  |  169|  27.0k|		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|  27.0k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  27.0k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  27.0k|		return _ret; \
  |  |  |  |  172|  27.0k|	} \
  |  |  |  |  173|  27.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 318]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4645|    318|	if (info->pubkey.value == NULL || info->pubkey.len == 0 || info->algorithm == 0) {
  ------------------
  |  Branch (4645:6): [True: 268, False: 50]
  |  Branch (4645:36): [True: 0, False: 50]
  |  Branch (4645:61): [True: 11, False: 39]
  ------------------
 4646|    279|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_DATA_OBJECT_NOT_FOUND);
  ------------------
  |  |  164|    279|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    279|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    279|	int _ret = r; \
  |  |  |  |  155|    279|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 279, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    279|		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|    279|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 279, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    279|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    279|	} 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|    279|	return _ret; \
  |  |  |  |  163|    279|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4647|    279|	}
 4648|       |
 4649|     39|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     39|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     39|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     39|	int _ret = r; \
  |  |  |  |  155|     39|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 39, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     39|		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: 39]
  |  |  |  |  ------------------
  |  |  |  |  157|     39|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     39|	} 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|     39|	return _ret; \
  |  |  |  |  163|     39|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4650|     39|}
card-piv.c:piv_pin_cmd:
 6438|    425|{
 6439|    425|	int r = 0;
 6440|    425|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|    425|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6441|       |
 6442|       |	/* Extra validation of (new) PIN during a PIN change request, to
 6443|       |	 * ensure it's not outside the FIPS 201 4.1.6.1 (numeric only) and
 6444|       |	 * FIPS 140-2 (6 character minimum) requirements.
 6445|       |	 */
 6446|    425|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 6447|       |
 6448|    425|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    425|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    425|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    425|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 425]
  |  |  ------------------
  ------------------
 6449|    425|	sc_log(card->ctx, "piv_pin_cmd tries_left=%d, logged_in=%d", priv->tries_left, priv->logged_in);
  ------------------
  |  |   71|    425|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6450|    425|	if (data->cmd == SC_PIN_CMD_CHANGE) {
  ------------------
  |  |  416|    425|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (6450:6): [True: 33, False: 392]
  ------------------
 6451|     33|		size_t i = 0;
 6452|     33|		if (data->pin2.len < 6) {
  ------------------
  |  Branch (6452:7): [True: 7, False: 26]
  ------------------
 6453|      7|			return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      7|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
 6454|      7|		}
 6455|    176|		for (i = 0; i < data->pin2.len; ++i) {
  ------------------
  |  Branch (6455:15): [True: 154, False: 22]
  ------------------
 6456|    154|			if (!isdigit(data->pin2.data[i])) {
  ------------------
  |  Branch (6456:8): [True: 4, False: 150]
  ------------------
 6457|      4|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      4|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 6458|      4|			}
 6459|    154|		}
 6460|     26|	}
 6461|       |
 6462|    414|	priv->pin_cmd_verify_sw1 = 0x00U;
 6463|       |
 6464|    414|	if (data->cmd == SC_PIN_CMD_GET_INFO) { /* fill in what we think it should be */
  ------------------
  |  |  418|    414|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (6464:6): [True: 273, False: 141]
  ------------------
 6465|    273|		data->pin1.logged_in = priv->logged_in;
 6466|    273|		data->pin1.tries_left = priv->tries_left;
 6467|       |
 6468|       |		/*
 6469|       |		 * If called to check on the login state for a context specific login
 6470|       |		 * return not logged in. Needed because of logic in e6f7373ef066
 6471|       |		 */
 6472|    273|		if (data->pin_type == SC_AC_CONTEXT_SPECIFIC) {
  ------------------
  |  |  160|    273|#define SC_AC_CONTEXT_SPECIFIC		0x00000200 /* Context specific login */
  ------------------
  |  Branch (6472:7): [True: 0, False: 273]
  ------------------
 6473|      0|			data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  431|      0|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 6474|      0|			LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6475|      0|		}
 6476|       |
 6477|    273|		if (priv->logged_in & SC_PIN_STATE_LOGGED_IN) {
  ------------------
  |  |  432|    273|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
  |  Branch (6477:7): [True: 0, False: 273]
  ------------------
 6478|       |			/* Avoid status requests when the user is logged in to handle NIST
 6479|       |			 * 800-73-4 Part 2:
 6480|       |			 * The PKI cryptographic function (see Table 4b) is protected with
 6481|       |			 * a “PIN Always” or “OCC Always” access rule. In other words, the
 6482|       |			 * PIN or OCC data must be submitted and verified every time
 6483|       |			 * immediately before a digital signature key operation.  This
 6484|       |			 * ensures cardholder participation every time the private key is
 6485|       |			 * used for digital signature generation */
 6486|      0|			LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6487|      0|		}
 6488|    273|	}
 6489|       |
 6490|       |	/*
 6491|       |	 * If this was for a CKU_CONTEXT_SPECFIC login, lock the card one more time.
 6492|       |	 * to avoid any interference from other applications.
 6493|       |	 * Sc_unlock will be called at a later time after the next card command
 6494|       |	 * that should be a crypto operation. If its not then it is a error by the
 6495|       |	 * calling application.
 6496|       |	 */
 6497|    414|	if (data->cmd == SC_PIN_CMD_VERIFY && data->pin_type == SC_AC_CONTEXT_SPECIFIC) {
  ------------------
  |  |  415|    828|#define SC_PIN_CMD_VERIFY	0
  ------------------
              	if (data->cmd == SC_PIN_CMD_VERIFY && data->pin_type == SC_AC_CONTEXT_SPECIFIC) {
  ------------------
  |  |  160|    119|#define SC_AC_CONTEXT_SPECIFIC		0x00000200 /* Context specific login */
  ------------------
  |  Branch (6497:6): [True: 119, False: 295]
  |  Branch (6497:40): [True: 4, False: 115]
  ------------------
 6498|      4|		priv->context_specific = 1;
 6499|      4|		sc_log(card->ctx, "Starting CONTEXT_SPECIFIC verify");
  ------------------
  |  |   71|      4|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6500|      4|		r = sc_lock(card);
 6501|      4|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  |  Branch (6501:7): [True: 0, False: 4]
  ------------------
 6502|      0|			sc_log(card->ctx, "sc_lock failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 6503|      0|			return r;
 6504|      0|		}
 6505|      4|	}
 6506|       |
 6507|    414|	priv->pin_cmd_verify = 1; /* tell piv_check_sw its a verify to save sw1, sw2 */
 6508|    414|	r = iso_drv->ops->pin_cmd(card, data);
 6509|    414|	priv->pin_cmd_verify = 0;
 6510|       |
 6511|       |	/* tell user verify not supported on contactless without VCI */
 6512|    414|	if (priv->pin_cmd_verify_sw1 == 0x69 && priv->pin_cmd_verify_sw2 == 0x82 &&
  ------------------
  |  Branch (6512:6): [True: 11, False: 403]
  |  Branch (6512:42): [True: 3, False: 8]
  ------------------
 6513|      3|			priv->init_flags & PIV_INIT_CONTACTLESS &&
  ------------------
  |  |  385|    417|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
  |  Branch (6513:4): [True: 0, False: 3]
  ------------------
 6514|      0|			card->type == SC_CARD_TYPE_PIV_II_800_73_4) {
  ------------------
  |  Branch (6514:4): [True: 0, False: 0]
  ------------------
 6515|      0|		sc_log(card->ctx, "Token does not support pin verify over contacless reader");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 6516|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 6517|      0|	}
 6518|       |
 6519|       |	/* if verify failed, release the lock */
 6520|    414|	if (data->cmd == SC_PIN_CMD_VERIFY && r < 0 && priv->context_specific) {
  ------------------
  |  |  415|    828|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (6520:6): [True: 119, False: 295]
  |  Branch (6520:40): [True: 85, False: 34]
  |  Branch (6520:49): [True: 1, False: 84]
  ------------------
 6521|      1|		sc_log(card->ctx, "Clearing CONTEXT_SPECIFIC");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 6522|      1|		priv->context_specific = 0;
 6523|      1|		sc_unlock(card);
 6524|      1|	}
 6525|       |
 6526|       |	/* if access to applet is know to be reset by other driver  we select_aid and try again */
 6527|    414|	if (priv->card_issues & CI_OTHER_AID_LOSE_STATE && priv->pin_cmd_verify_sw1 == 0x6DU) {
  ------------------
  |  |  600|    828|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
  |  Branch (6527:6): [True: 258, False: 156]
  |  Branch (6527:53): [True: 190, False: 68]
  ------------------
 6528|    190|		sc_log(card->ctx, "AID may be lost doing piv_find_aid and retry pin_cmd");
  ------------------
  |  |   71|    190|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6529|    190|		piv_find_aid(card);
 6530|       |
 6531|    190|		priv->pin_cmd_verify = 1; /* tell piv_check_sw its a verify to save sw1, sw2 */
 6532|    190|		r = iso_drv->ops->pin_cmd(card, data);
 6533|    190|		priv->pin_cmd_verify = 0;
 6534|    190|	}
 6535|       |
 6536|       |	/* If verify worked, we are logged_in */
 6537|    414|	if (data->cmd == SC_PIN_CMD_VERIFY) {
  ------------------
  |  |  415|    414|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (6537:6): [True: 119, False: 295]
  ------------------
 6538|    119|		if (r >= 0)
  ------------------
  |  Branch (6538:7): [True: 34, False: 85]
  ------------------
 6539|     34|			priv->logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  432|     34|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
 6540|     85|		else
 6541|     85|			priv->logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  431|     85|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 6542|    119|	}
 6543|       |
 6544|       |	/* Some cards never return 90 00  for SC_PIN_CMD_GET_INFO even if the card state is verified */
 6545|       |	/* PR 797 has changed the return codes from pin_cmd, and added a data->pin1.logged_in flag */
 6546|       |
 6547|    414|	if (data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  418|    414|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (6547:6): [True: 273, False: 141]
  ------------------
 6548|    273|		if (priv->card_issues & CI_CANT_USE_GETDATA_FOR_STATE) {
  ------------------
  |  |  595|    273|#define CI_CANT_USE_GETDATA_FOR_STATE	    0x00000008U /* No object to test verification inplace of VERIFY Lc=0 */
  ------------------
  |  Branch (6548:7): [True: 0, False: 273]
  ------------------
 6549|      0|			sc_log(card->ctx, "CI_CANT_USE_GETDATA_FOR_STATE set, assume logged_in=%d", priv->logged_in);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 6550|      0|			data->pin1.logged_in = priv->logged_in; /* use what ever we saw last */
 6551|    273|		} else if (priv->card_issues & CI_VERIFY_LC0_FAIL &&
  ------------------
  |  |  592|    546|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
  |  Branch (6551:14): [True: 83, False: 190]
  ------------------
 6552|     83|				priv->pin_cmd_verify_sw1 == 0x63U) { /* can not use modified return codes from iso->drv->pin_cmd */
  ------------------
  |  Branch (6552:5): [True: 6, False: 77]
  ------------------
 6553|       |			/* try another method, looking at a protected object this may require adding one of these to NEO */
 6554|      6|			r = piv_check_protected_objects(card);
 6555|      6|			if (r == SC_SUCCESS)
  ------------------
  |  |   28|      6|#define SC_SUCCESS				0
  ------------------
  |  Branch (6555:8): [True: 1, False: 5]
  ------------------
 6556|      1|				data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  432|      1|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
 6557|      5|			else if (r == SC_ERROR_PIN_CODE_INCORRECT) {
  ------------------
  |  |   64|      5|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (6557:13): [True: 5, False: 0]
  ------------------
 6558|      5|				if (priv->card_issues & CI_CANT_USE_GETDATA_FOR_STATE) { /* we still can not determine login state */
  ------------------
  |  |  595|      5|#define CI_CANT_USE_GETDATA_FOR_STATE	    0x00000008U /* No object to test verification inplace of VERIFY Lc=0 */
  ------------------
  |  Branch (6558:9): [True: 2, False: 3]
  ------------------
 6559|       |
 6560|      2|					data->pin1.logged_in = priv->logged_in; /* may have be set from SC_PIN_CMD_VERIFY */
 6561|      3|				} else {
 6562|      3|					data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  431|      3|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 6563|      3|				}
 6564|      5|				r = SC_SUCCESS;
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
 6565|      5|			}
 6566|      6|		}
 6567|    273|		priv->logged_in = data->pin1.logged_in;
 6568|    273|		priv->tries_left = data->pin1.tries_left;
 6569|    273|	}
 6570|       |
 6571|    414|	sc_log(card->ctx, "piv_pin_cmd tries_left=%d, logged_in=%d", priv->tries_left, priv->logged_in);
  ------------------
  |  |   71|    414|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6572|    414|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    414|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    414|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    414|	int _ret = r; \
  |  |  |  |  155|    414|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 414, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    414|		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|    364|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 364, False: 50]
  |  |  |  |  ------------------
  |  |  |  |  157|    414|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    414|	} 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|    414|	return _ret; \
  |  |  |  |  163|    414|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6573|    414|}
card-piv.c:piv_check_protected_objects:
 6369|      6|{
 6370|      6|	int r = 0;
 6371|      6|	int i;
 6372|      6|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  447|      6|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6373|      6|	u8 buf[8]; /* tag of 53 with 82 xx xx  will fit in 4 */
 6374|      6|	u8 *rbuf;
 6375|      6|	size_t buf_len;
 6376|      6|	static int protected_objects[] = {PIV_OBJ_PI, PIV_OBJ_CHF, PIV_OBJ_IRIS_IMAGE};
 6377|       |
 6378|      6|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      6|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      6|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      6|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      6|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6379|       |	/*
 6380|       |	 * routine only called from piv_pin_cmd after verify lc=0 did not return 90 00
 6381|       |	 * We will test for a protected object using GET DATA.
 6382|       |	 *
 6383|       |	 * Based on observations, of cards using the GET DATA APDU,
 6384|       |	 * SC_ERROR_SECURITY_STATUS_NOT_SATISFIED  means the PIN not verified,
 6385|       |	 * SC_SUCCESS means PIN has been verified even if it has length 0
 6386|       |	 * SC_ERROR_FILE_NOT_FOUND (which is the bug) does not tell us anything
 6387|       |	 * about the state of the PIN and we will try the next object.
 6388|       |	 *
 6389|       |	 * If we can't determine the security state from this process,
 6390|       |	 * set card_issues CI_CANT_USE_GETDATA_FOR_STATE
 6391|       |	 * and return SC_ERROR_PIN_CODE_INCORRECT
 6392|       |	 * The circumvention is to add a dummy Printed Info object in the card.
 6393|       |	 * so we will have an object to test.
 6394|       |	 *
 6395|       |	 * We save the object's number to use in the future.
 6396|       |	 *
 6397|       |	 */
 6398|      6|	if (priv->object_test_verify == 0) {
  ------------------
  |  Branch (6398:6): [True: 6, False: 0]
  ------------------
 6399|     15|		for (i = 0; i < (int)(sizeof(protected_objects) / sizeof(int)); i++) {
  ------------------
  |  Branch (6399:15): [True: 13, False: 2]
  ------------------
 6400|     13|			buf_len = sizeof(buf);
 6401|     13|			rbuf = buf;
 6402|     13|			r = piv_get_data(card, protected_objects[i], &rbuf, &buf_len);
 6403|     13|			if (r >= 0 || r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {
  ------------------
  |  |   61|     12|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (6403:8): [True: 1, False: 12]
  |  Branch (6403:18): [True: 3, False: 9]
  ------------------
 6404|       |
 6405|       |				/* we can use this object next time if needed */
 6406|      4|				priv->object_test_verify = protected_objects[i];
 6407|      4|				break;
 6408|      4|			}
 6409|     13|		}
 6410|      6|		if (priv->object_test_verify == 0) {
  ------------------
  |  Branch (6410:7): [True: 2, False: 4]
  ------------------
 6411|       |			/*
 6412|       |			 * none of the objects returned acceptable sw1, sw2
 6413|       |			 */
 6414|      2|			sc_log(card->ctx, "No protected objects found, setting CI_CANT_USE_GETDATA_FOR_STATE");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6415|      2|			priv->card_issues |= CI_CANT_USE_GETDATA_FOR_STATE;
  ------------------
  |  |  595|      2|#define CI_CANT_USE_GETDATA_FOR_STATE	    0x00000008U /* No object to test verification inplace of VERIFY Lc=0 */
  ------------------
 6416|      2|			r = SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|      2|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
 6417|      2|		}
 6418|      6|	} else {
 6419|       |		/* use the one object we found earlier. Test is security status has changed */
 6420|      0|		buf_len = sizeof(buf);
 6421|      0|		rbuf = buf;
 6422|      0|		r = piv_get_data(card, priv->object_test_verify, &rbuf, &buf_len);
 6423|      0|	}
 6424|      6|	if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      6|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (6424:6): [True: 0, False: 6]
  ------------------
 6425|      0|		r = SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|      0|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
 6426|      6|	else if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)
  ------------------
  |  |   61|      6|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (6426:11): [True: 3, False: 3]
  ------------------
 6427|      3|		r = SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|      3|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
 6428|      3|	else if (r > 0)
  ------------------
  |  Branch (6428:11): [True: 1, False: 2]
  ------------------
 6429|      1|		r = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 6430|       |
 6431|      6|	sc_log(card->ctx, "card->type:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   71|      6|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6432|      6|			card->type, priv->card_issues, r, priv->alg_ids);
 6433|      6|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6434|      6|}
card-piv.c:piv_card_reader_lock_obtained:
 6612|  9.25k|{
 6613|  9.25k|	int r = 0;
 6614|  9.25k|	u8 temp[SC_MAX_APDU_BUFFER_SIZE];
 6615|  9.25k|	size_t templen = sizeof(temp);
 6616|  9.25k|	piv_private_data_t *priv = PIV_DATA(card); /* may be null */
  ------------------
  |  |  447|  9.25k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6617|       |
 6618|  9.25k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  9.25k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  9.25k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  9.25k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 9.25k]
  |  |  ------------------
  ------------------
 6619|       |
 6620|       |	/* We have a PCSC transaction and sc_lock */
 6621|  9.25k|	if (priv == NULL || priv->pstate == PIV_STATE_MATCH) {
  ------------------
  |  Branch (6621:6): [True: 6.06k, False: 3.18k]
  |  Branch (6621:22): [True: 1.23k, False: 1.95k]
  ------------------
 6622|  7.29k|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  14.5k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (70:103): [True: 1.23k, False: 6.06k]
  |  |  ------------------
  ------------------
 6623|  7.29k|				priv ? "PIV_STATE_MATCH" : "priv==NULL");
 6624|  7.29k|		r = 0; /* do nothing, piv_match will take care of it */
 6625|  7.29k|		goto err;
 6626|  7.29k|	}
 6627|       |
 6628|  1.95k|	priv->init_flags |= PIV_INIT_IN_READER_LOCK_OBTAINED;
  ------------------
  |  |  384|  1.95k|#define PIV_INIT_IN_READER_LOCK_OBTAINED	0x00000010u
  ------------------
 6629|       |
 6630|       |	/* make sure our application is active */
 6631|       |
 6632|       |	/* first see if AID is active AID by reading discovery object '7E' */
 6633|       |	/* If not try selecting AID */
 6634|       |
 6635|       |	/* but if card does not support DISCOVERY object we can not use it */
 6636|  1.95k|	if (priv->card_issues & CI_DISCOVERY_USELESS) {
  ------------------
  |  |  597|  1.95k|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
  |  Branch (6636:6): [True: 1.75k, False: 205]
  ------------------
 6637|  1.75k|		r = SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|  1.75k|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
 6638|  1.75k|	} else {
 6639|    205|		r = piv_find_discovery(card);
 6640|       |#ifdef ENABLE_PIV_SM
 6641|       |		/*
 6642|       |		 * All 800-73-4 cards that support SM, also have a discovery object with
 6643|       |		 * the pin_policy, so can not have CI_DISCOVERY_USELESS
 6644|       |		 * Discovery object can be read with contact or contactless
 6645|       |		 * If read with SM and fails with 69 88  SC_ERROR_SM_INVALID_SESSION_KEY
 6646|       |		 * sm.c will close the SM connectrion, and set defer
 6647|       |		 */
 6648|       |		if (was_reset == 0 && (r == SC_ERROR_SM_INVALID_SESSION_KEY || priv->sm_flags & PIV_SM_FLAGS_DEFER_OPEN)) {
 6649|       |			sc_log(card->ctx, "SC_ERROR_SM_INVALID_SESSION_KEY || PIV_SM_FLAGS_DEFER_OPEN");
 6650|       |			piv_sm_open(card);
 6651|       |			r = piv_find_discovery(card);
 6652|       |		}
 6653|       |#endif /* ENABLE_PIV_SM */
 6654|    205|	}
 6655|       |
 6656|  1.95k|	if (r < 0) {
  ------------------
  |  Branch (6656:6): [True: 1.93k, False: 19]
  ------------------
 6657|  1.93k|		if (was_reset > 0 || !(priv->card_issues & CI_PIV_AID_LOSE_STATE)) {
  ------------------
  |  |  598|  1.93k|#define CI_PIV_AID_LOSE_STATE		    0x00000040U /* PIV AID can lose the login state run with out it*/
  ------------------
  |  Branch (6657:7): [True: 0, False: 1.93k]
  |  Branch (6657:24): [True: 1.88k, False: 55]
  ------------------
 6658|  1.88k|			r = iso7816_select_aid(card, piv_aids[0].value, piv_aids[0].len_short, temp, &templen);
 6659|  1.88k|			sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "iso7816_select_aid card->type:%d r:%d\n", card->type, r);
  ------------------
  |  |   70|  1.88k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 6660|  1.88k|		} else {
 6661|     55|			r = 0; /* can't do anything with this card, hope there was no interference */
 6662|     55|		}
 6663|  1.93k|	}
 6664|       |
 6665|  1.95k|	if (r < 0) /* bad error return will show up in sc_lock as error*/
  ------------------
  |  Branch (6665:6): [True: 1.71k, False: 242]
  ------------------
 6666|  1.71k|		goto err;
 6667|       |
 6668|    242|	if (was_reset > 0)
  ------------------
  |  Branch (6668:6): [True: 0, False: 242]
  ------------------
 6669|      0|		priv->logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|      0|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 6670|       |
 6671|    242|	r = 0;
 6672|       |
 6673|  9.25k|err:
 6674|  9.25k|	if (priv)
  ------------------
  |  Branch (6674:6): [True: 3.18k, False: 6.06k]
  ------------------
 6675|  3.18k|		priv->init_flags &= ~PIV_INIT_IN_READER_LOCK_OBTAINED;
  ------------------
  |  |  384|  3.18k|#define PIV_INIT_IN_READER_LOCK_OBTAINED	0x00000010u
  ------------------
 6676|  9.25k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  9.25k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  9.25k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  9.25k|	int _ret = r; \
  |  |  |  |  155|  9.25k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9.25k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  9.25k|		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|  1.71k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.71k, False: 7.54k]
  |  |  |  |  ------------------
  |  |  |  |  157|  9.25k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  9.25k|	} 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|  9.25k|	return _ret; \
  |  |  |  |  163|  9.25k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6677|  9.25k|}

sc_get_rtecp_driver:
  868|  17.0k|{
  869|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (869:6): [True: 1, False: 17.0k]
  ------------------
  870|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  871|  17.0k|	rtecp_ops = *iso_ops;
  872|       |
  873|  17.0k|	rtecp_ops.match_card = rtecp_match_card;
  874|  17.0k|	rtecp_ops.init = rtecp_init;
  875|       |	/* read_binary */
  876|  17.0k|	rtecp_ops.write_binary = NULL;
  877|       |	/* update_binary */
  878|  17.0k|	rtecp_ops.read_record = NULL;
  879|  17.0k|	rtecp_ops.write_record = NULL;
  880|  17.0k|	rtecp_ops.append_record = NULL;
  881|  17.0k|	rtecp_ops.update_record = NULL;
  882|  17.0k|	rtecp_ops.select_file = rtecp_select_file;
  883|       |	/* get_response */
  884|       |	/* get_challenge */
  885|  17.0k|	rtecp_ops.verify = rtecp_verify;
  886|  17.0k|	rtecp_ops.logout = rtecp_logout;
  887|       |	/* restore_security_env */
  888|  17.0k|	rtecp_ops.set_security_env = rtecp_set_security_env;
  889|  17.0k|	rtecp_ops.decipher = rtecp_decipher;
  890|  17.0k|	rtecp_ops.compute_signature = rtecp_compute_signature;
  891|  17.0k|	rtecp_ops.change_reference_data = rtecp_change_reference_data;
  892|  17.0k|	rtecp_ops.reset_retry_counter = rtecp_reset_retry_counter;
  893|  17.0k|	rtecp_ops.create_file = rtecp_create_file;
  894|       |	/* delete_file */
  895|  17.0k|	rtecp_ops.list_files = rtecp_list_files;
  896|       |	/* check_sw */
  897|  17.0k|	rtecp_ops.card_ctl = rtecp_card_ctl;
  898|       |	/* process_fci */
  899|  17.0k|	rtecp_ops.construct_fci = rtecp_construct_fci;
  900|       |	rtecp_ops.pin_cmd = NULL;
  901|  17.0k|	return &rtecp_drv;
  902|  17.0k|}
card-rtecp.c:rtecp_match_card:
   73|  10.2k|{
   74|  10.2k|	int i = -1;
   75|  10.2k|	i = _sc_match_atr(card, rtecp_atrs, &card->type);
   76|  10.2k|	if (i >= 0) {
  ------------------
  |  Branch (76:6): [True: 79, False: 10.2k]
  ------------------
   77|     79|		card->name = rtecp_atrs[i].name;
   78|     79|		LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  164|     79|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     79|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     79|	int _ret = r; \
  |  |  |  |  155|     79|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 79]
  |  |  |  |  ------------------
  |  |  |  |  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|     79|	} else { \
  |  |  |  |  159|     79|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     79|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     79|	} \
  |  |  |  |  162|     79|	return _ret; \
  |  |  |  |  163|     79|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   79|     79|	}
   80|  10.2k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  10.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  10.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  10.2k|	int _ret = r; \
  |  |  |  |  155|  10.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  10.2k|		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: 10.2k]
  |  |  |  |  ------------------
  |  |  |  |  157|  10.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  10.2k|	} 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|  10.2k|	return _ret; \
  |  |  |  |  163|  10.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   81|  10.2k|}
card-rtecp.c:rtecp_init:
   84|     79|{
   85|     79|	sc_algorithm_info_t info;
   86|     79|	unsigned long flags;
   87|       |
   88|     79|	if (!card || !card->ctx)
  ------------------
  |  Branch (88:6): [True: 0, False: 79]
  |  Branch (88:15): [True: 0, False: 79]
  ------------------
   89|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   90|       |
   91|     79|	card->cla = 0;
   92|       |
   93|     79|	if (card->type == SC_CARD_TYPE_RUTOKEN_LITE
  ------------------
  |  Branch (93:6): [True: 0, False: 79]
  ------------------
   94|     79|			|| card->type == SC_CARD_TYPE_RUTOKEN_LITE_SC)
  ------------------
  |  Branch (94:7): [True: 1, False: 78]
  ------------------
   95|      1|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      1|	int _ret = r; \
  |  |  155|      1|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  156|      1|		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: 1]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  163|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
   96|       |
   97|     78|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|     78|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
   98|       |
   99|     78|	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |  102|     78|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |   93|     78|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  100|     78|		| SC_ALGORITHM_RSA_PAD_NONE | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  104|     78|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
              		| SC_ALGORITHM_RSA_PAD_NONE | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|     78|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  101|       |
  102|     78|	_sc_card_add_rsa_alg(card, 256, flags, 0);
  103|     78|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  104|     78|	_sc_card_add_rsa_alg(card, 768, flags, 0);
  105|     78|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  106|     78|	_sc_card_add_rsa_alg(card, 1280, flags, 0);
  107|     78|	_sc_card_add_rsa_alg(card, 1536, flags, 0);
  108|     78|	_sc_card_add_rsa_alg(card, 1792, flags, 0);
  109|     78|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  110|     78|	_sc_card_add_rsa_alg(card, 4096, flags, 0);
  111|       |
  112|     78|	memset(&info, 0, sizeof(info));
  113|     78|	info.algorithm = SC_ALGORITHM_GOSTR3410;
  ------------------
  |  |   71|     78|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  114|     78|	info.key_length = 256;
  115|     78|	info.flags = SC_ALGORITHM_GOSTR3410_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |  156|     78|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  ------------------
              	info.flags = SC_ALGORITHM_GOSTR3410_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |   93|     78|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  116|     78|		| SC_ALGORITHM_GOSTR3410_HASH_NONE;
  ------------------
  |  |  157|     78|#define SC_ALGORITHM_GOSTR3410_HASH_NONE	SC_ALGORITHM_GOSTR3410_RAW /*XXX*/
  |  |  ------------------
  |  |  |  |  156|     78|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  |  |  ------------------
  ------------------
  117|     78|	_sc_card_add_algorithm(card, &info);
  118|       |
  119|     78|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|     78|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     78|	int _ret = r; \
  |  |  155|     78|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 78, False: 0]
  |  |  ------------------
  |  |  156|     78|		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: 78]
  |  |  ------------------
  |  |  157|     78|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     78|	} 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|     78|	return _ret; \
  |  |  163|     78|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  120|     78|}
card-rtecp.c:rtecp_select_file:
  285|    392|{
  286|    392|	sc_file_t *file = NULL;
  287|    392|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    392|#define SC_SUCCESS				0
  ------------------
  288|       |
  289|    392|	if (!card || !card->ctx || !in_path)
  ------------------
  |  Branch (289:6): [True: 0, False: 392]
  |  Branch (289:15): [True: 0, False: 392]
  |  Branch (289:29): [True: 0, False: 392]
  ------------------
  290|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  291|       |
  292|    392|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    392|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    392|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    392|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 392]
  |  |  ------------------
  ------------------
  293|       |
  294|    392|	switch (in_path->type)
  ------------------
  |  Branch (294:10): [True: 136, False: 256]
  ------------------
  295|    392|	{
  296|    136|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|    136|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (296:2): [True: 136, False: 256]
  ------------------
  297|    136|	case SC_PATH_TYPE_FROM_CURRENT:
  ------------------
  |  |  122|    136|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (297:2): [True: 0, False: 392]
  ------------------
  298|    136|	case SC_PATH_TYPE_PARENT:
  ------------------
  |  |  123|    136|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (298:2): [True: 0, False: 392]
  ------------------
  299|    136|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  153|    136|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    136|	int _ret = r; \
  |  |  155|    136|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 136, False: 0]
  |  |  ------------------
  |  |  156|    136|		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|    136|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 136, False: 0]
  |  |  ------------------
  |  |  157|    136|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    136|	} 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|    136|	return _ret; \
  |  |  163|    136|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  300|    392|	}
  301|       |
  302|       |	// Card Rutoken ECP SC T0 doesn't support SELECT FILE without return a file info.
  303|       |	// So here we request a file and then assign/free it depending on file_out.
  304|    256|	r = iso_ops->select_file(card, in_path, &file);
  305|    256|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    256|#define SC_SUCCESS				0
  ------------------
  |  Branch (305:6): [True: 127, False: 129]
  ------------------
  306|    127|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    127|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    127|	int _ret = r; \
  |  |  155|    127|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 127, False: 0]
  |  |  ------------------
  |  |  156|    127|		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|    127|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 127, False: 0]
  |  |  ------------------
  |  |  157|    127|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    127|	} 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|    127|	return _ret; \
  |  |  163|    127|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  307|       |
  308|    129|	if (file->sec_attr && file->sec_attr_len == SC_RTECP_SEC_ATTR_SIZE)
  ------------------
  |  |  781|    115|#define SC_RTECP_SEC_ATTR_SIZE 15
  ------------------
  |  Branch (308:6): [True: 115, False: 14]
  |  Branch (308:24): [True: 104, False: 11]
  ------------------
  309|    104|		set_acl_from_sec_attr(card, file);
  310|     25|	else
  311|     25|	{
  312|     25|		sc_file_free(file);
  313|     25|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  153|     25|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     25|	int _ret = r; \
  |  |  155|     25|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 25, False: 0]
  |  |  ------------------
  |  |  156|     25|		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|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 25, False: 0]
  |  |  ------------------
  |  |  157|     25|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     25|	} 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|     25|	return _ret; \
  |  |  163|     25|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  314|     25|	}
  315|       |
  316|    104|	if (file_out)
  ------------------
  |  Branch (316:6): [True: 81, False: 23]
  ------------------
  317|     81|		*file_out = file;
  318|     23|	else
  319|     23|		sc_file_free(file);
  320|       |
  321|    104|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    104|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    104|	int _ret = r; \
  |  |  155|    104|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 104, False: 0]
  |  |  ------------------
  |  |  156|    104|		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: 104]
  |  |  ------------------
  |  |  157|    104|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    104|	} 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|    104|	return _ret; \
  |  |  163|    104|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  322|    104|}
card-rtecp.c:set_acl_from_sec_attr:
  167|    104|{
  168|    104|	unsigned int method;
  169|    104|	unsigned long key_ref;
  170|       |
  171|    104|	if (!card || !card->ctx || !file || !file->sec_attr
  ------------------
  |  Branch (171:6): [True: 0, False: 104]
  |  Branch (171:15): [True: 0, False: 104]
  |  Branch (171:29): [True: 0, False: 104]
  |  Branch (171:38): [True: 0, False: 104]
  ------------------
  172|    104|		|| file->sec_attr_len != SC_RTECP_SEC_ATTR_SIZE
  ------------------
  |  |  781|    208|#define SC_RTECP_SEC_ATTR_SIZE 15
  ------------------
  |  Branch (172:6): [True: 0, False: 104]
  ------------------
  173|      0|		|| 1 + 6 >= SC_RTECP_SEC_ATTR_SIZE)
  ------------------
  |  |  781|      0|#define SC_RTECP_SEC_ATTR_SIZE 15
  ------------------
  |  Branch (173:6): [Folded, False: 0]
  ------------------
  174|      0|	{
  175|      0|		return;
  176|      0|	}
  177|       |
  178|    104|	sc_file_add_acl_entry(file, SC_AC_OP_SELECT, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  166|    104|#define SC_AC_OP_SELECT			0
  ------------------
              	sc_file_add_acl_entry(file, SC_AC_OP_SELECT, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|    104|#define SC_AC_NONE			0x00000000
  ------------------
              	sc_file_add_acl_entry(file, SC_AC_OP_SELECT, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    104|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  179|    104|	if (file->sec_attr[0] & 0x40) /* if AccessMode.6 */
  ------------------
  |  Branch (179:6): [True: 62, False: 42]
  ------------------
  180|     62|	{
  181|     62|		method = sec_attr_to_method(file->sec_attr[1 + 6]);
  182|     62|		key_ref = sec_attr_to_key_ref(file->sec_attr[1 + 6]);
  183|     62|		sc_log(card->ctx,
  ------------------
  |  |   71|     62|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  184|     62|			"SC_AC_OP_DELETE %i %lu\n",
  185|     62|			(int)method, key_ref);
  186|     62|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE, method, key_ref);
  ------------------
  |  |  168|     62|#define SC_AC_OP_DELETE			2
  ------------------
  187|     62|	}
  188|    104|	if (file->sec_attr[0] & 0x01) /* if AccessMode.0 */
  ------------------
  |  Branch (188:6): [True: 76, False: 28]
  ------------------
  189|     76|	{
  190|     76|		method = sec_attr_to_method(file->sec_attr[1 + 0]);
  191|     76|		key_ref = sec_attr_to_key_ref(file->sec_attr[1 + 0]);
  192|     76|		sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  |  |  |  Branch (71:110): [True: 9, False: 67]
  |  |  ------------------
  ------------------
  193|     76|			(file->type == SC_FILE_TYPE_DF) ?
  194|     76|				"SC_AC_OP_CREATE %i %lu\n"
  195|     76|				: "SC_AC_OP_READ %i %lu\n",
  196|     76|			(int)method, key_ref);
  197|     76|		sc_file_add_acl_entry(file, (file->type == SC_FILE_TYPE_DF) ?
  ------------------
  |  |  214|     76|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (197:31): [True: 9, False: 67]
  ------------------
  198|     67|				SC_AC_OP_CREATE : SC_AC_OP_READ, method, key_ref);
  ------------------
  |  |  169|      9|#define SC_AC_OP_CREATE			3
  ------------------
              				SC_AC_OP_CREATE : SC_AC_OP_READ, method, key_ref);
  ------------------
  |  |  188|    143|#define SC_AC_OP_READ			22
  ------------------
  199|     76|	}
  200|    104|	if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|    104|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (200:6): [True: 10, False: 94]
  ------------------
  201|     10|	{
  202|     10|		sc_file_add_acl_entry(file, SC_AC_OP_LIST_FILES,
  ------------------
  |  |  172|     10|#define SC_AC_OP_LIST_FILES		6
  ------------------
  203|     10|				SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     10|#define SC_AC_NONE			0x00000000
  ------------------
              				SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     10|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  204|     10|	}
  205|     94|	else
  206|     94|		if (file->sec_attr[0] & 0x02) /* if AccessMode.1 */
  ------------------
  |  Branch (206:7): [True: 61, False: 33]
  ------------------
  207|     61|		{
  208|     61|			method = sec_attr_to_method(file->sec_attr[1 + 1]);
  209|     61|			key_ref = sec_attr_to_key_ref(file->sec_attr[1 + 1]);
  210|     61|			sc_log(card->ctx,
  ------------------
  |  |   71|     61|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  211|     61|				"SC_AC_OP_UPDATE %i %lu\n",
  212|     61|				(int)method, key_ref);
  213|     61|			sc_file_add_acl_entry(file, SC_AC_OP_UPDATE, method, key_ref);
  ------------------
  |  |  189|     61|#define SC_AC_OP_UPDATE			23
  ------------------
  214|     61|			sc_log(card->ctx,
  ------------------
  |  |   71|     61|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  215|     61|				"SC_AC_OP_WRITE %i %lu\n",
  216|     61|				(int)method, key_ref);
  217|     61|			sc_file_add_acl_entry(file, SC_AC_OP_WRITE, method, key_ref);
  ------------------
  |  |  190|     61|#define SC_AC_OP_WRITE			24
  ------------------
  218|     61|		}
  219|    104|}
card-rtecp.c:sec_attr_to_method:
  139|    199|{
  140|    199|	if (attr == 0xFF)
  ------------------
  |  Branch (140:6): [True: 44, False: 155]
  ------------------
  141|     44|		return SC_AC_NEVER;
  ------------------
  |  |  163|     44|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  142|    155|	else if (attr == 0)
  ------------------
  |  Branch (142:11): [True: 45, False: 110]
  ------------------
  143|     45|		return SC_AC_NONE;
  ------------------
  |  |  150|     45|#define SC_AC_NONE			0x00000000
  ------------------
  144|    110|	else if (attr & 0x03)
  ------------------
  |  Branch (144:11): [True: 80, False: 30]
  ------------------
  145|     80|		return SC_AC_CHV;
  ------------------
  |  |  151|     80|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  146|     30|	else
  147|     30|		return SC_AC_UNKNOWN;
  ------------------
  |  |  162|     30|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  148|    199|}
card-rtecp.c:sec_attr_to_key_ref:
  151|    199|{
  152|    199|	if (attr == 1 || attr == 2)
  ------------------
  |  Branch (152:6): [True: 20, False: 179]
  |  Branch (152:19): [True: 20, False: 159]
  ------------------
  153|     40|		return attr;
  154|    159|	return 0;
  155|    199|}
card-rtecp.c:rtecp_card_ctl:
  704|     30|{
  705|     30|	sc_apdu_t apdu;
  706|     30|	u8 buf[512];
  707|     30|	sc_rtecp_genkey_data_t *genkey_data = data;
  708|     30|	sc_serial_number_t *serial = data;
  709|     30|	int r;
  710|       |
  711|     30|	const unsigned char rsa_prop[] = {0xA6, 0x06, 0x94, 0x04, 0x01, 0x00, 0x01, 0x00};
  712|       |
  713|     30|	if (!card || !card->ctx)
  ------------------
  |  Branch (713:6): [True: 0, False: 30]
  |  Branch (713:15): [True: 0, False: 30]
  ------------------
  714|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  715|       |
  716|     30|	switch (request)
  717|     30|	{
  718|      0|	case SC_CARDCTL_RTECP_INIT:
  ------------------
  |  Branch (718:2): [True: 0, False: 30]
  ------------------
  719|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x8A, 0, 0);
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  720|      0|		apdu.cla = 0x80;
  721|      0|		break;
  722|      0|	case SC_CARDCTL_RTECP_INIT_END:
  ------------------
  |  Branch (722:2): [True: 0, False: 30]
  ------------------
  723|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x84, 0x4E, 0x19);
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  724|      0|		apdu.cla = 0x80;
  725|      0|		break;
  726|     14|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (726:2): [True: 14, False: 16]
  ------------------
  727|     14|		if (!serial)
  ------------------
  |  Branch (727:7): [True: 0, False: 14]
  ------------------
  728|     14|			LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  729|     14|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x81);
  ------------------
  |  |  292|     14|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  730|     14|		apdu.resp = buf;
  731|     14|		apdu.resplen = sizeof(buf);
  732|     14|		apdu.le = 256;
  733|     14|		serial->len = sizeof(serial->value);
  734|     14|		break;
  735|      0|	case SC_CARDCTL_RTECP_GENERATE_KEY:
  ------------------
  |  Branch (735:2): [True: 0, False: 30]
  ------------------
  736|      0|		if (!genkey_data)
  ------------------
  |  Branch (736:7): [True: 0, False: 0]
  ------------------
  737|      0|			LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  738|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x46, 0x80,
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  739|      0|				genkey_data->key_id);
  740|      0|		apdu.resp = buf;
  741|      0|		apdu.resplen = sizeof(buf);
  742|      0|		apdu.le = 256;
  743|      0|		if (genkey_data->type == SC_ALGORITHM_RSA) {
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (743:7): [True: 0, False: 0]
  ------------------
  744|      0|			apdu.cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  745|      0|			apdu.data = rsa_prop;
  746|      0|			apdu.datalen = sizeof(rsa_prop);
  747|      0|			apdu.lc = sizeof(rsa_prop);
  748|      0|		}
  749|      0|		break;
  750|      4|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (750:2): [True: 4, False: 26]
  ------------------
  751|      4|		sc_log(card->ctx,  "%s\n",
  ------------------
  |  |   71|      4|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  752|      4|				"SC_CARDCTL_LIFECYCLE_SET not supported");
  753|       |		/* no call sc_debug (SC_FUNC_RETURN) */
  754|      4|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      4|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  755|     12|	default:
  ------------------
  |  Branch (755:2): [True: 12, False: 18]
  ------------------
  756|     12|		sc_log(card->ctx,
  ------------------
  |  |   71|     12|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  757|     12|			"request = 0x%lx\n", request);
  758|     12|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     12|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     12|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     12|	int _ret = r; \
  |  |  |  |  155|     12|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 12, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     12|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     12|	} 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|     12|	return _ret; \
  |  |  |  |  163|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  759|     30|	}
  760|     14|	r = sc_transmit_apdu(card, &apdu);
  761|     14|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  762|     13|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  763|     13|	if (!r && request == SC_CARDCTL_RTECP_GENERATE_KEY)
  ------------------
  |  Branch (763:6): [True: 7, False: 6]
  |  Branch (763:12): [True: 0, False: 7]
  ------------------
  764|      0|	{
  765|      0|		if (genkey_data->type == SC_ALGORITHM_RSA &&
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (765:7): [True: 0, False: 0]
  ------------------
  766|      0|				genkey_data->u.rsa.modulus_len >= apdu.resplen &&
  ------------------
  |  Branch (766:5): [True: 0, False: 0]
  ------------------
  767|      0|				genkey_data->u.rsa.exponent_len >= 3)
  ------------------
  |  Branch (767:5): [True: 0, False: 0]
  ------------------
  768|      0|		{
  769|      0|			memcpy(genkey_data->u.rsa.modulus, apdu.resp, apdu.resplen);
  770|      0|			genkey_data->u.rsa.modulus_len = apdu.resplen;
  771|      0|			reverse(genkey_data->u.rsa.modulus,
  772|      0|					genkey_data->u.rsa.modulus_len);
  773|      0|			memcpy(genkey_data->u.rsa.exponent, "\x01\x00\x01", 3);
  774|      0|			genkey_data->u.rsa.exponent_len = 3;
  775|      0|		}
  776|      0|		else if (genkey_data->type == SC_ALGORITHM_GOSTR3410 &&
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (776:12): [True: 0, False: 0]
  ------------------
  777|      0|				genkey_data->u.gostr3410.xy_len >= apdu.resplen)
  ------------------
  |  Branch (777:5): [True: 0, False: 0]
  ------------------
  778|      0|		{
  779|      0|			memcpy(genkey_data->u.gostr3410.xy, apdu.resp, apdu.resplen);
  780|      0|			genkey_data->u.gostr3410.xy_len = apdu.resplen;
  781|      0|		}
  782|      0|		else
  783|      0|			r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  784|      0|	}
  785|     13|	else if (!r && request == SC_CARDCTL_GET_SERIALNR)
  ------------------
  |  Branch (785:11): [True: 7, False: 6]
  |  Branch (785:17): [True: 7, False: 0]
  ------------------
  786|      7|	{
  787|      7|		if (apdu.resplen <= sizeof(serial->value))
  ------------------
  |  Branch (787:7): [True: 6, False: 1]
  ------------------
  788|      6|		{
  789|      6|			memcpy(serial->value, apdu.resp, apdu.resplen);
  790|      6|			serial->len = apdu.resplen;
  791|      6|		}
  792|      1|		else
  793|      1|			r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      1|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  794|      7|	}
  795|     13|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     13|	int _ret = r; \
  |  |  155|     13|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  ------------------
  |  |  156|     13|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 7, False: 6]
  |  |  ------------------
  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     13|	} 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|     13|	return _ret; \
  |  |  163|     13|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  796|     13|}

sc_get_rutoken_driver:
 1320|  17.0k|{
 1321|  17.0k|	return get_rutoken_driver();
 1322|  17.0k|}
card-rutoken.c:get_rutoken_driver:
 1281|  17.0k|{
 1282|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1282:6): [True: 1, False: 17.0k]
  ------------------
 1283|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1284|  17.0k|	rutoken_ops = *iso_ops;
 1285|       |
 1286|  17.0k|	rutoken_ops.match_card = rutoken_match_card;
 1287|  17.0k|	rutoken_ops.init = rutoken_init;
 1288|  17.0k|	rutoken_ops.finish = rutoken_finish;
 1289|       |	/* read_binary */
 1290|  17.0k|	rutoken_ops.write_binary = NULL;
 1291|       |	/* update_binary */
 1292|  17.0k|	rutoken_ops.read_record = NULL;
 1293|  17.0k|	rutoken_ops.write_record = NULL;
 1294|  17.0k|	rutoken_ops.append_record = NULL;
 1295|  17.0k|	rutoken_ops.update_record = NULL;
 1296|  17.0k|	rutoken_ops.select_file = rutoken_select_file;
 1297|  17.0k|	rutoken_ops.get_response = NULL;
 1298|  17.0k|	rutoken_ops.get_challenge = rutoken_get_challenge;
 1299|  17.0k|	rutoken_ops.verify = rutoken_verify;
 1300|  17.0k|	rutoken_ops.logout = rutoken_logout;
 1301|  17.0k|	rutoken_ops.restore_security_env = rutoken_restore_security_env;
 1302|  17.0k|	rutoken_ops.set_security_env = rutoken_set_security_env;
 1303|  17.0k|	rutoken_ops.decipher = NULL;
 1304|  17.0k|	rutoken_ops.compute_signature = rutoken_compute_signature;
 1305|  17.0k|	rutoken_ops.change_reference_data = rutoken_change_reference_data;
 1306|  17.0k|	rutoken_ops.reset_retry_counter = rutoken_reset_retry_counter;
 1307|  17.0k|	rutoken_ops.create_file = rutoken_create_file;
 1308|  17.0k|	rutoken_ops.delete_file = rutoken_delete_file;
 1309|  17.0k|	rutoken_ops.list_files = rutoken_list_files;
 1310|  17.0k|	rutoken_ops.check_sw = rutoken_check_sw;
 1311|  17.0k|	rutoken_ops.card_ctl = rutoken_card_ctl;
 1312|  17.0k|	rutoken_ops.process_fci = rutoken_process_fci;
 1313|  17.0k|	rutoken_ops.construct_fci = rutoken_construct_fci;
 1314|  17.0k|	rutoken_ops.pin_cmd = NULL;
 1315|       |
 1316|  17.0k|	return &rutoken_drv;
 1317|  17.0k|}
card-rutoken.c:rutoken_match_card:
  103|  10.4k|{
  104|  10.4k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  10.4k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  10.4k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  10.4k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 10.4k]
  |  |  ------------------
  ------------------
  105|  10.4k|	if (_sc_match_atr(card, rutoken_atrs, &card->type) >= 0)
  ------------------
  |  Branch (105:6): [True: 161, False: 10.2k]
  ------------------
  106|    161|	{
  107|    161|		sc_log(card->ctx,  "ATR recognized as Rutoken\n");
  ------------------
  |  |   71|    161|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  108|    161|		LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  164|    161|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    161|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    161|	int _ret = r; \
  |  |  |  |  155|    161|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 161]
  |  |  |  |  ------------------
  |  |  |  |  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|    161|	} else { \
  |  |  |  |  159|    161|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    161|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    161|	} \
  |  |  |  |  162|    161|	return _ret; \
  |  |  |  |  163|    161|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|    161|	}
  110|  10.2k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  10.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  10.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  10.2k|	int _ret = r; \
  |  |  |  |  155|  10.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  10.2k|		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: 10.2k]
  |  |  |  |  ------------------
  |  |  |  |  157|  10.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  10.2k|	} 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|  10.2k|	return _ret; \
  |  |  |  |  163|  10.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  111|  10.2k|}
card-rutoken.c:rutoken_init:
  127|    161|{
  128|    161|	int ret;
  129|       |
  130|    161|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    161|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    161|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    161|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 161]
  |  |  ------------------
  ------------------
  131|       |	/* &rutoken_atrs[1] : { uaToken S ATR, NULL ATR } */
  132|    161|	if (_sc_match_atr(card, &rutoken_atrs[1], &card->type) >= 0)
  ------------------
  |  Branch (132:6): [True: 1, False: 160]
  ------------------
  133|      1|		ret = token_init(card, "uaToken S card");
  134|    160|	else
  135|    160|		ret = token_init(card, "Rutoken S card");
  136|       |
  137|    161|	if (ret != SC_SUCCESS) {
  ------------------
  |  |   28|    161|#define SC_SUCCESS				0
  ------------------
  |  Branch (137:6): [True: 0, False: 161]
  ------------------
  138|      0|		ret = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  139|      0|	}
  140|    161|	LOG_FUNC_RETURN(card->ctx, ret);
  ------------------
  |  |  164|    161|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    161|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    161|	int _ret = r; \
  |  |  |  |  155|    161|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 161, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    161|		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: 161]
  |  |  |  |  ------------------
  |  |  |  |  157|    161|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    161|	} 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|    161|	return _ret; \
  |  |  |  |  163|    161|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|    161|}
card-rutoken.c:token_init:
  114|    161|{
  115|    161|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    161|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    161|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    161|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    161|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 161]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  116|       |
  117|    161|	card->name = card_name;
  118|    161|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    161|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  119|    161|	card->drv_data = calloc(1, sizeof(auth_senv_t));
  120|    161|	if (card->drv_data == NULL)
  ------------------
  |  Branch (120:6): [True: 0, False: 161]
  ------------------
  121|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  122|       |
  123|    161|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|    161|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    161|	int _ret = r; \
  |  |  155|    161|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 161, False: 0]
  |  |  ------------------
  |  |  156|    161|		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: 161]
  |  |  ------------------
  |  |  157|    161|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    161|	} 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|    161|	return _ret; \
  |  |  163|    161|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  124|    161|}
card-rutoken.c:rutoken_finish:
   94|    161|{
   95|    161|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    161|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    161|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    161|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 161]
  |  |  ------------------
  ------------------
   96|    161|	if (!card->drv_data)
  ------------------
  |  Branch (96:6): [True: 0, False: 161]
  ------------------
   97|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   98|    161|	free(card->drv_data);
   99|    161|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    161|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    161|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    161|	int _ret = r; \
  |  |  |  |  155|    161|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 161, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    161|		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: 161]
  |  |  |  |  ------------------
  |  |  |  |  157|    161|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    161|	} 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|    161|	return _ret; \
  |  |  |  |  163|    161|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|    161|}
card-rutoken.c:rutoken_select_file:
  363|    750|{
  364|    750|	sc_apdu_t apdu;
  365|    750|	u8 buf[SC_MAX_APDU_BUFFER_SIZE], pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  366|    750|	sc_file_t *file = NULL;
  367|    750|	size_t pathlen;
  368|    750|	int ret;
  369|       |
  370|    750|	if (!card || !card->ctx)
  ------------------
  |  Branch (370:6): [True: 0, False: 750]
  |  Branch (370:15): [True: 0, False: 750]
  ------------------
  371|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  372|    750|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    750|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    750|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    750|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 750]
  |  |  ------------------
  ------------------
  373|       |
  374|    750|	if (in_path == NULL || sizeof(pathbuf) < in_path->len)
  ------------------
  |  Branch (374:6): [True: 0, False: 750]
  |  Branch (374:25): [True: 0, False: 750]
  ------------------
  375|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  376|    750|	memcpy(path, in_path->value, in_path->len);
  377|    750|	pathlen = in_path->len;
  378|       |
  379|       |	/* p2 = 0; first record, return FCP */
  380|    750|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  294|    750|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  381|    750|	switch (in_path->type)
  382|    750|	{
  383|      0|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (383:2): [True: 0, False: 750]
  ------------------
  384|      0|		if (pathlen != 2)
  ------------------
  |  Branch (384:7): [True: 0, False: 0]
  ------------------
  385|      0|			LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  386|      0|		break;
  387|    546|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|    546|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (387:2): [True: 546, False: 204]
  ------------------
  388|    546|		if (pathlen >= 2 && memcmp(path, "\x3F\x00", 2) == 0)
  ------------------
  |  Branch (388:7): [True: 546, False: 0]
  |  Branch (388:23): [True: 475, False: 71]
  ------------------
  389|    475|		{
  390|    475|			if (pathlen == 2)
  ------------------
  |  Branch (390:8): [True: 10, False: 465]
  ------------------
  391|     10|				break; /* only 3F00 supplied */
  392|    465|			path += 2;
  393|    465|			pathlen -= 2;
  394|    465|		}
  395|    536|		apdu.p1 = 0x08;
  396|    536|		break;
  397|    204|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|    204|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (397:2): [True: 204, False: 546]
  ------------------
  398|    204|	case SC_PATH_TYPE_FROM_CURRENT:
  ------------------
  |  |  122|    204|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (398:2): [True: 0, False: 750]
  ------------------
  399|    204|	case SC_PATH_TYPE_PARENT:
  ------------------
  |  |  123|    204|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (399:2): [True: 0, False: 750]
  ------------------
  400|    204|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    204|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    204|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    204|	int _ret = r; \
  |  |  |  |  155|    204|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 204, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    204|		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|    204|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 204, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    204|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    204|	} 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|    204|	return _ret; \
  |  |  |  |  163|    204|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  401|      0|	default:
  ------------------
  |  Branch (401:2): [True: 0, False: 750]
  ------------------
  402|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  403|    750|	}
  404|    546|	swap_pair(path, pathlen);
  405|    546|	apdu.lc = pathlen;
  406|    546|	apdu.data = path;
  407|    546|	apdu.datalen = pathlen;
  408|       |
  409|    546|	apdu.resp = buf;
  410|    546|	apdu.resplen = sizeof(buf);
  411|    546|	apdu.le = 256;
  412|       |
  413|    546|	ret = sc_transmit_apdu(card, &apdu);
  414|    546|	LOG_TEST_RET(card->ctx, ret, "APDU transmit failed");
  ------------------
  |  |  174|    546|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    546|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    546|	int _ret = (r); \
  |  |  |  |  168|    546|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 17, False: 529]
  |  |  |  |  ------------------
  |  |  |  |  169|     17|		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|     17|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     17|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     17|		return _ret; \
  |  |  |  |  172|     17|	} \
  |  |  |  |  173|    546|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 529]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  415|    529|	if (file_out == NULL)
  ------------------
  |  Branch (415:6): [True: 198, False: 331]
  ------------------
  416|    198|	{
  417|    198|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (417:7): [True: 0, False: 198]
  ------------------
  418|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 0);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  419|    198|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|    198|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    198|	int _ret = r; \
  |  |  155|    198|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 198, False: 0]
  |  |  ------------------
  |  |  156|    198|		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|    124|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 124, False: 74]
  |  |  ------------------
  |  |  157|    198|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    198|	} 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|    198|	return _ret; \
  |  |  163|    198|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  420|    198|	}
  421|    331|	ret = sc_check_sw(card, apdu.sw1, apdu.sw2);
  422|    331|	LOG_TEST_RET(card->ctx, ret, "");
  ------------------
  |  |  174|    331|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    331|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    331|	int _ret = (r); \
  |  |  |  |  168|    331|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 119, False: 212]
  |  |  |  |  ------------------
  |  |  |  |  169|    119|		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|    119|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    119|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    119|		return _ret; \
  |  |  |  |  172|    119|	} \
  |  |  |  |  173|    331|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 212]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|       |
  424|    212|	if (apdu.resplen > 0 && apdu.resp[0] != 0x62) /* Tag 0x62 - FCP */
  ------------------
  |  Branch (424:6): [True: 198, False: 14]
  |  Branch (424:26): [True: 11, False: 187]
  ------------------
  425|    212|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     11|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     11|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     11|	int _ret = r; \
  |  |  |  |  155|     11|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     11|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     11|	} 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|     11|	return _ret; \
  |  |  |  |  163|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|       |
  427|    201|	file = sc_file_new();
  428|    201|	if (file == NULL)
  ------------------
  |  Branch (428:6): [True: 0, False: 201]
  ------------------
  429|    201|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  430|    201|	file->path = *in_path;
  431|    201|	if (card->ops->process_fci == NULL)
  ------------------
  |  Branch (431:6): [True: 0, False: 201]
  ------------------
  432|      0|	{
  433|      0|		sc_file_free(file);
  434|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  435|      0|	}
  436|    201|	if (apdu.resplen > 1  &&  apdu.resplen >= (size_t)apdu.resp[1] + 2)
  ------------------
  |  Branch (436:6): [True: 186, False: 15]
  |  Branch (436:28): [True: 176, False: 10]
  ------------------
  437|    176|	{
  438|    176|		ret = card->ops->process_fci(card, file, apdu.resp+2, apdu.resp[1]);
  439|    176|	}
  440|    201|	if (file->sec_attr && file->sec_attr_len == sizeof(sc_SecAttrV2_t))
  ------------------
  |  Branch (440:6): [True: 155, False: 46]
  |  Branch (440:24): [True: 146, False: 9]
  ------------------
  441|    146|		set_acl_from_sec_attr(card, file);
  442|     55|	else
  443|     55|		ret = SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     55|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  444|    201|	if (ret != SC_SUCCESS)
  ------------------
  |  |   28|    201|#define SC_SUCCESS				0
  ------------------
  |  Branch (444:6): [True: 55, False: 146]
  ------------------
  445|     55|		sc_file_free(file);
  446|    146|	else
  447|    146|	{
  448|    146|		*file_out = file;
  449|    146|	}
  450|    201|	LOG_FUNC_RETURN(card->ctx, ret);
  ------------------
  |  |  164|    201|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    201|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    201|	int _ret = r; \
  |  |  |  |  155|    201|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 201, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    201|		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|     55|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 55, False: 146]
  |  |  |  |  ------------------
  |  |  |  |  157|    201|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    201|	} 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|    201|	return _ret; \
  |  |  |  |  163|    201|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  451|    201|}
card-rutoken.c:swap_pair:
  216|    546|{
  217|    546|	size_t i;
  218|    546|	u8 tmp;
  219|       |
  220|  1.31k|	for (i = 0; i + 1 < len; i += 2)
  ------------------
  |  Branch (220:14): [True: 764, False: 546]
  ------------------
  221|    764|	{
  222|    764|		tmp = buf[i];
  223|    764|		buf[i] = buf[i + 1];
  224|    764|		buf[i + 1] = tmp;
  225|    764|	}
  226|    546|}
card-rutoken.c:set_acl_from_sec_attr:
  311|    146|{
  312|    146|	if (file->sec_attr  &&  file->sec_attr_len == sizeof(sc_SecAttrV2_t))
  ------------------
  |  Branch (312:6): [True: 146, False: 0]
  |  Branch (312:26): [True: 146, False: 0]
  ------------------
  313|    146|	{
  314|    146|		sc_file_add_acl_entry(file, SC_AC_OP_SELECT,
  ------------------
  |  |  166|    146|#define SC_AC_OP_SELECT			0
  ------------------
  315|    146|				SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|    146|#define SC_AC_NONE			0x00000000
  ------------------
              				SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    146|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  316|    146|		if (file->sec_attr[0] & 0x40) /* if AccessMode.6 */
  ------------------
  |  Branch (316:7): [True: 18, False: 128]
  ------------------
  317|     18|		{
  318|     18|			sc_log(card->ctx,  "SC_AC_OP_DELETE %i %i",
  ------------------
  |  |   71|     18|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  319|     18|					(int)(*(int8_t*)&file->sec_attr[1 +6]),
  320|     18|					file->sec_attr[1+7 +6*4]);
  321|     18|			sc_file_add_acl_entry(file, SC_AC_OP_DELETE,
  ------------------
  |  |  168|     18|#define SC_AC_OP_DELETE			2
  ------------------
  322|     18|					(int)(*(int8_t*)&file->sec_attr[1 +6]),
  323|     18|					file->sec_attr[1+7 +6*4]);
  324|     18|		}
  325|    146|		if (file->sec_attr[0] & 0x01) /* if AccessMode.0 */
  ------------------
  |  Branch (325:7): [True: 50, False: 96]
  ------------------
  326|     50|		{
  327|     50|			sc_log(card->ctx,  (file->type == SC_FILE_TYPE_DF) ?
  ------------------
  |  |   71|    100|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:110): [True: 3, False: 47]
  |  |  ------------------
  ------------------
  328|     50|					"SC_AC_OP_CREATE %i %i" : "SC_AC_OP_READ %i %i",
  329|     50|					(int)(*(int8_t*)&file->sec_attr[1 +0]),
  330|     50|					file->sec_attr[1+7 +0*4]);
  331|     50|			sc_file_add_acl_entry(file,
  332|     50|					(file->type == SC_FILE_TYPE_DF) ?
  ------------------
  |  |  214|     50|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (332:6): [True: 3, False: 47]
  ------------------
  333|     47|					SC_AC_OP_CREATE : SC_AC_OP_READ,
  ------------------
  |  |  169|      3|#define SC_AC_OP_CREATE			3
  ------------------
              					SC_AC_OP_CREATE : SC_AC_OP_READ,
  ------------------
  |  |  188|     97|#define SC_AC_OP_READ			22
  ------------------
  334|     50|					(int)(*(int8_t*)&file->sec_attr[1 +0]),
  335|     50|					file->sec_attr[1+7 +0*4]);
  336|     50|		}
  337|    146|		if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|    146|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (337:7): [True: 3, False: 143]
  ------------------
  338|      3|		{
  339|      3|			sc_file_add_acl_entry(file, SC_AC_OP_LIST_FILES,
  ------------------
  |  |  172|      3|#define SC_AC_OP_LIST_FILES		6
  ------------------
  340|      3|					SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|      3|#define SC_AC_NONE			0x00000000
  ------------------
              					SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|      3|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  341|      3|		}
  342|    143|		else
  343|    143|			if (file->sec_attr[0] & 0x02) /* if AccessMode.1 */
  ------------------
  |  Branch (343:8): [True: 38, False: 105]
  ------------------
  344|     38|			{
  345|     38|				sc_log(card->ctx,  "SC_AC_OP_UPDATE %i %i",
  ------------------
  |  |   71|     38|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  346|     38|						(int)(*(int8_t*)&file->sec_attr[1 +1]),
  347|     38|						file->sec_attr[1+7 +1*4]);
  348|     38|				sc_file_add_acl_entry(file, SC_AC_OP_UPDATE,
  ------------------
  |  |  189|     38|#define SC_AC_OP_UPDATE			23
  ------------------
  349|     38|						(int)(*(int8_t*)&file->sec_attr[1 +1]),
  350|     38|						file->sec_attr[1+7 +1*4]);
  351|     38|				sc_log(card->ctx,  "SC_AC_OP_WRITE %i %i",
  ------------------
  |  |   71|     38|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  352|     38|						(int)(*(int8_t*)&file->sec_attr[1 +1]),
  353|     38|						file->sec_attr[1+7 +1*4]);
  354|     38|				sc_file_add_acl_entry(file, SC_AC_OP_WRITE,
  ------------------
  |  |  190|     38|#define SC_AC_OP_WRITE			24
  ------------------
  355|     38|						(int)(*(int8_t*)&file->sec_attr[1 +1]),
  356|     38|						file->sec_attr[1+7 +1*4]);
  357|     38|			}
  358|    146|	}
  359|    146|}
card-rutoken.c:rutoken_get_challenge:
 1151|     87|{
 1152|     87|	unsigned char rbuf[32];
 1153|     87|	size_t out_len;
 1154|     87|	int r;
 1155|       |
 1156|     87|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     87|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     87|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     87|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     87|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 87]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1157|       |
 1158|     87|	r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
 1159|     87|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE cmd failed");
  ------------------
  |  |  174|     87|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     87|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     87|	int _ret = (r); \
  |  |  |  |  168|     87|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 78]
  |  |  |  |  ------------------
  |  |  |  |  169|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      9|		return _ret; \
  |  |  |  |  172|      9|	} \
  |  |  |  |  173|     87|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 78]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1160|       |
 1161|     78|	if (len < (size_t) r) {
  ------------------
  |  Branch (1161:6): [True: 1, False: 77]
  ------------------
 1162|      1|		out_len = len;
 1163|     77|	} else {
 1164|     77|		out_len = (size_t) r;
 1165|     77|	}
 1166|     78|	memcpy(rnd, rbuf, out_len);
 1167|       |
 1168|     78|	LOG_FUNC_RETURN(card->ctx, (int)out_len);
  ------------------
  |  |  164|     78|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     78|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     78|	int _ret = r; \
  |  |  |  |  155|     78|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 77]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     77|	} else { \
  |  |  |  |  159|     77|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     77|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     77|	} \
  |  |  |  |  162|     78|	return _ret; \
  |  |  |  |  163|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1169|     78|}
card-rutoken.c:rutoken_check_sw:
  200|  1.04k|{
  201|  1.04k|	size_t i;
  202|       |
  203|  39.7k|	for (i = 0; i < sizeof(rutoken_errors)/sizeof(rutoken_errors[0]); ++i) {
  ------------------
  |  Branch (203:14): [True: 39.7k, False: 50]
  ------------------
  204|  39.7k|		if (rutoken_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (204:7): [True: 997, False: 38.7k]
  ------------------
  205|    997|			if ( rutoken_errors[i].errorstr )
  ------------------
  |  Branch (205:9): [True: 331, False: 666]
  ------------------
  206|    331|				sc_log(card->ctx,  "%s\n", rutoken_errors[i].errorstr);
  ------------------
  |  |   71|    331|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  207|    997|			sc_log(card->ctx,  "sw1 = %x, sw2 = %x", sw1, sw2);
  ------------------
  |  |   71|    997|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  208|    997|			return rutoken_errors[i].errorno;
  209|    997|		}
  210|  39.7k|	}
  211|     50|	sc_log(card->ctx,  "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
  ------------------
  |  |   71|     50|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  212|     50|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|     50|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  213|  1.04k|}
card-rutoken.c:rutoken_card_ctl:
 1223|     31|{
 1224|     31|	int ret = (ptr != NULL
  ------------------
  |  Branch (1224:13): [True: 31, False: 0]
  ------------------
 1225|       |			/*|| cmd == SC_CARDCTL_ERASE_CARD */
 1226|      0|			|| cmd == SC_CARDCTL_RUTOKEN_FORMAT_INIT
  ------------------
  |  Branch (1226:7): [True: 0, False: 0]
  ------------------
 1227|      0|			|| cmd == SC_CARDCTL_RUTOKEN_FORMAT_END
  ------------------
  |  Branch (1227:7): [True: 0, False: 0]
  ------------------
 1228|     31|		) ? SC_SUCCESS : SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
              		) ? SC_SUCCESS : SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1229|       |
 1230|     31|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     31|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     31|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     31|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 31]
  |  |  ------------------
  ------------------
 1231|       |
 1232|     31|	if (ret == SC_SUCCESS)
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
  |  Branch (1232:6): [True: 31, False: 0]
  ------------------
 1233|     31|	{
 1234|     31|		switch (cmd)
 1235|     31|		{
 1236|      0|		case SC_CARDCTL_RUTOKEN_CREATE_DO:
  ------------------
  |  Branch (1236:3): [True: 0, False: 31]
  ------------------
 1237|      0|			ret = rutoken_create_do(card, ptr);
 1238|      0|			break;
 1239|      0|		case SC_CARDCTL_RUTOKEN_GENERATE_KEY_DO:
  ------------------
  |  Branch (1239:3): [True: 0, False: 31]
  ------------------
 1240|      0|			ret = rutoken_key_gen(card, ptr);
 1241|      0|			break;
 1242|      0|		case SC_CARDCTL_RUTOKEN_DELETE_DO:
  ------------------
  |  Branch (1242:3): [True: 0, False: 31]
  ------------------
 1243|      0|			ret = rutoken_delete_do(card, ptr);
 1244|      0|			break;
 1245|      0|		case SC_CARDCTL_RUTOKEN_GET_DO_INFO:
  ------------------
  |  Branch (1245:3): [True: 0, False: 31]
  ------------------
 1246|      0|			ret = rutoken_get_do_info(card, ptr);
 1247|      0|			break;
 1248|      0|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1248:3): [True: 0, False: 31]
  ------------------
 1249|      0|			ret = rutoken_get_serial(card, ptr);
 1250|      0|			break;
 1251|      0|		case SC_CARDCTL_RUTOKEN_CHANGE_DO:
  ------------------
  |  Branch (1251:3): [True: 0, False: 31]
  ------------------
 1252|      0|			ret = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1253|      0|			break;
 1254|      0|		case SC_CARDCTL_RUTOKEN_GET_INFO:
  ------------------
  |  Branch (1254:3): [True: 0, False: 31]
  ------------------
 1255|      0|			ret = rutoken_get_info(card, ptr);
 1256|      0|			break;
 1257|      0|		case SC_CARDCTL_RUTOKEN_GOST_ENCIPHER:
  ------------------
  |  Branch (1257:3): [True: 0, False: 31]
  ------------------
 1258|      0|			ret = rutoken_cipher_gost(card, ptr, 1);
 1259|      0|			break;
 1260|      0|		case SC_CARDCTL_RUTOKEN_GOST_DECIPHER:
  ------------------
  |  Branch (1260:3): [True: 0, False: 31]
  ------------------
 1261|      0|			ret = rutoken_cipher_gost(card, ptr, 0);
 1262|      0|			break;
 1263|       |		/* case SC_CARDCTL_ERASE_CARD: */
 1264|      0|		case SC_CARDCTL_RUTOKEN_FORMAT_INIT:
  ------------------
  |  Branch (1264:3): [True: 0, False: 31]
  ------------------
 1265|       |			/* ret = rutoken_format(card, 0x7a); *//*  APDU: INIT RUTOKEN */
 1266|      0|			ret = rutoken_format(card, 0x8a); /* APDU: NEW INIT RUTOKEN */
 1267|      0|			break;
 1268|      0|		case SC_CARDCTL_RUTOKEN_FORMAT_END:
  ------------------
  |  Branch (1268:3): [True: 0, False: 31]
  ------------------
 1269|      0|			ret = rutoken_format(card, 0x7b); /* APDU: FORMAT END */
 1270|      0|			break;
 1271|     31|		default:
  ------------------
  |  Branch (1271:3): [True: 31, False: 0]
  ------------------
 1272|     31|			sc_log(card->ctx,  "cmd = %lu", cmd);
  ------------------
  |  |   71|     31|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1273|     31|			ret = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     31|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1274|     31|			break;
 1275|     31|		}
 1276|     31|	}
 1277|     31|	LOG_FUNC_RETURN(card->ctx, ret);
  ------------------
  |  |  164|     31|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     31|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     31|	int _ret = r; \
  |  |  |  |  155|     31|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 31, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     31|		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|     31|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 31, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     31|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     31|	} 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|     31|	return _ret; \
  |  |  |  |  163|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1278|     31|}
card-rutoken.c:rutoken_process_fci:
  455|    176|{
  456|    176|	size_t taglen;
  457|    176|	int ret;
  458|    176|	const unsigned char *tag;
  459|       |
  460|    176|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    176|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    176|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    176|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 176]
  |  |  ------------------
  ------------------
  461|    176|	ret = iso_ops->process_fci(card, file, buf, buflen);
  462|    176|	if (ret == SC_SUCCESS)
  ------------------
  |  |   28|    176|#define SC_SUCCESS				0
  ------------------
  |  Branch (462:6): [True: 176, False: 0]
  ------------------
  463|    176|	{
  464|       |		/* Rutoken S returns buffers in little-endian. */
  465|       |		/* Set correct file id. */
  466|    176|		file->id = ((file->id & 0xFF) << 8) | ((file->id >> 8) & 0xFF);
  467|    176|		sc_log(card->ctx,  "  file identifier: 0x%04X", file->id);
  ------------------
  |  |   71|    176|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  468|       |		/* Determine file size. */
  469|    176|		tag = sc_asn1_find_tag(card->ctx, buf, buflen, 0x80, &taglen);
  470|       |		/* Rutoken S always returns 2 bytes. */
  471|    176|		if (tag != NULL && taglen == 2)
  ------------------
  |  Branch (471:7): [True: 26, False: 150]
  |  Branch (471:22): [True: 16, False: 10]
  ------------------
  472|     16|		{
  473|     16|			file->size = (tag[1] << 8) | tag[0];
  474|     16|			sc_log(card->ctx, "  bytes in file: %zu", file->size);
  ------------------
  |  |   71|     16|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  475|     16|		}
  476|    176|	}
  477|    176|	LOG_FUNC_RETURN(card->ctx, ret);
  ------------------
  |  |  164|    176|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    176|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    176|	int _ret = r; \
  |  |  |  |  155|    176|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 176, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    176|		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: 176]
  |  |  |  |  ------------------
  |  |  |  |  157|    176|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    176|	} 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|    176|	return _ret; \
  |  |  |  |  163|    176|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  478|    176|}

sc_get_sc_hsm_driver:
 2003|  17.0k|{
 2004|  17.0k|	return sc_get_driver();
 2005|  17.0k|}
card-sc-hsm.c:sc_get_driver:
 1967|  17.0k|{
 1968|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1969|       |
 1970|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1970:6): [True: 1, False: 17.0k]
  ------------------
 1971|      1|		iso_ops = iso_drv->ops;
 1972|       |
 1973|  17.0k|	sc_hsm_ops                   = *iso_drv->ops;
 1974|  17.0k|	sc_hsm_ops.match_card        = sc_hsm_match_card;
 1975|  17.0k|	sc_hsm_ops.select_file       = sc_hsm_select_file;
 1976|  17.0k|	sc_hsm_ops.get_challenge     = sc_hsm_get_challenge;
 1977|  17.0k|	sc_hsm_ops.read_binary       = sc_hsm_read_binary;
 1978|  17.0k|	sc_hsm_ops.update_binary     = sc_hsm_update_binary;
 1979|  17.0k|	sc_hsm_ops.list_files        = sc_hsm_list_files;
 1980|  17.0k|	sc_hsm_ops.create_file       = sc_hsm_create_file;
 1981|  17.0k|	sc_hsm_ops.delete_file       = sc_hsm_delete_file;
 1982|  17.0k|	sc_hsm_ops.set_security_env  = sc_hsm_set_security_env;
 1983|  17.0k|	sc_hsm_ops.compute_signature = sc_hsm_compute_signature;
 1984|  17.0k|	sc_hsm_ops.decipher          = sc_hsm_decipher;
 1985|  17.0k|	sc_hsm_ops.init              = sc_hsm_init;
 1986|  17.0k|	sc_hsm_ops.finish            = sc_hsm_finish;
 1987|  17.0k|	sc_hsm_ops.card_ctl          = sc_hsm_card_ctl;
 1988|  17.0k|	sc_hsm_ops.pin_cmd           = sc_hsm_pin_cmd;
 1989|  17.0k|	sc_hsm_ops.logout            = sc_hsm_logout;
 1990|       |
 1991|       |	/* no record oriented file services */
 1992|  17.0k|	sc_hsm_ops.read_record       = NULL;
 1993|  17.0k|	sc_hsm_ops.write_record      = NULL;
 1994|  17.0k|	sc_hsm_ops.append_record     = NULL;
 1995|  17.0k|	sc_hsm_ops.update_record     = NULL;
 1996|       |
 1997|  17.0k|	return &sc_hsm_drv;
 1998|  17.0k|}
card-sc-hsm.c:sc_hsm_match_card:
  267|  6.75k|{
  268|  6.75k|	sc_path_t path;
  269|  6.75k|	int i, r, type = 0;
  270|  6.75k|	sc_file_t *file = NULL;
  271|       |
  272|  6.75k|	i = _sc_match_atr(card, sc_hsm_atrs, &type);
  273|  6.75k|	if (i >= 0 && type != SC_CARD_TYPE_SC_HSM_SOC) {
  ------------------
  |  Branch (273:6): [True: 287, False: 6.46k]
  |  Branch (273:16): [True: 286, False: 1]
  ------------------
  274|    286|		card->type = type;
  275|    286|		return 1;
  276|    286|	}
  277|       |
  278|  6.46k|	sc_path_set(&path, SC_PATH_TYPE_DF_NAME, sc_hsm_aid.value, sc_hsm_aid.len, 0, 0);
  ------------------
  |  |  118|  6.46k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  279|  6.46k|	r = sc_hsm_select_file(card, &path, &file);
  280|  6.46k|	LOG_TEST_RET(card->ctx, r, "Could not select SmartCard-HSM application");
  ------------------
  |  |  174|  6.46k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  6.46k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  6.46k|	int _ret = (r); \
  |  |  |  |  168|  6.46k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6.15k, False: 311]
  |  |  |  |  ------------------
  |  |  |  |  169|  6.15k|		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|  6.15k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  6.15k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  6.15k|		return _ret; \
  |  |  |  |  172|  6.15k|	} \
  |  |  |  |  173|  6.46k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 311]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  281|       |
  282|       |	// Validate that card returns a FCP with a proprietary tag 85 with value longer than 2 byte (Fixes #1377)
  283|    311|	if (file != NULL) {
  ------------------
  |  Branch (283:6): [True: 311, False: 0]
  ------------------
  284|    311|		size_t sz = file->prop_attr_len;
  285|    311|		sc_file_free(file);
  286|    311|		if (sz < 2) {
  ------------------
  |  Branch (286:7): [True: 309, False: 2]
  ------------------
  287|    309|			return 0;
  288|    309|		}
  289|    311|	}
  290|       |
  291|      2|	if (type == SC_CARD_TYPE_SC_HSM_SOC) {
  ------------------
  |  Branch (291:6): [True: 0, False: 2]
  ------------------
  292|      0|		card->type = SC_CARD_TYPE_SC_HSM_SOC;
  293|      2|	} else {
  294|      2|		card->type = SC_CARD_TYPE_SC_HSM;
  295|      2|	}
  296|       |
  297|      2|	return 1;
  298|    311|}
card-sc-hsm.c:sc_hsm_select_file:
  247|  8.99k|{
  248|  8.99k|	return sc_hsm_select_file_ex(card, in_path, 0, file_out);
  249|  8.99k|}
card-sc-hsm.c:sc_hsm_select_file_ex:
  149|  10.4k|{
  150|  10.4k|	int rv;
  151|  10.4k|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
  152|  10.4k|	sc_file_t *file = NULL;
  153|  10.4k|	sc_path_t cpath;
  154|  10.4k|	size_t card_max_recv_size = card->max_recv_size;
  155|  10.4k|	size_t reader_max_recv_size = card->reader->max_recv_size;
  156|       |
  157|  10.4k|	if (file_out == NULL) {				// Versions before 0.16 of the SmartCard-HSM do not support P2='0C'
  ------------------
  |  Branch (157:6): [True: 1.20k, False: 9.28k]
  ------------------
  158|  1.20k|		rv = sc_hsm_select_file_ex(card, in_path, forceselect, &file);
  159|  1.20k|		sc_file_free(file);
  160|  1.20k|		return rv;
  161|  1.20k|	}
  162|       |
  163|  9.28k|	if ((in_path->type == SC_PATH_TYPE_FILE_ID) && in_path->aid.len) {
  ------------------
  |  |  117|  9.28k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (163:6): [True: 156, False: 9.12k]
  |  Branch (163:49): [True: 0, False: 156]
  ------------------
  164|       |		// Split applet selection and file selection into two separate calls
  165|      0|		cpath = *in_path;
  166|      0|		cpath.len = 0;
  167|      0|		cpath.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  168|      0|		rv = sc_hsm_select_file_ex(card, &cpath, forceselect, NULL);
  169|      0|		LOG_TEST_RET(card->ctx, rv, "Could not select SmartCard-HSM application");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  170|       |
  171|      0|		if (in_path->len) {
  ------------------
  |  Branch (171:7): [True: 0, False: 0]
  ------------------
  172|      0|			cpath = *in_path;
  173|      0|			cpath.aid.len = 0;
  174|      0|			rv = sc_hsm_select_file_ex(card, &cpath, forceselect, file_out);
  175|      0|		}
  176|      0|		return rv;
  177|      0|	}
  178|       |
  179|       |	// Prevent selection of applet unless this is the first time, selection is forced or the device is not authenticated
  180|  9.28k|	if (in_path->type == SC_PATH_TYPE_DF_NAME
  ------------------
  |  |  118|  18.5k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (180:6): [True: 7.71k, False: 1.56k]
  ------------------
  181|  1.56k|			|| (in_path->type == SC_PATH_TYPE_PATH
  ------------------
  |  |  119|  3.13k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (181:8): [True: 1.41k, False: 156]
  ------------------
  182|  1.41k|				&& in_path->len == sc_hsm_aid.len
  ------------------
  |  Branch (182:8): [True: 0, False: 1.41k]
  ------------------
  183|      0|				&& !memcmp(in_path->value, sc_hsm_aid.value, sc_hsm_aid.len))
  ------------------
  |  Branch (183:8): [True: 0, False: 0]
  ------------------
  184|  1.56k|			|| (in_path->type == SC_PATH_TYPE_PATH
  ------------------
  |  |  119|  3.13k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (184:8): [True: 1.41k, False: 156]
  ------------------
  185|  1.41k|				&& in_path->len == 0
  ------------------
  |  Branch (185:8): [True: 79, False: 1.33k]
  ------------------
  186|     79|				&& in_path->aid.len == sc_hsm_aid.len
  ------------------
  |  Branch (186:8): [True: 0, False: 79]
  ------------------
  187|  7.71k|				&& !memcmp(in_path->aid.value, sc_hsm_aid.value, sc_hsm_aid.len))) {
  ------------------
  |  Branch (187:8): [True: 0, False: 0]
  ------------------
  188|  7.71k|		if (!priv || (priv->dffcp == NULL) || forceselect) {
  ------------------
  |  Branch (188:7): [True: 6.46k, False: 1.25k]
  |  Branch (188:16): [True: 854, False: 397]
  |  Branch (188:41): [True: 0, False: 397]
  ------------------
  189|       |			/* Force use of Le = 0x00 in iso7816_select_file as required by SC-HSM */
  190|  7.31k|			card->max_recv_size = card->reader->max_recv_size = SC_READER_SHORT_APDU_MAX_RECV_SIZE;
  ------------------
  |  |  384|  7.31k|#define SC_READER_SHORT_APDU_MAX_RECV_SIZE 256
  ------------------
  191|  7.31k|			rv = (*iso_ops->select_file)(card, in_path, file_out);
  192|  7.31k|			card->max_recv_size = card_max_recv_size;
  193|  7.31k|			card->reader->max_recv_size = reader_max_recv_size;
  194|  7.31k|			LOG_TEST_RET(card->ctx, rv, "Could not select SmartCard-HSM application");
  ------------------
  |  |  174|  7.31k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.31k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.31k|	int _ret = (r); \
  |  |  |  |  168|  7.31k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6.79k, False: 526]
  |  |  |  |  ------------------
  |  |  |  |  169|  6.79k|		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|  6.79k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  6.79k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  6.79k|		return _ret; \
  |  |  |  |  172|  6.79k|	} \
  |  |  |  |  173|  7.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 526]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|       |
  196|    526|			if (priv) {
  ------------------
  |  Branch (196:8): [True: 215, False: 311]
  ------------------
  197|    215|				sc_file_free(priv->dffcp);
  198|       |				// Cache the FCP returned when selecting the applet
  199|    215|				sc_file_dup(&priv->dffcp, *file_out);
  200|    215|			}
  201|    526|		} else {
  202|    397|			sc_file_dup(file_out, priv->dffcp);
  203|    397|			rv = SC_SUCCESS;
  ------------------
  |  |   28|    397|#define SC_SUCCESS				0
  ------------------
  204|    397|		}
  205|    923|		return rv;
  206|  7.71k|	}
  207|       |
  208|  1.56k|	if ((in_path->len >= 2) && (in_path->value[0] == 0x3F) && (in_path->value[1] == 0x00)) {
  ------------------
  |  Branch (208:6): [True: 1.48k, False: 79]
  |  Branch (208:29): [True: 840, False: 649]
  |  Branch (208:60): [True: 830, False: 10]
  ------------------
  209|       |		// The SmartCard-HSM is an applet that is not default selected. Simulate selection of the MF
  210|    830|		if (in_path->len == 2) {
  ------------------
  |  Branch (210:7): [True: 15, False: 815]
  ------------------
  211|     15|			file = sc_file_new();
  212|     15|			if (file == NULL)
  ------------------
  |  Branch (212:8): [True: 0, False: 15]
  ------------------
  213|     15|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|     15|			file->path = *in_path;
  215|     15|			file->id = 0x3F00;
  216|     15|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     15|#define SC_FILE_TYPE_DF			0x04
  ------------------
  217|     15|			file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|     15|#define SC_FILE_MAGIC			0x14426950
  ------------------
  218|       |
  219|     15|			*file_out = file;
  220|     15|			return SC_SUCCESS;
  ------------------
  |  |   28|     15|#define SC_SUCCESS				0
  ------------------
  221|    815|		} else {
  222|       |			/* Force use of Le = 0x00 in iso7816_select_file as required by SC-HSM */
  223|    815|			card->max_recv_size = card->reader->max_recv_size = SC_READER_SHORT_APDU_MAX_RECV_SIZE;
  ------------------
  |  |  384|    815|#define SC_READER_SHORT_APDU_MAX_RECV_SIZE 256
  ------------------
  224|    815|			sc_path_t truncated;
  225|    815|			memcpy(&truncated, in_path, sizeof truncated);
  226|    815|			truncated.len = in_path->len - 2;
  227|    815|			memcpy(truncated.value, in_path->value+2, truncated.len);
  228|    815|			rv = (*iso_ops->select_file)(card, &truncated, file_out);
  229|    815|			card->max_recv_size = card_max_recv_size;
  230|    815|			card->reader->max_recv_size = reader_max_recv_size;
  231|    815|			return rv;
  232|    815|		}
  233|    830|	}
  234|       |	/* Force use of Le = 0x00 in iso7816_select_file as required by SC-HSM */
  235|    738|	card->max_recv_size = card->reader->max_recv_size = SC_READER_SHORT_APDU_MAX_RECV_SIZE;
  ------------------
  |  |  384|    738|#define SC_READER_SHORT_APDU_MAX_RECV_SIZE 256
  ------------------
  236|    738|	rv = (*iso_ops->select_file)(card, in_path, file_out);
  237|    738|	card->max_recv_size = card_max_recv_size;
  238|    738|	card->reader->max_recv_size = reader_max_recv_size;
  239|    738|	return rv;
  240|  1.56k|}
card-sc-hsm.c:sc_hsm_get_challenge:
  254|    240|{
  255|    240|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    240|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    240|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    240|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    240|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 240]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|       |
  257|    240|	if (len > 1024) {
  ------------------
  |  Branch (257:6): [True: 0, False: 240]
  ------------------
  258|      0|		len = 1024;
  259|      0|	}
  260|       |
  261|    240|	LOG_FUNC_RETURN(card->ctx, iso_ops->get_challenge(card, rnd, len));
  ------------------
  |  |  164|    240|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    240|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    240|	int _ret = r; \
  |  |  |  |  155|    240|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 36, False: 204]
  |  |  |  |  ------------------
  |  |  |  |  156|     36|		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|     34|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 34, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|     36|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    204|	} else { \
  |  |  |  |  159|    204|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    204|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    204|	} \
  |  |  |  |  162|    240|	return _ret; \
  |  |  |  |  163|    240|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|    240|}
card-sc-hsm.c:sc_hsm_read_binary:
  799|    767|{
  800|    767|	sc_context_t *ctx = card->ctx;
  801|    767|	sc_apdu_t apdu;
  802|    767|	u8 cmdbuff[4];
  803|    767|	int r;
  804|       |
  805|    767|	if (idx > 0xffff) {
  ------------------
  |  Branch (805:6): [True: 0, False: 767]
  ------------------
  806|      0|		sc_log(ctx,  "invalid EF offset: 0x%X > 0xFFFF", idx);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  807|      0|		return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      0|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
  808|      0|	}
  809|       |
  810|    767|	cmdbuff[0] = 0x54;
  811|    767|	cmdbuff[1] = 0x02;
  812|    767|	cmdbuff[2] = (idx >> 8) & 0xFF;
  813|    767|	cmdbuff[3] = idx & 0xFF;
  814|       |
  815|    767|	if (count > sc_get_max_recv_size(card))
  ------------------
  |  Branch (815:6): [True: 0, False: 767]
  ------------------
  816|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  817|    767|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0xB1, 0x00, 0x00);
  ------------------
  |  |  303|    767|#define SC_APDU_CASE_4			0x24
  ------------------
  818|    767|	apdu.data = cmdbuff;
  819|    767|	apdu.datalen = 4;
  820|    767|	apdu.lc = 4;
  821|    767|	apdu.le = count;
  822|    767|	apdu.resplen = count;
  823|    767|	apdu.resp = buf;
  824|       |
  825|    767|	r = sc_transmit_apdu(card, &apdu);
  826|    767|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    767|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    767|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    767|	int _ret = (r); \
  |  |  |  |  168|    767|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 755]
  |  |  |  |  ------------------
  |  |  |  |  169|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     12|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     12|		return _ret; \
  |  |  |  |  172|     12|	} \
  |  |  |  |  173|    767|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 755]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  827|       |
  828|    755|	r =  sc_check_sw(card, apdu.sw1, apdu.sw2);
  829|    755|	if (r != SC_ERROR_FILE_END_REACHED) {
  ------------------
  |  |   69|    755|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (829:6): [True: 557, False: 198]
  ------------------
  830|    557|		LOG_TEST_RET(ctx, r, "Check SW error");
  ------------------
  |  |  174|    557|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    557|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    557|	int _ret = (r); \
  |  |  |  |  168|    557|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 100, False: 457]
  |  |  |  |  ------------------
  |  |  |  |  169|    100|		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|    100|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    100|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    100|		return _ret; \
  |  |  |  |  172|    100|	} \
  |  |  |  |  173|    557|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 457]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  831|    557|	}
  832|       |
  833|    655|	LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  164|    655|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    655|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    655|	int _ret = r; \
  |  |  |  |  155|    655|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 50, False: 605]
  |  |  |  |  ------------------
  |  |  |  |  156|     50|		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: 50]
  |  |  |  |  ------------------
  |  |  |  |  157|     50|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    605|	} else { \
  |  |  |  |  159|    605|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    605|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    605|	} \
  |  |  |  |  162|    655|	return _ret; \
  |  |  |  |  163|    655|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  834|    655|}
card-sc-hsm.c:sc_hsm_set_security_env:
 1004|     72|{
 1005|     72|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
 1006|       |
 1007|     72|	priv->env = env;
 1008|       |
 1009|     72|	switch(env->algorithm) {
 1010|     72|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|     72|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1010:2): [True: 72, False: 0]
  ------------------
 1011|     72|		if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1) {
  ------------------
  |  |  111|     72|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     72|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     72|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  |  Branch (1011:7): [True: 0, False: 72]
  ------------------
 1012|      0|			if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA1) {
  ------------------
  |  |  134|      0|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  |  Branch (1012:8): [True: 0, False: 0]
  ------------------
 1013|      0|				priv->algorithm = ALGO_RSA_PKCS1_SHA1;
  ------------------
  |  |   41|      0|#define ALGO_RSA_PKCS1_SHA1	0x31		/* RSA signature with SHA-1 hash and PKCS#1 V1.5 padding */
  ------------------
 1014|      0|			} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA256) {
  ------------------
  |  |  138|      0|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  |  Branch (1014:15): [True: 0, False: 0]
  ------------------
 1015|      0|				priv->algorithm = ALGO_RSA_PKCS1_SHA256;
  ------------------
  |  |   42|      0|#define ALGO_RSA_PKCS1_SHA256	0x33		/* RSA signature with SHA-256 hash and PKCS#1 V1.5 padding */
  ------------------
 1016|      0|			} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA384) {
  ------------------
  |  |  139|      0|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
  |  Branch (1016:15): [True: 0, False: 0]
  ------------------
 1017|      0|				priv->algorithm = ALGO_RSA_PKCS1_SHA384;
  ------------------
  |  |   43|      0|#define ALGO_RSA_PKCS1_SHA384	0x34		/* RSA signature with SHA-384 hash and PKCS#1 V1.5 padding */
  ------------------
 1018|      0|			} else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA512) {
  ------------------
  |  |  140|      0|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
  |  Branch (1018:15): [True: 0, False: 0]
  ------------------
 1019|      0|				priv->algorithm = ALGO_RSA_PKCS1_SHA512;
  ------------------
  |  |   44|      0|#define ALGO_RSA_PKCS1_SHA512	0x35		/* RSA signature with SHA-512 hash and PKCS#1 V1.5 padding */
  ------------------
 1020|      0|			} else {
 1021|      0|				priv->algorithm = ALGO_RSA_PKCS1;
  ------------------
  |  |   40|      0|#define ALGO_RSA_PKCS1		0x30		/* RSA signature with DigestInfo input and PKCS#1 V1.5 padding */
  ------------------
 1022|      0|			}
 1023|     72|		} else if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PSS) {
  ------------------
  |  |  107|     72|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  |  Branch (1023:14): [True: 0, False: 72]
  ------------------
 1024|      0|			if ((env->algorithm_flags & SC_ALGORITHM_RSA_HASHES) &&
  ------------------
  |  |  142|      0|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
  |  Branch (1024:8): [True: 0, False: 0]
  ------------------
 1025|      0|					(((env->algorithm_flags & SC_ALGORITHM_MGF1_HASHES) >> 8) != (env->algorithm_flags & SC_ALGORITHM_RSA_HASHES))) {
  ------------------
  |  |  150|      0|#define SC_ALGORITHM_MGF1_HASHES	0x01F00000
  ------------------
              					(((env->algorithm_flags & SC_ALGORITHM_MGF1_HASHES) >> 8) != (env->algorithm_flags & SC_ALGORITHM_RSA_HASHES))) {
  ------------------
  |  |  142|      0|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
  |  Branch (1025:6): [True: 0, False: 0]
  ------------------
 1026|      0|				LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1027|      0|			}
 1028|      0|			priv->algorithm = ALGO_RSA_PSS;
  ------------------
  |  |   46|      0|#define ALGO_RSA_PSS	    0x40 /* RSA signature with external hash and PKCS#1 PSS padding*/
  ------------------
 1029|     72|		} else {
 1030|     72|			if (env->operation == SC_SEC_OPERATION_DECIPHER) {
  ------------------
  |  |   47|     72|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
  |  Branch (1030:8): [True: 62, False: 10]
  ------------------
 1031|     62|				priv->algorithm = ALGO_RSA_DECRYPT;
  ------------------
  |  |   39|     62|#define ALGO_RSA_DECRYPT	0x21		/* RSA decrypt */
  ------------------
 1032|     62|			} else {
 1033|     10|				priv->algorithm = ALGO_RSA_RAW;
  ------------------
  |  |   38|     10|#define ALGO_RSA_RAW		0x20		/* RSA signature with external padding */
  ------------------
 1034|     10|			}
 1035|     72|		}
 1036|     72|		break;
 1037|     72|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1037:2): [True: 0, False: 72]
  ------------------
 1038|      0|		if (env->operation == SC_SEC_OPERATION_DERIVE) {
  ------------------
  |  |   50|      0|#define SC_SEC_OPERATION_DERIVE         0x0004
  ------------------
  |  Branch (1038:7): [True: 0, False: 0]
  ------------------
 1039|      0|			priv->algorithm = ALGO_EC_DH;
  ------------------
  |  |   58|      0|#define ALGO_EC_DH     0x80 /* ECDH key derivation */
  ------------------
 1040|      0|		} else if (env->algorithm_flags & SC_ALGORITHM_ECDSA_HASH_NONE) {
  ------------------
  |  |  175|      0|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  |  Branch (1040:14): [True: 0, False: 0]
  ------------------
 1041|      0|			priv->algorithm = ALGO_EC_RAW;
  ------------------
  |  |   52|      0|#define ALGO_EC_RAW    0x70 /* ECDSA signature with hash input */
  ------------------
 1042|      0|		} else if (env->algorithm_flags & SC_ALGORITHM_ECDSA_HASH_SHA1) {
  ------------------
  |  |  176|      0|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|      0|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
  |  Branch (1042:14): [True: 0, False: 0]
  ------------------
 1043|      0|			priv->algorithm = ALGO_EC_SHA1;
  ------------------
  |  |   53|      0|#define ALGO_EC_SHA1   0x71 /* ECDSA signature with SHA-1 hash */
  ------------------
 1044|      0|		} else if (env->algorithm_flags & SC_ALGORITHM_ECDSA_HASH_SHA224) {
  ------------------
  |  |  177|      0|#define SC_ALGORITHM_ECDSA_HASH_SHA224		SC_ALGORITHM_RSA_HASH_SHA224
  |  |  ------------------
  |  |  |  |  141|      0|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  |  |  ------------------
  ------------------
  |  Branch (1044:14): [True: 0, False: 0]
  ------------------
 1045|      0|			priv->algorithm = ALGO_EC_SHA224;
  ------------------
  |  |   54|      0|#define ALGO_EC_SHA224 0x72 /* ECDSA signature with SHA-224 hash */
  ------------------
 1046|      0|		} else if (env->algorithm_flags & SC_ALGORITHM_ECDSA_HASH_SHA256) {
  ------------------
  |  |  178|      0|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  138|      0|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  |  Branch (1046:14): [True: 0, False: 0]
  ------------------
 1047|      0|			priv->algorithm = ALGO_EC_SHA256;
  ------------------
  |  |   55|      0|#define ALGO_EC_SHA256 0x73 /* ECDSA signature with SHA-256 hash */
  ------------------
 1048|      0|		} else if (env->algorithm_flags & SC_ALGORITHM_ECDSA_HASH_SHA384) {
  ------------------
  |  |  179|      0|#define SC_ALGORITHM_ECDSA_HASH_SHA384		SC_ALGORITHM_RSA_HASH_SHA384
  |  |  ------------------
  |  |  |  |  139|      0|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  |  |  ------------------
  ------------------
  |  Branch (1048:14): [True: 0, False: 0]
  ------------------
 1049|      0|			priv->algorithm = ALGO_EC_SHA384;
  ------------------
  |  |   56|      0|#define ALGO_EC_SHA384 0x74 /* ECDSA signature with SHA-384 hash */
  ------------------
 1050|      0|		} else if (env->algorithm_flags & SC_ALGORITHM_ECDSA_HASH_SHA512) {
  ------------------
  |  |  180|      0|#define SC_ALGORITHM_ECDSA_HASH_SHA512		SC_ALGORITHM_RSA_HASH_SHA512
  |  |  ------------------
  |  |  |  |  140|      0|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  |  |  ------------------
  ------------------
  |  Branch (1050:14): [True: 0, False: 0]
  ------------------
 1051|      0|			priv->algorithm = ALGO_EC_SHA512;
  ------------------
  |  |   57|      0|#define ALGO_EC_SHA512 0x75 /* ECDSA signature with SHA-512 hash */
  ------------------
 1052|      0|		} else if (env->algorithm_flags & SC_ALGORITHM_ECDSA_RAW) {
  ------------------
  |  |  174|      0|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  |  Branch (1052:14): [True: 0, False: 0]
  ------------------
 1053|      0|			priv->algorithm = ALGO_EC_RAW;
  ------------------
  |  |   52|      0|#define ALGO_EC_RAW    0x70 /* ECDSA signature with hash input */
  ------------------
 1054|      0|		} else {
 1055|      0|			LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1056|      0|		}
 1057|      0|		break;
 1058|      0|	default:
  ------------------
  |  Branch (1058:2): [True: 0, False: 72]
  ------------------
 1059|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1060|      0|		break;
 1061|     72|	}
 1062|     72|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     72|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     72|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     72|	int _ret = r; \
  |  |  |  |  155|     72|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 72, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     72|		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: 72]
  |  |  |  |  ------------------
  |  |  |  |  157|     72|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     72|	} 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|     72|	return _ret; \
  |  |  |  |  163|     72|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1063|     72|}
card-sc-hsm.c:sc_hsm_compute_signature:
 1086|     10|{
 1087|     10|	int r;
 1088|     10|	sc_apdu_t apdu;
 1089|     10|	u8 rbuf[514];
 1090|     10|	sc_hsm_private_data_t *priv;
 1091|       |
 1092|     10|	if (card == NULL || data == NULL || out == NULL) {
  ------------------
  |  Branch (1092:6): [True: 0, False: 10]
  |  Branch (1092:22): [True: 0, False: 10]
  |  Branch (1092:38): [True: 0, False: 10]
  ------------------
 1093|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1094|      0|	}
 1095|     10|	priv = (sc_hsm_private_data_t *) card->drv_data;
 1096|       |
 1097|     10|	if (priv->env == NULL) {
  ------------------
  |  Branch (1097:6): [True: 0, False: 10]
  ------------------
 1098|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1099|      0|	}
 1100|       |
 1101|     10|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_EXT, 0x68, priv->env->key_ref[0], priv->algorithm);
  ------------------
  |  |  299|     10|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|     10|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|     10|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
 1102|     10|	apdu.cla = 0x80;
 1103|     10|	apdu.resp = rbuf;
 1104|     10|	apdu.resplen = sizeof(rbuf);
 1105|     10|	apdu.le = 512;
 1106|       |
 1107|     10|	apdu.data = data;
 1108|     10|	apdu.lc = datalen;
 1109|     10|	apdu.datalen = datalen;
 1110|     10|	r = sc_transmit_apdu(card, &apdu);
 1111|       |
 1112|     10|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1113|      9|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (1113:6): [True: 4, False: 5]
  |  Branch (1113:26): [True: 3, False: 1]
  ------------------
 1114|      3|		int len;
 1115|       |
 1116|      3|		if ((priv->algorithm & 0xF0) == ALGO_EC_RAW) {
  ------------------
  |  |   52|      3|#define ALGO_EC_RAW    0x70 /* ECDSA signature with hash input */
  ------------------
  |  Branch (1116:7): [True: 0, False: 3]
  ------------------
 1117|      0|			len = sc_hsm_decode_ecdsa_signature(card, apdu.resp, apdu.resplen, out, outlen, priv->env->key_size_bits);
 1118|      0|			if (len < 0) {
  ------------------
  |  Branch (1118:8): [True: 0, False: 0]
  ------------------
 1119|      0|				LOG_FUNC_RETURN(card->ctx, len);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1120|      0|			}
 1121|      3|		} else {
 1122|      3|			len = (int)(apdu.resplen > outlen ? outlen : apdu.resplen);
  ------------------
  |  Branch (1122:16): [True: 1, False: 2]
  ------------------
 1123|      3|			memcpy(out, apdu.resp, len);
 1124|      3|		}
 1125|      3|		LOG_FUNC_RETURN(card->ctx, len);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} else { \
  |  |  |  |  159|      2|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      2|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      2|	} \
  |  |  |  |  162|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1126|      3|	}
 1127|      6|	LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1128|      6|}
card-sc-hsm.c:sc_hsm_decipher:
 1133|     62|{
 1134|     62|	int r;
 1135|     62|	size_t len;
 1136|     62|	sc_apdu_t apdu;
 1137|     62|	u8 rbuf[514];
 1138|     62|	sc_hsm_private_data_t *priv;
 1139|       |
 1140|     62|	if (card == NULL || crgram == NULL || out == NULL) {
  ------------------
  |  Branch (1140:6): [True: 0, False: 62]
  |  Branch (1140:22): [True: 0, False: 62]
  |  Branch (1140:40): [True: 0, False: 62]
  ------------------
 1141|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1142|      0|	}
 1143|     62|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     62|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     62|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     62|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     62|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1144|     62|	priv = (sc_hsm_private_data_t *) card->drv_data;
 1145|       |
 1146|     62|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_EXT, 0x62, priv->env->key_ref[0], priv->algorithm);
  ------------------
  |  |  299|     62|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|     62|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|     62|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
 1147|     62|	apdu.cla = 0x80;
 1148|     62|	apdu.resp = rbuf;
 1149|     62|	apdu.resplen = sizeof(rbuf);
 1150|     62|	apdu.le = 512;
 1151|       |
 1152|     62|	apdu.data = (u8 *)crgram;
 1153|     62|	apdu.lc = crgram_len;
 1154|     62|	apdu.datalen = crgram_len;
 1155|       |
 1156|     62|	r = sc_transmit_apdu(card, &apdu);
 1157|       |
 1158|     62|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     62|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     62|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     62|	int _ret = (r); \
  |  |  |  |  168|     62|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 57]
  |  |  |  |  ------------------
  |  |  |  |  169|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      5|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      5|		return _ret; \
  |  |  |  |  172|      5|	} \
  |  |  |  |  173|     62|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1159|     57|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (1159:6): [True: 45, False: 12]
  |  Branch (1159:26): [True: 44, False: 1]
  ------------------
 1160|     44|		if (priv->algorithm == ALGO_EC_DH) {
  ------------------
  |  |   58|     44|#define ALGO_EC_DH     0x80 /* ECDH key derivation */
  ------------------
  |  Branch (1160:7): [True: 0, False: 44]
  ------------------
 1161|       |			//
 1162|       |			// The SmartCard-HSM returns the point result of the DH operation
 1163|       |			// with a leading '04'
 1164|      0|			if (apdu.resplen <= 0)
  ------------------
  |  Branch (1164:8): [True: 0, False: 0]
  ------------------
 1165|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1166|      0|			len = apdu.resplen - 1 > outlen ? outlen : apdu.resplen - 1;
  ------------------
  |  Branch (1166:10): [True: 0, False: 0]
  ------------------
 1167|      0|			memcpy(out, apdu.resp + 1, len);
 1168|      0|			LOG_FUNC_RETURN(card->ctx, (int)len);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1169|     44|		} else {
 1170|     44|			len = apdu.resplen > outlen ? outlen : apdu.resplen;
  ------------------
  |  Branch (1170:10): [True: 1, False: 43]
  ------------------
 1171|     44|			memcpy(out, apdu.resp, len);
 1172|     44|			LOG_FUNC_RETURN(card->ctx, (int)len);
  ------------------
  |  |  164|     44|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     44|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     44|	int _ret = r; \
  |  |  |  |  155|     44|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 42]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     42|	} else { \
  |  |  |  |  159|     42|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     42|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     42|	} \
  |  |  |  |  162|     44|	return _ret; \
  |  |  |  |  163|     44|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1173|     44|		}
 1174|     44|	}
 1175|     13|	else
 1176|     57|		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|     13|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     13|	int _ret = r; \
  |  |  |  |  155|     13|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     13|		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|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     13|	} 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|     13|	return _ret; \
  |  |  |  |  163|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1177|     57|}
card-sc-hsm.c:sc_hsm_init:
 1802|    288|{
 1803|       |#if defined(ENABLE_SM) && defined(ENABLE_OPENPACE) && defined(_WIN32)
 1804|       |	char expanded_val[PATH_MAX];
 1805|       |	size_t expanded_len = PATH_MAX;
 1806|       |#endif
 1807|    288|	int flags,ext_flags;
 1808|    288|	sc_file_t *file = NULL;
 1809|    288|	sc_path_t path;
 1810|    288|	sc_hsm_private_data_t *priv = NULL;
 1811|       |
 1812|    288|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    288|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    288|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    288|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    288|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 288]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1813|       |
 1814|    288|	flags = SC_ALGORITHM_RSA_RAW|SC_ALGORITHM_RSA_PAD_PSS|SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |  102|    288|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW|SC_ALGORITHM_RSA_PAD_PSS|SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |  107|    288|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW|SC_ALGORITHM_RSA_PAD_PSS|SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |   93|    288|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
 1815|    288|			|SC_ALGORITHM_RSA_HASH_SHA1|SC_ALGORITHM_RSA_HASH_SHA256|SC_ALGORITHM_RSA_HASH_SHA384|SC_ALGORITHM_RSA_HASH_SHA512
  ------------------
  |  |  134|    288|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
              			|SC_ALGORITHM_RSA_HASH_SHA1|SC_ALGORITHM_RSA_HASH_SHA256|SC_ALGORITHM_RSA_HASH_SHA384|SC_ALGORITHM_RSA_HASH_SHA512
  ------------------
  |  |  138|    288|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
              			|SC_ALGORITHM_RSA_HASH_SHA1|SC_ALGORITHM_RSA_HASH_SHA256|SC_ALGORITHM_RSA_HASH_SHA384|SC_ALGORITHM_RSA_HASH_SHA512
  ------------------
  |  |  139|    288|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
              			|SC_ALGORITHM_RSA_HASH_SHA1|SC_ALGORITHM_RSA_HASH_SHA256|SC_ALGORITHM_RSA_HASH_SHA384|SC_ALGORITHM_RSA_HASH_SHA512
  ------------------
  |  |  140|    288|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
 1816|    288|			|SC_ALGORITHM_MGF1_SHA256|SC_ALGORITHM_MGF1_SHA384|SC_ALGORITHM_MGF1_SHA512;
  ------------------
  |  |  146|    288|#define SC_ALGORITHM_MGF1_SHA256	0x00200000
  ------------------
              			|SC_ALGORITHM_MGF1_SHA256|SC_ALGORITHM_MGF1_SHA384|SC_ALGORITHM_MGF1_SHA512;
  ------------------
  |  |  147|    288|#define SC_ALGORITHM_MGF1_SHA384	0x00400000
  ------------------
              			|SC_ALGORITHM_MGF1_SHA256|SC_ALGORITHM_MGF1_SHA384|SC_ALGORITHM_MGF1_SHA512;
  ------------------
  |  |  148|    288|#define SC_ALGORITHM_MGF1_SHA512	0x00800000
  ------------------
 1817|       |
 1818|    288|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
 1819|    288|	_sc_card_add_rsa_alg(card, 1536, flags, 0);
 1820|    288|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
 1821|    288|	_sc_card_add_rsa_alg(card, 3072, flags, 0);
 1822|    288|	_sc_card_add_rsa_alg(card, 4096, flags, 0);
 1823|       |
 1824|    288|	flags = SC_ALGORITHM_ECDSA_RAW|
  ------------------
  |  |  174|    288|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
 1825|    288|		SC_ALGORITHM_ECDH_CDH_RAW|
  ------------------
  |  |  173|    288|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
 1826|    288|		SC_ALGORITHM_ECDSA_HASH_NONE|
  ------------------
  |  |  175|    288|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|    288|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
 1827|    288|		SC_ALGORITHM_ECDSA_HASH_SHA1|
  ------------------
  |  |  176|    288|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|    288|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
 1828|    288|		SC_ALGORITHM_ECDSA_HASH_SHA224|
  ------------------
  |  |  177|    288|#define SC_ALGORITHM_ECDSA_HASH_SHA224		SC_ALGORITHM_RSA_HASH_SHA224
  |  |  ------------------
  |  |  |  |  141|    288|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  |  |  ------------------
  ------------------
 1829|    288|		SC_ALGORITHM_ECDSA_HASH_SHA256|
  ------------------
  |  |  178|    288|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  138|    288|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
 1830|    288|		SC_ALGORITHM_ECDSA_HASH_SHA384|
  ------------------
  |  |  179|    288|#define SC_ALGORITHM_ECDSA_HASH_SHA384		SC_ALGORITHM_RSA_HASH_SHA384
  |  |  ------------------
  |  |  |  |  139|    288|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  |  |  ------------------
  ------------------
 1831|    288|		SC_ALGORITHM_ECDSA_HASH_SHA512|
  ------------------
  |  |  180|    288|#define SC_ALGORITHM_ECDSA_HASH_SHA512		SC_ALGORITHM_RSA_HASH_SHA512
  |  |  ------------------
  |  |  |  |  140|    288|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  |  |  ------------------
  ------------------
 1832|    288|		SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    288|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
 1833|       |
 1834|    288|	ext_flags = SC_ALGORITHM_EXT_EC_F_P|
  ------------------
  |  |  198|    288|#define SC_ALGORITHM_EXT_EC_F_P          0x00000001
  ------------------
 1835|    288|			SC_ALGORITHM_EXT_EC_ECPARAMETERS|
  ------------------
  |  |  200|    288|#define SC_ALGORITHM_EXT_EC_ECPARAMETERS 0x00000004
  ------------------
 1836|    288|			SC_ALGORITHM_EXT_EC_NAMEDCURVE|
  ------------------
  |  |  201|    288|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
 1837|    288|			SC_ALGORITHM_EXT_EC_UNCOMPRESES|
  ------------------
  |  |  202|    288|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
 1838|    288|			SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    288|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
 1839|    288|	_sc_card_add_ec_alg(card, 192, flags, ext_flags, NULL);
 1840|    288|	_sc_card_add_ec_alg(card, 224, flags, ext_flags, NULL);
 1841|    288|	_sc_card_add_ec_alg(card, 256, flags, ext_flags, NULL);
 1842|    288|	_sc_card_add_ec_alg(card, 320, flags, ext_flags, NULL);
 1843|    288|	_sc_card_add_ec_alg(card, 384, flags, ext_flags, NULL);
 1844|    288|	_sc_card_add_ec_alg(card, 512, flags, ext_flags, NULL);
 1845|    288|	_sc_card_add_ec_alg(card, 521, flags, ext_flags, NULL);
 1846|       |
 1847|    288|	card->caps |= SC_CARD_CAP_RNG|SC_CARD_CAP_APDU_EXT|SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  550|    288|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG|SC_CARD_CAP_APDU_EXT|SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  547|    288|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
              	card->caps |= SC_CARD_CAP_RNG|SC_CARD_CAP_APDU_EXT|SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    288|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
 1848|       |
 1849|       |	// APDU Size limits
 1850|       |	//   JCOP 2.4.1r3           1462
 1851|       |	//   JCOP 2.4.2r3           1454
 1852|       |	//   JCOP 3                 1232
 1853|       |	//   JCOP 4                 1454
 1854|       |	//   MicroSD with JCOP 3    478 / 506 - handled in reader-pcsc.c
 1855|       |	//   Reiner SCT             1014 - handled in reader-pcsc.c
 1856|       |	//
 1857|       |	// Note, that these are limits for the whole APDU, but the semantics of max_send_size
 1858|       |	// is the size of the APDU send buffer so to get the right value from them, we need
 1859|       |	// to subtract APDU headers (CLA, INS, P1, P2, Lc (3B)), 7 bytes altogether for
 1860|       |	// class 3 APDU
 1861|       |	// (or 9 bytes for case 4 when we pass in >255 B data and expect return of more than 255 B)
 1862|       |
 1863|       |	// Use JCOP 3 (smallest unhandled by reader limitation) card limits for sending
 1864|       |	// And make it 9 smaller to make sure we fit the rest of the APDU.
 1865|    288|	card->max_send_size = 1232 - 9;
 1866|       |	// Assume that card supports sending with extended length APDU and without limit
 1867|    288|	card->max_recv_size = 0;
 1868|       |
 1869|    288|	if (card->type == SC_CARD_TYPE_SC_HSM_SOC
  ------------------
  |  Branch (1869:6): [True: 0, False: 288]
  ------------------
 1870|    288|			|| card->type == SC_CARD_TYPE_SC_HSM_GOID) {
  ------------------
  |  Branch (1870:7): [True: 286, False: 2]
  ------------------
 1871|    286|		card->max_recv_size = 0x0630;	// SoC Proxy forces this limit
 1872|    286|	} else {
 1873|       |		// Adjust to the limits set by the reader
 1874|      2|		if (card->reader->max_send_size < card->max_send_size) {
  ------------------
  |  Branch (1874:7): [True: 2, False: 0]
  ------------------
 1875|      2|			if (18 >= card->reader->max_send_size)
  ------------------
  |  Branch (1875:8): [True: 2, False: 0]
  ------------------
 1876|      2|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCONSISTENT_CONFIGURATION);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1877|       |
 1878|       |			// 17 byte header and TLV because of odd ins in UPDATE BINARY
 1879|      0|			card->max_send_size = card->reader->max_send_size - 17;
 1880|      0|		}
 1881|       |
 1882|      0|		if (0 < card->reader->max_recv_size) {
  ------------------
  |  Branch (1882:7): [True: 0, False: 0]
  ------------------
 1883|      0|			if (3 >= card->reader->max_recv_size)
  ------------------
  |  Branch (1883:8): [True: 0, False: 0]
  ------------------
 1884|      0|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCONSISTENT_CONFIGURATION);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1885|      0|			card->max_recv_size = card->reader->max_recv_size - 2;
 1886|      0|		}
 1887|      0|	}
 1888|       |
 1889|    286|	priv = card->drv_data;
 1890|    286|	if (!priv) {
  ------------------
  |  Branch (1890:6): [True: 286, False: 0]
  ------------------
 1891|    286|		priv = calloc(1, sizeof(sc_hsm_private_data_t));
 1892|    286|		if (!priv)
  ------------------
  |  Branch (1892:7): [True: 0, False: 286]
  ------------------
 1893|    286|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1894|    286|		card->drv_data = priv;
 1895|    286|	}
 1896|       |
 1897|    286|	sc_path_set(&path, SC_PATH_TYPE_DF_NAME, sc_hsm_aid.value, sc_hsm_aid.len, 0, 0);
  ------------------
  |  |  118|    286|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 1898|    286|	if (sc_hsm_select_file_ex(card, &path, 0, &file) == SC_SUCCESS
  ------------------
  |  |   28|    572|#define SC_SUCCESS				0
  ------------------
  |  Branch (1898:6): [True: 67, False: 219]
  ------------------
 1899|     67|			&& file && file->prop_attr && file->prop_attr_len >= 2) {
  ------------------
  |  Branch (1899:7): [True: 67, False: 0]
  |  Branch (1899:15): [True: 4, False: 63]
  |  Branch (1899:34): [True: 3, False: 1]
  ------------------
 1900|      3|		static char card_name[SC_MAX_APDU_BUFFER_SIZE];
 1901|      3|		u8 type = 0xFF;
 1902|      3|		u8 major = file->prop_attr[file->prop_attr_len - 2];
 1903|      3|		u8 minor = file->prop_attr[file->prop_attr_len - 1];
 1904|      3|		char p00[] = "SmartCard-HSM Applet for JCOP";
 1905|      3|		char p01[] = "SmartCard-HSM Demo Applet for JCOP";
 1906|      3|		char *p = "SmartCard-HSM";
 1907|      3|		if (file->prop_attr_len >= 3) {
  ------------------
  |  Branch (1907:7): [True: 2, False: 1]
  ------------------
 1908|      2|			type = file->prop_attr[file->prop_attr_len - 3];
 1909|      2|		}
 1910|      3|		switch (type) {
 1911|      1|			case 0x00:
  ------------------
  |  Branch (1911:4): [True: 1, False: 2]
  ------------------
 1912|      1|				p = p00;
 1913|      1|				break;
 1914|      1|			case 0x01:
  ------------------
  |  Branch (1914:4): [True: 1, False: 2]
  ------------------
 1915|      1|				p = p01;
 1916|      1|				break;
 1917|      1|			default:
  ------------------
  |  Branch (1917:4): [True: 1, False: 2]
  ------------------
 1918|      1|				break;
 1919|      3|		}
 1920|      3|		snprintf(card_name, sizeof card_name, "%s version %u.%u", p, major, minor);
 1921|      3|		card->name = card_name;
 1922|       |
 1923|      3|		if (file->prop_attr[1] & 0x04) {
  ------------------
  |  Branch (1923:7): [True: 1, False: 2]
  ------------------
 1924|      1|			card->caps |= SC_CARD_CAP_SESSION_PIN;
  ------------------
  |  |  563|      1|#define SC_CARD_CAP_SESSION_PIN	0x00000200
  ------------------
 1925|      1|		}
 1926|      3|	}
 1927|    286|	sc_file_free(file);
 1928|       |
 1929|    286|	priv->EF_C_DevAut = NULL;
 1930|    286|	priv->EF_C_DevAut_len = 0;
 1931|       |
 1932|    286|#if defined(ENABLE_SM) && defined(ENABLE_OPENPACE)
 1933|    286|	EAC_init();
 1934|       |#ifdef _WIN32
 1935|       |	expanded_len = ExpandEnvironmentStringsA(CVCDIR, expanded_val, sizeof expanded_val);
 1936|       |	if (0 < expanded_len && expanded_len < sizeof expanded_val)
 1937|       |		EAC_set_cvc_default_dir(expanded_val);
 1938|       |#else
 1939|    286|	EAC_set_cvc_default_dir(CVCDIR);
  ------------------
  |  |    8|    286|#define CVCDIR "/usr/etc/eac/cvc"
  ------------------
 1940|    286|#endif
 1941|    286|#endif
 1942|       |
 1943|    286|	return 0;
 1944|    286|}
card-sc-hsm.c:sc_hsm_finish:
 1949|    286|{
 1950|    286|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
 1951|    286|#ifdef ENABLE_SM
 1952|    286|	sc_sm_stop(card);
 1953|    286|#endif
 1954|    286|	if (priv) {
  ------------------
  |  Branch (1954:6): [True: 286, False: 0]
  ------------------
 1955|    286|		free(priv->serialno);
 1956|    286|		sc_file_free(priv->dffcp);
 1957|    286|		free(priv->EF_C_DevAut);
 1958|    286|	}
 1959|    286|	free(priv);
 1960|       |
 1961|    286|	return SC_SUCCESS;
  ------------------
  |  |   28|    286|#define SC_SUCCESS				0
  ------------------
 1962|    286|}
card-sc-hsm.c:sc_hsm_card_ctl:
 1773|    278|{
 1774|    278|	switch (cmd) {
  ------------------
  |  Branch (1774:10): [True: 132, False: 146]
  ------------------
 1775|    118|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1775:2): [True: 118, False: 160]
  ------------------
 1776|    118|		return sc_hsm_get_serialnr(card, (sc_serial_number_t *)ptr);
 1777|      0|	case SC_CARDCTL_PKCS11_INIT_TOKEN:
  ------------------
  |  Branch (1777:2): [True: 0, False: 278]
  ------------------
 1778|      0|		return sc_hsm_init_token(card, (sc_cardctl_pkcs11_init_token_t *)ptr);
 1779|     14|	case SC_CARDCTL_PKCS11_INIT_PIN:
  ------------------
  |  Branch (1779:2): [True: 14, False: 264]
  ------------------
 1780|     14|		return sc_hsm_init_pin(card, (sc_cardctl_pkcs11_init_pin_t *)ptr);
 1781|      0|	case SC_CARDCTL_SC_HSM_GENERATE_KEY:
  ------------------
  |  Branch (1781:2): [True: 0, False: 278]
  ------------------
 1782|      0|		return sc_hsm_generate_keypair(card, (sc_cardctl_sc_hsm_keygen_info_t *)ptr);
 1783|      0|	case SC_CARDCTL_SC_HSM_INITIALIZE:
  ------------------
  |  Branch (1783:2): [True: 0, False: 278]
  ------------------
 1784|      0|		return sc_hsm_initialize(card, (sc_cardctl_sc_hsm_init_param_t *)ptr);
 1785|      0|	case SC_CARDCTL_SC_HSM_MANAGE_KEY_DOMAIN:
  ------------------
  |  Branch (1785:2): [True: 0, False: 278]
  ------------------
 1786|      0|		return sc_hsm_manage_key_domain(card, (sc_cardctl_sc_hsm_key_domain_t *)ptr);
 1787|      0|	case SC_CARDCTL_SC_HSM_WRAP_KEY:
  ------------------
  |  Branch (1787:2): [True: 0, False: 278]
  ------------------
 1788|      0|		return sc_hsm_wrap_key(card, (sc_cardctl_sc_hsm_wrapped_key_t *)ptr);
 1789|      0|	case SC_CARDCTL_SC_HSM_UNWRAP_KEY:
  ------------------
  |  Branch (1789:2): [True: 0, False: 278]
  ------------------
 1790|      0|		return sc_hsm_unwrap_key(card, (sc_cardctl_sc_hsm_wrapped_key_t *)ptr);
 1791|      0|	case SC_CARDCTL_SC_HSM_REGISTER_PUBLIC_KEY:
  ------------------
  |  Branch (1791:2): [True: 0, False: 278]
  ------------------
 1792|      0|		return sc_hsm_register_public_key(card, ptr);
 1793|      0|	case SC_CARDCTL_SC_HSM_PUBLIC_KEY_AUTH_STATUS:
  ------------------
  |  Branch (1793:2): [True: 0, False: 278]
  ------------------
 1794|      0|		return sc_hsm_public_key_auth_status(card, ptr);
 1795|    278|	}
 1796|    146|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    146|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1797|    278|}
card-sc-hsm.c:sc_hsm_get_serialnr:
 1195|    118|{
 1196|    118|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
 1197|       |
 1198|    118|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    118|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    118|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    118|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    118|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 118]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1199|       |
 1200|    118|	if (!priv->serialno && 0 == strcmp(card->ctx->app_name, "opensc-tool")) {
  ------------------
  |  Branch (1200:6): [True: 118, False: 0]
  |  Branch (1200:25): [True: 0, False: 118]
  ------------------
 1201|       |		/* sc-hsm initializes the serial number via its PKCS#15 layer.
 1202|       |		 * Create and destroy a dummy card to get this initialized.  Only do
 1203|       |		 * this for `opensc-tool --serial` to avoid unnecessary card commands
 1204|       |		 * in all other cases. */
 1205|      0|		sc_pkcs15_card_t *p15card = NULL;
 1206|      0|		(void)sc_pkcs15_bind(card, NULL, &p15card);
 1207|      0|		sc_pkcs15_unbind(p15card);
 1208|      0|	}
 1209|       |
 1210|    118|	if (!priv->serialno) {
  ------------------
  |  Branch (1210:6): [True: 118, False: 0]
  ------------------
 1211|    118|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    118|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1212|    118|	}
 1213|       |
 1214|      0|	serial->len = strlen(priv->serialno);
 1215|      0|	if (serial->len > sizeof(serial->value))
  ------------------
  |  Branch (1215:6): [True: 0, False: 0]
  ------------------
 1216|      0|		serial->len = sizeof(serial->value);
 1217|       |
 1218|      0|	memcpy(serial->value, priv->serialno, serial->len);
 1219|       |
 1220|      0|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1221|      0|}
card-sc-hsm.c:sc_hsm_init_pin:
 1673|     14|{
 1674|     14|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
 1675|     14|	sc_context_t *ctx = card->ctx;
 1676|     14|	int r;
 1677|     14|	sc_apdu_t apdu;
 1678|     14|	u8 ibuff[50], *p;
 1679|       |
 1680|     14|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     14|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     14|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     14|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     14|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1681|       |
 1682|     14|	if (params->pin_len > 16) {
  ------------------
  |  Branch (1682:6): [True: 3, False: 11]
  ------------------
 1683|      3|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "User PIN too long");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1684|      3|	}
 1685|       |
 1686|     11|	p = ibuff;
 1687|       |
 1688|     11|	memcpy(p, priv->sopin, sizeof(priv->sopin));
 1689|     11|	p += sizeof(priv->sopin);
 1690|       |
 1691|     11|	memcpy(p, params->pin, params->pin_len);
 1692|     11|	p += params->pin_len;
 1693|       |
 1694|     11|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x2C, 0x00, 0x81);
  ------------------
  |  |  293|     11|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1695|     11|	apdu.data = ibuff;
 1696|     11|	apdu.datalen = p - ibuff;
 1697|     11|	apdu.lc = apdu.datalen;
 1698|       |
 1699|     11|	r = sc_transmit_apdu(card, &apdu);
 1700|     11|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1701|       |
 1702|     10|	r =  sc_check_sw(card, apdu.sw1, apdu.sw2);
 1703|       |
 1704|       |	// Cards before version 1.0 do not implement RESET_RETRY_COUNTER
 1705|       |	// For those cards the CHANGE REFERENCE DATA command is used instead
 1706|     10|	if (r == SC_ERROR_INS_NOT_SUPPORTED) {
  ------------------
  |  |   54|     10|#define SC_ERROR_INS_NOT_SUPPORTED		-1204
  ------------------
  |  Branch (1706:6): [True: 6, False: 4]
  ------------------
 1707|      6|		p = ibuff;
 1708|      6|		memcpy(p, priv->sopin, 6);
 1709|      6|		p += 6;
 1710|       |
 1711|      6|		memcpy(p, params->pin, params->pin_len);
 1712|      6|		p += params->pin_len;
 1713|       |
 1714|      6|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x24, 0x00, 0x81);
  ------------------
  |  |  293|      6|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1715|      6|		apdu.data = ibuff;
 1716|      6|		apdu.datalen = p - ibuff;
 1717|      6|		apdu.lc = apdu.datalen;
 1718|       |
 1719|      6|		r = sc_transmit_apdu(card, &apdu);
 1720|      6|		LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1721|       |
 1722|      5|		r =  sc_check_sw(card, apdu.sw1, apdu.sw2);
 1723|      5|	}
 1724|       |
 1725|      9|	LOG_TEST_RET(ctx, r, "Check SW error");
  ------------------
  |  |  174|      9|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      9|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      9|	int _ret = (r); \
  |  |  |  |  168|      9|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      8|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      8|		return _ret; \
  |  |  |  |  172|      8|	} \
  |  |  |  |  173|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1726|       |
 1727|      1|	memset(priv->sopin, 0, sizeof(priv->sopin));
 1728|       |
 1729|      1|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1730|      1|}
card-sc-hsm.c:sc_hsm_pin_cmd:
  620|    141|{
  621|    141|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
  622|    141|	sc_apdu_t apdu;
  623|    141|	u8 cmdbuff[16];
  624|    141|#ifdef ENABLE_SM
  625|    141|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  626|    141|#endif
  627|    141|	int r;
  628|    141|	int cmd = data->cmd;
  629|    141|	size_t pin2_len = data->pin2.len;
  630|       |
  631|    141|	if (cmd == SC_PIN_CMD_GET_SESSION_PIN) {
  ------------------
  |  |  419|    141|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (631:6): [True: 0, False: 141]
  ------------------
  632|       |		/* First, perform a standard VERIFY */
  633|      0|		data->cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  634|       |		/* we assign pin2.len to 0 early on so that in case of an error we are
  635|       |		 * not exiting with an undefined session PIN */
  636|      0|		data->pin2.len = 0;
  637|      0|	}
  638|       |
  639|    141|	if ((card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)
  ------------------
  |  |  560|    141|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (639:6): [True: 0, False: 141]
  ------------------
  640|      0|		   	&& (data->cmd == SC_PIN_CMD_CHANGE)
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (640:10): [True: 0, False: 0]
  ------------------
  641|      0|		   	&& (data->pin_reference == 0x81)
  ------------------
  |  Branch (641:10): [True: 0, False: 0]
  ------------------
  642|      0|			&& (!data->pin1.data || data->pin1.len <= 0)) {
  ------------------
  |  Branch (642:8): [True: 0, False: 0]
  |  Branch (642:28): [True: 0, False: 0]
  ------------------
  643|      0|		return sc_hsm_soc_change(card, data);
  644|    141|	} else if ((card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)
  ------------------
  |  |  560|    141|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (644:13): [True: 0, False: 141]
  ------------------
  645|      0|		   	&& (data->cmd == SC_PIN_CMD_UNBLOCK)
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (645:10): [True: 0, False: 0]
  ------------------
  646|      0|		   	&& (data->pin_reference == 0x81)
  ------------------
  |  Branch (646:10): [True: 0, False: 0]
  ------------------
  647|      0|			&& (!data->pin1.data || data->pin1.len <= 0)) {
  ------------------
  |  Branch (647:8): [True: 0, False: 0]
  |  Branch (647:28): [True: 0, False: 0]
  ------------------
  648|      0|		return sc_hsm_soc_unblock(card, data);
  649|      0|	}
  650|       |
  651|    141|#ifdef ENABLE_SM
  652|       |	/* For contactless cards always establish a secure channel before PIN
  653|       |	 * verification. Also, Session PIN generation requires SM. */
  654|    141|	if ((card->type == SC_CARD_TYPE_SC_HSM_SOC
  ------------------
  |  Branch (654:7): [True: 0, False: 141]
  ------------------
  655|    141|				|| card->type == SC_CARD_TYPE_SC_HSM_GOID
  ------------------
  |  Branch (655:8): [True: 141, False: 0]
  ------------------
  656|      0|				|| card->reader->uid.len || cmd == SC_PIN_CMD_GET_SESSION_PIN)
  ------------------
  |  |  419|      0|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (656:8): [True: 0, False: 0]
  |  Branch (656:33): [True: 0, False: 0]
  ------------------
  657|    141|			&& (data->cmd != SC_PIN_CMD_GET_INFO)) {
  ------------------
  |  |  418|    141|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (657:7): [True: 11, False: 130]
  ------------------
  658|     11|		struct sc_pin_cmd_data check_sm_pin_data;
  659|     11|		memset(&check_sm_pin_data, 0, sizeof(check_sm_pin_data));
  660|     11|		check_sm_pin_data.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|     11|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  661|     11|		check_sm_pin_data.pin_type = data->pin_type;
  662|     11|		check_sm_pin_data.pin_reference = data->pin_reference;
  663|       |
  664|     11|		r = SC_ERROR_NOT_ALLOWED;
  ------------------
  |  |   59|     11|#define SC_ERROR_NOT_ALLOWED			-1209
  ------------------
  665|     11|		if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT) {
  ------------------
  |  |   47|     11|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (665:7): [True: 0, False: 11]
  ------------------
  666|       |			/* check if the existing SM channel is still valid */
  667|      0|			r = sc_pin_cmd(card, &check_sm_pin_data);
  668|      0|		}
  669|     11|		if (r == SC_ERROR_ASN1_OBJECT_NOT_FOUND || r == SC_ERROR_NOT_ALLOWED) {
  ------------------
  |  |   83|     22|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
              		if (r == SC_ERROR_ASN1_OBJECT_NOT_FOUND || r == SC_ERROR_NOT_ALLOWED) {
  ------------------
  |  |   59|     11|#define SC_ERROR_NOT_ALLOWED			-1209
  ------------------
  |  Branch (669:7): [True: 0, False: 11]
  |  Branch (669:46): [True: 11, False: 0]
  ------------------
  670|       |			/* need to establish a new SM channel */
  671|     11|			LOG_TEST_RET(card->ctx,
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  672|     11|					sc_hsm_perform_chip_authentication(card),
  673|     11|					"Could not perform chip authentication");
  674|     11|		}
  675|     11|	}
  676|    130|#endif
  677|       |
  678|    130|	if ((card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)
  ------------------
  |  |  560|    130|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (678:6): [True: 0, False: 130]
  ------------------
  679|      0|			&& (data->cmd == SC_PIN_CMD_VERIFY)
  ------------------
  |  |  415|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (679:7): [True: 0, False: 0]
  ------------------
  680|      0|			&& (data->pin_reference == 0x81)
  ------------------
  |  Branch (680:7): [True: 0, False: 0]
  ------------------
  681|      0|			&& (!data->pin1.data || data->pin1.len <= 0)) {
  ------------------
  |  Branch (681:8): [True: 0, False: 0]
  |  Branch (681:28): [True: 0, False: 0]
  ------------------
  682|      0|		r = sc_hsm_soc_biomatch(card, data);
  683|    130|	} else {
  684|    130|		if ((data->cmd == SC_PIN_CMD_VERIFY) && (data->pin_reference == 0x88)) {
  ------------------
  |  |  415|    130|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (684:7): [True: 0, False: 130]
  |  Branch (684:43): [True: 0, False: 0]
  ------------------
  685|      0|			if (data->pin1.len != 16)
  ------------------
  |  Branch (685:8): [True: 0, False: 0]
  ------------------
  686|      0|				return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      0|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
  687|       |
  688|       |			// Save SO PIN for later use in sc_hsm_init_pin()
  689|      0|			r = sc_hsm_encode_sopin(data->pin1.data, priv->sopin);
  690|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  691|       |
  692|      0|			LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  693|      0|		}
  694|       |
  695|    130|		if ((data->cmd == SC_PIN_CMD_CHANGE) && (data->pin_reference == 0x88)) {
  ------------------
  |  |  416|    130|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (695:7): [True: 0, False: 130]
  |  Branch (695:43): [True: 0, False: 0]
  ------------------
  696|      0|			if ((data->pin1.len != 16) || (data->pin2.len != 16))
  ------------------
  |  Branch (696:8): [True: 0, False: 0]
  |  Branch (696:34): [True: 0, False: 0]
  ------------------
  697|      0|				return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      0|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
  698|       |
  699|      0|			r = sc_hsm_encode_sopin(data->pin1.data, cmdbuff);
  700|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  701|       |
  702|      0|			r = sc_hsm_encode_sopin(data->pin2.data, cmdbuff + 8);
  703|      0|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  704|       |
  705|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x24, 0x00, data->pin_reference);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  706|      0|			apdu.data = cmdbuff;
  707|      0|			apdu.datalen = sizeof(cmdbuff);
  708|      0|			apdu.lc = 16;
  709|      0|			apdu.resplen = 0;
  710|      0|			data->apdu = &apdu;
  711|      0|		}
  712|       |
  713|    130|#ifdef ENABLE_SM
  714|    130|		if ((data->cmd == SC_PIN_CMD_GET_INFO)
  ------------------
  |  |  418|    130|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (714:7): [True: 130, False: 0]
  ------------------
  715|    130|				&& (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT)) {
  ------------------
  |  |   47|    130|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (715:8): [True: 0, False: 130]
  ------------------
  716|       |			/* JCOP's SM accelerator is incapable of using case 1 APDU in SM */
  717|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x20, 0x00, data->pin_reference);
  ------------------
  |  |  301|      0|#define SC_APDU_CASE_2			0x22
  ------------------
  718|      0|			apdu.resp = rbuf;
  719|      0|			apdu.resplen = sizeof rbuf;
  720|      0|			data->apdu = &apdu;
  721|      0|		}
  722|    130|#endif
  723|       |
  724|    130|		data->pin1.offset = 5;
  725|    130|		data->pin2.offset = 5;
  726|       |
  727|    130|		r = (*iso_ops->pin_cmd)(card, data);
  728|    130|		data->apdu = NULL;
  729|    130|	}
  730|    130|	LOG_TEST_RET(card->ctx, r, "Verification failed");
  ------------------
  |  |  174|    130|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    130|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    130|	int _ret = (r); \
  |  |  |  |  168|    130|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 36, False: 94]
  |  |  |  |  ------------------
  |  |  |  |  169|     36|		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|     36|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     36|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     36|		return _ret; \
  |  |  |  |  172|     36|	} \
  |  |  |  |  173|    130|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  731|       |
  732|     94|	if (cmd == SC_PIN_CMD_GET_SESSION_PIN) {
  ------------------
  |  |  419|     94|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (732:6): [True: 0, False: 94]
  ------------------
  733|       |		/* reset data->cmd to its original value */
  734|      0|		data->cmd = SC_PIN_CMD_GET_SESSION_PIN;
  ------------------
  |  |  419|      0|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  735|      0|		if (data->pin_reference == 0x81) {
  ------------------
  |  Branch (735:7): [True: 0, False: 0]
  ------------------
  736|      0|			u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
  737|      0|#ifdef ENABLE_SM
  738|      0|			if (card->sm_ctx.sm_mode != SM_MODE_TRANSMIT) {
  ------------------
  |  |   47|      0|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (738:8): [True: 0, False: 0]
  ------------------
  739|      0|				sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  740|      0|						"Session PIN generation only supported in SM");
  741|      0|				LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|      0|			}
  743|       |#else
  744|       |			sc_log(card->ctx,
  745|       |					"Session PIN generation only supported in SM");
  746|       |			LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  747|       |#endif
  748|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x5A, 0x01, data->pin_reference);
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  749|      0|			apdu.cla = 0x80;
  750|      0|			apdu.resp = recvbuf;
  751|      0|			apdu.resplen = sizeof recvbuf;
  752|      0|			apdu.le = 0;
  753|      0|			if (sc_transmit_apdu(card, &apdu) != SC_SUCCESS
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (753:8): [True: 0, False: 0]
  ------------------
  754|      0|					|| sc_check_sw(card, apdu.sw1, apdu.sw2) != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (754:9): [True: 0, False: 0]
  ------------------
  755|      0|				sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  756|      0|						"Generating session PIN failed");
  757|      0|				LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  758|      0|			}
  759|      0|			if (data->pin2.data && pin2_len > 0) {
  ------------------
  |  Branch (759:8): [True: 0, False: 0]
  |  Branch (759:27): [True: 0, False: 0]
  ------------------
  760|      0|				if (pin2_len >= apdu.resplen) {
  ------------------
  |  Branch (760:9): [True: 0, False: 0]
  ------------------
  761|      0|					memcpy((unsigned char *) data->pin2.data, apdu.resp,
  762|      0|							apdu.resplen);
  763|      0|					data->pin2.len = apdu.resplen;
  764|      0|				} else {
  765|      0|					sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  766|      0|							"Buffer too small for session PIN");
  767|      0|				}
  768|      0|			}
  769|      0|		} else {
  770|      0|			sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  771|      0|					"Session PIN not supported for this PIN (0x%02X)",
  772|      0|					data->pin_reference);
  773|      0|		}
  774|      0|	}
  775|     94|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     94|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     94|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     94|	int _ret = r; \
  |  |  |  |  155|     94|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 94, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     94|		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: 94]
  |  |  |  |  ------------------
  |  |  |  |  157|     94|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     94|	} 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|     94|	return _ret; \
  |  |  |  |  163|     94|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  776|     94|}
card-sc-hsm.c:sc_hsm_perform_chip_authentication:
  492|     11|{
  493|     11|	int r, protocol;
  494|     11|	sc_path_t path;
  495|     11|	u8 all_certs[1024];
  496|     11|	EAC_CTX *ctx = NULL;
  497|     11|	size_t all_certs_len = sizeof all_certs, left, device_cert_len, issuer_cert_len;
  498|     11|	const unsigned char *cert = all_certs, *device_cert, *issuer_cert;
  499|     11|	BUF_MEM *comp_pub_key = NULL;
  500|     11|	sc_cvc_t cvc_device, cvc_issuer;
  501|       |	/* this is only needed to call sc_pkcs15emu_sc_hsm_decode_cvc */
  502|     11|	sc_pkcs15_card_t p15card;
  503|     11|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
  504|       |	/* we know that sc_pkcs15emu_sc_hsm_decode_cvc does not require anything
  505|       |	 * else to be initialized than p15card->card */
  506|     11|	p15card.card = card;
  507|       |
  508|     11|	memset(&cvc_device, 0, sizeof(cvc_device));
  509|     11|	memset(&cvc_issuer, 0, sizeof(cvc_issuer));
  510|       |
  511|       |
  512|     11|	if (priv->EF_C_DevAut && priv->EF_C_DevAut_len) {
  ------------------
  |  Branch (512:6): [True: 0, False: 11]
  |  Branch (512:27): [True: 0, False: 0]
  ------------------
  513|      0|		all_certs_len = priv->EF_C_DevAut_len;
  514|      0|		cert = priv->EF_C_DevAut;
  515|     11|	} else {
  516|       |		/* get issuer and device certificate from the card */
  517|     11|		r = sc_path_set(&path, SC_PATH_TYPE_FILE_ID, (u8 *) "\x2F\x02", 2, 0, 0);
  ------------------
  |  |  117|     11|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  518|     11|		if (r < 0)
  ------------------
  |  Branch (518:7): [True: 0, False: 11]
  ------------------
  519|      0|			goto err;
  520|     11|		r = sc_select_file(card, &path, NULL);
  521|     11|		if (r < 0)
  ------------------
  |  Branch (521:7): [True: 8, False: 3]
  ------------------
  522|      8|			goto err;
  523|      3|		r = sc_read_binary(card, 0, all_certs, all_certs_len, 0);
  524|      3|		if (r < 0)
  ------------------
  |  Branch (524:7): [True: 1, False: 2]
  ------------------
  525|      1|			goto err;
  526|      2|		if (r == 0) {
  ------------------
  |  Branch (526:7): [True: 1, False: 1]
  ------------------
  527|      1|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      1|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  528|      1|			goto err;
  529|      1|		}
  530|       |
  531|      1|		all_certs_len = r;
  532|       |
  533|       |		/* save EF_C_DevAut for further use */
  534|      1|		cert = realloc(priv->EF_C_DevAut, all_certs_len);
  535|      1|		if (cert) {
  ------------------
  |  Branch (535:7): [True: 1, False: 0]
  ------------------
  536|      1|			memcpy((unsigned char *) cert, all_certs, all_certs_len);
  537|      1|			priv->EF_C_DevAut = (unsigned char *) cert;
  538|      1|			priv->EF_C_DevAut_len = all_certs_len;
  539|      1|		}
  540|       |
  541|      1|		cert = all_certs;
  542|      1|	}
  543|      1|	left = all_certs_len;
  544|       |
  545|      1|	device_cert = cert;
  546|      1|	r = sc_pkcs15emu_sc_hsm_decode_cvc(&p15card, &cert, &left, &cvc_device);
  547|      1|	if (r < 0)
  ------------------
  |  Branch (547:6): [True: 1, False: 0]
  ------------------
  548|      1|		goto err;
  549|      0|	device_cert_len = all_certs_len - left;
  550|       |
  551|      0|	issuer_cert = cert;
  552|      0|	r = sc_pkcs15emu_sc_hsm_decode_cvc(&p15card, &cert, &left, &cvc_issuer);
  553|      0|	if (r < 0)
  ------------------
  |  Branch (553:6): [True: 0, False: 0]
  ------------------
  554|      0|		goto err;
  555|      0|	issuer_cert_len = all_certs_len - device_cert_len - left;
  556|       |
  557|      0|	ctx = EAC_CTX_new();
  558|      0|	if (!ctx) {
  ------------------
  |  Branch (558:6): [True: 0, False: 0]
  ------------------
  559|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  560|      0|		goto err;
  561|      0|	}
  562|       |
  563|       |	/* FIXME set flags with opensc.conf */
  564|      0|	TA_disable_checks(ctx);
  565|      0|	CA_disable_passive_authentication(ctx);
  566|       |
  567|       |	/* check all CVCs given of the document's pki */
  568|      0|	if (!TA_STEP2_import_certificate(ctx, issuer_cert, issuer_cert_len)
  ------------------
  |  Branch (568:6): [True: 0, False: 0]
  ------------------
  569|      0|			|| !TA_STEP2_import_certificate(ctx, device_cert, device_cert_len)) {
  ------------------
  |  Branch (569:7): [True: 0, False: 0]
  ------------------
  570|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  571|      0|		goto err;
  572|      0|	}
  573|       |
  574|       |	/* XXX on older JCOPs only NID_id_CA_ECDH_3DES_CBC_CBC may be
  575|       |	 * supported. The card does not export its capabilities. We hardcode
  576|       |	 * NID_id_CA_ECDH_AES_CBC_CMAC_128 here, because we don't have the older
  577|       |	 * cards in production. */
  578|      0|	protocol = NID_id_CA_ECDH_AES_CBC_CMAC_128;
  579|       |
  580|       |	/* initialize CA domain parameter with the document's public key */
  581|      0|	if (!EAC_CTX_init_ca(ctx, protocol, 8)) {
  ------------------
  |  Branch (581:6): [True: 0, False: 0]
  ------------------
  582|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  583|      0|		goto err;
  584|      0|	}
  585|      0|	EVP_PKEY_free(ctx->ca_ctx->ka_ctx->key);
  586|      0|	if (!EVP_PKEY_up_ref(ctx->ta_ctx->pub_key)) {
  ------------------
  |  Branch (586:6): [True: 0, False: 0]
  ------------------
  587|      0|		sc_log_openssl(card->ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  588|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  589|      0|		goto err;
  590|      0|	}
  591|      0|	ctx->ca_ctx->ka_ctx->key = ctx->ta_ctx->pub_key;
  592|       |
  593|       |	/* generate keys for CA */
  594|      0|	comp_pub_key = TA_STEP3_generate_ephemeral_key(ctx);
  595|      0|	r = perform_chip_authentication_ex(card, ctx,
  596|      0|			cvc_device.publicPoint, cvc_device.publicPointlen);
  597|       |
  598|     11|err:
  599|     11|	if (r < 0)
  ------------------
  |  Branch (599:6): [True: 11, False: 0]
  ------------------
  600|     11|		EAC_CTX_clear_free(ctx);
  601|     11|	if (comp_pub_key)
  ------------------
  |  Branch (601:6): [True: 0, False: 11]
  ------------------
  602|      0|		BUF_MEM_free(comp_pub_key);
  603|     11|	sc_pkcs15emu_sc_hsm_free_cvc(&cvc_device);
  604|     11|	sc_pkcs15emu_sc_hsm_free_cvc(&cvc_issuer);
  605|       |
  606|     11|	return r;
  607|      0|}

sc_get_setcos_driver:
 1136|  17.0k|{
 1137|  17.0k|	return sc_get_driver();
 1138|  17.0k|}
card-setcos.c:sc_get_driver:
 1116|  17.0k|{
 1117|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1118|       |
 1119|  17.0k|	setcos_ops = *iso_drv->ops;
 1120|  17.0k|	setcos_ops.match_card = setcos_match_card;
 1121|  17.0k|	setcos_ops.init = setcos_init;
 1122|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1122:6): [True: 1, False: 17.0k]
  ------------------
 1123|      1|		iso_ops = iso_drv->ops;
 1124|  17.0k|	setcos_ops.create_file = setcos_create_file;
 1125|  17.0k|	setcos_ops.set_security_env = setcos_set_security_env;
 1126|  17.0k|	setcos_ops.select_file = setcos_select_file;
 1127|  17.0k|	setcos_ops.list_files = setcos_list_files;
 1128|  17.0k|	setcos_ops.process_fci = setcos_process_fci;
 1129|  17.0k|	setcos_ops.construct_fci = setcos_construct_fci;
 1130|  17.0k|	setcos_ops.card_ctl = setcos_card_ctl;
 1131|       |
 1132|  17.0k|	return &setcos_drv;
 1133|  17.0k|}
card-setcos.c:setcos_match_card:
   83|  6.46k|{
   84|  6.46k|	sc_apdu_t apdu;
   85|  6.46k|	u8 buf[6];
   86|  6.46k|	int i;
   87|       |
   88|  6.46k|	i = _sc_match_atr(card, setcos_atrs, &card->type);
   89|  6.46k|	if (i < 0) {
  ------------------
  |  Branch (89:6): [True: 6.45k, False: 10]
  ------------------
   90|  6.45k|		if (match_hist_bytes(card, "FISE", 0)) {
  ------------------
  |  Branch (90:7): [True: 106, False: 6.34k]
  ------------------
   91|    106|			card->type = SC_CARD_TYPE_SETCOS_GENERIC;
   92|    106|			return 1;
   93|    106|		}
   94|       |		/* Check if it's a EID2.x applet by reading the version info */
   95|  6.34k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0xDF, 0x30);
  ------------------
  |  |  292|  6.34k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
   96|  6.34k|		apdu.cla = 0x00;
   97|  6.34k|		apdu.resp = buf;
   98|  6.34k|		apdu.resplen = 5;
   99|  6.34k|		apdu.le = 5;
  100|  6.34k|		i = sc_transmit_apdu(card, &apdu);
  101|  6.34k|		if (i == 0 && apdu.sw1 == 0x90 && apdu.sw2 == 0x00 && apdu.resplen == 5) {
  ------------------
  |  Branch (101:7): [True: 6.00k, False: 344]
  |  Branch (101:17): [True: 422, False: 5.58k]
  |  Branch (101:37): [True: 409, False: 13]
  |  Branch (101:57): [True: 307, False: 102]
  ------------------
  102|    307|			if (memcmp(buf, "v2.0", 4) == 0)
  ------------------
  |  Branch (102:8): [True: 170, False: 137]
  ------------------
  103|    170|				card->type = SC_CARD_TYPE_SETCOS_EID_V2_0;
  104|    137|			else if (memcmp(buf, "v2.1", 4) == 0)
  ------------------
  |  Branch (104:13): [True: 108, False: 29]
  ------------------
  105|    108|				card->type = SC_CARD_TYPE_SETCOS_EID_V2_1;
  106|     29|			else {
  107|     29|				buf[sizeof(buf) - 1] = '\0';
  108|     29|				sc_log(card->ctx,  "SetCOS EID applet %s is not supported", (char *) buf);
  ------------------
  |  |   71|     29|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  109|     29|				return 0;
  110|     29|			}
  111|    278|			return 1;
  112|    307|		}
  113|       |
  114|  6.04k|		return 0;
  115|  6.34k|	}
  116|     10|	card->flags = setcos_atrs[i].flags;
  117|     10|	return 1;
  118|  6.46k|}
card-setcos.c:match_hist_bytes:
   64|  6.45k|{
   65|  6.45k|	const char *src = (const char *) card->reader->atr_info.hist_bytes;
   66|  6.45k|	size_t srclen = card->reader->atr_info.hist_bytes_len;
   67|  6.45k|	size_t offset = 0;
   68|       |
   69|  6.45k|	if (len == 0)
  ------------------
  |  Branch (69:6): [True: 6.45k, False: 0]
  ------------------
   70|  6.45k|		len = strlen(str);
   71|  6.45k|	if (srclen < len)
  ------------------
  |  Branch (71:6): [True: 5.02k, False: 1.42k]
  ------------------
   72|  5.02k|		return 0;
   73|  10.2k|	while (srclen - offset > len) {
  ------------------
  |  Branch (73:9): [True: 8.92k, False: 1.31k]
  ------------------
   74|  8.92k|		if (memcmp(src + offset, str, len) == 0) {
  ------------------
  |  Branch (74:7): [True: 106, False: 8.82k]
  ------------------
   75|    106|			return 1;
   76|    106|		}
   77|  8.82k|		offset++;
   78|  8.82k|	}
   79|  1.31k|	return 0;
   80|  1.42k|}
card-setcos.c:setcos_init:
  133|    394|{
  134|    394|	card->name = "SetCOS";
  135|       |
  136|       |	/* Handle unknown or forced cards */
  137|    394|	if (card->type < 0) {
  ------------------
  |  Branch (137:6): [True: 0, False: 394]
  ------------------
  138|      0|		card->type = SC_CARD_TYPE_SETCOS_GENERIC;
  139|      0|	}
  140|       |
  141|    394|	switch (card->type) {
  142|      0|	case SC_CARD_TYPE_SETCOS_NIDEL:
  ------------------
  |  Branch (142:2): [True: 0, False: 394]
  ------------------
  143|      0|		card->cla = 0x00;
  144|      0|		select_pkcs15_app(card);
  145|      0|		if (card->flags & SC_CARD_FLAG_RNG)
  ------------------
  |  |  536|      0|#define SC_CARD_FLAG_RNG		0x00000002
  ------------------
  |  Branch (145:7): [True: 0, False: 0]
  ------------------
  146|      0|			card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|      0|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  147|      0|		break;
  148|      9|	case SC_CARD_TYPE_SETCOS_44:
  ------------------
  |  Branch (148:2): [True: 9, False: 385]
  ------------------
  149|    179|	case SC_CARD_TYPE_SETCOS_EID_V2_0:
  ------------------
  |  Branch (149:2): [True: 170, False: 224]
  ------------------
  150|    287|	case SC_CARD_TYPE_SETCOS_EID_V2_1:
  ------------------
  |  Branch (150:2): [True: 108, False: 286]
  ------------------
  151|    287|		card->cla = 0x00;
  152|    287|		card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  557|    287|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  153|    287|		card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    287|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  154|    287|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|    287|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  155|    287|		break;
  156|    107|	default:
  ------------------
  |  Branch (156:2): [True: 107, False: 287]
  ------------------
  157|       |		/* XXX: Get SetCOS version */
  158|    107|		card->cla = 0x80;	/* SetCOS 4.3.x */
  159|       |		/* State that we have an RNG */
  160|    107|		card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    107|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  161|    107|		break;
  162|    394|	}
  163|       |
  164|    394|	switch (card->type) {
  ------------------
  |  Branch (164:10): [True: 288, False: 106]
  ------------------
  165|      1|	case SC_CARD_TYPE_SETCOS_PKI: {
  ------------------
  |  Branch (165:2): [True: 1, False: 393]
  ------------------
  166|      1|		unsigned long flags;
  167|       |
  168|      1|		flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  102|      1|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              		flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|      1|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|      1|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|      1|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  169|      1|		flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  133|      1|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              		flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|      1|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  170|       |
  171|      1|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  172|      1|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  173|      1|	} break;
  174|      9|	case SC_CARD_TYPE_SETCOS_44:
  ------------------
  |  Branch (174:2): [True: 9, False: 385]
  ------------------
  175|      9|	case SC_CARD_TYPE_SETCOS_NIDEL:
  ------------------
  |  Branch (175:2): [True: 0, False: 394]
  ------------------
  176|    179|	case SC_CARD_TYPE_SETCOS_EID_V2_0:
  ------------------
  |  Branch (176:2): [True: 170, False: 224]
  ------------------
  177|    287|	case SC_CARD_TYPE_SETCOS_EID_V2_1:
  ------------------
  |  Branch (177:2): [True: 108, False: 286]
  ------------------
  178|    287|		{
  179|    287|			unsigned long flags;
  180|       |
  181|    287|			flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  102|    287|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              			flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|    287|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    287|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    287|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  182|    287|			flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  133|    287|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              			flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|    287|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  183|    287|			flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |   93|    287|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  184|       |
  185|    287|			_sc_card_add_rsa_alg(card, 512, flags, 0);
  186|    287|			_sc_card_add_rsa_alg(card, 768, flags, 0);
  187|    287|			_sc_card_add_rsa_alg(card, 1024, flags, 0);
  188|    287|			_sc_card_add_rsa_alg(card, 2048, flags, 0);
  189|    287|		}
  190|    287|		break;
  191|    394|	}
  192|    394|	return 0;
  193|    394|}
card-setcos.c:setcos_select_file:
  901|  2.64k|{
  902|  2.64k|	int r;
  903|       |
  904|  2.64k|	r = iso_ops->select_file(card, in_path, file);
  905|  2.64k|	if (r)
  ------------------
  |  Branch (905:6): [True: 1.80k, False: 841]
  ------------------
  906|  1.80k|		return r;
  907|    841|	if (file != NULL) {
  ------------------
  |  Branch (907:6): [True: 570, False: 271]
  ------------------
  908|    570|		if (card->type == SC_CARD_TYPE_SETCOS_44 ||
  ------------------
  |  Branch (908:7): [True: 14, False: 556]
  ------------------
  909|    556|		    card->type == SC_CARD_TYPE_SETCOS_NIDEL ||
  ------------------
  |  Branch (909:7): [True: 0, False: 556]
  ------------------
  910|    556|		    SETCOS_IS_EID_APPLET(card))
  ------------------
  |  |   46|    556|#define SETCOS_IS_EID_APPLET(card) ((card)->type == SC_CARD_TYPE_SETCOS_EID_V2_0 || (card)->type == SC_CARD_TYPE_SETCOS_EID_V2_1)
  |  |  ------------------
  |  |  |  Branch (46:37): [True: 290, False: 266]
  |  |  |  Branch (46:85): [True: 153, False: 113]
  |  |  ------------------
  ------------------
  911|    457|			parse_sec_attr_44(*file, (*file)->sec_attr, (*file)->sec_attr_len);
  912|    113|		else
  913|    113|			parse_sec_attr(*file, (*file)->sec_attr, (*file)->sec_attr_len);
  914|    570|	}
  915|    841|	return 0;
  916|  2.64k|}
card-setcos.c:parse_sec_attr_44:
  746|    457|{
  747|       |	/* OpenSc Operation values for each command operation-type */
  748|    457|	const int df_idx[8] = {	 /* byte 1 = OpenSC type of AC Bit0,  byte 2 = OpenSC type of AC Bit1 ...*/
  749|    457|		SC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,
  ------------------
  |  |  168|    457|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,
  ------------------
  |  |  169|    457|#define SC_AC_OP_CREATE			3
  ------------------
              		SC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,
  ------------------
  |  |  169|    457|#define SC_AC_OP_CREATE			3
  ------------------
  750|    457|		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  171|    457|#define SC_AC_OP_INVALIDATE		5
  ------------------
              		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|    457|#define SC_AC_OP_REHABILITATE		4
  ------------------
  751|    457|		SC_AC_OP_LOCK, SC_AC_OP_DELETE, -1};
  ------------------
  |  |  167|    457|#define SC_AC_OP_LOCK			1
  ------------------
              		SC_AC_OP_LOCK, SC_AC_OP_DELETE, -1};
  ------------------
  |  |  168|    457|#define SC_AC_OP_DELETE			2
  ------------------
  752|    457|	const int ef_idx[8] = {
  753|    457|		SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  188|    457|#define SC_AC_OP_READ			22
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  189|    457|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  190|    457|#define SC_AC_OP_WRITE			24
  ------------------
  754|    457|		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  171|    457|#define SC_AC_OP_INVALIDATE		5
  ------------------
              		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|    457|#define SC_AC_OP_REHABILITATE		4
  ------------------
  755|    457|		-1, SC_AC_OP_ERASE, -1};
  ------------------
  |  |  202|    457|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|    457|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  756|    457|	const int efi_idx[8] = { /* internal EF used for RSA keys */
  757|    457|		SC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,
  ------------------
  |  |  188|    457|#define SC_AC_OP_READ			22
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,
  ------------------
  |  |  202|    457|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|    457|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,
  ------------------
  |  |  189|    457|#define SC_AC_OP_UPDATE			23
  ------------------
  758|    457|		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  171|    457|#define SC_AC_OP_INVALIDATE		5
  ------------------
              		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|    457|#define SC_AC_OP_REHABILITATE		4
  ------------------
  759|    457|		-1, SC_AC_OP_ERASE, -1};
  ------------------
  |  |  202|    457|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|    457|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  760|       |
  761|    457|	u8		bValue;
  762|    457|	int		i;
  763|    457|	int		iKeyRef = 0;
  764|    457|	int		iMethod;
  765|    457|	int		iPinCount;
  766|    457|	int		iOffset = 0;
  767|    457|	int		iOperation;
  768|    457|	const int*	p_idx;
  769|       |
  770|       |	/* Check all sub-AC definitions within the total AC */
  771|  1.98k|	while (len > 1 && (size_t)iOffset < len) {	/* minimum length = 2 */
  ------------------
  |  Branch (771:9): [True: 1.68k, False: 298]
  |  Branch (771:20): [True: 1.57k, False: 116]
  ------------------
  772|  1.57k|		size_t iACLen   = buf[iOffset] & 0x0F;
  773|  1.57k|		if (iACLen >= len)
  ------------------
  |  Branch (773:7): [True: 34, False: 1.53k]
  ------------------
  774|     34|			break;
  775|       |
  776|  1.53k|		iMethod = SC_AC_NONE;		/* default no authentication required */
  ------------------
  |  |  150|  1.53k|#define SC_AC_NONE			0x00000000
  ------------------
  777|       |
  778|  1.53k|		if (buf[iOffset] & 0X80) { /* AC in adaptive coding */
  ------------------
  |  Branch (778:7): [True: 503, False: 1.03k]
  ------------------
  779|       |			/* Evaluates only the command-byte, not the optional P1/P2/Option bytes */
  780|    503|			size_t	iParmLen = 1;			/* command-byte is always present */
  781|    503|			size_t	iKeyLen  = 0;			/* Encryption key is optional */
  782|       |
  783|    503|			if (buf[iOffset]   & 0x20) iKeyLen++;
  ------------------
  |  Branch (783:8): [True: 336, False: 167]
  ------------------
  784|    503|			if (buf[iOffset+1] & 0x40) iParmLen++;
  ------------------
  |  Branch (784:8): [True: 199, False: 304]
  ------------------
  785|    503|			if (buf[iOffset+1] & 0x20) iParmLen++;
  ------------------
  |  Branch (785:8): [True: 260, False: 243]
  ------------------
  786|    503|			if (buf[iOffset+1] & 0x10) iParmLen++;
  ------------------
  |  Branch (786:8): [True: 197, False: 306]
  ------------------
  787|    503|			if (buf[iOffset+1] & 0x08) iParmLen++;
  ------------------
  |  Branch (787:8): [True: 71, False: 432]
  ------------------
  788|       |
  789|       |			/* Get KeyNumber if available */
  790|    503|			if(iKeyLen) {
  ------------------
  |  Branch (790:7): [True: 336, False: 167]
  ------------------
  791|    336|				int iSC;
  792|    336|				if (len < 1 + iACLen)
  ------------------
  |  Branch (792:9): [True: 0, False: 336]
  ------------------
  793|      0|					break;
  794|    336|				iSC = buf[iOffset+iACLen];
  795|       |
  796|    336|				switch( (iSC>>5) & 0x03 ){
  ------------------
  |  Branch (796:13): [True: 336, False: 0]
  ------------------
  797|     50|				case 0:
  ------------------
  |  Branch (797:5): [True: 50, False: 286]
  ------------------
  798|     50|					iMethod = SC_AC_TERM;		/* key authentication */
  ------------------
  |  |  152|     50|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  799|     50|					break;
  800|    132|				case 1:
  ------------------
  |  Branch (800:5): [True: 132, False: 204]
  ------------------
  801|    132|					iMethod = SC_AC_AUT;		/* key authentication  */
  ------------------
  |  |  154|    132|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  802|    132|					break;
  803|     43|				case 2:
  ------------------
  |  Branch (803:5): [True: 43, False: 293]
  ------------------
  804|    154|				case 3:
  ------------------
  |  Branch (804:5): [True: 111, False: 225]
  ------------------
  805|    154|					iMethod = SC_AC_PRO;		/* secure messaging */
  ------------------
  |  |  153|    154|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  806|    154|					break;
  807|    336|				}
  808|    336|				iKeyRef = iSC & 0x1F;			/* get key number */
  809|    336|			}
  810|       |
  811|       |			/* Get PinNumber if available */
  812|    503|			if (iACLen > (1+iParmLen+iKeyLen)) {  /* check via total length if pin is present */
  ------------------
  |  Branch (812:8): [True: 57, False: 446]
  ------------------
  813|     57|				if (len < 1+1+1+(size_t)iParmLen)
  ------------------
  |  Branch (813:9): [True: 0, False: 57]
  ------------------
  814|      0|					break;
  815|     57|				iKeyRef = buf[iOffset+1+1+iParmLen];  /* PTL + AM-header + parameter-bytes */
  816|     57|				iMethod = SC_AC_CHV;
  ------------------
  |  |  151|     57|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  817|     57|			}
  818|       |
  819|       |			/* Convert SETCOS command to OpenSC command group */
  820|    503|			if (len < 1+2)
  ------------------
  |  Branch (820:8): [True: 9, False: 494]
  ------------------
  821|      9|				break;
  822|    494|			switch(buf[iOffset+2]){
  823|     11|			case 0x2A:			/* crypto operation */
  ------------------
  |  Branch (823:4): [True: 11, False: 483]
  ------------------
  824|     11|				iOperation = SC_AC_OP_CRYPTO;
  ------------------
  |  |  173|     11|#define SC_AC_OP_CRYPTO			7
  ------------------
  825|     11|				break;
  826|     19|			case 0x46:			/* key-generation operation */
  ------------------
  |  Branch (826:4): [True: 19, False: 475]
  ------------------
  827|     19|				iOperation = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|     19|#define SC_AC_OP_UPDATE			23
  ------------------
  828|     19|				break;
  829|    464|			default:
  ------------------
  |  Branch (829:4): [True: 464, False: 30]
  ------------------
  830|    464|				iOperation = SC_AC_OP_SELECT;
  ------------------
  |  |  166|    464|#define SC_AC_OP_SELECT			0
  ------------------
  831|    464|				break;
  832|    494|			}
  833|    494|			sc_file_add_acl_entry(file, iOperation, iMethod, iKeyRef);
  834|    494|		}
  835|  1.03k|		else { /* AC in simple coding */
  836|       |			   /* Initial AC is treated as an operational AC */
  837|       |
  838|       |			/* Get specific Cmd groups for specified file-type */
  839|  1.03k|			switch (file->type) {
  840|     72|			case SC_FILE_TYPE_DF:            /* DF */
  ------------------
  |  |  214|     72|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (840:4): [True: 72, False: 962]
  ------------------
  841|     72|				p_idx = df_idx;
  842|     72|				break;
  843|     70|			case SC_FILE_TYPE_INTERNAL_EF:   /* EF for RSA keys */
  ------------------
  |  |  215|     70|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (843:4): [True: 70, False: 964]
  ------------------
  844|     70|				p_idx = efi_idx;
  845|     70|				break;
  846|    892|			default:                         /* EF */
  ------------------
  |  Branch (846:4): [True: 892, False: 142]
  ------------------
  847|    892|				p_idx = ef_idx;
  848|    892|				break;
  849|  1.03k|			}
  850|       |
  851|       |			/* Encryption key present ? */
  852|  1.03k|			iPinCount = iACLen > 0 ? (int)iACLen - 1 : 0;
  ------------------
  |  Branch (852:16): [True: 395, False: 639]
  ------------------
  853|       |
  854|  1.03k|			if (buf[iOffset] & 0x20) {
  ------------------
  |  Branch (854:8): [True: 573, False: 461]
  ------------------
  855|    573|				int iSC;
  856|    573|				if (len < 1 + (size_t)iACLen)
  ------------------
  |  Branch (856:9): [True: 0, False: 573]
  ------------------
  857|      0|					break;
  858|    573|				iSC = buf[iOffset + iACLen];
  859|       |
  860|    573|				switch( (iSC>>5) & 0x03 ) {
  ------------------
  |  Branch (860:13): [True: 573, False: 0]
  ------------------
  861|     84|				case 0:
  ------------------
  |  Branch (861:5): [True: 84, False: 489]
  ------------------
  862|     84|					iMethod = SC_AC_TERM;		/* key authentication */
  ------------------
  |  |  152|     84|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  863|     84|					break;
  864|    173|				case 1:
  ------------------
  |  Branch (864:5): [True: 173, False: 400]
  ------------------
  865|    173|					iMethod = SC_AC_AUT;		/* key authentication  */
  ------------------
  |  |  154|    173|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  866|    173|					break;
  867|     46|				case 2:
  ------------------
  |  Branch (867:5): [True: 46, False: 527]
  ------------------
  868|    316|				case 3:
  ------------------
  |  Branch (868:5): [True: 270, False: 303]
  ------------------
  869|    316|					iMethod = SC_AC_PRO;		/* secure messaging */
  ------------------
  |  |  153|    316|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  870|    316|					break;
  871|    573|				}
  872|    573|				iKeyRef = iSC & 0x1F;			/* get key number */
  873|       |
  874|    573|				iPinCount--;				/* one byte used for keyReference  */
  875|    573|			}
  876|       |
  877|       |			/* Pin present ? */
  878|  1.03k|			if ( iPinCount > 0 ) {
  ------------------
  |  Branch (878:9): [True: 181, False: 853]
  ------------------
  879|    181|				if (len < 1 + 2)
  ------------------
  |  Branch (879:9): [True: 0, False: 181]
  ------------------
  880|      0|					break;
  881|    181|				iKeyRef = buf[iOffset + 2];	/* pin ref */
  882|    181|				iMethod = SC_AC_CHV;
  ------------------
  |  |  151|    181|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  883|    181|			}
  884|       |
  885|       |			/* Add AC for each command-operationType into OpenSc structure */
  886|  1.03k|			bValue = buf[iOffset + 1];
  887|  9.30k|			for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (887:16): [True: 8.27k, False: 1.03k]
  ------------------
  888|  8.27k|				if((bValue & 1) && (p_idx[i] >= 0))
  ------------------
  |  Branch (888:8): [True: 2.34k, False: 5.92k]
  |  Branch (888:24): [True: 1.76k, False: 581]
  ------------------
  889|  1.76k|					sc_file_add_acl_entry(file, p_idx[i], iMethod, iKeyRef);
  890|  8.27k|				bValue >>= 1;
  891|  8.27k|			}
  892|  1.03k|		}
  893|       |		/* Current field treated, get next AC sub-field */
  894|  1.52k|		iOffset += iACLen +1;		/* AC + PTL-byte */
  895|  1.52k|		len     -= iACLen +1;
  896|  1.52k|	}
  897|    457|}
card-setcos.c:parse_sec_attr:
  718|    113|{
  719|    113|	int i;
  720|    113|	int idx[6];
  721|       |
  722|    113|	if (len < 6)
  ------------------
  |  Branch (722:6): [True: 76, False: 37]
  ------------------
  723|     76|		return;
  724|     37|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     37|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (724:6): [True: 6, False: 31]
  ------------------
  725|      6|		const int df_idx[6] = {
  726|      6|			SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
  ------------------
  |  |  166|      6|#define SC_AC_OP_SELECT			0
  ------------------
              			SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
  ------------------
  |  |  167|      6|#define SC_AC_OP_LOCK			1
  ------------------
              			SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
  ------------------
  |  |  168|      6|#define SC_AC_OP_DELETE			2
  ------------------
  727|      6|			SC_AC_OP_CREATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  169|      6|#define SC_AC_OP_CREATE			3
  ------------------
              			SC_AC_OP_CREATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|      6|#define SC_AC_OP_REHABILITATE		4
  ------------------
  728|      6|			SC_AC_OP_INVALIDATE
  ------------------
  |  |  171|      6|#define SC_AC_OP_INVALIDATE		5
  ------------------
  729|      6|		};
  730|     42|		for (i = 0; i < 6; i++)
  ------------------
  |  Branch (730:15): [True: 36, False: 6]
  ------------------
  731|     36|			idx[i] = df_idx[i];
  732|     31|	} else {
  733|     31|		const int ef_idx[6] = {
  734|     31|			SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  188|     31|#define SC_AC_OP_READ			22
  ------------------
              			SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  189|     31|#define SC_AC_OP_UPDATE			23
  ------------------
              			SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  190|     31|#define SC_AC_OP_WRITE			24
  ------------------
  735|     31|			SC_AC_OP_ERASE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  202|     31|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     31|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
              			SC_AC_OP_ERASE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|     31|#define SC_AC_OP_REHABILITATE		4
  ------------------
  736|     31|			SC_AC_OP_INVALIDATE
  ------------------
  |  |  171|     31|#define SC_AC_OP_INVALIDATE		5
  ------------------
  737|     31|		};
  738|    217|		for (i = 0; i < 6; i++)
  ------------------
  |  Branch (738:15): [True: 186, False: 31]
  ------------------
  739|    186|			idx[i] = ef_idx[i];
  740|     31|	}
  741|    259|	for (i = 0; i < 6; i++)
  ------------------
  |  Branch (741:14): [True: 222, False: 37]
  ------------------
  742|    222|		add_acl_entry(file, idx[i], buf[i]);
  743|     37|}
card-setcos.c:add_acl_entry:
  689|    222|{
  690|    222|	unsigned int method, key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|    222|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  691|       |
  692|    222|	switch (byte >> 4) {
  693|     27|	case 0:
  ------------------
  |  Branch (693:2): [True: 27, False: 195]
  ------------------
  694|     27|		method = SC_AC_NONE;
  ------------------
  |  |  150|     27|#define SC_AC_NONE			0x00000000
  ------------------
  695|     27|		break;
  696|     20|	case 1:
  ------------------
  |  Branch (696:2): [True: 20, False: 202]
  ------------------
  697|     20|		method = SC_AC_CHV;
  ------------------
  |  |  151|     20|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  698|     20|		key_ref = 1;
  699|     20|		break;
  700|     22|	case 2:
  ------------------
  |  Branch (700:2): [True: 22, False: 200]
  ------------------
  701|     22|		method = SC_AC_CHV;
  ------------------
  |  |  151|     22|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  702|     22|		key_ref = 2;
  703|     22|		break;
  704|     41|	case 4:
  ------------------
  |  Branch (704:2): [True: 41, False: 181]
  ------------------
  705|     41|		method = SC_AC_TERM;
  ------------------
  |  |  152|     41|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  706|     41|		break;
  707|     31|	case 15:
  ------------------
  |  Branch (707:2): [True: 31, False: 191]
  ------------------
  708|     31|		method = SC_AC_NEVER;
  ------------------
  |  |  163|     31|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  709|     31|		break;
  710|     81|	default:
  ------------------
  |  Branch (710:2): [True: 81, False: 141]
  ------------------
  711|     81|		method = SC_AC_UNKNOWN;
  ------------------
  |  |  162|     81|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  712|     81|		break;
  713|    222|	}
  714|    222|	sc_file_add_acl_entry(file, op, method, key_ref);
  715|    222|}
card-setcos.c:setcos_process_fci:
  942|    551|{
  943|    551|	int r = iso_ops->process_fci(card, file, buf, buflen);
  944|       |
  945|       |	/* SetCOS 4.4: RSA key file is an internal EF but it's
  946|       |	 * file descriptor doesn't seem to follow ISO7816. */
  947|    551|	if (r >= 0 && (card->type == SC_CARD_TYPE_SETCOS_44 ||
  ------------------
  |  Branch (947:6): [True: 551, False: 0]
  |  Branch (947:17): [True: 14, False: 537]
  ------------------
  948|    537|	               SETCOS_IS_EID_APPLET(card))) {
  ------------------
  |  |   46|    537|#define SETCOS_IS_EID_APPLET(card) ((card)->type == SC_CARD_TYPE_SETCOS_EID_V2_0 || (card)->type == SC_CARD_TYPE_SETCOS_EID_V2_1)
  |  |  ------------------
  |  |  |  Branch (46:37): [True: 280, False: 257]
  |  |  |  Branch (46:85): [True: 149, False: 108]
  |  |  ------------------
  ------------------
  949|    443|		const u8 *tag;
  950|    443|		size_t taglen = 1;
  951|    443|		tag = (u8 *) sc_asn1_find_tag(card->ctx, buf, buflen, 0x82, &taglen);
  952|    443|		if (tag != NULL && taglen == 1 && *tag == 0x11)
  ------------------
  |  Branch (952:7): [True: 112, False: 331]
  |  Branch (952:22): [True: 80, False: 32]
  |  Branch (952:37): [True: 23, False: 57]
  ------------------
  953|     23|			file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     23|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  954|    443|	}
  955|       |
  956|    551|	return r;
  957|    551|}
card-setcos.c:setcos_card_ctl:
 1092|    375|{
 1093|    375|	if (card->type != SC_CARD_TYPE_SETCOS_44 && !SETCOS_IS_EID_APPLET(card))
  ------------------
  |  |   46|    358|#define SETCOS_IS_EID_APPLET(card) ((card)->type == SC_CARD_TYPE_SETCOS_EID_V2_0 || (card)->type == SC_CARD_TYPE_SETCOS_EID_V2_1)
  |  |  ------------------
  |  |  |  Branch (46:37): [True: 78, False: 280]
  |  |  |  Branch (46:85): [True: 38, False: 242]
  |  |  ------------------
  ------------------
  |  Branch (1093:6): [True: 358, False: 17]
  ------------------
 1094|    242|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    242|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1095|       |
 1096|    133|	switch(cmd) {
  ------------------
  |  Branch (1096:9): [True: 0, False: 133]
  ------------------
 1097|      0|	case SC_CARDCTL_SETCOS_PUTDATA:
  ------------------
  |  Branch (1097:2): [True: 0, False: 133]
  ------------------
 1098|      0|		return setcos_putdata(card,
 1099|      0|				(struct sc_cardctl_setcos_data_obj*) ptr);
 1100|      0|		break;
 1101|      0|	case SC_CARDCTL_SETCOS_GETDATA:
  ------------------
  |  Branch (1101:2): [True: 0, False: 133]
  ------------------
 1102|      0|		return setcos_getdata(card,
 1103|      0|				(struct sc_cardctl_setcos_data_obj*) ptr);
 1104|      0|		break;
 1105|      0|	case SC_CARDCTL_SETCOS_GENERATE_STORE_KEY:
  ------------------
  |  Branch (1105:2): [True: 0, False: 133]
  ------------------
 1106|      0|		return setcos_generate_store_key(card,
 1107|      0|				(struct sc_cardctl_setcos_gen_store_key_info *) ptr);
 1108|      0|	case SC_CARDCTL_SETCOS_ACTIVATE_FILE:
  ------------------
  |  Branch (1108:2): [True: 0, False: 133]
  ------------------
 1109|      0|		return setcos_activate_file(card);
 1110|    133|	}
 1111|       |
 1112|    133|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    133|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1113|    133|}

sc_get_skeid_driver:
  179|  17.0k|{
  180|  17.0k|	if (iso_ops == NULL) iso_ops = sc_get_iso7816_driver()->ops;
  ------------------
  |  Branch (180:6): [True: 1, False: 17.0k]
  ------------------
  181|  17.0k|	skeid_ops = *iso_ops;
  182|  17.0k|	skeid_ops.match_card = skeid_match_card;
  183|  17.0k|	skeid_ops.init = skeid_init;
  184|  17.0k|	skeid_ops.set_security_env = skeid_set_security_env;
  185|  17.0k|	skeid_ops.logout = skeid_logout;
  186|  17.0k|	return &skeid_drv;
  187|  17.0k|}
card-skeid.c:skeid_match_card:
   73|  16.3k|{
   74|  16.3k|	if (_sc_match_atr(card, skeid_atrs, &card->type) < 0 || skeid_known_url(card) != SC_SUCCESS)
  ------------------
  |  |   28|     67|#define SC_SUCCESS				0
  ------------------
  |  Branch (74:6): [True: 16.2k, False: 67]
  |  Branch (74:58): [True: 53, False: 14]
  ------------------
   75|  16.3k|		return 0;
   76|       |
   77|     14|	sc_log(card->ctx,  "Slovak eID card v3 (CardOS 5.4)");
  ------------------
  |  |   71|     14|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   78|       |
   79|     14|	return 1;
   80|  16.3k|}
card-skeid.c:skeid_known_url:
   53|     67|{
   54|     67|	const struct sc_aid skeid_aid_eid = {{0xE8, 0x07, 0x04, 0x00, 0x7F, 0x00, 0x07, 0x03, 0x02}, 9};
   55|     67|	const char *known_url = "\x80\x01\x00\x5F\x50\x28http://www.minv.sk/cif/cif-sk-eid-v3.xml";
   56|     67|	u8 buf[SKEID_KNOWN_URL_LEN];
   57|       |
   58|     67|	sc_path_t url_path;
   59|       |
   60|     67|	int r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|     67|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   61|       |
   62|     67|	sc_path_set(&url_path, SC_PATH_TYPE_DF_NAME, skeid_aid_eid.value, skeid_aid_eid.len, 0, 0);
  ------------------
  |  |  118|     67|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
   63|       |
   64|     67|	if (sc_select_file(card, &url_path, NULL) == SC_SUCCESS
  ------------------
  |  |   28|    134|#define SC_SUCCESS				0
  ------------------
  |  Branch (64:6): [True: 41, False: 26]
  ------------------
   65|     41|		&& sc_get_data(card, 0x7F62, buf, SKEID_KNOWN_URL_LEN) == SKEID_KNOWN_URL_LEN
  ------------------
  |  |   30|     41|#define SKEID_KNOWN_URL_LEN 46
  ------------------
              		&& sc_get_data(card, 0x7F62, buf, SKEID_KNOWN_URL_LEN) == SKEID_KNOWN_URL_LEN
  ------------------
  |  |   30|    108|#define SKEID_KNOWN_URL_LEN 46
  ------------------
  |  Branch (65:6): [True: 26, False: 15]
  ------------------
   66|     26|		&& !memcmp(buf, known_url, SKEID_KNOWN_URL_LEN))
  ------------------
  |  |   30|     26|#define SKEID_KNOWN_URL_LEN 46
  ------------------
  |  Branch (66:6): [True: 14, False: 12]
  ------------------
   67|     14|		r = SC_SUCCESS;
  ------------------
  |  |   28|     14|#define SC_SUCCESS				0
  ------------------
   68|       |
   69|     67|	return r;
   70|     67|}
card-skeid.c:skeid_init:
  108|     14|{
  109|     14|	const unsigned long flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  111|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	const unsigned long flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|     14|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  110|     14|	const size_t data_field_length = 437;
  111|     14|	int r;
  112|       |
  113|     14|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     14|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     14|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     14|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 14]
  |  |  ------------------
  ------------------
  114|       |
  115|     14|	card->name = "Slovak eID (CardOS)";
  116|     14|	card->type = SC_CARD_TYPE_SKEID_V3;
  117|     14|	card->cla = 0x00;
  118|       |
  119|     14|	r = skeid_get_serialnr(card);
  120|     14|	LOG_TEST_RET(card->ctx, r, "Error reading serial number.");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  121|       |
  122|      8|	card->caps |= SC_CARD_CAP_APDU_EXT | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  547|      8|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
              	card->caps |= SC_CARD_CAP_APDU_EXT | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|      8|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  123|       |
  124|      8|	card->max_send_size = data_field_length - 6;
  125|       |#ifdef _WIN32
  126|       |	/* see card-cardos.c */
  127|       |	if (card->reader->max_send_size == 255 && card->reader->max_recv_size == 256) {
  128|       |		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "resetting reader to use data_field_length");
  129|       |		card->reader->max_send_size = data_field_length - 6;
  130|       |		card->reader->max_recv_size = data_field_length - 3;
  131|       |	}
  132|       |#endif
  133|       |
  134|      8|	card->max_send_size = sc_get_max_send_size(card); /* see card-cardos.c */
  135|      8|	card->max_recv_size = data_field_length - 2;
  136|      8|	card->max_recv_size = sc_get_max_recv_size(card);
  137|       |
  138|      8|	r = _sc_card_add_rsa_alg(card, 3072, flags, 0);
  139|       |
  140|      8|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|      8|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      8|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      8|	int _ret = r; \
  |  |  |  |  155|      8|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      8|		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: 8]
  |  |  |  |  ------------------
  |  |  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      8|	} 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|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|      8|}
card-skeid.c:skeid_get_serialnr:
   83|     14|{
   84|     14|	int r;
   85|     14|	sc_apdu_t apdu;
   86|     14|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
   87|       |
   88|     14|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x81);
  ------------------
  |  |  292|     14|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
   89|     14|	apdu.resp = rbuf;
   90|     14|	apdu.resplen = sizeof(rbuf);
   91|     14|	apdu.le = 256;
   92|     14|	r = sc_transmit_apdu(card, &apdu);
   93|     14|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   94|     11|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (94:6): [True: 1, False: 10]
  |  Branch (94:26): [True: 1, False: 9]
  ------------------
   95|      2|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      2|#define SC_ERROR_INTERNAL			-1400
  ------------------
   96|      9|	if (apdu.resplen == 8) {
  ------------------
  |  Branch (96:6): [True: 8, False: 1]
  ------------------
   97|       |		/* cache serial number */
   98|      8|		memcpy(card->serialnr.value, rbuf, 8);
   99|      8|		card->serialnr.len = 8;
  100|      8|	} else {
  101|      1|		sc_log(card->ctx, "unexpected response to GET DATA serial number");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  102|      1|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      1|#define SC_ERROR_INTERNAL			-1400
  ------------------
  103|      1|	}
  104|      8|	return SC_SUCCESS;
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  105|      9|}
card-skeid.c:skeid_set_security_env:
  146|      7|{
  147|      7|	int key_id;
  148|      7|	int r;
  149|       |
  150|      7|	if (card == NULL || env == NULL)
  ------------------
  |  Branch (150:6): [True: 0, False: 7]
  |  Branch (150:22): [True: 0, False: 7]
  ------------------
  151|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  152|       |
  153|      7|	if (!(env->flags & SC_SEC_ENV_KEY_REF_PRESENT) || env->key_ref_len != 1) {
  ------------------
  |  |   58|      7|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
  |  Branch (153:6): [True: 0, False: 7]
  |  Branch (153:52): [True: 0, False: 7]
  ------------------
  154|      0|		sc_log(card->ctx, "No or invalid key reference");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  155|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  156|      0|	}
  157|       |
  158|       |	/* here we follow the behaviour of the proprietary driver accompanying the card
  159|       |	 * where security operations are preceded by MSE RESTORE rather than MSE SET
  160|       |	 */
  161|      7|	key_id = env->key_ref[0];
  162|      7|	r = sc_restore_security_env(card, key_id);
  163|       |
  164|      7|	return r;
  165|      7|}

sc_get_srbeid_driver:
  305|  17.0k|{
  306|       |	/* Save ISO ops for delegation, then override what we handle. */
  307|  17.0k|	iso_ops = sc_get_iso7816_driver()->ops;
  308|  17.0k|	srbeid_ops = *iso_ops;
  309|  17.0k|	srbeid_ops.match_card = srbeid_match_card;
  310|  17.0k|	srbeid_ops.init = srbeid_init;
  311|  17.0k|	srbeid_ops.select_file = srbeid_select_file;
  312|  17.0k|	srbeid_ops.set_security_env = srbeid_set_security_env;
  313|  17.0k|	srbeid_ops.compute_signature = srbeid_compute_signature;
  314|  17.0k|	srbeid_ops.decipher = srbeid_decipher;
  315|       |
  316|  17.0k|	return &srbeid_drv;
  317|  17.0k|}
card-srbeid.c:srbeid_match_card:
   72|  8.63k|{
   73|  8.63k|	int i = _sc_match_atr(card, srbeid_atrs, &card->type);
   74|  8.63k|	if (i >= 0 && iso7816_select_aid(card, AID_PKCS15, AID_PKCS15_LEN, NULL, NULL) == SC_SUCCESS) {
  ------------------
  |  |   30|    593|#define AID_PKCS15_LEN (sizeof(AID_PKCS15))
  ------------------
              	if (i >= 0 && iso7816_select_aid(card, AID_PKCS15, AID_PKCS15_LEN, NULL, NULL) == SC_SUCCESS) {
  ------------------
  |  |   28|    593|#define SC_SUCCESS				0
  ------------------
  |  Branch (74:6): [True: 593, False: 8.04k]
  |  Branch (74:16): [True: 380, False: 213]
  ------------------
   75|    380|		card->name = srbeid_atrs[i].name;
   76|    380|		return 1;
   77|    380|	}
   78|  8.25k|	return 0;
   79|  8.63k|}
card-srbeid.c:srbeid_init:
   83|    380|{
   84|    380|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    380|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    380|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    380|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    380|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 380]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   85|       |
   86|    380|	card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    380|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
   87|       |
   88|       |	/* Keep the card's own PKCS#1 signing, and add raw RSA on top: that gives
   89|       |	 * CKM_RSA_X_509 and makes 2048-bit decrypt work (OpenSC does the padding). */
   90|    380|	_sc_card_add_rsa_alg(card, 2048,
   91|    380|			SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_RAW |
  ------------------
  |  |  109|    380|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              			SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_RAW |
  ------------------
  |  |  102|    380|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
   92|    380|					SC_ALGORITHM_RSA_HASH_NONE,
  ------------------
  |  |  133|    380|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
   93|    380|			0);
   94|       |
   95|    380|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    380|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    380|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    380|	int _ret = r; \
  |  |  |  |  155|    380|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 380, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    380|		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: 380]
  |  |  |  |  ------------------
  |  |  |  |  157|    380|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    380|	} 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|    380|	return _ret; \
  |  |  |  |  163|    380|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   96|    380|}
card-srbeid.c:srbeid_select_file:
  112|  3.00k|{
  113|  3.00k|	sc_apdu_t apdu;
  114|  3.00k|	u8 fci[16];
  115|  3.00k|	sc_file_t *file;
  116|  3.00k|	int r;
  117|       |
  118|  3.00k|	if (in_path->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  3.00k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (118:6): [True: 800, False: 2.20k]
  ------------------
  119|    800|		return iso_ops->select_file(card, in_path, file_out);
  120|       |
  121|       |	/* AID-only path (path.len==0, path.aid.len>0): PKCS#15 layer wants
  122|       |	 * to select the applet before a PIN or key operation. */
  123|  2.20k|	if (in_path->len == 0 && in_path->aid.len > 0)
  ------------------
  |  Branch (123:6): [True: 71, False: 2.13k]
  |  Branch (123:27): [True: 71, False: 0]
  ------------------
  124|     71|		return iso7816_select_aid(card, in_path->aid.value,
  125|     71|				in_path->aid.len, NULL, NULL);
  126|       |
  127|  2.13k|	if (in_path->len != 2)
  ------------------
  |  Branch (127:6): [True: 1.14k, False: 993]
  ------------------
  128|  2.13k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|  1.14k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.14k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.14k|	int _ret = r; \
  |  |  |  |  155|  1.14k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.14k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.14k|		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|  1.14k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.14k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.14k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.14k|	} 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|  1.14k|	return _ret; \
  |  |  |  |  163|  1.14k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  129|       |
  130|    993|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|    993|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  131|    993|	apdu.data = in_path->value;
  132|    993|	apdu.datalen = 2;
  133|    993|	apdu.lc = 2;
  134|    993|	apdu.resp = fci;
  135|    993|	apdu.resplen = sizeof(fci);
  136|    993|	apdu.le = 10;
  137|       |
  138|    993|	r = sc_transmit_apdu(card, &apdu);
  139|    993|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    993|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    993|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    993|	int _ret = (r); \
  |  |  |  |  168|    993|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 24, False: 969]
  |  |  |  |  ------------------
  |  |  |  |  169|     24|		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|     24|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     24|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     24|		return _ret; \
  |  |  |  |  172|     24|	} \
  |  |  |  |  173|    993|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 969]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  140|    969|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  141|    969|	LOG_TEST_RET(card->ctx, r, "SELECT FILE failed");
  ------------------
  |  |  174|    969|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    969|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    969|	int _ret = (r); \
  |  |  |  |  168|    969|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 340, False: 629]
  |  |  |  |  ------------------
  |  |  |  |  169|    340|		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|    340|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    340|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    340|		return _ret; \
  |  |  |  |  172|    340|	} \
  |  |  |  |  173|    969|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 629]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  142|       |
  143|    629|	if (apdu.resplen < 4)
  ------------------
  |  Branch (143:6): [True: 39, False: 590]
  ------------------
  144|    629|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     39|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     39|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     39|	int _ret = r; \
  |  |  |  |  155|     39|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 39, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     39|		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|     39|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 39, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     39|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     39|	} 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|     39|	return _ret; \
  |  |  |  |  163|     39|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  145|       |
  146|    590|	if (file_out) {
  ------------------
  |  Branch (146:6): [True: 519, False: 71]
  ------------------
  147|    519|		file = sc_file_new();
  148|    519|		if (!file)
  ------------------
  |  Branch (148:7): [True: 0, False: 519]
  ------------------
  149|    519|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|       |
  151|    519|		file->id = ((unsigned)in_path->value[0] << 8) | in_path->value[1];
  152|    519|		file->path = *in_path;
  153|    519|		file->size = ((size_t)fci[2] << 8) | (size_t)fci[3];
  154|    519|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    519|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  155|    519|		*file_out = file;
  156|    519|	}
  157|       |
  158|    590|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    590|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    590|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    590|	int _ret = r; \
  |  |  |  |  155|    590|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 590, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    590|		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: 590]
  |  |  |  |  ------------------
  |  |  |  |  157|    590|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    590|	} 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|    590|	return _ret; \
  |  |  |  |  163|    590|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|    590|}
card-srbeid.c:srbeid_set_security_env:
  177|     28|{
  178|     28|	sc_apdu_t apdu;
  179|     28|	u8 mse_data[7];
  180|     28|	unsigned key_ref;
  181|     28|	u8 p2;
  182|     28|	int r;
  183|       |
  184|     28|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     28|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     28|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     28|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     28|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  185|     28|	(void)se_num;
  186|       |
  187|       |	/* Extract key FID. */
  188|     28|	if ((env->flags & SC_SEC_ENV_FILE_REF_PRESENT) && env->file_ref.len >= 2) {
  ------------------
  |  |   57|     28|#define SC_SEC_ENV_FILE_REF_PRESENT	0x0002
  ------------------
  |  Branch (188:6): [True: 0, False: 28]
  |  Branch (188:52): [True: 0, False: 0]
  ------------------
  189|      0|		key_ref = ((unsigned)env->file_ref.value[0] << 8) | (unsigned)env->file_ref.value[1];
  190|     28|	} else if ((env->flags & SC_SEC_ENV_KEY_REF_PRESENT) && env->key_ref_len >= 1) {
  ------------------
  |  |   58|     28|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
  |  Branch (190:13): [True: 28, False: 0]
  |  Branch (190:58): [True: 28, False: 0]
  ------------------
  191|     28|		key_ref = CE_KEYS_BASE_FID | (unsigned)env->key_ref[0];
  ------------------
  |  |   33|     28|#define CE_KEYS_BASE_FID 0x6000u
  ------------------
  192|     28|	} else {
  193|      0|		sc_log(card->ctx, "srbeid: set_security_env: no key reference");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  194|      0|		return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  195|      0|	}
  196|       |
  197|       |	/* Determine MSE SET template from operation type. */
  198|     28|	switch (env->operation) {
  199|     18|	case SC_SEC_OPERATION_SIGN:
  ------------------
  |  |   48|     18|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (199:2): [True: 18, False: 10]
  ------------------
  200|     18|		p2 = 0xB6;
  201|     18|		break;
  202|     10|	case SC_SEC_OPERATION_DECIPHER:
  ------------------
  |  |   47|     10|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
  |  Branch (202:2): [True: 10, False: 18]
  ------------------
  203|     10|		p2 = 0xB8;
  204|     10|		break;
  205|      0|	default:
  ------------------
  |  Branch (205:2): [True: 0, False: 28]
  ------------------
  206|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  207|     28|	}
  208|       |
  209|       |	/* MSE SET: tag 0x80 = algorithm, tag 0x84 = key ref (2 bytes BE).
  210|       |	 * The algorithm byte tells the card to pad (PKCS#1) or not (raw RSA). */
  211|     28|	mse_data[0] = 0x80;
  212|     28|	mse_data[1] = 0x01;
  213|     28|	mse_data[2] = (env->algorithm_flags & SC_ALGORITHM_RSA_RAW)
  ------------------
  |  |  102|     28|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  |  Branch (213:16): [True: 25, False: 3]
  ------------------
  214|     28|				      ? CE_MSE_ALG_RSA_RAW
  ------------------
  |  |   37|     25|#define CE_MSE_ALG_RSA_RAW   0x00u /* raw RSA; OpenSC pads */
  ------------------
  215|     28|				      : CE_MSE_ALG_RSA_PKCS1;
  ------------------
  |  |   36|     31|#define CE_MSE_ALG_RSA_PKCS1 0x02u /* card adds PKCS#1 padding */
  ------------------
  216|     28|	mse_data[3] = 0x84;
  217|     28|	mse_data[4] = 0x02;
  218|     28|	mse_data[5] = (u8)((key_ref >> 8) & 0xFF);
  219|     28|	mse_data[6] = (u8)(key_ref & 0xFF);
  220|       |
  221|     28|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x41, p2);
  ------------------
  |  |  293|     28|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  222|     28|	apdu.data = mse_data;
  223|     28|	apdu.datalen = sizeof(mse_data);
  224|     28|	apdu.lc = sizeof(mse_data);
  225|       |
  226|     28|	r = sc_transmit_apdu(card, &apdu);
  227|     28|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     28|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     28|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     28|	int _ret = (r); \
  |  |  |  |  168|     28|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 27]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  228|     27|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  229|     27|	LOG_TEST_RET(card->ctx, r, "MSE SET failed");
  ------------------
  |  |  174|     27|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     27|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     27|	int _ret = (r); \
  |  |  |  |  168|     27|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  169|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     12|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     12|		return _ret; \
  |  |  |  |  172|     12|	} \
  |  |  |  |  173|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  230|       |
  231|     15|	sc_log(card->ctx, "srbeid: set_security_env: key_ref=0x%04x p2=0x%02x algo=0x%02x",
  ------------------
  |  |   71|     15|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  232|     15|			key_ref, p2, mse_data[2]);
  233|     15|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		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: 15]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     15|	} 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|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|     15|}
card-srbeid.c:srbeid_compute_signature:
  282|      6|{
  283|      6|	return srbeid_pso(card, 0x9E, data, datalen, out, outlen);
  284|      6|}
card-srbeid.c:srbeid_pso:
  243|     17|{
  244|     17|	sc_apdu_t apdu;
  245|     17|	u8 resp[256];
  246|     17|	u8 p2 = 0x00;
  247|     17|	int r;
  248|       |
  249|     17|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     17|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     17|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     17|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     17|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  250|       |
  251|     17|	if (datalen == 0 || datalen > sizeof(resp))
  ------------------
  |  Branch (251:6): [True: 0, False: 17]
  |  Branch (251:22): [True: 1, False: 16]
  ------------------
  252|     17|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  253|       |
  254|     16|	if (datalen > SC_MAX_APDU_DATA_SIZE) {
  ------------------
  |  |   35|     16|#define SC_MAX_APDU_DATA_SIZE		0xFF
  ------------------
  |  Branch (254:6): [True: 4, False: 12]
  ------------------
  255|      4|		p2 = data[0];
  256|      4|		++data;
  257|      4|		--datalen;
  258|      4|	}
  259|       |
  260|     16|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, p1, p2);
  ------------------
  |  |  294|     16|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  261|     16|	apdu.data = data;
  262|     16|	apdu.datalen = apdu.lc = datalen;
  263|     16|	apdu.resp = resp;
  264|     16|	apdu.resplen = sizeof(resp);
  265|     16|	apdu.le = sizeof(resp);
  266|       |
  267|     16|	r = sc_transmit_apdu(card, &apdu);
  268|     16|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     16|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     16|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     16|	int _ret = (r); \
  |  |  |  |  168|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  269|     13|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  270|     13|	LOG_TEST_RET(card->ctx, r, "PSO failed");
  ------------------
  |  |  174|     13|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     13|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     13|	int _ret = (r); \
  |  |  |  |  168|     13|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      9|		return _ret; \
  |  |  |  |  172|      9|	} \
  |  |  |  |  173|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|       |
  272|      4|	if (apdu.resplen > outlen)
  ------------------
  |  Branch (272:6): [True: 0, False: 4]
  ------------------
  273|      4|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_BUFFER_TOO_SMALL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  274|      4|	memcpy(out, resp, apdu.resplen);
  275|      4|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|      4|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      4|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      4|	int _ret = r; \
  |  |  |  |  155|      4|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} else { \
  |  |  |  |  159|      3|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      3|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      3|	} \
  |  |  |  |  162|      4|	return _ret; \
  |  |  |  |  163|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  276|      4|}
card-srbeid.c:srbeid_decipher:
  295|      9|{
  296|      9|	int r = srbeid_pso(card, 0x80, crgram, crgram_len, out, outlen);
  297|       |
  298|      9|	if (r == SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   55|      9|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (298:6): [True: 2, False: 7]
  ------------------
  299|      2|		r = srbeid_pso(card, 0x9E, crgram, crgram_len, out, outlen);
  300|      9|	return r;
  301|      9|}

sc_get_starcos_driver:
 2120|  17.0k|{
 2121|  17.0k|	return sc_get_driver();
 2122|  17.0k|}
card-starcos.c:sc_get_driver:
 2095|  17.0k|{
 2096|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2097|  17.0k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2097:6): [True: 1, False: 17.0k]
  ------------------
 2098|      1|		iso_ops = iso_drv->ops;
 2099|       |
 2100|  17.0k|	starcos_ops = *iso_drv->ops;
 2101|  17.0k|	starcos_ops.match_card = starcos_match_card;
 2102|  17.0k|	starcos_ops.init   = starcos_init;
 2103|  17.0k|	starcos_ops.finish = starcos_finish;
 2104|  17.0k|	starcos_ops.select_file = starcos_select_file;
 2105|  17.0k|	starcos_ops.get_challenge = starcos_get_challenge;
 2106|  17.0k|	starcos_ops.check_sw    = starcos_check_sw;
 2107|  17.0k|	starcos_ops.create_file = starcos_create_file;
 2108|  17.0k|	starcos_ops.delete_file = NULL;
 2109|  17.0k|	starcos_ops.set_security_env  = starcos_set_security_env;
 2110|  17.0k|	starcos_ops.compute_signature = starcos_compute_signature;
 2111|  17.0k|	starcos_ops.decipher = starcos_decipher;
 2112|  17.0k|	starcos_ops.card_ctl    = starcos_card_ctl;
 2113|  17.0k|	starcos_ops.logout      = starcos_logout;
 2114|  17.0k|	starcos_ops.pin_cmd     = starcos_pin_cmd;
 2115|       |
 2116|  17.0k|	return &starcos_drv;
 2117|  17.0k|}
card-starcos.c:starcos_match_card:
  125|  15.1k|{
  126|  15.1k|	int i;
  127|       |
  128|  15.1k|	i = _sc_match_atr(card, starcos_atrs, &card->type);
  129|  15.1k|	if (i < 0)
  ------------------
  |  Branch (129:6): [True: 14.1k, False: 929]
  ------------------
  130|  14.1k|		return 0;
  131|    929|	return 1;
  132|  15.1k|}
card-starcos.c:starcos_init:
  359|    929|{
  360|    929|	unsigned int flags;
  361|    929|	starcos_ex_data *ex_data;
  362|       |
  363|    929|	ex_data = calloc(1, sizeof(starcos_ex_data));
  364|    929|	if (ex_data == NULL)
  ------------------
  |  Branch (364:6): [True: 0, False: 929]
  ------------------
  365|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  366|       |
  367|    929|	card->name = "STARCOS";
  368|    929|	card->cla  = 0x00;
  369|    929|	card->drv_data = (void *)ex_data;
  370|    929|	ex_data->pin_encoding = PIN_ENCODING_DETERMINE;
  ------------------
  |  |   96|    929|#define PIN_ENCODING_DETERMINE	0
  ------------------
  371|       |
  372|    929|	flags = SC_ALGORITHM_RSA_PAD_PKCS1
  ------------------
  |  |  111|    929|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    929|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    929|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  373|    929|		| SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |   93|    929|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  374|    929|		| SC_ALGORITHM_RSA_PAD_ISO9796
  ------------------
  |  |  106|    929|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  375|    929|		| SC_ALGORITHM_RSA_HASH_NONE
  ------------------
  |  |  133|    929|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  376|    929|		| SC_ALGORITHM_RSA_HASH_SHA1
  ------------------
  |  |  134|    929|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  377|    929|		| SC_ALGORITHM_RSA_HASH_MD5
  ------------------
  |  |  135|    929|#define SC_ALGORITHM_RSA_HASH_MD5	0x00000400
  ------------------
  378|    929|		| SC_ALGORITHM_RSA_HASH_RIPEMD160
  ------------------
  |  |  137|    929|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
  379|    929|		| SC_ALGORITHM_RSA_HASH_MD5_SHA1;
  ------------------
  |  |  136|    929|#define SC_ALGORITHM_RSA_HASH_MD5_SHA1	0x00000800
  ------------------
  380|       |
  381|    929|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  550|    929|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  382|       |
  383|    929|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|  1.85k|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|    929|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 506, False: 423]
  |  |  |  |  |  Branch (119:65): [True: 0, False: 423]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|    423|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 82, False: 341]
  |  |  |  |  |  Branch (120:65): [True: 12, False: 329]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|       |
  385|    600|		flags |= SC_CARD_FLAG_RNG
  ------------------
  |  |  536|    600|#define SC_CARD_FLAG_RNG		0x00000002
  ------------------
  386|    600|			| SC_ALGORITHM_RSA_HASH_SHA224
  ------------------
  |  |  141|    600|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  ------------------
  387|    600|			| SC_ALGORITHM_RSA_HASH_SHA256
  ------------------
  |  |  138|    600|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  388|    600|			| SC_ALGORITHM_RSA_HASH_SHA384
  ------------------
  |  |  139|    600|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
  389|    600|			| SC_ALGORITHM_RSA_HASH_SHA512
  ------------------
  |  |  140|    600|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
  390|    600|			| SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  107|    600|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  391|       |
  392|    600|		_sc_card_add_rsa_alg(card, 512, flags, 0x10001);
  393|    600|		_sc_card_add_rsa_alg(card, 768, flags, 0x10001);
  394|    600|		_sc_card_add_rsa_alg(card,1024, flags, 0x10001);
  395|    600|		_sc_card_add_rsa_alg(card,1728, flags, 0x10001);
  396|    600|		_sc_card_add_rsa_alg(card,1976, flags, 0x10001);
  397|    600|		_sc_card_add_rsa_alg(card,2048, flags, 0x10001);
  398|    600|		if ( IS_V34(card) ) {
  ------------------
  |  |  119|    600|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  ------------------
  |  |  |  Branch (119:22): [True: 506, False: 94]
  |  |  |  Branch (119:65): [True: 0, False: 94]
  |  |  ------------------
  ------------------
  399|    506|			card->name = "STARCOS 3.4";
  400|    506|			card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  553|    506|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  401|    506|		} else {
  402|     94|			card->name = "STARCOS 3.5";
  403|     94|			_sc_card_add_rsa_alg(card,3072, flags, 0x10001);
  404|     94|		}
  405|    600|		card->max_send_size = 255;
  406|    600|		card->max_recv_size = 256;
  407|    600|	} else {
  408|    329|		_sc_card_add_rsa_alg(card, 512, flags, 0x10001);
  409|    329|		_sc_card_add_rsa_alg(card, 768, flags, 0x10001);
  410|    329|		_sc_card_add_rsa_alg(card,1024, flags, 0x10001);
  411|       |
  412|       |		/* we need read_binary&friends with max 128 bytes per read */
  413|    329|		card->max_send_size = 128;
  414|    329|		card->max_recv_size = 128;
  415|    329|	}
  416|       |
  417|    929|	if (sc_parse_ef_atr(card) == SC_SUCCESS) {
  ------------------
  |  |   28|    929|#define SC_SUCCESS				0
  ------------------
  |  Branch (417:6): [True: 87, False: 842]
  ------------------
  418|     87|		size_t max_recv_size = 0;
  419|     87|		size_t max_send_size = 0;
  420|       |
  421|       |		/* Add max. length values from IAS/ECC specific issuer data */
  422|     87|		if ( card->ef_atr->issuer_data_len >= 4 ) {
  ------------------
  |  Branch (422:8): [True: 23, False: 64]
  ------------------
  423|     23|			max_recv_size = bebytes2ushort(card->ef_atr->issuer_data);
  424|     23|			max_send_size = bebytes2ushort(card->ef_atr->issuer_data + 2);
  425|     23|		}
  426|       |		/* which could be overridden with ISO7816 EF.ATR options, if present */
  427|     87|		if (card->ef_atr->max_response_apdu > 0) {
  ------------------
  |  Branch (427:7): [True: 23, False: 64]
  ------------------
  428|     23|			max_recv_size = card->ef_atr->max_response_apdu;
  429|     23|		}
  430|     87|		if (card->ef_atr->max_command_apdu > 0) {
  ------------------
  |  Branch (430:7): [True: 25, False: 62]
  ------------------
  431|     25|			max_send_size = card->ef_atr->max_command_apdu;
  432|     25|		}
  433|       |
  434|     87|		if ( max_send_size > 256 && max_recv_size > 256 ) {
  ------------------
  |  Branch (434:8): [True: 41, False: 46]
  |  Branch (434:31): [True: 27, False: 14]
  ------------------
  435|     27|			size_t max_recv_size_prev = card->max_recv_size;
  436|     27|			size_t max_send_size_prev = card->max_send_size;
  437|       |			/* allow SC_CARD_CAP_APDU_EXT independent of ef_atr->caps, see IAS/ECC issuer data above */
  438|     27|			card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|     27|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  439|       |			/* the received data should not exceed max_recv_size including the sw1/sw2 */
  440|     27|			card->max_recv_size = max_recv_size - 2;
  441|       |			/* the sent APDU should not exceed max_send_size including the 4 bytes of the APDU and 2 * 3 bytes Lc/Le */
  442|     27|			card->max_send_size = max_send_size - 10;
  443|       |			/* probe reader for extended APDU support */
  444|     27|			if ( starcos_probe_reader_for_ext_apdu(card) ) {
  ------------------
  |  Branch (444:9): [True: 1, False: 26]
  ------------------
  445|      1|				sc_log(card->ctx, "Successfully probed extended APDU, enabling extended APDU with max send/recv %d/%d",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  446|      1|					(int)card->max_send_size, (int)card->max_recv_size);
  447|     26|			} else {
  448|     26|				card->caps &= ~(SC_CARD_CAP_APDU_EXT);
  ------------------
  |  |  547|     26|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  449|     26|				card->max_recv_size = max_recv_size_prev;
  450|     26|				card->max_send_size = max_send_size_prev;
  451|     26|				sc_log(card->ctx, "Ext APDU probing failed, the actual reader does not support ext APDU");
  ------------------
  |  |   71|     26|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  452|     26|			}
  453|     27|		}
  454|     87|	}
  455|       |
  456|    929|	if ( ex_data->pin_encoding == PIN_ENCODING_DETERMINE ) {
  ------------------
  |  |   96|    929|#define PIN_ENCODING_DETERMINE	0
  ------------------
  |  Branch (456:7): [True: 929, False: 0]
  ------------------
  457|       |		// about to determine PIN encoding
  458|    929|		ex_data->pin_encoding = starcos_determine_pin_encoding(card);
  459|    929|	}
  460|       |
  461|    929|	if ( card->type == SC_CARD_TYPE_STARCOS_V3_4 && starcos_has_esign_app(card) ) {
  ------------------
  |  Branch (461:7): [True: 506, False: 423]
  |  Branch (461:50): [True: 75, False: 431]
  ------------------
  462|     75|		card->type = SC_CARD_TYPE_STARCOS_V3_4_ESIGN;
  463|     75|		sc_log(card->ctx, "Card has eSign app, card type changed to %d", card->type);
  ------------------
  |  |   71|     75|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  464|     75|	}
  465|       |
  466|    929|	return 0;
  467|    929|}
card-starcos.c:starcos_probe_reader_for_ext_apdu:
  301|     27|static int starcos_probe_reader_for_ext_apdu(sc_card_t * card) {
  302|     27|	sc_apdu_t apdu;
  303|     27|	int rv;
  304|       |	/* try to read STARCOS3X_PROBE_APDU_LENGTH bytes */
  305|     27|	u8 data[STARCOS3X_PROBE_APDU_LENGTH];
  306|       |
  307|       |	/* Get Data: Get Chip Serial Number */
  308|     27|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_EXT, 0xCA, 0x9F, 0x6C);
  ------------------
  |  |  297|     27|#define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  292|     27|#define SC_APDU_CASE_2_SHORT		0x02
  |  |  ------------------
  |  |               #define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|     27|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  309|     27|	apdu.cla = 0xA0;
  310|     27|	apdu.resp = data;
  311|     27|	apdu.resplen = sizeof(data);
  312|     27|	apdu.le = apdu.resplen;
  313|     27|	rv = sc_transmit_apdu(card, &apdu);
  314|     27|	LOG_TEST_RET(card->ctx, rv, "Failed to send Get Data ext. APDU");
  ------------------
  |  |  174|     27|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     27|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     27|	int _ret = (r); \
  |  |  |  |  168|     27|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|     26|	return (apdu.sw1 == 0x90 && apdu.sw2 == 0x00);
  ------------------
  |  Branch (315:10): [True: 1, False: 25]
  |  Branch (315:30): [True: 0, False: 1]
  ------------------
  316|     27|}
card-starcos.c:starcos_determine_pin_encoding:
  269|    929|{
  270|    929|	unsigned int pin_format = PIN_FORMAT_DEFAULT;
  ------------------
  |  |  107|    929|#define PIN_FORMAT_DEFAULT		PIN_FORMAT_F2
  |  |  ------------------
  |  |  |  |  101|    929|#define PIN_FORMAT_F2			0x12
  |  |  ------------------
  ------------------
  271|    929|	unsigned int encoding = PIN_ENCODING_DETERMINE;
  ------------------
  |  |   96|    929|#define PIN_ENCODING_DETERMINE	0
  ------------------
  272|       |
  273|    929|	if ( IS_V34(card) ) {
  ------------------
  |  |  119|    929|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  ------------------
  |  |  |  Branch (119:22): [True: 506, False: 423]
  |  |  |  Branch (119:65): [True: 0, False: 423]
  |  |  ------------------
  ------------------
  274|    506|		starcos_determine_pin_format34(card, &pin_format);
  275|    506|	} else if ( IS_V35(card) ) {
  ------------------
  |  |  120|    423|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  ------------------
  |  |  |  Branch (120:22): [True: 82, False: 341]
  |  |  |  Branch (120:65): [True: 12, False: 329]
  |  |  ------------------
  ------------------
  276|     94|		starcos_determine_pin_format35(card, &pin_format);
  277|     94|	}
  278|       |
  279|    929|	switch (pin_format) {
  ------------------
  |  Branch (279:10): [True: 928, False: 1]
  ------------------
  280|      1|	case PIN_FORMAT_PW_ASCII:
  ------------------
  |  |  105|      1|#define PIN_FORMAT_PW_ASCII		0x21
  ------------------
  |  Branch (280:2): [True: 1, False: 928]
  ------------------
  281|      2|	case PIN_FORMAT_ASCII:
  ------------------
  |  |  104|      2|#define PIN_FORMAT_ASCII		0x14
  ------------------
  |  Branch (281:2): [True: 1, False: 928]
  ------------------
  282|      2|		encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|      2|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  283|      2|		break;
  284|      1|	case PIN_FORMAT_BCD:
  ------------------
  |  |  103|      1|#define PIN_FORMAT_BCD			0x13
  ------------------
  |  Branch (284:2): [True: 1, False: 928]
  ------------------
  285|      1|		encoding = SC_PIN_ENCODING_BCD;
  ------------------
  |  |  426|      1|#define SC_PIN_ENCODING_BCD	1
  ------------------
  286|      1|		break;
  287|      1|	case PIN_FORMAT_F1:
  ------------------
  |  |  100|      1|#define PIN_FORMAT_F1			0x11
  ------------------
  |  Branch (287:2): [True: 1, False: 928]
  ------------------
  288|    925|	case PIN_FORMAT_F2:
  ------------------
  |  |  101|    925|#define PIN_FORMAT_F2			0x12
  ------------------
  |  Branch (288:2): [True: 924, False: 5]
  ------------------
  289|    925|		encoding = SC_PIN_ENCODING_GLP;
  ------------------
  |  |  427|    925|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  290|    925|		break;
  291|    929|	}
  292|       |
  293|    929|	sc_log(card->ctx, "Determined PIN encoding: %d", encoding);
  ------------------
  |  |   71|    929|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  294|    929|	return encoding;
  295|    929|}
card-starcos.c:starcos_determine_pin_format34:
  189|    506|{
  190|    506|	struct sc_context *ctx = card->ctx;
  191|    506|	struct sc_path path;
  192|    506|	struct sc_file *file;
  193|    506|	unsigned char buf[256];
  194|    506|	int rv;
  195|    506|	int retval = SC_SUCCESS;
  ------------------
  |  |   28|    506|#define SC_SUCCESS				0
  ------------------
  196|    506|	int rec_no=1;
  197|       |
  198|    506|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    506|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    506|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    506|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    506|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 506]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|       |
  200|    506|	sc_format_path(starcos_ef_pwdd, &path);
  201|    506|	rv = sc_select_file(card, &path, &file);
  202|    506|	LOG_TEST_RET(ctx, rv, "Cannot select EF.PWDD file");
  ------------------
  |  |  174|    506|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    506|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    506|	int _ret = (r); \
  |  |  |  |  168|    506|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 444, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  169|    444|		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|    444|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    444|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    444|		return _ret; \
  |  |  |  |  172|    444|	} \
  |  |  |  |  173|    506|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  203|       |
  204|     62|	if ( (rv = sc_read_record(card, rec_no, 0, buf, sizeof(buf), SC_RECORD_BY_REC_NR)) > 0 ) {
  ------------------
  |  | 1298|     62|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (204:7): [True: 22, False: 40]
  ------------------
  205|     22|		starcos_ctrl_ref_template ctrl_ref_template;
  206|     22|		memset((void*)&ctrl_ref_template, 0, sizeof(ctrl_ref_template));
  207|     22|		rv = starcos_parse_supported_sec_mechanisms(card, buf, rv, &ctrl_ref_template);
  208|     22|		if ( rv == SC_SUCCESS ) {
  ------------------
  |  |   28|     22|#define SC_SUCCESS				0
  ------------------
  |  Branch (208:8): [True: 5, False: 17]
  ------------------
  209|      5|			*pin_format = ctrl_ref_template.transmission_format;
  210|      5|			sc_log(ctx, "Determined StarCOS 3.4 PIN format: 0x%x", *pin_format);
  ------------------
  |  |   71|      5|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  211|     17|		} else {
  212|     17|			sc_log(ctx, "Failed to parse record %d of EF.PWD, err=%d", rec_no, rv);
  ------------------
  |  |   71|     17|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  213|     17|			retval = rv;
  214|     17|		}
  215|     40|	} else {
  216|     40|		sc_log(ctx, "Failed to read record %d of EF.PWDD, err=%d", rec_no, rv);
  ------------------
  |  |   71|     40|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  217|     40|		retval = rv;
  218|     40|	}
  219|       |
  220|     62|	sc_file_free(file);
  221|     62|	LOG_FUNC_RETURN(ctx, retval);
  ------------------
  |  |  164|     62|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     62|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     62|	int _ret = r; \
  |  |  |  |  155|     62|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 62, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     62|		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|     51|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 51, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  157|     62|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     62|	} 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|     62|	return _ret; \
  |  |  |  |  163|     62|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|     62|}
card-starcos.c:starcos_parse_supported_sec_mechanisms:
  158|    410|{
  159|    410|	struct sc_context *ctx = card->ctx;
  160|    410|	const unsigned char *supported_sec_mechanisms_tag = NULL;
  161|    410|	size_t taglen;
  162|       |
  163|    410|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    410|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    410|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    410|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    410|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 410]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|       |
  165|    410|	supported_sec_mechanisms_tag = sc_asn1_find_tag(ctx, buf, buflen, TAG_STARCOS3X_SUPPORTED_SEC_MECHANISMS_tag, &taglen);
  ------------------
  |  |  146|    410|#define TAG_STARCOS3X_SUPPORTED_SEC_MECHANISMS_tag		0x7B
  ------------------
  166|    410|	if (supported_sec_mechanisms_tag != NULL && taglen >= 1)   {
  ------------------
  |  Branch (166:6): [True: 11, False: 399]
  |  Branch (166:46): [True: 10, False: 1]
  ------------------
  167|     10|		const unsigned char *tx_fmt_tag = NULL;
  168|     10|		const unsigned char *ctrl_ref_template_tag = NULL;
  169|     10|		size_t supported_sec_mechanisms_taglen = taglen;
  170|       |
  171|       |		// control-reference template is either included in the supported security mechanisms tag or it can be the CRT tag itself (EF.PWDD)
  172|     10|		ctrl_ref_template_tag = sc_asn1_find_tag(ctx, supported_sec_mechanisms_tag, taglen, TAG_STARCOS3X_CTRL_REF_TEMPLATE, &taglen);
  ------------------
  |  |  147|     10|#define TAG_STARCOS3X_CTRL_REF_TEMPLATE				0xA4
  ------------------
  173|     10|		if ( ctrl_ref_template_tag == NULL || taglen == 0 ) {
  ------------------
  |  Branch (173:8): [True: 8, False: 2]
  |  Branch (173:41): [True: 1, False: 1]
  ------------------
  174|      9|			ctrl_ref_template_tag = supported_sec_mechanisms_tag;
  175|      9|			taglen = supported_sec_mechanisms_taglen;
  176|      9|		}
  177|       |
  178|     10|		tx_fmt_tag = sc_asn1_find_tag(ctx, ctrl_ref_template_tag, taglen, TAG_STARCOS3X_TRANSMISSION_FORMAT, &taglen);
  ------------------
  |  |  148|     10|#define TAG_STARCOS3X_TRANSMISSION_FORMAT			0x89
  ------------------
  179|     10|		if ( tx_fmt_tag != NULL && taglen >= 1 ) {
  ------------------
  |  Branch (179:8): [True: 6, False: 4]
  |  Branch (179:30): [True: 5, False: 1]
  ------------------
  180|      5|			ctrl_ref_template->transmission_format = *(tx_fmt_tag + 0);
  181|      5|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      5|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      5|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      5|	int _ret = r; \
  |  |  |  |  155|      5|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      5|		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: 5]
  |  |  |  |  ------------------
  |  |  |  |  157|      5|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      5|	} 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|      5|	return _ret; \
  |  |  |  |  163|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|      5|		}
  183|     10|	}
  184|       |
  185|    405|	LOG_FUNC_RETURN(ctx, SC_ERROR_TEMPLATE_NOT_FOUND);
  ------------------
  |  |  164|    405|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    405|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    405|	int _ret = r; \
  |  |  |  |  155|    405|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 405, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    405|		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|    405|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 405, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    405|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    405|	} 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|    405|	return _ret; \
  |  |  |  |  163|    405|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  186|    405|}
card-starcos.c:starcos_determine_pin_format35:
  225|     94|{
  226|     94|	struct sc_context *ctx = card->ctx;
  227|     94|	struct sc_path path;
  228|     94|	struct sc_file *file;
  229|     94|	unsigned char buf[256];
  230|     94|	int rv;
  231|     94|	int retval = SC_ERROR_RECORD_NOT_FOUND;
  ------------------
  |  |   52|     94|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  232|     94|	int rec_no=1;
  233|     94|	starcos_ctrl_ref_template ctrl_ref_template;
  234|       |
  235|     94|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     94|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     94|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     94|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     94|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|       |
  237|     94|	sc_format_path(starcos_ef_keyd, &path);
  238|     94|	rv = sc_select_file(card, &path, &file);
  239|     94|	LOG_TEST_RET(ctx, rv, "Cannot select EF.KEYD file");
  ------------------
  |  |  174|     94|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     94|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     94|	int _ret = (r); \
  |  |  |  |  168|     94|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 30, False: 64]
  |  |  |  |  ------------------
  |  |  |  |  169|     30|		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|     30|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     30|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     30|		return _ret; \
  |  |  |  |  172|     30|	} \
  |  |  |  |  173|     94|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 64]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  240|       |
  241|  2.59k|	while ( (rv = sc_read_record(card, rec_no++, 0, buf, sizeof(buf), SC_RECORD_BY_REC_NR)) > 0 ) {
  ------------------
  |  | 1298|  2.59k|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (241:10): [True: 2.52k, False: 64]
  ------------------
  242|  2.52k|		if ( buf[0] != TAG_STARCOS35_PIN_REFERENCE ) continue;
  ------------------
  |  |  145|  2.52k|#define TAG_STARCOS35_PIN_REFERENCE					0x88
  ------------------
  |  Branch (242:8): [True: 2.14k, False: 388]
  ------------------
  243|       |
  244|    388|		memset((void*)&ctrl_ref_template, 0, sizeof(ctrl_ref_template));
  245|    388|		rv = starcos_parse_supported_sec_mechanisms(card, buf, rv, &ctrl_ref_template);
  246|    388|		if ( rv == SC_SUCCESS ) {
  ------------------
  |  |   28|    388|#define SC_SUCCESS				0
  ------------------
  |  Branch (246:8): [True: 0, False: 388]
  ------------------
  247|      0|			*pin_format = ctrl_ref_template.transmission_format;
  248|      0|			sc_log(ctx, "Determined StarCOS 3.5 PIN format: 0x%x", *pin_format);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  249|      0|			retval = rv;
  250|       |			// assuming that all PINs and PUKs have the same transmission format
  251|      0|			break;
  252|    388|		} else {
  253|    388|			sc_log(ctx, "Failed to parse record %d of EF.KEYD, err=%d", rec_no-1, rv);
  ------------------
  |  |   71|    388|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  254|    388|			retval = rv;
  255|    388|		}
  256|    388|	}
  257|       |
  258|     64|	sc_file_free(file);
  259|     64|	LOG_FUNC_RETURN(ctx, retval);
  ------------------
  |  |  164|     64|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     64|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     64|	int _ret = r; \
  |  |  |  |  155|     64|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 64, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     64|		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|     64|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 64, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     64|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     64|	} 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|     64|	return _ret; \
  |  |  |  |  163|     64|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|     64|}
card-starcos.c:starcos_has_esign_app:
  339|    506|static int starcos_has_esign_app(sc_card_t * card) {
  340|    506|	static const char * starcos_esign_aid = "A0:00:00:02:45:53:69:67:6E";
  341|    506|	int rv;
  342|       |
  343|    506|	rv = starcos_select_mf(card);
  344|    506|	if ( rv == SC_SUCCESS ) {
  ------------------
  |  |   28|    506|#define SC_SUCCESS				0
  ------------------
  |  Branch (344:7): [True: 495, False: 11]
  ------------------
  345|    495|		u8 aid[SC_MAX_PATH_SIZE];
  346|    495|		size_t len = sizeof(aid);
  347|       |
  348|    495|		rv = sc_hex_to_bin(starcos_esign_aid, aid, &len);
  349|    495|		LOG_TEST_RET(card->ctx, rv, "Failed to convert eSing AID");
  ------------------
  |  |  174|    495|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    495|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    495|	int _ret = (r); \
  |  |  |  |  168|    495|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 495]
  |  |  |  |  ------------------
  |  |  |  |  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|    495|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 495]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|    495|		rv = starcos_select_aid(card, aid, len, NULL);
  351|    495|		if ( rv == SC_SUCCESS ) {
  ------------------
  |  |   28|    495|#define SC_SUCCESS				0
  ------------------
  |  Branch (351:8): [True: 75, False: 420]
  ------------------
  352|     75|			starcos_select_mf(card);
  353|     75|		}
  354|    495|	}
  355|    506|	return ( rv == SC_SUCCESS );
  ------------------
  |  |   28|    506|#define SC_SUCCESS				0
  ------------------
  356|    506|}
card-starcos.c:starcos_select_mf:
  318|    581|static int starcos_select_mf(sc_card_t * card) {
  319|    581|	sc_apdu_t apdu;
  320|    581|	const u8 mf_buf[2] = {0x3f, 0x00};
  321|       |
  322|    581|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x00, 0x0C);
  ------------------
  |  |  293|    581|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  323|    581|	apdu.le = 0;
  324|    581|	apdu.lc = 2;
  325|    581|	apdu.data    = mf_buf;
  326|    581|	apdu.datalen = 2;
  327|    581|	apdu.resplen = 0;
  328|       |
  329|    581|	return sc_transmit_apdu(card, &apdu);
  330|    581|}
card-starcos.c:starcos_select_aid:
  745|  2.86k|{
  746|  2.86k|	sc_apdu_t apdu;
  747|  2.86k|	int r;
  748|  2.86k|	size_t i = 0;
  749|       |
  750|  2.86k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x04, 0x0C);
  ------------------
  |  |  293|  2.86k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  751|  2.86k|	apdu.lc = len;
  752|  2.86k|	apdu.data = (u8*)aid;
  753|  2.86k|	apdu.datalen = len;
  754|  2.86k|	apdu.resplen = 0;
  755|  2.86k|	apdu.le = 0;
  756|  2.86k|	r = sc_transmit_apdu(card, &apdu);
  757|  2.86k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.86k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.86k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.86k|	int _ret = (r); \
  |  |  |  |  168|  2.86k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 22, False: 2.84k]
  |  |  |  |  ------------------
  |  |  |  |  169|     22|		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|     22|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     22|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     22|		return _ret; \
  |  |  |  |  172|     22|	} \
  |  |  |  |  173|  2.86k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.84k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  758|       |
  759|       |	/* check return value */
  760|  2.84k|	if (!(apdu.sw1 == 0x90 && apdu.sw2 == 0x00) && apdu.sw1 != 0x61 )
  ------------------
  |  Branch (760:8): [True: 825, False: 2.01k]
  |  Branch (760:28): [True: 726, False: 99]
  |  Branch (760:49): [True: 2.11k, False: 0]
  ------------------
  761|  2.11k|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|  2.11k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  2.11k|	int _ret = r; \
  |  |  155|  2.11k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 2.11k, False: 0]
  |  |  ------------------
  |  |  156|  2.11k|		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|  2.11k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 2.11k, False: 0]
  |  |  ------------------
  |  |  157|  2.11k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  2.11k|	} 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|  2.11k|	return _ret; \
  |  |  163|  2.11k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  762|       |
  763|    726|	if (file_out) {
  ------------------
  |  Branch (763:6): [True: 0, False: 726]
  ------------------
  764|      0|		sc_file_t *file = sc_file_new();
  765|      0|		if (!file)
  ------------------
  |  Branch (765:7): [True: 0, False: 0]
  ------------------
  766|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  767|      0|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  768|      0|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      0|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  769|      0|		file->path.len = 0;
  770|      0|		file->size = 0;
  771|       |		/* AID */
  772|      0|		for (i = 0; i < len; i++)
  ------------------
  |  Branch (772:15): [True: 0, False: 0]
  ------------------
  773|      0|			file->name[i] = aid[i];
  774|      0|		file->namelen = len;
  775|      0|		file->id = 0x0000;
  776|      0|		file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|      0|#define SC_FILE_MAGIC			0x14426950
  ------------------
  777|       |
  778|      0|		*file_out = file;
  779|      0|	}
  780|    726|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|    726|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    726|	int _ret = r; \
  |  |  155|    726|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 726, False: 0]
  |  |  ------------------
  |  |  156|    726|		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: 726]
  |  |  ------------------
  |  |  157|    726|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    726|	} 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|    726|	return _ret; \
  |  |  163|    726|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  781|    726|}
card-starcos.c:starcos_finish:
  470|    929|{
  471|    929|	if (card->drv_data)
  ------------------
  |  Branch (471:6): [True: 929, False: 0]
  ------------------
  472|    929|		free((starcos_ex_data *)card->drv_data);
  473|    929|	return 0;
  474|    929|}
card-starcos.c:starcos_select_file:
  913|  8.24k|{
  914|  8.24k|	u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  915|  8.24k|	int    r, pathtype;
  916|  8.24k|	size_t i, pathlen;
  917|       |
  918|  8.24k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  8.24k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  8.24k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  8.24k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 8.24k]
  |  |  ------------------
  ------------------
  919|       |
  920|  8.24k|	if ( in_path->len > sizeof(pathbuf) ) {
  ------------------
  |  Branch (920:7): [True: 0, False: 8.24k]
  ------------------
  921|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_BUFFER_TOO_SMALL);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  922|      0|	}
  923|  8.24k|	memcpy(path, in_path->value, in_path->len);
  924|  8.24k|	pathlen = in_path->len;
  925|  8.24k|	pathtype = in_path->type;
  926|       |
  927|  8.24k|	if (in_path->aid.len) {
  ------------------
  |  Branch (927:6): [True: 191, False: 8.05k]
  ------------------
  928|    191|		if (!pathlen) {
  ------------------
  |  Branch (928:7): [True: 0, False: 191]
  ------------------
  929|      0|			if ( in_path->aid.len > sizeof(pathbuf) ) {
  ------------------
  |  Branch (929:9): [True: 0, False: 0]
  ------------------
  930|      0|				SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_BUFFER_TOO_SMALL);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  931|      0|			}
  932|      0|			memcpy(path, in_path->aid.value, in_path->aid.len);
  933|      0|			pathlen = in_path->aid.len;
  934|      0|			pathtype = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  935|    191|		} else {
  936|    191|			r = starcos_select_aid(card, in_path->aid.value, in_path->aid.len, NULL);
  937|    191|			LOG_TEST_RET(card->ctx, r, "Could not select AID!");
  ------------------
  |  |  174|    191|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    191|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    191|	int _ret = (r); \
  |  |  |  |  168|    191|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 68, False: 123]
  |  |  |  |  ------------------
  |  |  |  |  169|     68|		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|     68|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     68|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     68|		return _ret; \
  |  |  |  |  172|     68|	} \
  |  |  |  |  173|    191|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 123]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  938|       |
  939|    123|			if (pathtype == SC_PATH_TYPE_DF_NAME) {
  ------------------
  |  |  118|    123|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (939:8): [True: 0, False: 123]
  ------------------
  940|      0|				pathtype = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  941|      0|			}
  942|    123|		}
  943|    191|	}
  944|       |
  945|  8.18k|	if (pathtype == SC_PATH_TYPE_FILE_ID)
  ------------------
  |  |  117|  8.18k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (945:6): [True: 10, False: 8.17k]
  ------------------
  946|     10|	{	/* SELECT EF/DF with ID */
  947|       |		/* Select with 2byte File-ID */
  948|     10|		if (pathlen != 2)
  ------------------
  |  Branch (948:7): [True: 0, False: 10]
  ------------------
  949|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  950|     10|		r = starcos_select_fid(card, path[0],
  951|     10|				path[1], path[0] == 0x3F && path[1] == 0x00 ? NULL : file_out, 1);
  ------------------
  |  Branch (951:14): [True: 7, False: 3]
  |  Branch (951:33): [True: 6, False: 1]
  ------------------
  952|     10|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|     10|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     10|	int _ret = r; \
  |  |  155|     10|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 10, False: 0]
  |  |  ------------------
  |  |  156|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 10, False: 0]
  |  |  ------------------
  |  |  157|     10|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     10|	} 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|     10|	return _ret; \
  |  |  163|     10|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  953|     10|	}
  954|  8.17k|	else if (pathtype == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  8.17k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (954:11): [True: 2.17k, False: 5.99k]
  ------------------
  955|  2.17k|	{	/* SELECT DF with AID */
  956|       |		/* Select with 1-16byte Application-ID */
  957|  2.17k|		r = starcos_select_aid(card, pathbuf, pathlen, file_out);
  958|  2.17k|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  2.17k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  2.17k|	int _ret = r; \
  |  |  155|  2.17k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 2.17k, False: 0]
  |  |  ------------------
  |  |  156|  2.17k|		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|  1.64k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1.64k, False: 528]
  |  |  ------------------
  |  |  157|  2.17k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  2.17k|	} 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|  2.17k|	return _ret; \
  |  |  163|  2.17k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  959|  2.17k|	}
  960|  5.99k|	else if (pathtype == SC_PATH_TYPE_PATH)
  ------------------
  |  |  119|  5.99k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (960:11): [True: 5.99k, False: 0]
  ------------------
  961|  5.99k|	{
  962|  5.99k|		u8 n_pathbuf[SC_MAX_PATH_SIZE];
  963|       |
  964|       |		/* Select with path (sequence of File-IDs) */
  965|       |		/* Starcos (S 2.1 and SPK 2.3) only supports one
  966|       |		 * level of subdirectories, therefore a path is
  967|       |		 * at most 3 FID long (the last one being the FID
  968|       |		 * of a EF) => pathlen must be even and less than 6
  969|       |		 */
  970|  5.99k|		if (pathlen%2 != 0 || pathlen > 6 || pathlen <= 0)
  ------------------
  |  Branch (970:7): [True: 0, False: 5.99k]
  |  Branch (970:25): [True: 70, False: 5.92k]
  |  Branch (970:40): [True: 41, False: 5.88k]
  ------------------
  971|    111|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  153|    111|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    111|	int _ret = r; \
  |  |  155|    111|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 111, False: 0]
  |  |  ------------------
  |  |  156|    111|		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|    111|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 111, False: 0]
  |  |  ------------------
  |  |  157|    111|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    111|	} 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|    111|	return _ret; \
  |  |  163|    111|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  972|       |		/* if pathlen == 6 then the first FID must be MF (== 3F00) */
  973|  5.88k|		if (pathlen == 6 && ( path[0] != 0x3f || path[1] != 0x00 ))
  ------------------
  |  Branch (973:7): [True: 669, False: 5.21k]
  |  Branch (973:25): [True: 11, False: 658]
  |  Branch (973:44): [True: 10, False: 648]
  ------------------
  974|     21|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     21|	int _ret = r; \
  |  |  155|     21|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 21, False: 0]
  |  |  ------------------
  |  |  156|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 21, False: 0]
  |  |  ------------------
  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     21|	} 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|     21|	return _ret; \
  |  |  163|     21|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  975|       |
  976|  5.86k|		if ( IS_V3x(card) ) {
  ------------------
  |  |  121|  11.7k|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|  5.86k|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 2.42k, False: 3.44k]
  |  |  |  |  |  Branch (119:65): [True: 393, False: 3.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|  3.04k|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 425, False: 2.62k]
  |  |  |  |  |  Branch (120:65): [True: 78, False: 2.54k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  977|       |			/* unify path (the first FID should be MF) */
  978|  3.31k|			if (path[0] != 0x3f || path[1] != 0x00)
  ------------------
  |  Branch (978:8): [True: 147, False: 3.17k]
  |  Branch (978:27): [True: 0, False: 3.17k]
  ------------------
  979|    147|			{
  980|    147|				n_pathbuf[0] = 0x3f;
  981|    147|				n_pathbuf[1] = 0x00;
  982|    147|				memcpy(n_pathbuf+2, path, pathlen);
  983|    147|				path = n_pathbuf;
  984|    147|				pathlen += 2;
  985|    147|			}
  986|  3.31k|		}
  987|       |
  988|  7.47k|		for ( i=0; i<pathlen-2; i+=2 )
  ------------------
  |  Branch (988:14): [True: 5.91k, False: 1.56k]
  ------------------
  989|  5.91k|		{
  990|  5.91k|			r = starcos_select_fid(card, path[i], path[i+1], NULL, 0);
  991|  5.91k|			LOG_TEST_RET(card->ctx, r, "SELECT FILE (DF-ID) failed");
  ------------------
  |  |  174|  5.91k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  5.91k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  5.91k|	int _ret = (r); \
  |  |  |  |  168|  5.91k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4.30k, False: 1.61k]
  |  |  |  |  ------------------
  |  |  |  |  169|  4.30k|		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|  4.30k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  4.30k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  4.30k|		return _ret; \
  |  |  |  |  172|  4.30k|	} \
  |  |  |  |  173|  5.91k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.61k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  992|  5.91k|		}
  993|  1.56k|		r = starcos_select_fid(card, path[pathlen-2], path[pathlen-1], file_out, 1);
  994|  1.56k|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  1.56k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  1.56k|	int _ret = r; \
  |  |  155|  1.56k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1.56k, False: 0]
  |  |  ------------------
  |  |  156|  1.56k|		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|    578|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 578, False: 984]
  |  |  ------------------
  |  |  157|  1.56k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  1.56k|	} 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|  1.56k|	return _ret; \
  |  |  163|  1.56k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  995|  1.56k|	}
  996|      0|	else
  997|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  998|  8.18k|}
card-starcos.c:starcos_select_fid:
  786|  7.48k|{
  787|  7.48k|	sc_apdu_t apdu;
  788|  7.48k|	u8 data[] = {id_hi & 0xff, id_lo & 0xff};
  789|  7.48k|	u8 resp[SC_MAX_APDU_BUFFER_SIZE];
  790|  7.48k|	int bIsDF = 0, r;
  791|  7.48k|	int isFCP = 0;
  792|  7.48k|	int isMF = 0;
  793|       |
  794|       |	/* request FCI to distinguish between EFs and DFs */
  795|  7.48k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  7.48k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  796|  7.48k|	apdu.p2   = 0x00;
  797|  7.48k|	apdu.resp = (u8*)resp;
  798|  7.48k|	apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|  7.48k|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
  799|  7.48k|	apdu.le = 256;
  800|  7.48k|	apdu.lc = 2;
  801|  7.48k|	apdu.data = (u8*)data;
  802|  7.48k|	apdu.datalen = 2;
  803|       |
  804|  7.48k|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|  14.9k|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|  7.48k|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 2.92k, False: 4.55k]
  |  |  |  |  |  Branch (119:65): [True: 575, False: 3.98k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|  3.98k|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 528, False: 3.45k]
  |  |  |  |  |  Branch (120:65): [True: 97, False: 3.35k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  805|  4.12k|		if (id_hi == 0x3f && id_lo == 0x0) {
  ------------------
  |  Branch (805:7): [True: 3.31k, False: 811]
  |  Branch (805:24): [True: 3.31k, False: 0]
  ------------------
  806|  3.31k|			apdu.p1 = 0x0;
  807|  3.31k|			apdu.p2 = 0x0C;
  808|  3.31k|			apdu.le = 0;
  809|  3.31k|			apdu.resplen = 0;
  810|  3.31k|			apdu.resp = NULL;
  811|  3.31k|			apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  3.31k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  812|  3.31k|			isMF = 1;
  813|  3.31k|		} else if (file_out || is_file) {
  ------------------
  |  Branch (813:14): [True: 689, False: 122]
  |  Branch (813:26): [True: 55, False: 67]
  ------------------
  814|       |			// last component (i.e. file or path)
  815|    744|			apdu.p1 = 0x2;
  816|    744|			apdu.p2 = 0x4;
  817|    744|		} else {
  818|       |			// path component
  819|     67|			apdu.p1 = 0x1;
  820|     67|			apdu.p2 = 0x0;
  821|     67|		}
  822|  4.12k|	}
  823|       |
  824|  7.48k|	r = sc_transmit_apdu(card, &apdu);
  825|  7.48k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  7.48k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.48k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.48k|	int _ret = (r); \
  |  |  |  |  168|  7.48k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 151, False: 7.33k]
  |  |  |  |  ------------------
  |  |  |  |  169|    151|		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|    151|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    151|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    151|		return _ret; \
  |  |  |  |  172|    151|	} \
  |  |  |  |  173|  7.48k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  826|       |
  827|  7.33k|	if (apdu.p2 == 0x00 && apdu.sw1 == 0x62 && apdu.sw2 == 0x84 ) {
  ------------------
  |  Branch (827:6): [True: 3.33k, False: 4.00k]
  |  Branch (827:25): [True: 50, False: 3.28k]
  |  Branch (827:45): [True: 26, False: 24]
  ------------------
  828|       |		/* no FCI => we have a DF (see comment in process_fci()) */
  829|     26|		bIsDF = 1;
  830|     26|		apdu.p2 = 0x0C;
  831|     26|		apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|     26|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  832|     26|		apdu.resplen = 0;
  833|     26|		apdu.le = 0;
  834|     26|		r = sc_transmit_apdu(card, &apdu);
  835|     26|		LOG_TEST_RET(card->ctx, r, "APDU re-transmit failed");
  ------------------
  |  |  174|     26|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     26|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     26|	int _ret = (r); \
  |  |  |  |  168|     26|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  836|  7.31k|	} else if ((IS_V3x(card))
  ------------------
  |  |  121|  7.31k|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|  7.31k|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 2.89k, False: 4.41k]
  |  |  |  |  |  Branch (119:65): [True: 573, False: 3.84k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|  3.84k|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 519, False: 3.32k]
  |  |  |  |  |  Branch (120:65): [True: 88, False: 3.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  837|  4.07k|			&& apdu.p2 == 0x4 && apdu.sw1 == 0x6a && apdu.sw2 == 0x82) {
  ------------------
  |  Branch (837:7): [True: 742, False: 3.33k]
  |  Branch (837:25): [True: 159, False: 583]
  |  Branch (837:45): [True: 142, False: 17]
  ------------------
  838|       |		/* not a file, could be a path */
  839|    142|		bIsDF = 1;
  840|    142|		apdu.p1 = 0x1;
  841|    142|		apdu.p2 = 0x0;
  842|    142|		apdu.resplen = sizeof(resp);
  843|    142|		apdu.le = 256;
  844|    142|		apdu.lc = 2;
  845|    142|		r = sc_transmit_apdu(card, &apdu);
  846|    142|		LOG_TEST_RET(card->ctx, r, "APDU re-transmit failed");
  ------------------
  |  |  174|    142|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    142|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    142|	int _ret = (r); \
  |  |  |  |  168|    142|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|    142|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 128]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  847|  7.16k|	} else if (apdu.sw1 == 0x61 || (apdu.sw1 == 0x90 && apdu.sw2 == 0x00 && !isMF)) {
  ------------------
  |  Branch (847:13): [True: 0, False: 7.16k]
  |  Branch (847:34): [True: 3.00k, False: 4.16k]
  |  Branch (847:54): [True: 2.87k, False: 131]
  |  Branch (847:74): [True: 2.11k, False: 763]
  ------------------
  848|       |		/* SELECT returned some data (possible FCI) =>
  849|       |		 * try a READ BINARY to see if a EF is selected */
  850|  2.11k|		sc_apdu_t apdu2;
  851|  2.11k|		u8 resp2[2];
  852|  2.11k|		sc_format_apdu(card, &apdu2, SC_APDU_CASE_2_SHORT, 0xB0, 0, 0);
  ------------------
  |  |  292|  2.11k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  853|  2.11k|		apdu2.resp = (u8*)resp2;
  854|  2.11k|		apdu2.resplen = 2;
  855|  2.11k|		apdu2.le = 1;
  856|  2.11k|		apdu2.lc = 0;
  857|  2.11k|		r = sc_transmit_apdu(card, &apdu2);
  858|  2.11k|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.11k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.11k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.11k|	int _ret = (r); \
  |  |  |  |  168|  2.11k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 70, False: 2.04k]
  |  |  |  |  ------------------
  |  |  |  |  169|     70|		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|     70|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     70|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     70|		return _ret; \
  |  |  |  |  172|     70|	} \
  |  |  |  |  173|  2.11k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  859|  2.04k|		if (apdu2.sw1 == 0x69 && apdu2.sw2 == 0x86) {
  ------------------
  |  Branch (859:7): [True: 93, False: 1.94k]
  |  Branch (859:28): [True: 59, False: 34]
  ------------------
  860|       |			/* no current EF is selected => we have a DF */
  861|     59|			bIsDF = 1;
  862|  1.98k|		} else {
  863|  1.98k|			isFCP = 1;
  864|  1.98k|		}
  865|  2.04k|	}
  866|       |
  867|  7.24k|	if (apdu.sw1 != 0x61 && (apdu.sw1 != 0x90 || apdu.sw2 != 0x00))
  ------------------
  |  Branch (867:6): [True: 7.24k, False: 0]
  |  Branch (867:27): [True: 4.18k, False: 3.05k]
  |  Branch (867:47): [True: 133, False: 2.92k]
  ------------------
  868|  4.31k|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|  4.31k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  4.31k|	int _ret = r; \
  |  |  155|  4.31k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 4.31k, False: 0]
  |  |  ------------------
  |  |  156|  4.31k|		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|  4.31k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 4.31k, False: 0]
  |  |  ------------------
  |  |  157|  4.31k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  4.31k|	} 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|  4.31k|	return _ret; \
  |  |  163|  4.31k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  869|       |
  870|  2.92k|	if (file_out) {
  ------------------
  |  Branch (870:6): [True: 1.00k, False: 1.92k]
  ------------------
  871|  1.00k|		sc_file_t *file = sc_file_new();
  872|  1.00k|		if (!file)
  ------------------
  |  Branch (872:7): [True: 0, False: 1.00k]
  ------------------
  873|  1.00k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  874|  1.00k|		file->id = (id_hi << 8) + id_lo;
  875|       |
  876|  1.00k|		if (bIsDF || isMF) {
  ------------------
  |  Branch (876:7): [True: 164, False: 836]
  |  Branch (876:16): [True: 0, False: 836]
  ------------------
  877|       |			/* we have a DF */
  878|    164|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    164|#define SC_FILE_TYPE_DF			0x04
  ------------------
  879|    164|			file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|    164|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  880|    164|			file->size = 0;
  881|    164|			file->namelen = 0;
  882|    164|			file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|    164|#define SC_FILE_MAGIC			0x14426950
  ------------------
  883|    164|			*file_out = file;
  884|    836|		} else {
  885|       |			/* ok, assume we have a EF */
  886|    836|			if ( IS_V3x(card) ) {
  ------------------
  |  |  121|  1.67k|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|    836|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 270, False: 566]
  |  |  |  |  |  Branch (119:65): [True: 86, False: 480]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|    480|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 52, False: 428]
  |  |  |  |  |  Branch (120:65): [True: 11, False: 417]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|    419|				if (isFCP) {
  ------------------
  |  Branch (887:9): [True: 419, False: 0]
  ------------------
  888|    419|					r = process_fcp_v3_4(card->ctx, file, apdu.resp,
  889|    419|							apdu.resplen);
  890|    419|				} else {
  891|      0|					r = process_fci_v3_4(card->ctx, file, apdu.resp,
  892|      0|							apdu.resplen);
  893|      0|				}
  894|    419|			} else {
  895|    417|				r = process_fci(card->ctx, file, apdu.resp,
  896|    417|						apdu.resplen);
  897|    417|			}
  898|    836|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    836|#define SC_SUCCESS				0
  ------------------
  |  Branch (898:8): [True: 324, False: 512]
  ------------------
  899|    324|				sc_file_free(file);
  900|    324|				return r;
  901|    324|			}
  902|       |
  903|    512|			*file_out = file;
  904|    512|		}
  905|  1.00k|	}
  906|       |
  907|  2.59k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|  2.59k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  2.59k|	int _ret = r; \
  |  |  155|  2.59k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 2.59k, False: 0]
  |  |  ------------------
  |  |  156|  2.59k|		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: 2.59k]
  |  |  ------------------
  |  |  157|  2.59k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  2.59k|	} 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|  2.59k|	return _ret; \
  |  |  163|  2.59k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  908|  2.59k|}
card-starcos.c:process_fcp_v3_4:
  605|    419|{
  606|    419|	size_t taglen, len = buflen;
  607|    419|	const u8 *tag = NULL, *p;
  608|       |
  609|    419|	sc_log(ctx, "processing %zu FCP bytes\n", buflen);
  ------------------
  |  |   71|    419|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  610|       |
  611|    419|	if (buflen < 2)
  ------------------
  |  Branch (611:6): [True: 85, False: 334]
  ------------------
  612|     85|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     85|#define SC_ERROR_INTERNAL			-1400
  ------------------
  613|    334|	if (buf[0] != 0x62)
  ------------------
  |  Branch (613:6): [True: 24, False: 310]
  ------------------
  614|     24|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     24|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  615|    310|	len = (size_t)buf[1];
  616|    310|	if (buflen - 2 < len)
  ------------------
  |  Branch (616:6): [True: 12, False: 298]
  ------------------
  617|     12|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     12|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  618|    298|	p = buf + 2;
  619|       |
  620|    298|	tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
  621|    298|	if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (621:6): [True: 27, False: 271]
  |  Branch (621:21): [True: 15, False: 12]
  ------------------
  622|     15|		int bytes = (tag[0] << 8) + tag[1];
  623|     15|		sc_log(ctx,
  ------------------
  |  |   71|     15|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  624|     15|			"  bytes in file: %d\n", bytes);
  625|     15|		file->size = bytes;
  626|     15|	}
  627|       |
  628|    298|	tag = sc_asn1_find_tag(ctx, p, len, 0xc5, &taglen);
  629|    298|	if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (629:6): [True: 56, False: 242]
  |  Branch (629:21): [True: 18, False: 38]
  ------------------
  630|     18|		int bytes = (tag[0] << 8) + tag[1];
  631|     18|		sc_log(ctx,
  ------------------
  |  |   71|     18|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  632|     18|			"  bytes in file 2: %d\n", bytes);
  633|     18|		file->size = bytes;
  634|     18|	}
  635|       |
  636|    298|	tag = sc_asn1_find_tag(ctx, p, len, 0x82, &taglen);
  637|    298|	if (tag != NULL) {
  ------------------
  |  Branch (637:6): [True: 89, False: 209]
  ------------------
  638|     89|		const char *type = "unknown";
  639|     89|		const char *structure = "unknown";
  640|       |
  641|     89|		if (taglen >= 1) {
  ------------------
  |  Branch (641:7): [True: 68, False: 21]
  ------------------
  642|     68|			unsigned char byte = tag[0];
  643|     68|			if (byte & 0x40) {
  ------------------
  |  Branch (643:8): [True: 27, False: 41]
  ------------------
  644|     27|				file->shareable = 1;
  645|     27|			}
  646|     68|			if (byte == 0x38) {
  ------------------
  |  Branch (646:8): [True: 10, False: 58]
  ------------------
  647|     10|				type = "DF";
  648|     10|				file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     10|#define SC_FILE_TYPE_DF			0x04
  ------------------
  649|     10|				file->shareable = 1;
  650|     10|			}
  651|     68|			switch (byte & 7) {
  652|     11|			case 1:
  ------------------
  |  Branch (652:4): [True: 11, False: 57]
  ------------------
  653|       |				/* transparent EF */
  654|     11|				type = "working EF";
  655|     11|				structure = "transparent";
  656|     11|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     11|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  657|     11|				file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     11|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  658|     11|				break;
  659|     11|			case 2:
  ------------------
  |  Branch (659:4): [True: 11, False: 57]
  ------------------
  660|       |				/* linear fixed EF */
  661|     11|				type = "working EF";
  662|     11|				structure = "linear fixed";
  663|     11|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     11|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  664|     11|				file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|     11|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  665|     11|				break;
  666|     10|			case 4:
  ------------------
  |  Branch (666:4): [True: 10, False: 58]
  ------------------
  667|       |				/* linear variable EF */
  668|     10|				type = "working EF";
  669|     10|				structure = "linear variable";
  670|     10|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     10|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  671|     10|				file->ef_structure = SC_FILE_EF_LINEAR_VARIABLE;
  ------------------
  |  |  224|     10|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  672|     10|				break;
  673|     13|			case 6:
  ------------------
  |  Branch (673:4): [True: 13, False: 55]
  ------------------
  674|       |				/* cyclic EF */
  675|     13|				type = "working EF";
  676|     13|				structure = "cyclic";
  677|     13|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     13|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  678|     13|				file->ef_structure = SC_FILE_EF_CYCLIC;
  ------------------
  |  |  226|     13|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  679|     13|				break;
  680|     23|			default:
  ------------------
  |  Branch (680:4): [True: 23, False: 45]
  ------------------
  681|       |				/* use defaults from above */
  682|     23|				break;
  683|     68|			}
  684|     68|		}
  685|     89|		sc_log(ctx,
  ------------------
  |  |   71|     89|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  686|     89|			"  type: %s\n", type);
  687|     89|		sc_log(ctx,
  ------------------
  |  |   71|     89|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  688|     89|			"  EF structure: %s\n", structure);
  689|     89|		if (taglen >= 2) {
  ------------------
  |  Branch (689:7): [True: 61, False: 28]
  ------------------
  690|     61|			if (tag[1] != 0x41 || taglen != 5) {
  ------------------
  |  Branch (690:8): [True: 50, False: 11]
  |  Branch (690:26): [True: 11, False: 0]
  ------------------
  691|     61|				SC_FUNC_RETURN(ctx, 2,SC_ERROR_INVALID_DATA);
  ------------------
  |  |  153|     61|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     61|	int _ret = r; \
  |  |  155|     61|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 61, False: 0]
  |  |  ------------------
  |  |  156|     61|		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|     61|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 61, False: 0]
  |  |  ------------------
  |  |  157|     61|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     61|	} 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|     61|	return _ret; \
  |  |  163|     61|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  692|     61|			}
  693|       |			/* formatted EF */
  694|      0|			file->record_length = (tag[2] << 8) + tag[3];
  695|      0|			file->record_count = tag[4];
  696|      0|			sc_log(ctx, "  rec_len: %zu  rec_cnt: %zu", file->record_length, file->record_count);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  697|      0|		}
  698|     89|	}
  699|       |
  700|    237|	tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen);
  701|    237|	if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (701:6): [True: 20, False: 217]
  |  Branch (701:21): [True: 10, False: 10]
  ------------------
  702|     10|		file->id = (tag[0] << 8) | tag[1];
  703|     10|		sc_log(ctx,  "  file identifier: 0x%02X%02X\n",
  ------------------
  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  704|     10|			tag[0], tag[1]);
  705|     10|	}
  706|       |
  707|    237|	tag = sc_asn1_find_tag(ctx, p, len, 0x84, &taglen);
  708|    237|	if (tag != NULL && taglen > 0 && taglen <= 16) {
  ------------------
  |  Branch (708:6): [True: 22, False: 215]
  |  Branch (708:21): [True: 11, False: 11]
  |  Branch (708:35): [True: 10, False: 1]
  ------------------
  709|     10|		memcpy(file->name, tag, taglen);
  710|     10|		file->namelen = taglen;
  711|     10|		sc_log(ctx,  "  filename %s",
  ------------------
  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  712|     10|			sc_dump_hex(file->name, file->namelen));
  713|     10|	}
  714|       |
  715|    237|	tag = sc_asn1_find_tag(ctx, p, len, 0x8a, &taglen);
  716|    237|	if (tag != NULL && taglen == 1) {
  ------------------
  |  Branch (716:6): [True: 15, False: 222]
  |  Branch (716:21): [True: 5, False: 10]
  ------------------
  717|      5|		char* status = "unknown";
  718|      5|		switch (tag[0]) {
  719|      1|		case 1:
  ------------------
  |  Branch (719:3): [True: 1, False: 4]
  ------------------
  720|      1|			status = "creation";
  721|      1|			file->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|      1|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  722|      1|			break;
  723|      1|		case 5:
  ------------------
  |  Branch (723:3): [True: 1, False: 4]
  ------------------
  724|      1|			status = "operational active";
  725|      1|			file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|      1|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  726|      1|			break;
  727|      1|		case 12:
  ------------------
  |  Branch (727:3): [True: 1, False: 4]
  ------------------
  728|      2|		case 13:
  ------------------
  |  Branch (728:3): [True: 1, False: 4]
  ------------------
  729|      2|			status = "creation";
  730|      2|			file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|      2|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  731|      2|			break;
  732|      1|		default:
  ------------------
  |  Branch (732:3): [True: 1, False: 4]
  ------------------
  733|      1|			break;
  734|      5|		}
  735|      5|		sc_log(ctx,  "  file status: %s\n", status);
  ------------------
  |  |   71|      5|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  736|      5|	}
  737|       |
  738|    237|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|    237|#define SC_FILE_MAGIC			0x14426950
  ------------------
  739|    237|	return SC_SUCCESS;
  ------------------
  |  |   28|    237|#define SC_SUCCESS				0
  ------------------
  740|    237|}
card-starcos.c:process_fci:
  478|    417|{
  479|       |	/* NOTE: According to the Starcos S 2.1 manual it's possible
  480|       |	 *       that a SELECT DF returns as a FCI arbitrary data which
  481|       |	 *       is stored in a object file (in the corresponding DF)
  482|       |	 *       with the tag 0x6f.
  483|       |	 */
  484|       |
  485|    417|	size_t taglen, len = buflen;
  486|    417|	const u8 *tag = NULL, *p;
  487|       |
  488|    417|	sc_log(ctx,  "processing FCI bytes\n");
  ------------------
  |  |   71|    417|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  489|       |
  490|    417|	if (buflen < 2)
  ------------------
  |  Branch (490:6): [True: 59, False: 358]
  ------------------
  491|     59|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     59|#define SC_ERROR_INTERNAL			-1400
  ------------------
  492|    358|	if (buf[0] != 0x6f)
  ------------------
  |  Branch (492:6): [True: 45, False: 313]
  ------------------
  493|     45|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     45|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  494|    313|	len = (size_t)buf[1];
  495|    313|	if (buflen - 2 < len)
  ------------------
  |  Branch (495:6): [True: 38, False: 275]
  ------------------
  496|     38|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     38|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  497|    275|	p = buf + 2;
  498|       |
  499|       |	/* defaults */
  500|    275|	file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    275|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  501|    275|	file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|    275|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  502|    275|	file->shareable = 0;
  503|    275|	file->record_length = 0;
  504|    275|	file->size = 0;
  505|       |
  506|    275|	tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
  507|    275|	if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (507:6): [True: 30, False: 245]
  |  Branch (507:21): [True: 27, False: 3]
  ------------------
  508|     27|		int bytes = (tag[0] << 8) + tag[1];
  509|     27|		sc_log(ctx,
  ------------------
  |  |   71|     27|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  510|     27|			"  bytes in file: %d\n", bytes);
  511|     27|		file->size = bytes;
  512|     27|	}
  513|       |
  514|    275|	tag = sc_asn1_find_tag(ctx, p, len, 0x82, &taglen);
  515|    275|	if (tag != NULL) {
  ------------------
  |  Branch (515:6): [True: 64, False: 211]
  ------------------
  516|     64|		const char *type = "unknown";
  517|     64|		const char *structure = "unknown";
  518|       |
  519|     64|		if (taglen == 1 && tag[0] == 0x01) {
  ------------------
  |  Branch (519:7): [True: 26, False: 38]
  |  Branch (519:22): [True: 11, False: 15]
  ------------------
  520|       |			/* transparent EF */
  521|     11|			type = "working EF";
  522|     11|			structure = "transparent";
  523|     11|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     11|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  524|     11|			file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     11|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  525|     53|		} else if (taglen == 1 && tag[0] == 0x11) {
  ------------------
  |  Branch (525:14): [True: 15, False: 38]
  |  Branch (525:29): [True: 4, False: 11]
  ------------------
  526|       |			/* object EF */
  527|      4|			type = "working EF";
  528|      4|			structure = "object";
  529|      4|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      4|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  530|      4|			file->ef_structure = SC_FILE_EF_TRANSPARENT; /* TODO */
  ------------------
  |  |  221|      4|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  531|     49|		} else if (taglen == 3 && tag[1] == 0x21) {
  ------------------
  |  Branch (531:14): [True: 31, False: 18]
  |  Branch (531:29): [True: 25, False: 6]
  ------------------
  532|     25|			type = "working EF";
  533|     25|			file->record_length = tag[2];
  534|     25|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     25|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  535|       |			/* linear fixed, cyclic or compute */
  536|     25|			switch ( tag[0] )
  537|     25|			{
  538|      3|				case 0x02:
  ------------------
  |  Branch (538:5): [True: 3, False: 22]
  ------------------
  539|      3|					structure = "linear fixed";
  540|      3|					file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|      3|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  541|      3|					break;
  542|      6|				case 0x07:
  ------------------
  |  Branch (542:5): [True: 6, False: 19]
  ------------------
  543|      6|					structure = "cyclic";
  544|      6|					file->ef_structure = SC_FILE_EF_CYCLIC;
  ------------------
  |  |  226|      6|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  545|      6|					break;
  546|      6|				case 0x17:
  ------------------
  |  Branch (546:5): [True: 6, False: 19]
  ------------------
  547|      6|					structure = "compute";
  548|      6|					file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      6|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  549|      6|					break;
  550|     10|				default:
  ------------------
  |  Branch (550:5): [True: 10, False: 15]
  ------------------
  551|     10|					structure = "unknown";
  552|     10|					file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|     10|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  553|     10|					file->record_length = 0;
  554|     10|					break;
  555|     25|			}
  556|     25|		}
  557|       |
  558|     64|		sc_log(ctx,
  ------------------
  |  |   71|     64|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  559|     64|			"  type: %s\n", type);
  560|     64|		sc_log(ctx,
  ------------------
  |  |   71|     64|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  561|     64|			"  EF structure: %s\n", structure);
  562|     64|	}
  563|    275|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|    275|#define SC_FILE_MAGIC			0x14426950
  ------------------
  564|       |
  565|    275|	return SC_SUCCESS;
  ------------------
  |  |   28|    275|#define SC_SUCCESS				0
  ------------------
  566|    275|}
card-starcos.c:starcos_get_challenge:
 1001|    309|{
 1002|    309|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    309|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    309|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    309|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    309|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 309]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1003|       |
 1004|    309|	if (len > 8) {
  ------------------
  |  Branch (1004:6): [True: 281, False: 28]
  ------------------
 1005|    281|		len = 8;
 1006|    281|	}
 1007|       |
 1008|    309|	LOG_FUNC_RETURN(card->ctx, iso_ops->get_challenge(card, rnd, len));
  ------------------
  |  |  164|    309|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    309|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    309|	int _ret = r; \
  |  |  |  |  155|    309|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 70, False: 239]
  |  |  |  |  ------------------
  |  |  |  |  156|     70|		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|     70|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 70, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     70|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    239|	} else { \
  |  |  |  |  159|    239|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    239|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    239|	} \
  |  |  |  |  162|    309|	return _ret; \
  |  |  |  |  163|    309|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1009|    309|}
card-starcos.c:starcos_check_sw:
 1941|  14.5k|{
 1942|  14.5k|	const int err_count = sizeof(starcos_errors)/sizeof(starcos_errors[0]);
 1943|  14.5k|	int i;
 1944|       |
 1945|  14.5k|	sc_log(card->ctx,
  ------------------
  |  |   71|  14.5k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1946|  14.5k|		"sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
 1947|       |
 1948|  14.5k|	if (sw1 == 0x90 && sw2 == 0x00)
  ------------------
  |  Branch (1948:6): [True: 6.00k, False: 8.51k]
  |  Branch (1948:21): [True: 5.63k, False: 366]
  ------------------
 1949|  5.63k|		return SC_SUCCESS;
  ------------------
  |  |   28|  5.63k|#define SC_SUCCESS				0
  ------------------
 1950|  8.87k|	if (sw1 == 0x63 && (sw2 & ~0x0fU) == 0xc0 )
  ------------------
  |  Branch (1950:6): [True: 508, False: 8.37k]
  |  Branch (1950:21): [True: 37, False: 471]
  ------------------
 1951|     37|	{
 1952|     37|		sc_log(card->ctx,  "Verification failed (remaining tries: %d)\n",
  ------------------
  |  |   71|     37|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1953|     37|		(sw2 & 0x0f));
 1954|     37|		return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|     37|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
 1955|     37|	}
 1956|       |
 1957|       |	/* check starcos error messages */
 1958|   132k|	for (i = 0; i < err_count; i++)
  ------------------
  |  Branch (1958:14): [True: 123k, False: 8.79k]
  ------------------
 1959|   123k|		if (starcos_errors[i].SWs == ((sw1 << 8) | sw2))
  ------------------
  |  Branch (1959:7): [True: 46, False: 123k]
  ------------------
 1960|     46|		{
 1961|     46|			sc_log(card->ctx,  "%s\n", starcos_errors[i].errorstr);
  ------------------
  |  |   71|     46|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1962|     46|			return starcos_errors[i].errorno;
 1963|     46|		}
 1964|       |
 1965|       |	/* iso error */
 1966|  8.79k|	return iso_ops->check_sw(card, sw1, sw2);
 1967|  8.84k|}
card-starcos.c:starcos_set_security_env:
 1538|     39|{
 1539|     39|	u8              *p, *pp;
 1540|     39|	int              r, operation = env->operation;
 1541|     39|	sc_apdu_t   apdu;
 1542|     39|	u8               sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1543|     39|	starcos_ex_data *ex_data = (starcos_ex_data *)card->drv_data;
 1544|       |
 1545|     39|	p     = sbuf;
 1546|       |
 1547|     39|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|     78|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|     39|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 11, False: 28]
  |  |  |  |  |  Branch (119:65): [True: 3, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|     25|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 0, False: 25]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|     14|		u8 algorithm_supported = (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1) ||
  ------------------
  |  |  111|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  |  Branch (1548:28): [True: 14, False: 0]
  ------------------
 1549|      0|								(env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PSS);
  ------------------
  |  |  107|      0|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  |  Branch (1549:9): [True: 0, False: 0]
  ------------------
 1550|     14|		if (!algorithm_supported ||
  ------------------
  |  Branch (1550:7): [True: 0, False: 14]
  ------------------
 1551|     14|			!(env->flags & SC_SEC_ENV_KEY_REF_PRESENT) || env->key_ref_len != 1) {
  ------------------
  |  |   58|     14|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
  |  Branch (1551:4): [True: 0, False: 14]
  |  Branch (1551:50): [True: 0, False: 14]
  ------------------
 1552|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1553|      0|		}
 1554|       |
 1555|       |		/* Tag '84' (length 1) denotes key name or key reference */
 1556|     14|		*p++ = 0x84;
 1557|     14|		*p++ = 0x01;
 1558|     14|		if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT) {
  ------------------
  |  |   57|     14|#define SC_SEC_ENV_FILE_REF_PRESENT	0x0002
  ------------------
  |  Branch (1558:7): [True: 0, False: 14]
  ------------------
 1559|      0|			*p++ = *env->key_ref | 0x80;
 1560|     14|		} else {
 1561|     14|			*p++ = *env->key_ref;
 1562|     14|		}
 1563|       |
 1564|     14|		switch (operation) {
 1565|      3|			case SC_SEC_OPERATION_SIGN:
  ------------------
  |  |   48|      3|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (1565:4): [True: 3, False: 11]
  ------------------
 1566|      3|				sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x41, 0xB6);
  ------------------
  |  |  293|      3|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1567|       |
 1568|       |				/* algorithm / cipher selector? */
 1569|       |				/* algorithm: 13.23 PKCS#1 signature with RSA (standard) */
 1570|       |				/* algorithm: 13.33.30 PKCS#1-PSS signature with SHA-256 */
 1571|      3|				*p++ = 0x89;
 1572|      3|				if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PSS) {
  ------------------
  |  |  107|      3|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  |  Branch (1572:9): [True: 0, False: 3]
  ------------------
 1573|      0|					*p++ = 0x03;
 1574|      0|					*p++ = 0x13;
 1575|      0|					*p++ = 0x33;
 1576|      0|					*p++ = 0x30;
 1577|      3|				} else {
 1578|       |					// fall back, RSA PKCS1 Padding
 1579|      3|					*p++ = 0x02;
 1580|      3|					*p++ = 0x13;
 1581|      3|					*p++ = 0x23;
 1582|      3|				}
 1583|      3|				break;
 1584|       |
 1585|     11|			case SC_SEC_OPERATION_DECIPHER:
  ------------------
  |  |   47|     11|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
  |  Branch (1585:4): [True: 11, False: 3]
  ------------------
 1586|     11|				sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x41, 0xB8);
  ------------------
  |  |  293|     11|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1587|       |
 1588|       |				/* algorithm / cipher selector? */
 1589|       |				/* algorithm: 11.3  Encipherment RSA (standard) */
 1590|       |				/* algorithm: 11.31 Encipherment RSA (standard) with PKCS#1 padding */
 1591|       |				/* algorithm: 11.32 Encipherment RSA OAEP padding */
 1592|     11|				*p++ = 0x89;
 1593|     11|				*p++ = 0x02;
 1594|     11|				*p++ = 0x11;
 1595|     11|				if ( IS_V34(card) )
  ------------------
  |  |  119|     11|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  ------------------
  |  |  |  Branch (119:22): [True: 9, False: 2]
  |  |  |  Branch (119:65): [True: 2, False: 0]
  |  |  ------------------
  ------------------
 1596|     11|					*p++ = 0x30;
 1597|      0|				else
 1598|      0|					*p++ = 0x31;
 1599|     11|				break;
 1600|       |
 1601|      0|			default:
  ------------------
  |  Branch (1601:4): [True: 0, False: 14]
  ------------------
 1602|      0|				sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1603|      0|						"not supported for STARCOS 3.4 cards");
 1604|      0|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1605|     14|		}
 1606|       |
 1607|     14|		apdu.data    = sbuf;
 1608|     14|		apdu.datalen = p - sbuf;
 1609|     14|		apdu.lc      = p - sbuf;
 1610|     14|		apdu.le      = 0;
 1611|     14|		r = sc_transmit_apdu(card, &apdu);
 1612|     14|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1613|     13|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1613:7): [True: 8, False: 5]
  |  Branch (1613:27): [True: 1, False: 4]
  ------------------
 1614|      9|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|      9|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      9|	int _ret = r; \
  |  |  155|      9|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 9, False: 0]
  |  |  ------------------
  |  |  156|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 9, False: 0]
  |  |  ------------------
  |  |  157|      9|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      9|	} 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|      9|	return _ret; \
  |  |  163|      9|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1615|       |
 1616|      4|		if ((operation == SC_SEC_OPERATION_SIGN && env->algorithm_flags == SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01)
  ------------------
  |  |   48|      8|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
              		if ((operation == SC_SEC_OPERATION_SIGN && env->algorithm_flags == SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01)
  ------------------
  |  |  109|      2|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (1616:8): [True: 2, False: 2]
  |  Branch (1616:46): [True: 0, False: 2]
  ------------------
 1617|      4|			|| (operation == SC_SEC_OPERATION_DECIPHER && env->algorithm_flags == SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02)) {
  ------------------
  |  |   47|      8|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
              			|| (operation == SC_SEC_OPERATION_DECIPHER && env->algorithm_flags == SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02)) {
  ------------------
  |  |  110|      2|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  |  Branch (1617:8): [True: 2, False: 2]
  |  Branch (1617:50): [True: 2, False: 0]
  ------------------
 1618|       |			// input data will be already padded
 1619|      2|			ex_data->fix_digestInfo = 0;
 1620|      2|		} else {
 1621|      2|			ex_data->fix_digestInfo = env->algorithm_flags;
 1622|      2|		}
 1623|      4|		ex_data->sec_ops        = SC_SEC_OPERATION_SIGN;
  ------------------
  |  |   48|      4|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
 1624|      4|		return SC_SUCCESS;
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
 1625|     13|	}
 1626|       |
 1627|       |	/* copy key reference, if present */
 1628|     25|	if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT) {
  ------------------
  |  |   58|     25|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
  |  Branch (1628:6): [True: 25, False: 0]
  ------------------
 1629|     25|		if (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC)
  ------------------
  |  |   59|     25|#define SC_SEC_ENV_KEY_REF_SYMMETRIC	0x0008
  ------------------
  |  Branch (1629:7): [True: 0, False: 25]
  ------------------
 1630|      0|			*p++ = 0x83;
 1631|     25|		else
 1632|     25|			*p++ = 0x84;
 1633|     25|		*p++ = env->key_ref_len;
 1634|     25|		memcpy(p, env->key_ref, env->key_ref_len);
 1635|     25|		p += env->key_ref_len;
 1636|     25|	}
 1637|     25|	pp = p;
 1638|     25|	if (operation == SC_SEC_OPERATION_DECIPHER){
  ------------------
  |  |   47|     25|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
  |  Branch (1638:6): [True: 0, False: 25]
  ------------------
 1639|      0|		if (env->algorithm_flags & 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 */
  ------------------
  |  Branch (1639:7): [True: 0, False: 0]
  ------------------
 1640|      0|			*p++ = 0x80;
 1641|      0|			*p++ = 0x01;
 1642|      0|			*p++ = 0x02;
 1643|      0|		} else
 1644|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1645|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x81,
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1646|      0|		               0xb8);
 1647|      0|		apdu.data    = sbuf;
 1648|      0|		apdu.datalen = p - sbuf;
 1649|      0|		apdu.lc      = p - sbuf;
 1650|      0|		apdu.le      = 0;
 1651|      0|		r = sc_transmit_apdu(card, &apdu);
 1652|      0|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1653|      0|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1653:7): [True: 0, False: 0]
  |  Branch (1653:27): [True: 0, False: 0]
  ------------------
 1654|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1655|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1656|      0|	}
 1657|       |	/* try COMPUTE SIGNATURE */
 1658|     25|	if (operation == SC_SEC_OPERATION_SIGN && (
  ------------------
  |  |   48|     50|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (1658:6): [True: 25, False: 0]
  ------------------
 1659|     25|	    env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 ||
  ------------------
  |  |  109|     50|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (1659:6): [True: 25, False: 0]
  ------------------
 1660|     25|	    env->algorithm_flags & SC_ALGORITHM_RSA_PAD_ISO9796)) {
  ------------------
  |  |  106|      0|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  |  Branch (1660:6): [True: 0, False: 0]
  ------------------
 1661|     25|		if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT) {
  ------------------
  |  |   56|     25|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
  |  Branch (1661:7): [True: 0, False: 25]
  ------------------
 1662|      0|			*p++ = 0x80;
 1663|      0|			*p++ = 0x01;
 1664|      0|			*p++ = env->algorithm_ref & 0xFF;
 1665|     25|		} else if (env->flags & SC_SEC_ENV_ALG_PRESENT &&
  ------------------
  |  |   60|     50|#define SC_SEC_ENV_ALG_PRESENT		0x0010
  ------------------
  |  Branch (1665:14): [True: 25, False: 0]
  ------------------
 1666|     25|		            env->algorithm == SC_ALGORITHM_RSA) {
  ------------------
  |  |   69|     25|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1666:15): [True: 25, False: 0]
  ------------------
 1667|       |			/* set the method to use based on the algorithm_flags */
 1668|     25|			*p++ = 0x80;
 1669|     25|			*p++ = 0x01;
 1670|     25|			if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01) {
  ------------------
  |  |  109|     25|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (1670:8): [True: 25, False: 0]
  ------------------
 1671|     25|				if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA1)
  ------------------
  |  |  134|     25|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  |  Branch (1671:9): [True: 3, False: 22]
  ------------------
 1672|      3|					*p++ = 0x12;
 1673|     22|				else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_RIPEMD160)
  ------------------
  |  |  137|     22|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
  |  Branch (1673:14): [True: 1, False: 21]
  ------------------
 1674|      1|					*p++ = 0x22;
 1675|     21|				else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_MD5)
  ------------------
  |  |  135|     21|#define SC_ALGORITHM_RSA_HASH_MD5	0x00000400
  ------------------
  |  Branch (1675:14): [True: 18, False: 3]
  ------------------
 1676|     18|					*p++ = 0x32;
 1677|      3|				else {
 1678|       |					/* can't use COMPUTE SIGNATURE =>
 1679|       |					 * try INTERNAL AUTHENTICATE */
 1680|      3|					p = pp;
 1681|      3|					operation = SC_SEC_OPERATION_AUTHENTICATE;
  ------------------
  |  |   49|      3|#define SC_SEC_OPERATION_AUTHENTICATE	0x0003
  ------------------
 1682|      3|					goto try_authenticate;
 1683|      3|				}
 1684|     25|			} else if (env->algorithm_flags & SC_ALGORITHM_RSA_PAD_ISO9796) {
  ------------------
  |  |  106|      0|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  |  Branch (1684:15): [True: 0, False: 0]
  ------------------
 1685|      0|				if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_SHA1)
  ------------------
  |  |  134|      0|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  |  Branch (1685:9): [True: 0, False: 0]
  ------------------
 1686|      0|					*p++ = 0x11;
 1687|      0|				else if (env->algorithm_flags & SC_ALGORITHM_RSA_HASH_RIPEMD160)
  ------------------
  |  |  137|      0|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
  |  Branch (1687:14): [True: 0, False: 0]
  ------------------
 1688|      0|					*p++ = 0x21;
 1689|      0|				else
 1690|      0|					return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1691|      0|			} else
 1692|      0|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1693|     25|		}
 1694|     22|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x41, 0xb6);
  ------------------
  |  |  293|     22|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1695|     22|		apdu.data    = sbuf;
 1696|     22|		apdu.datalen = p - sbuf;
 1697|     22|		apdu.lc      = p - sbuf;
 1698|     22|		apdu.le      = 0;
 1699|       |		/* we don't know whether to use
 1700|       |		 * COMPUTE SIGNATURE or INTERNAL AUTHENTICATE */
 1701|     22|		r = sc_transmit_apdu(card, &apdu);
 1702|     22|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     22|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     22|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     22|	int _ret = (r); \
  |  |  |  |  168|     22|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 21]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1703|     21|		if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (1703:7): [True: 16, False: 5]
  |  Branch (1703:27): [True: 10, False: 6]
  ------------------
 1704|     10|			ex_data->fix_digestInfo = 0;
 1705|     10|			ex_data->sec_ops        = SC_SEC_OPERATION_SIGN;
  ------------------
  |  |   48|     10|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
 1706|     10|			return SC_SUCCESS;
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
 1707|     10|		}
 1708|       |		/* reset pointer */
 1709|     11|		p = pp;
 1710|       |		/* doesn't work => try next op */
 1711|     11|		operation = SC_SEC_OPERATION_AUTHENTICATE;
  ------------------
  |  |   49|     11|#define SC_SEC_OPERATION_AUTHENTICATE	0x0003
  ------------------
 1712|     11|	}
 1713|     14|try_authenticate:
 1714|       |	/* try INTERNAL AUTHENTICATE */
 1715|     14|	if (operation == SC_SEC_OPERATION_AUTHENTICATE &&
  ------------------
  |  |   49|     28|#define SC_SEC_OPERATION_AUTHENTICATE	0x0003
  ------------------
  |  Branch (1715:6): [True: 14, False: 0]
  ------------------
 1716|     14|	    env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1) {
  ------------------
  |  |  111|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  |  Branch (1716:6): [True: 14, False: 0]
  ------------------
 1717|     14|		*p++ = 0x80;
 1718|     14|		*p++ = 0x01;
 1719|     14|		*p++ = 0x01;
 1720|     14|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x41,
  ------------------
  |  |  293|     14|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1721|     14|		               0xa4);
 1722|     14|		apdu.data    = sbuf;
 1723|     14|		apdu.datalen = p - sbuf;
 1724|     14|		apdu.lc      = p - sbuf;
 1725|     14|		apdu.le      = 0;
 1726|     14|		r = sc_transmit_apdu(card, &apdu);
 1727|     14|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1728|     13|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1728:7): [True: 5, False: 8]
  |  Branch (1728:27): [True: 1, False: 7]
  ------------------
 1729|      6|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      6|	int _ret = r; \
  |  |  155|      6|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  ------------------
  |  |  156|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 6, False: 0]
  |  |  ------------------
  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  163|      6|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1730|      7|		ex_data->fix_digestInfo = env->algorithm_flags;
 1731|      7|		ex_data->sec_ops        = SC_SEC_OPERATION_AUTHENTICATE;
  ------------------
  |  |   49|      7|#define SC_SEC_OPERATION_AUTHENTICATE	0x0003
  ------------------
 1732|      7|		return SC_SUCCESS;
  ------------------
  |  |   28|      7|#define SC_SUCCESS				0
  ------------------
 1733|     13|	}
 1734|       |
 1735|      0|	return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1736|     14|}
card-starcos.c:starcos_compute_signature:
 1741|     19|{
 1742|     19|	int r;
 1743|     19|	sc_apdu_t apdu;
 1744|     19|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1745|     19|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1746|     19|	starcos_ex_data *ex_data = (starcos_ex_data *)card->drv_data;
 1747|       |
 1748|     19|	if (datalen > SC_MAX_APDU_BUFFER_SIZE)
  ------------------
  |  |   34|     19|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
  |  Branch (1748:6): [True: 0, False: 19]
  ------------------
 1749|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1750|       |
 1751|     19|	if (ex_data->sec_ops == SC_SEC_OPERATION_SIGN) {
  ------------------
  |  |   48|     19|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (1751:6): [True: 12, False: 7]
  ------------------
 1752|       |		/* compute signature with the COMPUTE SIGNATURE command */
 1753|       |
 1754|     12|		if ( IS_V3x(card) ) {
  ------------------
  |  |  121|     24|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|     12|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 1, False: 11]
  |  |  |  |  |  Branch (119:65): [True: 1, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|     10|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 0, False: 10]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1755|      2|			size_t tmp_len;
 1756|       |
 1757|      2|			sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x2A,
  ------------------
  |  |  303|      2|#define SC_APDU_CASE_4			0x24
  ------------------
 1758|      2|					   0x9E, 0x9A);
 1759|      2|			apdu.resp = out;
 1760|      2|			apdu.resplen = outlen;
 1761|      2|			apdu.le = outlen;
 1762|      2|			if (ex_data->fix_digestInfo) {
  ------------------
  |  Branch (1762:8): [True: 2, False: 0]
  ------------------
 1763|       |				// need to pad data
 1764|      2|				unsigned int flags = ex_data->fix_digestInfo & SC_ALGORITHM_RSA_HASHES;
  ------------------
  |  |  142|      2|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
 1765|      2|				if (flags == 0x00) {
  ------------------
  |  Branch (1765:9): [True: 0, False: 2]
  ------------------
 1766|      0|					flags = SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
 1767|      0|				}
 1768|      2|				tmp_len = sizeof(sbuf);
 1769|      2|				if (ex_data->fix_digestInfo & SC_ALGORITHM_RSA_PAD_PSS) {
  ------------------
  |  |  107|      2|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  |  Branch (1769:9): [True: 0, False: 2]
  ------------------
 1770|      0|					r = sc_pkcs1_strip_digest_info_prefix(NULL, data, datalen, sbuf, &tmp_len);
 1771|      2|				} else {
 1772|      2|					r = sc_pkcs1_encode(card->ctx, flags, data, datalen, sbuf, &tmp_len, sizeof(sbuf)*8, NULL);
 1773|      2|				}
 1774|      2|				LOG_TEST_RET(card->ctx, r, "sc_pkcs1_encode failed");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1775|      2|			} else {
 1776|      0|				memcpy(sbuf, data, datalen);
 1777|      0|				tmp_len = datalen;
 1778|      0|			}
 1779|       |
 1780|      2|			apdu.data = sbuf;
 1781|      2|			apdu.datalen = tmp_len;
 1782|      2|			apdu.lc = tmp_len;
 1783|       |
 1784|      2|			r = sc_transmit_apdu(card, &apdu);
 1785|      2|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1786|     10|		} else {
 1787|       |			/* set the hash value     */
 1788|     10|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x2A,
  ------------------
  |  |  293|     10|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1789|     10|					   0x90, 0x81);
 1790|     10|			apdu.resp = rbuf;
 1791|     10|			apdu.resplen = sizeof(rbuf);
 1792|     10|			apdu.le = 0;
 1793|     10|			memcpy(sbuf, data, datalen);
 1794|     10|			apdu.data = sbuf;
 1795|     10|			apdu.lc = datalen;
 1796|     10|			apdu.datalen = datalen;
 1797|     10|			r = sc_transmit_apdu(card, &apdu);
 1798|     10|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1799|      9|			if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1799:8): [True: 1, False: 8]
  |  Branch (1799:28): [True: 1, False: 7]
  ------------------
 1800|      2|				SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      2|	int _ret = r; \
  |  |  155|      2|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  ------------------
  |  |  156|      2|		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|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 2, False: 0]
  |  |  ------------------
  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  163|      2|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1801|      9|						   sc_check_sw(card, apdu.sw1, apdu.sw2));
 1802|       |
 1803|       |			/* call COMPUTE SIGNATURE */
 1804|      7|			sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x2A,
  ------------------
  |  |  292|      7|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1805|      7|					   0x9E, 0x9A);
 1806|      7|			apdu.resp = rbuf;
 1807|      7|			apdu.resplen = sizeof(rbuf);
 1808|      7|			apdu.le = 256;
 1809|       |
 1810|      7|			apdu.lc = 0;
 1811|      7|			apdu.datalen = 0;
 1812|      7|			r = sc_transmit_apdu(card, &apdu);
 1813|      7|			LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1814|      7|		}
 1815|      6|		if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (1815:7): [True: 3, False: 3]
  |  Branch (1815:27): [True: 2, False: 1]
  ------------------
 1816|      2|			size_t len = apdu.resplen > outlen ? outlen : apdu.resplen;
  ------------------
  |  Branch (1816:17): [True: 0, False: 2]
  ------------------
 1817|      2|			if ( out != apdu.resp ) {
  ------------------
  |  Branch (1817:9): [True: 2, False: 0]
  ------------------
 1818|      2|				memcpy(out, apdu.resp, len);
 1819|      2|			}
 1820|      2|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)len);
  ------------------
  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      2|	int _ret = r; \
  |  |  155|      2|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 1]
  |  |  ------------------
  |  |  156|      1|		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: 1]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} else { \
  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  161|      1|	} \
  |  |  162|      2|	return _ret; \
  |  |  163|      2|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1821|      2|		}
 1822|      7|	} else if (ex_data->sec_ops == SC_SEC_OPERATION_AUTHENTICATE) {
  ------------------
  |  |   49|      7|#define SC_SEC_OPERATION_AUTHENTICATE	0x0003
  ------------------
  |  Branch (1822:13): [True: 7, False: 0]
  ------------------
 1823|      7|		size_t tmp_len;
 1824|      7|		CHECK_NOT_SUPPORTED_V3_4(card);
  ------------------
  |  |  110|      7|	do { \
  |  |  111|      7|		if ((card)->type == SC_CARD_TYPE_STARCOS_V3_4) { \
  |  |  ------------------
  |  |  |  Branch (111:7): [True: 0, False: 7]
  |  |  ------------------
  |  |  112|      0|			sc_log((card)->ctx,  \
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  113|      0|				"not supported for STARCOS 3.4 cards"); \
  |  |  114|      0|			return SC_ERROR_NOT_SUPPORTED; \
  |  |  ------------------
  |  |  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  |  |  ------------------
  |  |  115|      0|		} \
  |  |  116|      7|	} while (0);
  |  |  ------------------
  |  |  |  Branch (116:11): [Folded, False: 7]
  |  |  ------------------
  ------------------
 1825|       |		/* call INTERNAL AUTHENTICATE */
 1826|      7|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x88, 0x10, 0x00);
  ------------------
  |  |  294|      7|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1827|       |		/* fix/create DigestInfo structure (if necessary) */
 1828|      7|		if (ex_data->fix_digestInfo) {
  ------------------
  |  Branch (1828:7): [True: 7, False: 0]
  ------------------
 1829|      7|			unsigned int flags = ex_data->fix_digestInfo & SC_ALGORITHM_RSA_HASHES;
  ------------------
  |  |  142|      7|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
 1830|      7|			if (flags == 0x0)
  ------------------
  |  Branch (1830:8): [True: 0, False: 7]
  ------------------
 1831|       |				/* XXX: assume no hash is wanted */
 1832|      0|				flags = SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
 1833|      7|			tmp_len = sizeof(sbuf);
 1834|      7|			r = sc_pkcs1_encode(card->ctx, flags, data, datalen,
 1835|      7|					sbuf, &tmp_len, sizeof(sbuf)*8, NULL);
 1836|      7|			if (r < 0)
  ------------------
  |  Branch (1836:8): [True: 0, False: 7]
  ------------------
 1837|      0|				return r;
 1838|      7|		} else {
 1839|      0|			memcpy(sbuf, data, datalen);
 1840|      0|			tmp_len = datalen;
 1841|      0|		}
 1842|      7|		apdu.lc = tmp_len;
 1843|      7|		apdu.data = sbuf;
 1844|      7|		apdu.datalen = tmp_len;
 1845|      7|		apdu.resp = rbuf;
 1846|      7|		apdu.resplen = sizeof(rbuf);
 1847|      7|		apdu.le = 256;
 1848|      7|		r = sc_transmit_apdu(card, &apdu);
 1849|      7|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1850|      6|		if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (1850:7): [True: 3, False: 3]
  |  Branch (1850:27): [True: 2, False: 1]
  ------------------
 1851|      2|			size_t len = apdu.resplen > outlen ? outlen : apdu.resplen;
  ------------------
  |  Branch (1851:17): [True: 0, False: 2]
  ------------------
 1852|       |
 1853|      2|			memcpy(out, apdu.resp, len);
 1854|      2|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)len);
  ------------------
  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      2|	int _ret = r; \
  |  |  155|      2|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 1]
  |  |  ------------------
  |  |  156|      1|		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: 1]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} else { \
  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  161|      1|	} \
  |  |  162|      2|	return _ret; \
  |  |  163|      2|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1855|      2|		}
 1856|      6|	} else
 1857|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1858|       |
 1859|       |	/* clear old state */
 1860|      8|	ex_data->sec_ops = 0;
 1861|      8|	ex_data->fix_digestInfo = 0;
 1862|       |
 1863|      8|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|      8|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      8|	int _ret = r; \
  |  |  155|      8|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 8, False: 0]
  |  |  ------------------
  |  |  156|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 8, False: 0]
  |  |  ------------------
  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      8|	} 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|      8|	return _ret; \
  |  |  163|      8|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1864|      8|}
card-starcos.c:starcos_decipher:
 1869|      2|{
 1870|      2|	int r;
 1871|      2|	size_t card_max_send_size = card->max_send_size;
 1872|      2|	size_t reader_max_send_size = card->reader->max_send_size;
 1873|      2|	size_t card_max_recv_size = card->max_recv_size;
 1874|      2|	size_t reader_max_recv_size = card->reader->max_recv_size;
 1875|       |
 1876|      2|	if (sc_get_max_send_size(card) < crgram_len + 1) {
  ------------------
  |  Branch (1876:6): [True: 0, False: 2]
  ------------------
 1877|       |		/* Starcos doesn't support chaining for PSO:DEC, so we just _hope_
 1878|       |		 * that both, the reader and the card are able to send enough data.
 1879|       |		 * (data is prefixed with 1 byte padding content indicator) */
 1880|      0|		card->max_send_size = crgram_len + 1;
 1881|      0|		card->reader->max_send_size = crgram_len + 1;
 1882|      0|	}
 1883|       |
 1884|      2|	if (sc_get_max_recv_size(card) < outlen) {
  ------------------
  |  Branch (1884:6): [True: 2, False: 0]
  ------------------
 1885|       |		/* Starcos doesn't support get response for PSO:DEC, so we just _hope_
 1886|       |		 * that both, the reader and the card are able to receive enough data.
 1887|       |		 */
 1888|      2|		if (0 == (card->caps & SC_CARD_CAP_APDU_EXT)
  ------------------
  |  |  547|      2|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (1888:7): [True: 2, False: 0]
  ------------------
 1889|      2|				&& outlen > 256) {
  ------------------
  |  Branch (1889:8): [True: 2, False: 0]
  ------------------
 1890|      2|			card->max_recv_size = 256;
 1891|      2|			card->reader->max_recv_size = 256;
 1892|      2|		} else {
 1893|      0|			card->max_recv_size = outlen;
 1894|      0|			card->reader->max_recv_size = outlen;
 1895|      0|		}
 1896|      2|	}
 1897|       |
 1898|      2|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|      4|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|      2|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 1, False: 1]
  |  |  |  |  |  Branch (119:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|      0|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 0, False: 0]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1899|      2|		sc_apdu_t apdu;
 1900|       |
 1901|      2|		u8 *sbuf = malloc(crgram_len + 1);
 1902|      2|		if (sbuf == NULL)
  ------------------
  |  Branch (1902:7): [True: 0, False: 2]
  ------------------
 1903|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1904|       |
 1905|      2|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x2A, 0x80, 0x86);
  ------------------
  |  |  303|      2|#define SC_APDU_CASE_4			0x24
  ------------------
 1906|      2|		apdu.resp    = out;
 1907|      2|		apdu.resplen = outlen;
 1908|      2|		apdu.le      = outlen;
 1909|       |
 1910|      2|		sbuf[0] = 0x81;
 1911|      2|		memcpy(sbuf + 1, crgram, crgram_len);
 1912|      2|		apdu.data = sbuf;
 1913|      2|		apdu.lc = crgram_len + 1;
 1914|      2|		apdu.datalen = crgram_len + 1;
 1915|       |
 1916|      2|		r = sc_transmit_apdu(card, &apdu);
 1917|      2|		sc_mem_clear(sbuf, crgram_len + 1);
 1918|       |
 1919|      2|		free(sbuf);
 1920|       |
 1921|      2|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1922|       |
 1923|      0|		if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (1923:7): [True: 0, False: 0]
  |  Branch (1923:27): [True: 0, False: 0]
  ------------------
 1924|      0|			r = (int)apdu.resplen;
 1925|      0|		else
 1926|      0|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1927|      0|	} else {
 1928|      0|		r = iso_ops->decipher(card, crgram, crgram_len, out, outlen);
 1929|      0|	}
 1930|       |
 1931|       |	/* reset whatever we've modified above */
 1932|      0|	card->max_send_size = card_max_send_size;
 1933|      0|	card->reader->max_send_size = reader_max_send_size;
 1934|      0|	card->max_recv_size = card_max_recv_size;
 1935|      0|	card->reader->max_recv_size = reader_max_recv_size;
 1936|       |
 1937|      0|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1938|      0|}
card-starcos.c:starcos_card_ctl:
 2016|    528|{
 2017|    528|	sc_starcos_create_data *tmp;
 2018|       |
 2019|    528|	switch (cmd)
 2020|    528|	{
 2021|      0|	case SC_CARDCTL_STARCOS_CREATE_FILE:
  ------------------
  |  Branch (2021:2): [True: 0, False: 528]
  ------------------
 2022|      0|		tmp = (sc_starcos_create_data *) ptr;
 2023|      0|		if (tmp->type == SC_STARCOS_MF_DATA)
  ------------------
  |  |  375|      0|#define	SC_STARCOS_MF_DATA	0x01
  ------------------
  |  Branch (2023:7): [True: 0, False: 0]
  ------------------
 2024|      0|			return starcos_create_mf(card, tmp);
 2025|      0|		else if (tmp->type == SC_STARCOS_DF_DATA)
  ------------------
  |  |  376|      0|#define SC_STARCOS_DF_DATA	0x02
  ------------------
  |  Branch (2025:12): [True: 0, False: 0]
  ------------------
 2026|      0|			return starcos_create_df(card, tmp);
 2027|      0|		else if (tmp->type == SC_STARCOS_EF_DATA)
  ------------------
  |  |  377|      0|#define SC_STARCOS_EF_DATA	0x04
  ------------------
  |  Branch (2027:12): [True: 0, False: 0]
  ------------------
 2028|      0|			return starcos_create_ef(card, tmp);
 2029|      0|		else
 2030|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2031|      0|	case SC_CARDCTL_STARCOS_CREATE_END:
  ------------------
  |  Branch (2031:2): [True: 0, False: 528]
  ------------------
 2032|      0|		return starcos_create_end(card, (sc_file_t *)ptr);
 2033|      0|	case SC_CARDCTL_STARCOS_WRITE_KEY:
  ------------------
  |  Branch (2033:2): [True: 0, False: 528]
  ------------------
 2034|      0|		return starcos_write_key(card, (sc_starcos_wkey_data *)ptr);
 2035|      0|	case SC_CARDCTL_STARCOS_GENERATE_KEY:
  ------------------
  |  Branch (2035:2): [True: 0, False: 528]
  ------------------
 2036|      0|		return starcos_gen_key(card, (sc_starcos_gen_key_data *)ptr);
 2037|      0|	case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (2037:2): [True: 0, False: 528]
  ------------------
 2038|      0|		return starcos_erase_card(card);
 2039|    301|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (2039:2): [True: 301, False: 227]
  ------------------
 2040|    301|		return starcos_get_serialnr(card, (sc_serial_number_t *)ptr);
 2041|    227|	default:
  ------------------
  |  Branch (2041:2): [True: 227, False: 301]
  ------------------
 2042|    227|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    227|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2043|    528|	}
 2044|    528|}
card-starcos.c:starcos_get_serialnr:
 1970|    301|{
 1971|    301|	int r;
 1972|    301|	u8  rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1973|    301|	sc_apdu_t apdu;
 1974|       |
 1975|    301|	if (!serial)
  ------------------
  |  Branch (1975:6): [True: 0, False: 301]
  ------------------
 1976|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1977|       |
 1978|       |	/* see if we have cached serial number */
 1979|    301|	if (card->serialnr.len) {
  ------------------
  |  Branch (1979:6): [True: 42, False: 259]
  ------------------
 1980|     42|		memcpy(serial, &card->serialnr, sizeof(*serial));
 1981|     42|		return SC_SUCCESS;
  ------------------
  |  |   28|     42|#define SC_SUCCESS				0
  ------------------
 1982|     42|	}
 1983|       |
 1984|    259|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|    518|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|    259|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 35, False: 224]
  |  |  |  |  |  Branch (119:65): [True: 50, False: 174]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|    174|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 7, False: 167]
  |  |  |  |  |  Branch (120:65): [True: 3, False: 164]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1985|     95|		card->serialnr.len = SC_MAX_SERIALNR;
  ------------------
  |  |  372|     95|#define SC_MAX_SERIALNR         32
  ------------------
 1986|     95|		r = sc_parse_ef_gdo(card, card->serialnr.value, &card->serialnr.len, NULL, 0);
 1987|     95|		if (r < 0) {
  ------------------
  |  Branch (1987:7): [True: 85, False: 10]
  ------------------
 1988|     85|			card->serialnr.len = 0;
 1989|     85|			return r;
 1990|     85|		}
 1991|    164|	} else {
 1992|       |		/* get serial number via GET CARD DATA */
 1993|    164|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xf6, 0x00, 0x00);
  ------------------
  |  |  292|    164|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1994|    164|		apdu.cla |= 0x80;
 1995|    164|		apdu.resp = rbuf;
 1996|    164|		apdu.resplen = sizeof(rbuf);
 1997|    164|		apdu.le   = 256;
 1998|    164|		apdu.lc   = 0;
 1999|    164|		apdu.datalen = 0;
 2000|    164|		r = sc_transmit_apdu(card, &apdu);
 2001|    164|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    164|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    164|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    164|	int _ret = (r); \
  |  |  |  |  168|    164|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 150]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|    164|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 150]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2002|    150|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (2002:7): [True: 28, False: 122]
  |  Branch (2002:27): [True: 14, False: 108]
  ------------------
 2003|     42|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     42|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2004|       |		/* cache serial number */
 2005|    108|		memcpy(card->serialnr.value, apdu.resp, MIN(apdu.resplen, SC_MAX_SERIALNR));
  ------------------
  |  |   69|    108|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 101, False: 7]
  |  |  ------------------
  ------------------
 2006|    108|		card->serialnr.len = MIN(apdu.resplen, SC_MAX_SERIALNR);
  ------------------
  |  |   69|    108|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 101, False: 7]
  |  |  ------------------
  ------------------
 2007|    108|	}
 2008|       |
 2009|       |	/* copy and return serial number */
 2010|    118|	memcpy(serial, &card->serialnr, sizeof(*serial));
 2011|       |
 2012|    118|	return SC_SUCCESS;
  ------------------
  |  |   28|    118|#define SC_SUCCESS				0
  ------------------
 2013|    259|}
card-starcos.c:starcos_pin_cmd:
 2081|    223|{
 2082|    223|	int r;
 2083|       |
 2084|    223|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    223|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    223|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    223|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    223|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 223]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2085|    223|	starcos_ex_data * ex_data = (starcos_ex_data*)card->drv_data;
 2086|    223|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|    446|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|    223|#define IS_V34(card) card->type == SC_CARD_TYPE_STARCOS_V3_4 || card->type == SC_CARD_TYPE_STARCOS_V3_4_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:22): [True: 64, False: 159]
  |  |  |  |  |  Branch (119:65): [True: 68, False: 91]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|     91|#define IS_V35(card) card->type == SC_CARD_TYPE_STARCOS_V3_5 || card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (120:22): [True: 7, False: 84]
  |  |  |  |  |  Branch (120:65): [True: 3, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2087|    142|		data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|    142|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 2088|    142|		data->pin1.encoding = ex_data->pin_encoding;
 2089|    142|	}
 2090|    223|	r = iso_ops->pin_cmd(card, data);
 2091|    223|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    223|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    223|	int _ret = r; \
  |  |  155|    223|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 223, False: 0]
  |  |  ------------------
  |  |  156|    223|		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|    162|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 162, False: 61]
  |  |  ------------------
  |  |  157|    223|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    223|	} 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|    223|	return _ret; \
  |  |  163|    223|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 2092|    223|}

sc_get_tcos_driver:
  720|  17.0k|{
  721|  17.0k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  722|       |
  723|  17.0k|	if (iso_ops == NULL) iso_ops = iso_drv->ops;
  ------------------
  |  Branch (723:6): [True: 1, False: 17.0k]
  ------------------
  724|  17.0k|	tcos_ops = *iso_drv->ops;
  725|       |
  726|  17.0k|	tcos_ops.match_card           = tcos_match_card;
  727|  17.0k|	tcos_ops.init                 = tcos_init;
  728|  17.0k|	tcos_ops.finish               = tcos_finish;
  729|  17.0k|	tcos_ops.create_file          = tcos_create_file;
  730|  17.0k|	tcos_ops.set_security_env     = tcos_set_security_env;
  731|  17.0k|	tcos_ops.select_file          = tcos_select_file;
  732|  17.0k|	tcos_ops.list_files           = tcos_list_files;
  733|  17.0k|	tcos_ops.delete_file          = tcos_delete_file;
  734|  17.0k|	tcos_ops.compute_signature    = tcos_compute_signature;
  735|  17.0k|	tcos_ops.decipher             = tcos_decipher;
  736|  17.0k|	tcos_ops.restore_security_env = tcos_restore_security_env;
  737|  17.0k|	tcos_ops.card_ctl             = tcos_card_ctl;
  738|       |
  739|  17.0k|	return &tcos_drv;
  740|  17.0k|}
card-tcos.c:tcos_match_card:
   77|  14.1k|{
   78|  14.1k|	int i;
   79|       |
   80|  14.1k|	i = _sc_match_atr(card, tcos_atrs, &card->type);
   81|  14.1k|	if (i < 0)
  ------------------
  |  Branch (81:6): [True: 13.3k, False: 793]
  ------------------
   82|  13.3k|		return 0;
   83|    793|	return 1;
   84|  14.1k|}
card-tcos.c:tcos_init:
   88|    793|{
   89|    793|	unsigned long flags;
   90|       |
   91|    793|	tcos_data *data = malloc(sizeof(tcos_data));
   92|    793|	if (!data) return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  |  Branch (92:6): [True: 0, False: 793]
  ------------------
   93|       |
   94|    793|	card->name = "TCOS";
   95|    793|	card->drv_data = (void *)data;
   96|    793|	card->cla = 0x00;
   97|       |
   98|    793|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|    793|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
   99|    793|	flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|    793|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    793|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    793|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  100|    793|	flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|    793|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  101|       |
  102|    793|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  103|    793|	_sc_card_add_rsa_alg(card, 768, flags, 0);
  104|    793|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  105|       |
  106|    793|	if (card->type == SC_CARD_TYPE_TCOS_V3) {
  ------------------
  |  Branch (106:6): [True: 0, False: 793]
  ------------------
  107|      0|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  547|      0|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  108|      0|		_sc_card_add_rsa_alg(card, 1280, flags, 0);
  109|      0|		_sc_card_add_rsa_alg(card, 1536, flags, 0);
  110|      0|		_sc_card_add_rsa_alg(card, 1792, flags, 0);
  111|      0|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  112|      0|	}
  113|       |
  114|    793|	return 0;
  115|    793|}
card-tcos.c:tcos_finish:
   70|    793|{
   71|    793|	free(card->drv_data);
   72|    793|	return 0;
   73|    793|}
card-tcos.c:tcos_set_security_env:
  474|     24|{
  475|     24|	sc_context_t *ctx;
  476|     24|	sc_apdu_t apdu;
  477|     24|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE], *p;
  478|     24|	int r, default_key, tcos3;
  479|     24|	tcos_data *data;
  480|       |
  481|     24|	if (card == NULL || env == NULL)
  ------------------
  |  Branch (481:6): [True: 0, False: 24]
  |  Branch (481:22): [True: 0, False: 24]
  ------------------
  482|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  483|     24|	ctx = card->ctx;
  484|     24|	tcos3=(card->type==SC_CARD_TYPE_TCOS_V3);
  485|     24|	data=(tcos_data *)card->drv_data;
  486|       |
  487|     24|	if (se_num || (env->operation!=SC_SEC_OPERATION_DECIPHER && env->operation!=SC_SEC_OPERATION_SIGN)) {
  ------------------
  |  |   47|     48|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
              	if (se_num || (env->operation!=SC_SEC_OPERATION_DECIPHER && env->operation!=SC_SEC_OPERATION_SIGN)) {
  ------------------
  |  |   48|     14|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (487:6): [True: 0, False: 24]
  |  Branch (487:17): [True: 14, False: 10]
  |  Branch (487:62): [True: 0, False: 14]
  ------------------
  488|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|      0|	}
  490|     24|	if(!(env->flags & SC_SEC_ENV_KEY_REF_PRESENT))
  ------------------
  |  |   58|     24|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
  |  Branch (490:5): [True: 0, False: 24]
  ------------------
  491|      0|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  492|     24|			"No Key-Reference in SecEnvironment\n");
  493|     24|	else
  494|     24|		sc_log(ctx, "Key-Reference %02X (len=%zu)", env->key_ref[0], env->key_ref_len);
  ------------------
  |  |   71|     24|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  495|       |	/* Key-Reference 0x80 ?? */
  496|     24|	default_key= !(env->flags & SC_SEC_ENV_KEY_REF_PRESENT) || (env->key_ref_len==1 && env->key_ref[0]==0x80);
  ------------------
  |  |   58|     24|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
  |  Branch (496:15): [True: 0, False: 24]
  |  Branch (496:62): [True: 24, False: 0]
  |  Branch (496:85): [True: 0, False: 24]
  ------------------
  497|     24|	sc_log(ctx, "TCOS3:%d PKCS1 type 01:%d PKCS1 type 02: %d\n", tcos3,
  ------------------
  |  |   71|     24|#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)
  |  |  ------------------
  |  |  |  |  497|     48|	sc_log(ctx, "TCOS3:%d PKCS1 type 01:%d PKCS1 type 02: %d\n", tcos3,
  |  |  |  |  498|     48|			!!(env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01),
  |  |  |  |  ------------------
  |  |  |  |  |  |  109|     24|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  |  |  ------------------
  |  |  |  |  499|     48|			!!(env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02));
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|     24|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  498|     24|			!!(env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01),
  499|     24|			!!(env->algorithm_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02));
  500|       |
  501|     24|	data->pad_flags = env->algorithm_flags;
  502|     24|	data->next_sign = default_key;
  503|       |
  504|     24|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, tcos3 ? 0x41 : 0xC1, 0xB8);
  ------------------
  |  |  293|     24|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (504:58): [True: 0, False: 24]
  ------------------
  505|     24|	p = sbuf;
  506|     24|	if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT) {
  ------------------
  |  |   58|     24|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
  |  Branch (506:6): [True: 24, False: 0]
  ------------------
  507|     24|		*p++ = (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC) ? 0x83 : 0x84;
  ------------------
  |  |   59|     24|#define SC_SEC_ENV_KEY_REF_SYMMETRIC	0x0008
  ------------------
  |  Branch (507:10): [True: 0, False: 24]
  ------------------
  508|     24|		*p++ = env->key_ref_len;
  509|     24|		memcpy(p, env->key_ref, env->key_ref_len);
  510|     24|		p += env->key_ref_len;
  511|     24|	}
  512|     24|	apdu.data = sbuf;
  513|     24|	apdu.lc = apdu.datalen = (p - sbuf);
  514|       |
  515|     24|	r=sc_transmit_apdu(card, &apdu);
  516|     24|	if (r) {
  ------------------
  |  Branch (516:6): [True: 1, False: 23]
  ------------------
  517|      1|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  518|      1|			"%s: APDU transmit failed", sc_strerror(r));
  519|      1|		return r;
  520|      1|	}
  521|     23|	if (apdu.sw1==0x6A && (apdu.sw2==0x81 || apdu.sw2==0x88)) {
  ------------------
  |  Branch (521:6): [True: 5, False: 18]
  |  Branch (521:25): [True: 1, False: 4]
  |  Branch (521:43): [True: 1, False: 3]
  ------------------
  522|      2|		sc_log(ctx,
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  523|      2|			"Detected Signature-Only key\n");
  524|      2|		if (env->operation==SC_SEC_OPERATION_SIGN && default_key) return SC_SUCCESS;
  ------------------
  |  |   48|      4|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
              		if (env->operation==SC_SEC_OPERATION_SIGN && default_key) return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (524:7): [True: 1, False: 1]
  |  Branch (524:48): [True: 0, False: 1]
  ------------------
  525|      2|	}
  526|     23|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|     23|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     23|	int _ret = r; \
  |  |  155|     23|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 23, False: 0]
  |  |  ------------------
  |  |  156|     23|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 11, False: 12]
  |  |  ------------------
  |  |  157|     23|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     23|	} 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|     23|	return _ret; \
  |  |  163|     23|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  527|     23|}
card-tcos.c:tcos_select_file:
  336|  10.6k|{
  337|  10.6k|	sc_context_t *ctx;
  338|  10.6k|	sc_apdu_t apdu;
  339|  10.6k|	sc_file_t *file=NULL;
  340|  10.6k|	u8 buf[SC_MAX_APDU_BUFFER_SIZE], pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  341|  10.6k|	int r;
  342|  10.6k|	size_t pathlen;
  343|       |
  344|  10.6k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (344:6): [True: 0, False: 10.6k]
  |  Branch (344:22): [True: 0, False: 10.6k]
  ------------------
  345|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  346|  10.6k|	ctx=card->ctx;
  347|  10.6k|	memcpy(path, in_path->value, in_path->len);
  348|  10.6k|	pathlen = in_path->len;
  349|       |
  350|  10.6k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0x04);
  ------------------
  |  |  294|  10.6k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  351|       |
  352|  10.6k|	switch (in_path->type) {
  353|     10|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|     10|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (353:2): [True: 10, False: 10.6k]
  ------------------
  354|     10|		if (pathlen != 2) return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  |  Branch (354:7): [True: 0, False: 10]
  ------------------
  355|       |		/* fall through */
  356|     10|	case SC_PATH_TYPE_FROM_CURRENT:
  ------------------
  |  |  122|     10|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (356:2): [True: 0, False: 10.6k]
  ------------------
  357|     10|		apdu.p1 = 9;
  358|     10|		break;
  359|  2.02k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  2.02k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (359:2): [True: 2.02k, False: 8.60k]
  ------------------
  360|  2.02k|		apdu.p1 = 4;
  361|  2.02k|		break;
  362|  8.59k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  8.59k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (362:2): [True: 8.59k, False: 2.03k]
  ------------------
  363|  8.59k|		apdu.p1 = 8;
  364|  8.59k|		if (pathlen >= 2 && memcmp(path, "\x3F\x00", 2) == 0) path += 2, pathlen -= 2;
  ------------------
  |  Branch (364:7): [True: 8.58k, False: 10]
  |  Branch (364:23): [True: 3.34k, False: 5.24k]
  ------------------
  365|  8.59k|		if (pathlen == 0) apdu.p1 = 0;
  ------------------
  |  Branch (365:7): [True: 11, False: 8.58k]
  ------------------
  366|  8.59k|		break;
  367|      0|	case SC_PATH_TYPE_PARENT:
  ------------------
  |  |  123|      0|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (367:2): [True: 0, False: 10.6k]
  ------------------
  368|      0|		apdu.p1 = 3;
  369|      0|		pathlen = 0;
  370|      0|		break;
  371|      0|	default:
  ------------------
  |  Branch (371:2): [True: 0, False: 10.6k]
  ------------------
  372|      0|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  373|  10.6k|	}
  374|  10.6k|	if( pathlen == 0 ) apdu.cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|     11|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  |  Branch (374:6): [True: 11, False: 10.6k]
  ------------------
  375|       |
  376|  10.6k|	apdu.lc = pathlen;
  377|  10.6k|	apdu.data = path;
  378|  10.6k|	apdu.datalen = pathlen;
  379|       |
  380|  10.6k|	if (file_out != NULL) {
  ------------------
  |  Branch (380:6): [True: 5.54k, False: 5.07k]
  ------------------
  381|  5.54k|		apdu.resp = buf;
  382|  5.54k|		apdu.resplen = sizeof(buf);
  383|  5.54k|		apdu.le = 256;
  384|  5.54k|	} else {
  385|  5.07k|		apdu.resplen = 0;
  386|  5.07k|		apdu.le = 0;
  387|  5.07k|		apdu.p2 = 0x0C;
  388|  5.07k|		apdu.cse = (pathlen == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  291|      1|#define SC_APDU_CASE_1			0x01
  ------------------
              		apdu.cse = (pathlen == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  10.1k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (388:14): [True: 1, False: 5.07k]
  ------------------
  389|  5.07k|	}
  390|       |
  391|  10.6k|	r = sc_transmit_apdu(card, &apdu);
  392|  10.6k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  10.6k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  10.6k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  10.6k|	int _ret = (r); \
  |  |  |  |  168|  10.6k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 265, False: 10.3k]
  |  |  |  |  ------------------
  |  |  |  |  169|    265|		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|    265|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    265|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    265|		return _ret; \
  |  |  |  |  172|    265|	} \
  |  |  |  |  173|  10.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  393|  10.3k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  394|  10.3k|	if (r || file_out == NULL) SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  8.34k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  8.34k|	int _ret = r; \
  |  |  155|  8.34k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 8.34k, False: 0]
  |  |  ------------------
  |  |  156|  8.34k|		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|  7.18k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 7.18k, False: 1.16k]
  |  |  ------------------
  |  |  157|  8.34k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  8.34k|	} 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|  8.34k|	return _ret; \
  |  |  163|  8.34k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (394:6): [True: 7.18k, False: 3.17k]
  |  Branch (394:11): [True: 1.16k, False: 2.01k]
  ------------------
  395|       |
  396|  2.01k|	if (apdu.resplen < 1 || apdu.resp[0] != 0x62) {
  ------------------
  |  Branch (396:6): [True: 529, False: 1.48k]
  |  Branch (396:26): [True: 180, False: 1.30k]
  ------------------
  397|    709|		sc_log(ctx, "received invalid template %02X\n", apdu.resp[0]);
  ------------------
  |  |   71|    709|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  398|    709|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  153|    709|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    709|	int _ret = r; \
  |  |  155|    709|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 709, False: 0]
  |  |  ------------------
  |  |  156|    709|		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|    709|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 709, False: 0]
  |  |  ------------------
  |  |  157|    709|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    709|	} 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|    709|	return _ret; \
  |  |  163|    709|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  399|    709|	}
  400|       |
  401|  1.30k|	file = sc_file_new();
  402|  1.30k|	if (file == NULL) LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (402:6): [True: 0, False: 1.30k]
  ------------------
  403|  1.30k|	*file_out = file;
  404|  1.30k|	file->path = *in_path;
  405|       |
  406|  1.30k|	iso_ops->process_fci(card, file, apdu.resp, apdu.resplen);
  407|       |
  408|  1.30k|	parse_sec_attr(card, file, file->sec_attr, file->sec_attr_len);
  409|       |
  410|  1.30k|	return 0;
  411|  1.30k|}
card-tcos.c:parse_sec_attr:
  271|  1.30k|{
  272|  1.30k|	unsigned int op;
  273|       |
  274|       |	/* list directory is not covered by ACLs - so always add an entry */
  275|  1.30k|	sc_file_add_acl_entry (file, SC_AC_OP_LIST_FILES,
  ------------------
  |  |  172|  1.30k|#define SC_AC_OP_LIST_FILES		6
  ------------------
  276|  1.30k|                               SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|  1.30k|#define SC_AC_NONE			0x00000000
  ------------------
                                             SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|  1.30k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  277|       |	/* FIXME: check for what LOCK is used */
  278|  1.30k|	sc_file_add_acl_entry (file, SC_AC_OP_LOCK,
  ------------------
  |  |  167|  1.30k|#define SC_AC_OP_LOCK			1
  ------------------
  279|  1.30k|                               SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|  1.30k|#define SC_AC_NONE			0x00000000
  ------------------
                                             SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|  1.30k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  280|  3.04k|	for (; len >= 6; len -= 6, buf += 6) {
  ------------------
  |  Branch (280:9): [True: 1.73k, False: 1.30k]
  ------------------
  281|       |		/* FIXME: temporary hacks */
  282|  1.73k|		if (!memcmp(buf, "\xa4\x00\x00\x00\xff\xff", 6)) {/* select */
  ------------------
  |  Branch (282:7): [True: 10, False: 1.72k]
  ------------------
  283|     10|			sc_file_add_acl_entry (file, SC_AC_OP_SELECT,
  ------------------
  |  |  166|     10|#define SC_AC_OP_SELECT			0
  ------------------
  284|     10|                                               SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     10|#define SC_AC_NONE			0x00000000
  ------------------
                                                             SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     10|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  285|  1.72k|		} else if (!memcmp(buf, "\xb0\x00\x00\x00\xff\xff", 6)) {/*read*/
  ------------------
  |  Branch (285:14): [True: 18, False: 1.70k]
  ------------------
  286|     18|			sc_file_add_acl_entry (file, SC_AC_OP_READ,
  ------------------
  |  |  188|     18|#define SC_AC_OP_READ			22
  ------------------
  287|     18|                                               SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     18|#define SC_AC_NONE			0x00000000
  ------------------
                                                             SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     18|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  288|  1.70k|		} else if (!memcmp(buf, "\xd6\x00\x00\x00\xff\xff", 6)) {/*upd*/
  ------------------
  |  Branch (288:14): [True: 18, False: 1.69k]
  ------------------
  289|     18|			sc_file_add_acl_entry (file, SC_AC_OP_UPDATE,
  ------------------
  |  |  189|     18|#define SC_AC_OP_UPDATE			23
  ------------------
  290|     18|                                               SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     18|#define SC_AC_NONE			0x00000000
  ------------------
                                                             SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     18|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  291|  1.69k|		} else if (!memcmp(buf, "\x60\x00\x00\x00\xff\xff", 6)) {/*adm */
  ------------------
  |  Branch (291:14): [True: 10, False: 1.68k]
  ------------------
  292|     10|			sc_file_add_acl_entry (file, SC_AC_OP_WRITE,
  ------------------
  |  |  190|     10|#define SC_AC_OP_WRITE			24
  ------------------
  293|     10|                                               SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     10|#define SC_AC_NONE			0x00000000
  ------------------
                                                             SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     10|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  294|     10|			sc_file_add_acl_entry (file, SC_AC_OP_CREATE,
  ------------------
  |  |  169|     10|#define SC_AC_OP_CREATE			3
  ------------------
  295|     10|                                               SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     10|#define SC_AC_NONE			0x00000000
  ------------------
                                                             SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     10|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  296|     10|			sc_file_add_acl_entry (file, SC_AC_OP_INVALIDATE,
  ------------------
  |  |  171|     10|#define SC_AC_OP_INVALIDATE		5
  ------------------
  297|     10|                                               SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     10|#define SC_AC_NONE			0x00000000
  ------------------
                                                             SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     10|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  298|     10|			sc_file_add_acl_entry (file, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|     10|#define SC_AC_OP_REHABILITATE		4
  ------------------
  299|     10|                                               SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|     10|#define SC_AC_NONE			0x00000000
  ------------------
                                                             SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     10|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  300|  1.68k|		} else {
  301|       |			/* the first byte tells use the command or the
  302|       |			   command group.  We have to mask bit 0
  303|       |			   because this one distinguish between AND/OR
  304|       |			   combination of PINs*/
  305|  1.68k|			op = map_operations (buf[0]);
  306|  1.68k|			if (op == (unsigned int)-1) {
  ------------------
  |  Branch (306:8): [True: 150, False: 1.53k]
  ------------------
  307|    150|				sc_log(card->ctx,
  ------------------
  |  |   71|    150|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  308|    150|					"Unknown security command byte %02x\n",
  309|    150|					buf[0]);
  310|    150|				continue;
  311|    150|			}
  312|  1.53k|			if (!buf[1])
  ------------------
  |  Branch (312:8): [True: 134, False: 1.39k]
  ------------------
  313|    134|				sc_file_add_acl_entry (file, op,
  314|    134|                                                       SC_AC_NONE,
  ------------------
  |  |  150|    134|#define SC_AC_NONE			0x00000000
  ------------------
  315|    134|                                                       SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    134|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  316|  1.39k|			else
  317|  1.39k|				sc_file_add_acl_entry (file, op,
  318|  1.39k|                                                       SC_AC_CHV, buf[1]);
  ------------------
  |  |  151|  1.39k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  319|       |
  320|  1.53k|			if (!buf[2] && !buf[3])
  ------------------
  |  Branch (320:8): [True: 140, False: 1.39k]
  |  Branch (320:19): [True: 53, False: 87]
  ------------------
  321|     53|				sc_file_add_acl_entry (file, op,
  322|     53|                                                       SC_AC_NONE,
  ------------------
  |  |  150|     53|#define SC_AC_NONE			0x00000000
  ------------------
  323|     53|                                                       SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     53|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  324|  1.47k|			else
  325|  1.47k|				sc_file_add_acl_entry (file, op,
  326|  1.47k|                                                       SC_AC_TERM,
  ------------------
  |  |  152|  1.47k|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  327|  1.47k|                                                       (buf[2]<<8)|buf[3]);
  328|  1.53k|		}
  329|  1.73k|	}
  330|  1.30k|}
card-tcos.c:map_operations:
  236|  1.68k|{
  237|  1.68k|	unsigned int op = (unsigned int)-1;
  238|       |
  239|  1.68k|	switch ( (commandbyte & 0xfe) ) {
  ------------------
  |  Branch (239:11): [True: 1.53k, False: 150]
  ------------------
  240|     70|		case 0xe2: /* append record */   op = SC_AC_OP_UPDATE; break;
  ------------------
  |  |  189|     70|#define SC_AC_OP_UPDATE			23
  ------------------
  |  Branch (240:3): [True: 70, False: 1.61k]
  ------------------
  241|     67|		case 0x24: /* change password */ op = SC_AC_OP_UPDATE; break;
  ------------------
  |  |  189|     67|#define SC_AC_OP_UPDATE			23
  ------------------
  |  Branch (241:3): [True: 67, False: 1.61k]
  ------------------
  242|     71|		case 0xe0: /* create */          op = SC_AC_OP_CREATE; break;
  ------------------
  |  |  169|     71|#define SC_AC_OP_CREATE			3
  ------------------
  |  Branch (242:3): [True: 71, False: 1.61k]
  ------------------
  243|     66|		case 0xe4: /* delete */          op = SC_AC_OP_DELETE; break;
  ------------------
  |  |  168|     66|#define SC_AC_OP_DELETE			2
  ------------------
  |  Branch (243:3): [True: 66, False: 1.61k]
  ------------------
  244|     70|		case 0xe8: /* exclude sfi */     op = SC_AC_OP_WRITE; break;
  ------------------
  |  |  190|     70|#define SC_AC_OP_WRITE			24
  ------------------
  |  Branch (244:3): [True: 70, False: 1.61k]
  ------------------
  245|     74|		case 0x82: /* external auth */   op = SC_AC_OP_READ; break;
  ------------------
  |  |  188|     74|#define SC_AC_OP_READ			22
  ------------------
  |  Branch (245:3): [True: 74, False: 1.60k]
  ------------------
  246|     70|		case 0xe6: /* include sfi */     op = SC_AC_OP_WRITE; break;
  ------------------
  |  |  190|     70|#define SC_AC_OP_WRITE			24
  ------------------
  |  Branch (246:3): [True: 70, False: 1.61k]
  ------------------
  247|     69|		case 0x88: /* internal auth */   op = SC_AC_OP_READ; break;
  ------------------
  |  |  188|     69|#define SC_AC_OP_READ			22
  ------------------
  |  Branch (247:3): [True: 69, False: 1.61k]
  ------------------
  248|    106|		case 0x04: /* invalidate */      op = SC_AC_OP_INVALIDATE; break;
  ------------------
  |  |  171|    106|#define SC_AC_OP_INVALIDATE		5
  ------------------
  |  Branch (248:3): [True: 106, False: 1.57k]
  ------------------
  249|     66|		case 0x2a: /* perform sec. op */ op = SC_AC_OP_SELECT; break;
  ------------------
  |  |  166|     66|#define SC_AC_OP_SELECT			0
  ------------------
  |  Branch (249:3): [True: 66, False: 1.61k]
  ------------------
  250|     74|		case 0xb0: /* read binary */     op = SC_AC_OP_READ; break;
  ------------------
  |  |  188|     74|#define SC_AC_OP_READ			22
  ------------------
  |  Branch (250:3): [True: 74, False: 1.60k]
  ------------------
  251|     76|		case 0xb2: /* read record */     op = SC_AC_OP_READ; break;
  ------------------
  |  |  188|     76|#define SC_AC_OP_READ			22
  ------------------
  |  Branch (251:3): [True: 76, False: 1.60k]
  ------------------
  252|     69|		case 0x44: /* rehabilitate */    op = SC_AC_OP_REHABILITATE; break;
  ------------------
  |  |  170|     69|#define SC_AC_OP_REHABILITATE		4
  ------------------
  |  Branch (252:3): [True: 69, False: 1.61k]
  ------------------
  253|     79|		case 0xa4: /* select */          op = SC_AC_OP_SELECT; break;
  ------------------
  |  |  166|     79|#define SC_AC_OP_SELECT			0
  ------------------
  |  Branch (253:3): [True: 79, False: 1.60k]
  ------------------
  254|     71|		case 0xee: /* set permanent */   op = SC_AC_OP_CREATE; break;
  ------------------
  |  |  169|     71|#define SC_AC_OP_CREATE			3
  ------------------
  |  Branch (254:3): [True: 71, False: 1.61k]
  ------------------
  255|     69|		case 0x2c: /* unblock password */op = SC_AC_OP_WRITE; break;
  ------------------
  |  |  190|     69|#define SC_AC_OP_WRITE			24
  ------------------
  |  Branch (255:3): [True: 69, False: 1.61k]
  ------------------
  256|     77|		case 0xd6: /* update binary */   op = SC_AC_OP_WRITE; break;
  ------------------
  |  |  190|     77|#define SC_AC_OP_WRITE			24
  ------------------
  |  Branch (256:3): [True: 77, False: 1.60k]
  ------------------
  257|     71|		case 0xdc: /* update record */   op = SC_AC_OP_WRITE; break;
  ------------------
  |  |  190|     71|#define SC_AC_OP_WRITE			24
  ------------------
  |  Branch (257:3): [True: 71, False: 1.61k]
  ------------------
  258|     89|		case 0x20: /* verify password */ op = SC_AC_OP_SELECT; break;
  ------------------
  |  |  166|     89|#define SC_AC_OP_SELECT			0
  ------------------
  |  Branch (258:3): [True: 89, False: 1.59k]
  ------------------
  259|    127|		case 0x60: /* admin group */     op = SC_AC_OP_CREATE; break;
  ------------------
  |  |  169|    127|#define SC_AC_OP_CREATE			3
  ------------------
  |  Branch (259:3): [True: 127, False: 1.55k]
  ------------------
  260|  1.68k|	}
  261|  1.68k|	return op;
  262|  1.68k|}
card-tcos.c:tcos_compute_signature:
  537|      7|{
  538|      7|	size_t dlen = datalen;
  539|      7|	sc_apdu_t apdu;
  540|      7|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  541|      7|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
  542|      7|	int tcos3, r;
  543|       |
  544|      7|	if (card == NULL || data == NULL || out == NULL) {
  ------------------
  |  Branch (544:6): [True: 0, False: 7]
  |  Branch (544:22): [True: 0, False: 7]
  |  Branch (544:38): [True: 0, False: 7]
  ------------------
  545|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  546|      0|	}
  547|       |
  548|      7|	tcos3 = (card->type == SC_CARD_TYPE_TCOS_V3);
  549|       |
  550|       |	// We can sign (key length / 8) bytes
  551|      7|	if (datalen > 256) {
  ------------------
  |  Branch (551:6): [True: 0, False: 7]
  ------------------
  552|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  553|      0|	}
  554|       |
  555|      7|	if (((tcos_data *)card->drv_data)->next_sign) {
  ------------------
  |  Branch (555:6): [True: 0, False: 7]
  ------------------
  556|      0|		if (datalen > 48) {
  ------------------
  |  Branch (556:7): [True: 0, False: 0]
  ------------------
  557|      0|			sc_log(card->ctx, "Data to be signed is too long (TCOS supports max. 48 bytes)\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  558|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  559|      0|		}
  560|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x9E, 0x9A);
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  561|      0|		memcpy(sbuf, data, datalen);
  562|      0|		dlen = datalen;
  563|      7|	} else {
  564|      7|		size_t keylen = tcos3 ? 256 : 128;
  ------------------
  |  Branch (564:19): [True: 0, False: 7]
  ------------------
  565|       |
  566|      7|		if (datalen > keylen) {
  ------------------
  |  Branch (566:7): [True: 0, False: 7]
  ------------------
  567|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  568|      0|		}
  569|       |
  570|      7|		sc_format_apdu(card, &apdu, keylen > 255 ? SC_APDU_CASE_4_EXT : SC_APDU_CASE_4_SHORT, 0x2A, 0x80, 0x86);
  ------------------
  |  |  299|      0|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      0|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
              		sc_format_apdu(card, &apdu, keylen > 255 ? SC_APDU_CASE_4_EXT : SC_APDU_CASE_4_SHORT, 0x2A, 0x80, 0x86);
  ------------------
  |  |  294|      7|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (570:31): [True: 0, False: 7]
  ------------------
  571|      7|		memset(sbuf, 0xff, sizeof(sbuf));
  572|      7|		sbuf[0] = 0x02;
  573|      7|		sbuf[1] = 0x00;
  574|      7|		sbuf[2] = 0x01;
  575|      7|		sbuf[keylen - datalen] = 0x00;
  576|      7|		memcpy(sbuf + keylen - datalen + 1, data, datalen);
  577|      7|		dlen = keylen + 1;
  578|      7|	}
  579|      7|	apdu.resp = rbuf;
  580|      7|	apdu.resplen = sizeof(rbuf);
  581|      7|	apdu.le = tcos3 ? 256 : 128;
  ------------------
  |  Branch (581:12): [True: 0, False: 7]
  ------------------
  582|      7|	apdu.data = sbuf;
  583|      7|	apdu.lc = apdu.datalen = dlen;
  584|       |
  585|      7|	r = sc_transmit_apdu(card, &apdu);
  586|      7|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  587|      6|	if (tcos3 && apdu.p1 == 0x80 && apdu.sw1 == 0x6A && apdu.sw2 == 0x87) {
  ------------------
  |  Branch (587:6): [True: 0, False: 6]
  |  Branch (587:15): [True: 0, False: 0]
  |  Branch (587:34): [True: 0, False: 0]
  |  Branch (587:54): [True: 0, False: 0]
  ------------------
  588|      0|		size_t keylen = 128;
  589|       |
  590|      0|		if (datalen > keylen) {
  ------------------
  |  Branch (590:7): [True: 0, False: 0]
  ------------------
  591|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  592|      0|		}
  593|       |
  594|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x2A, 0x80, 0x86);
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  595|      0|		memset(sbuf, 0xff, sizeof(sbuf));
  596|      0|		sbuf[0] = 0x02;
  597|      0|		sbuf[1] = 0x00;
  598|      0|		sbuf[2] = 0x01;
  599|      0|		sbuf[keylen - datalen] = 0x00;
  600|      0|		memcpy(sbuf + keylen - datalen + 1, data, datalen);
  601|      0|		dlen = keylen + 1;
  602|       |
  603|      0|		apdu.resp = rbuf;
  604|      0|		apdu.resplen = sizeof(rbuf);
  605|      0|		apdu.le = 128;
  606|      0|		apdu.data = sbuf;
  607|      0|		apdu.lc = apdu.datalen = dlen;
  608|      0|		r = sc_transmit_apdu(card, &apdu);
  609|      0|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  610|      0|	}
  611|      6|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (611:6): [True: 3, False: 3]
  |  Branch (611:26): [True: 2, False: 1]
  ------------------
  612|      2|		size_t len = apdu.resplen>outlen ? outlen : apdu.resplen;
  ------------------
  |  Branch (612:16): [True: 0, False: 2]
  ------------------
  613|      2|		memcpy(out, apdu.resp, len);
  614|      2|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)len);
  ------------------
  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      2|	int _ret = r; \
  |  |  155|      2|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 1]
  |  |  ------------------
  |  |  156|      1|		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: 1]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} else { \
  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  161|      1|	} \
  |  |  162|      2|	return _ret; \
  |  |  163|      2|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  615|      2|	}
  616|      4|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|      4|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      4|	int _ret = r; \
  |  |  155|      4|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 4, False: 0]
  |  |  ------------------
  |  |  156|      4|		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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 4, False: 0]
  |  |  ------------------
  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      4|	} 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|      4|	return _ret; \
  |  |  163|      4|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  617|      4|}
card-tcos.c:tcos_decipher:
  621|      5|{
  622|      5|	sc_context_t *ctx;
  623|      5|	sc_apdu_t apdu;
  624|      5|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  625|      5|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
  626|      5|	tcos_data *data;
  627|      5|	int tcos3, r;
  628|       |
  629|      5|	if (card == NULL || crgram == NULL || out == NULL) {
  ------------------
  |  Branch (629:6): [True: 0, False: 5]
  |  Branch (629:22): [True: 0, False: 5]
  |  Branch (629:40): [True: 0, False: 5]
  ------------------
  630|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  631|      0|	}
  632|      5|	ctx = card->ctx;
  633|      5|	tcos3 = (card->type == SC_CARD_TYPE_TCOS_V3);
  634|      5|	data = (tcos_data *)card->drv_data;
  635|       |
  636|      5|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|      5|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      5|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      5|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      5|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  637|      5|	sc_log(ctx, "TCOS3:%d PKCS1 type 02:%d\n", tcos3,
  ------------------
  |  |   71|      5|#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)
  |  |  ------------------
  |  |  |  |  637|      5|	sc_log(ctx, "TCOS3:%d PKCS1 type 02:%d\n", tcos3,
  |  |  |  |  638|      5|			!!(data->pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02));
  |  |  |  |  ------------------
  |  |  |  |  |  |  110|      5|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|      5|			!!(data->pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02));
  639|       |
  640|      5|	sc_format_apdu(card, &apdu, crgram_len > 255 ? SC_APDU_CASE_4_EXT : SC_APDU_CASE_4_SHORT, 0x2A, 0x80, 0x86);
  ------------------
  |  |  299|      2|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|      2|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|      2|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
              	sc_format_apdu(card, &apdu, crgram_len > 255 ? SC_APDU_CASE_4_EXT : SC_APDU_CASE_4_SHORT, 0x2A, 0x80, 0x86);
  ------------------
  |  |  294|      3|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (640:30): [True: 2, False: 3]
  ------------------
  641|      5|	apdu.resp = rbuf;
  642|      5|	apdu.resplen = sizeof(rbuf);
  643|      5|	apdu.le = crgram_len;
  644|       |
  645|      5|	apdu.data = sbuf;
  646|      5|	apdu.lc = apdu.datalen = crgram_len + 1;
  647|      5|	sbuf[0] = tcos3 ? 0x00 : ((data->pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) ? 0x81 : 0x02);
  ------------------
  |  |  110|      5|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  |  Branch (647:12): [True: 0, False: 5]
  |  Branch (647:28): [True: 0, False: 5]
  ------------------
  648|      5|	if (sizeof sbuf - 1 < crgram_len)
  ------------------
  |  Branch (648:6): [True: 1, False: 4]
  ------------------
  649|      1|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  650|      4|	memcpy(sbuf + 1, crgram, crgram_len);
  651|       |
  652|      4|	r = sc_transmit_apdu(card, &apdu);
  653|      4|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      4|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      4|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      4|	int _ret = (r); \
  |  |  |  |  168|      4|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  654|       |
  655|      1|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      1|	int _ret = r; \
  |  |  155|      1|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  163|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  656|      1|}
card-tcos.c:tcos_card_ctl:
  708|  1.18k|{
  709|  1.18k|	switch (cmd) {
  ------------------
  |  Branch (709:10): [True: 964, False: 216]
  ------------------
  710|      0|	case SC_CARDCTL_TCOS_SETPERM:
  ------------------
  |  Branch (710:2): [True: 0, False: 1.18k]
  ------------------
  711|      0|		return tcos_setperm(card, !!ptr);
  712|    964|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (712:2): [True: 964, False: 216]
  ------------------
  713|    964|		return tcos_get_serialnr(card, (sc_serial_number_t *)ptr);
  714|  1.18k|	}
  715|    216|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    216|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  716|  1.18k|}
card-tcos.c:tcos_get_serialnr:
  681|    964|{
  682|    964|	int r;
  683|       |
  684|    964|	if (!serial)
  ------------------
  |  Branch (684:6): [True: 0, False: 964]
  ------------------
  685|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  686|       |
  687|       |	/* see if we have cached serial number */
  688|    964|	if (card->serialnr.len) {
  ------------------
  |  Branch (688:6): [True: 111, False: 853]
  ------------------
  689|    111|		memcpy(serial, &card->serialnr, sizeof(*serial));
  690|    111|		return SC_SUCCESS;
  ------------------
  |  |   28|    111|#define SC_SUCCESS				0
  ------------------
  691|    111|	}
  692|       |
  693|    853|	card->serialnr.len = sizeof card->serialnr.value;
  694|    853|	r = sc_parse_ef_gdo(card, card->serialnr.value, &card->serialnr.len, NULL, 0);
  695|    853|	if (r < 0) {
  ------------------
  |  Branch (695:6): [True: 530, False: 323]
  ------------------
  696|    530|		card->serialnr.len = 0;
  697|    530|		return r;
  698|    530|	}
  699|       |
  700|       |	/* copy and return serial number */
  701|    323|	memcpy(serial, &card->serialnr, sizeof(*serial));
  702|       |
  703|    323|	return SC_SUCCESS;
  ------------------
  |  |   28|    323|#define SC_SUCCESS				0
  ------------------
  704|    853|}

sc_check_sw:
   44|   464k|{
   45|   464k|	if (card == NULL)
  ------------------
  |  Branch (45:6): [True: 0, False: 464k]
  ------------------
   46|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   47|   464k|	if (card->ops->check_sw == NULL)
  ------------------
  |  Branch (47:6): [True: 0, False: 464k]
  ------------------
   48|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
   49|   464k|	return card->ops->check_sw(card, sw1, sw2);
   50|   464k|}
sc_format_apdu:
   54|   600k|{
   55|   600k|	if (card == NULL || apdu == NULL) {
  ------------------
  |  Branch (55:6): [True: 0, False: 600k]
  |  Branch (55:22): [True: 0, False: 600k]
  ------------------
   56|      0|		return;
   57|      0|	}
   58|   600k|	memset(apdu, 0, sizeof(*apdu));
   59|   600k|	apdu->cla = (u8) card->cla;
   60|   600k|	apdu->cse = cse;
   61|   600k|	apdu->ins = (u8) ins;
   62|   600k|	apdu->p1 = (u8) p1;
   63|   600k|	apdu->p2 = (u8) p2;
   64|   600k|}
sc_format_apdu_cse_lc_le:
   67|  4.97k|{
   68|       |	/* TODO calculating the APDU case, Lc and Le should actually only be
   69|       |	 * done in sc_apdu2bytes, but to gradually change OpenSC we start here. */
   70|       |	/* Let sc_detect_apdu_cse set short or extended  and test for chaining */
   71|       |
   72|  4.97k|	if (!apdu)
  ------------------
  |  Branch (72:6): [True: 0, False: 4.97k]
  ------------------
   73|      0|		return;
   74|  4.97k|	if (apdu->datalen > SC_MAX_APDU_DATA_SIZE
  ------------------
  |  |   35|  9.94k|#define SC_MAX_APDU_DATA_SIZE		0xFF
  ------------------
  |  Branch (74:6): [True: 20, False: 4.95k]
  ------------------
   75|  4.95k|			|| apdu->resplen > SC_MAX_APDU_RESP_SIZE) {
  ------------------
  |  |   36|  4.95k|#define SC_MAX_APDU_RESP_SIZE		(0xFF+1)
  ------------------
  |  Branch (75:7): [True: 290, False: 4.66k]
  ------------------
   76|       |		/* extended length  or data chaining and/or get response */
   77|    310|		if (apdu->datalen <= SC_MAX_EXT_APDU_DATA_SIZE)
  ------------------
  |  |   38|    310|#define SC_MAX_EXT_APDU_DATA_SIZE		0xFFFF
  ------------------
  |  Branch (77:7): [True: 310, False: 0]
  ------------------
   78|    310|			apdu->lc = apdu->datalen;
   79|    310|		if (apdu->resplen <= SC_MAX_EXT_APDU_RESP_SIZE)
  ------------------
  |  |   39|    310|#define SC_MAX_EXT_APDU_RESP_SIZE		(0xFFFF+1)
  ------------------
  |  Branch (79:7): [True: 310, False: 0]
  ------------------
   80|    310|			apdu->le = apdu->resplen;
   81|    310|		if (apdu->resplen && !apdu->datalen)
  ------------------
  |  Branch (81:7): [True: 310, False: 0]
  |  Branch (81:24): [True: 257, False: 53]
  ------------------
   82|    257|			apdu->cse = SC_APDU_CASE_2;
  ------------------
  |  |  301|    257|#define SC_APDU_CASE_2			0x22
  ------------------
   83|    310|		if (!apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (83:7): [True: 0, False: 310]
  |  Branch (83:25): [True: 0, False: 0]
  ------------------
   84|      0|			apdu->cse = SC_APDU_CASE_3;
  ------------------
  |  |  302|      0|#define SC_APDU_CASE_3			0x23
  ------------------
   85|    310|		if (apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (85:7): [True: 310, False: 0]
  |  Branch (85:24): [True: 53, False: 257]
  ------------------
   86|     53|			apdu->cse = SC_APDU_CASE_4;
  ------------------
  |  |  303|     53|#define SC_APDU_CASE_4			0x24
  ------------------
   87|  4.66k|	} else {
   88|       |		/* short length */
   89|  4.66k|		if (apdu->datalen <= SC_MAX_APDU_DATA_SIZE)
  ------------------
  |  |   35|  4.66k|#define SC_MAX_APDU_DATA_SIZE		0xFF
  ------------------
  |  Branch (89:7): [True: 4.66k, False: 0]
  ------------------
   90|  4.66k|			apdu->lc = apdu->datalen;
   91|  4.66k|		if (apdu->resplen <= SC_MAX_APDU_RESP_SIZE)
  ------------------
  |  |   36|  4.66k|#define SC_MAX_APDU_RESP_SIZE		(0xFF+1)
  ------------------
  |  Branch (91:7): [True: 4.66k, False: 0]
  ------------------
   92|  4.66k|			apdu->le = apdu->resplen;
   93|  4.66k|		if (!apdu->resplen && !apdu->datalen)
  ------------------
  |  Branch (93:7): [True: 2.81k, False: 1.85k]
  |  Branch (93:25): [True: 0, False: 2.81k]
  ------------------
   94|      0|			apdu->cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
   95|  4.66k|		if (apdu->resplen && !apdu->datalen)
  ------------------
  |  Branch (95:7): [True: 1.85k, False: 2.81k]
  |  Branch (95:24): [True: 1.75k, False: 101]
  ------------------
   96|  1.75k|			apdu->cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|  1.75k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
   97|  4.66k|		if (!apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (97:7): [True: 2.81k, False: 1.85k]
  |  Branch (97:25): [True: 2.81k, False: 0]
  ------------------
   98|  2.81k|			apdu->cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  2.81k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
   99|  4.66k|		if (apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (99:7): [True: 1.85k, False: 2.81k]
  |  Branch (99:24): [True: 101, False: 1.75k]
  ------------------
  100|    101|			apdu->cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|    101|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  101|  4.66k|	}
  102|  4.97k|}
sc_format_apdu_ex:
  108|  4.97k|{
  109|  4.97k|	if (!apdu) {
  ------------------
  |  Branch (109:6): [True: 0, False: 4.97k]
  ------------------
  110|      0|		return;
  111|      0|	}
  112|       |
  113|  4.97k|	memset(apdu, 0, sizeof(*apdu));
  114|  4.97k|	apdu->cla = cla;
  115|  4.97k|	apdu->ins = ins;
  116|  4.97k|	apdu->p1 = p1;
  117|  4.97k|	apdu->p2 = p2;
  118|  4.97k|	apdu->resp = resp;
  119|  4.97k|	apdu->resplen = resplen;
  120|  4.97k|	apdu->data = data;
  121|  4.97k|	apdu->datalen = datalen;
  122|  4.97k|	sc_format_apdu_cse_lc_le(apdu);
  123|  4.97k|}
sc_get_max_recv_size:
  187|   357k|{
  188|   357k|	size_t max_recv_size;
  189|   357k|	if (card == NULL || card->reader == NULL) {
  ------------------
  |  Branch (189:6): [True: 0, False: 357k]
  |  Branch (189:22): [True: 0, False: 357k]
  ------------------
  190|      0|		return 0;
  191|      0|	}
  192|   357k|	max_recv_size = card->max_recv_size;
  193|       |
  194|       |	/* initialize max_recv_size to a meaningful value */
  195|   357k|	if (card->caps & SC_CARD_CAP_APDU_EXT) {
  ------------------
  |  |  547|   357k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (195:6): [True: 25.3k, False: 332k]
  ------------------
  196|  25.3k|		if (!max_recv_size)
  ------------------
  |  Branch (196:7): [True: 2.21k, False: 23.1k]
  ------------------
  197|  2.21k|			max_recv_size = 65536;
  198|   332k|	} else {
  199|   332k|		if (!max_recv_size)
  ------------------
  |  Branch (199:7): [True: 161k, False: 170k]
  ------------------
  200|   161k|			max_recv_size = 256;
  201|   332k|	}
  202|       |
  203|       |	/*  Override card limitations with reader limitations. */
  204|   357k|	if (card->reader->max_recv_size != 0
  ------------------
  |  Branch (204:6): [True: 9.27k, False: 348k]
  ------------------
  205|  9.27k|			&& (card->reader->max_recv_size < card->max_recv_size))
  ------------------
  |  Branch (205:7): [True: 0, False: 9.27k]
  ------------------
  206|      0|		max_recv_size = card->reader->max_recv_size;
  207|       |
  208|   357k|	return max_recv_size;
  209|   357k|}
sc_get_max_send_size:
  212|  60.6k|{
  213|  60.6k|	size_t max_send_size;
  214|       |
  215|  60.6k|	if (card == NULL || card->reader == NULL) {
  ------------------
  |  Branch (215:6): [True: 0, False: 60.6k]
  |  Branch (215:22): [True: 0, False: 60.6k]
  ------------------
  216|      0|		return 0;
  217|      0|	}
  218|       |
  219|  60.6k|	max_send_size = card->max_send_size;
  220|       |
  221|       |	/* initialize max_send_size to a meaningful value */
  222|  60.6k|	if (card->caps & SC_CARD_CAP_APDU_EXT
  ------------------
  |  |  547|   121k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (222:6): [True: 10.8k, False: 49.8k]
  ------------------
  223|  10.8k|			&& card->reader->active_protocol != SC_PROTO_T0) {
  ------------------
  |  |  352|  10.8k|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (223:7): [True: 10.8k, False: 0]
  ------------------
  224|  10.8k|		if (!max_send_size)
  ------------------
  |  Branch (224:7): [True: 753, False: 10.0k]
  ------------------
  225|    753|			max_send_size = 65535;
  226|  49.8k|	} else {
  227|  49.8k|		if (!max_send_size)
  ------------------
  |  Branch (227:7): [True: 9.97k, False: 39.8k]
  ------------------
  228|  9.97k|			max_send_size = 255;
  229|  49.8k|	}
  230|       |
  231|       |	/*  Override card limitations with reader limitations. */
  232|  60.6k|	if (card->reader->max_send_size != 0
  ------------------
  |  Branch (232:6): [True: 0, False: 60.6k]
  ------------------
  233|      0|			&& (card->reader->max_send_size < card->max_send_size))
  ------------------
  |  Branch (233:7): [True: 0, False: 0]
  ------------------
  234|      0|		max_send_size = card->reader->max_send_size;
  235|       |
  236|  60.6k|	return max_send_size;
  237|  60.6k|}
sc_connect_card:
  240|  17.0k|{
  241|  17.0k|	sc_card_t *card;
  242|  17.0k|	sc_context_t *ctx;
  243|  17.0k|	struct sc_card_driver *driver;
  244|  17.0k|	int i, r = 0, idx, connected = 0;
  245|       |
  246|  17.0k|	if (card_out == NULL || reader == NULL)
  ------------------
  |  Branch (246:6): [True: 0, False: 17.0k]
  |  Branch (246:26): [True: 0, False: 17.0k]
  ------------------
  247|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  248|  17.0k|	ctx = reader->ctx;
  249|  17.0k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  17.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  17.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  17.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 17.0k]
  |  |  ------------------
  ------------------
  250|  17.0k|	if (reader->ops->connect == NULL)
  ------------------
  |  Branch (250:6): [True: 0, False: 17.0k]
  ------------------
  251|  17.0k|		LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  252|       |
  253|  17.0k|	card = sc_card_new(ctx);
  254|  17.0k|	if (card == NULL)
  ------------------
  |  Branch (254:6): [True: 0, False: 17.0k]
  ------------------
  255|  17.0k|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|  17.0k|	r = reader->ops->connect(reader);
  257|  17.0k|	if (r)
  ------------------
  |  Branch (257:6): [True: 0, False: 17.0k]
  ------------------
  258|      0|		goto err;
  259|       |
  260|  17.0k|	connected = 1;
  261|  17.0k|	card->reader = reader;
  262|  17.0k|	card->ctx = ctx;
  263|       |
  264|  17.0k|	if (reader->flags & SC_READER_ENABLE_ESCAPE)
  ------------------
  |  |  372|  17.0k|#define SC_READER_ENABLE_ESCAPE		0x00000040
  ------------------
  |  Branch (264:6): [True: 0, False: 17.0k]
  ------------------
  265|      0|		sc_detect_escape_cmds(reader);
  266|       |
  267|  17.0k|	memcpy(&card->atr, &reader->atr, sizeof(card->atr));
  268|  17.0k|	memcpy(&card->uid, &reader->uid, sizeof(card->uid));
  269|       |
  270|  17.0k|	_sc_parse_atr(reader);
  271|       |
  272|       |	/* See if the ATR matches any ATR specified in the config file */
  273|  17.0k|	if ((driver = ctx->forced_driver) == NULL) {
  ------------------
  |  Branch (273:6): [True: 17.0k, False: 0]
  ------------------
  274|  17.0k|		sc_log(ctx, "matching configured ATRs");
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  275|   800k|		for (i = 0; ctx->card_drivers[i] != NULL; i++) {
  ------------------
  |  Branch (275:15): [True: 783k, False: 17.0k]
  ------------------
  276|   783k|			driver = ctx->card_drivers[i];
  277|       |
  278|   783k|			if (driver->atr_map == NULL ||
  ------------------
  |  Branch (278:8): [True: 783k, False: 0]
  ------------------
  279|   783k|			    !strcmp(driver->short_name, "default")) {
  ------------------
  |  Branch (279:8): [True: 0, False: 0]
  ------------------
  280|   783k|				driver = NULL;
  281|   783k|				continue;
  282|   783k|			}
  283|      0|			sc_log(ctx, "trying driver '%s'", driver->short_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__
  |  |  ------------------
  ------------------
  284|      0|			idx = _sc_match_atr(card, driver->atr_map, NULL);
  285|      0|			if (idx >= 0) {
  ------------------
  |  Branch (285:8): [True: 0, False: 0]
  ------------------
  286|      0|				struct sc_atr_table *src = &driver->atr_map[idx];
  287|       |
  288|      0|				sc_log(ctx, "matched driver '%s'", driver->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__
  |  |  ------------------
  ------------------
  289|       |				/* It's up to card driver to notice these correctly */
  290|      0|				card->name = src->name;
  291|      0|				card->type = src->type;
  292|      0|				card->flags = src->flags;
  293|      0|				break;
  294|      0|			}
  295|      0|			driver = NULL;
  296|      0|		}
  297|  17.0k|	}
  298|       |
  299|  17.0k|	if (driver != NULL) {
  ------------------
  |  Branch (299:6): [True: 0, False: 17.0k]
  ------------------
  300|       |		/* Forced driver, or matched via ATR mapping from config file */
  301|      0|		card->driver = driver;
  302|       |
  303|      0|		memcpy(card->ops, card->driver->ops, sizeof(struct sc_card_operations));
  304|      0|		if (card->ops->match_card != NULL)
  ------------------
  |  Branch (304:7): [True: 0, False: 0]
  ------------------
  305|      0|			if (card->ops->match_card(card) != 1)
  ------------------
  |  Branch (305:8): [True: 0, False: 0]
  ------------------
  306|      0|				sc_log(ctx, "driver '%s' match_card() failed: %s (will continue anyway)", card->driver->name, sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  307|       |
  308|      0|		if (card->ops->init != NULL) {
  ------------------
  |  Branch (308:7): [True: 0, False: 0]
  ------------------
  309|      0|			r = card->ops->init(card);
  310|      0|			if (r) {
  ------------------
  |  Branch (310:8): [True: 0, False: 0]
  ------------------
  311|      0|				sc_log(ctx, "driver '%s' init() failed: %s", card->driver->name, sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  312|      0|				goto err;
  313|      0|			}
  314|      0|		}
  315|      0|	}
  316|  17.0k|	else {
  317|  17.0k|		sc_card_t uninitialized = *card;
  318|  17.0k|		sc_log(ctx, "matching built-in ATRs");
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  319|   437k|		for (i = 0; ctx->card_drivers[i] != NULL; i++) {
  ------------------
  |  Branch (319:15): [True: 435k, False: 2.38k]
  ------------------
  320|       |			/* FIXME If we had a clean API description, we'd probably get a
  321|       |			 * cleaner implementation of the driver's match_card and init,
  322|       |			 * which should normally *not* modify the card object if
  323|       |			 * unsuccessful. However, after years of relentless hacking, reality
  324|       |			 * is different: The card object is changed in virtually every card
  325|       |			 * driver so in order to prevent unwanted interaction, we reset the
  326|       |			 * card object here and hope that the card driver at least doesn't
  327|       |			 * allocate any internal resources that need to be freed. If we
  328|       |			 * had more time, we should refactor the existing code to not
  329|       |			 * modify sc_card_t until complete success (possibly by combining
  330|       |			 * `match_card()` and `init()`) */
  331|   435k|			*card = uninitialized;
  332|       |
  333|   435k|			struct sc_card_driver *drv = ctx->card_drivers[i];
  334|   435k|			const struct sc_card_operations *ops = drv->ops;
  335|       |
  336|   435k|			sc_log(ctx, "trying driver '%s'", drv->short_name);
  ------------------
  |  |   71|   435k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  337|   435k|			if (ops == NULL || ops->match_card == NULL)   {
  ------------------
  |  Branch (337:8): [True: 0, False: 435k]
  |  Branch (337:23): [True: 0, False: 435k]
  ------------------
  338|      0|				continue;
  339|      0|			}
  340|   435k|			else if (!(ctx->flags & SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER)
  ------------------
  |  |  860|   435k|#define SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER	0x00000008
  ------------------
  |  Branch (340:13): [True: 435k, False: 0]
  ------------------
  341|   435k|				   	&& !strcmp("default", drv->short_name))   {
  ------------------
  |  Branch (341:12): [True: 2.38k, False: 433k]
  ------------------
  342|  2.38k|				sc_log(ctx , "ignore 'default' card driver");
  ------------------
  |  |   71|  2.38k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  343|  2.38k|				continue;
  344|  2.38k|			}
  345|       |
  346|       |			/* Needed if match_card() needs to talk with the card (e.g. card-muscle) */
  347|   433k|			*card->ops = *ops;
  348|   433k|			if (ops->match_card(card) != 1)
  ------------------
  |  Branch (348:8): [True: 417k, False: 15.4k]
  ------------------
  349|   417k|				continue;
  350|  15.4k|			sc_log(ctx, "matched: %s", drv->name);
  ------------------
  |  |   71|  15.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  351|  15.4k|			memcpy(card->ops, ops, sizeof(struct sc_card_operations));
  352|  15.4k|			card->driver = drv;
  353|  15.4k|			r = ops->init(card);
  354|  15.4k|			if (r) {
  ------------------
  |  Branch (354:8): [True: 1.61k, False: 13.8k]
  ------------------
  355|  1.61k|				sc_log(ctx, "driver '%s' init() failed: %s", drv->name, sc_strerror(r));
  ------------------
  |  |   71|  1.61k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  356|  1.61k|				if (r == SC_ERROR_INVALID_CARD) {
  ------------------
  |  |   60|  1.61k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  |  Branch (356:9): [True: 843, False: 768]
  ------------------
  357|    843|					card->driver = NULL;
  358|    843|					continue;
  359|    843|				}
  360|    768|				goto err;
  361|  1.61k|			}
  362|  13.8k|			break;
  363|  15.4k|		}
  364|  17.0k|	}
  365|  16.2k|	if (card->driver == NULL) {
  ------------------
  |  Branch (365:6): [True: 2.38k, False: 13.8k]
  ------------------
  366|  2.38k|		sc_log(ctx, "unable to find driver for inserted card");
  ------------------
  |  |   71|  2.38k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  367|  2.38k|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  2.38k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  368|  2.38k|		goto err;
  369|  2.38k|	}
  370|  13.8k|	if (card->name == NULL)
  ------------------
  |  Branch (370:6): [True: 3.10k, False: 10.7k]
  ------------------
  371|  3.10k|		card->name = card->driver->name;
  372|       |
  373|       |	/* initialize max_send_size/max_recv_size to a meaningful value */
  374|  13.8k|	card->max_recv_size = sc_get_max_recv_size(card);
  375|  13.8k|	card->max_send_size = sc_get_max_send_size(card);
  376|       |
  377|  13.8k|	sc_log(ctx, "card info name:'%s', type:%i, flags:0x%lX, max_send/recv_size:%zu/%zu",
  ------------------
  |  |   71|  13.8k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  378|  13.8k|			card->name, card->type, card->flags, card->max_send_size, card->max_recv_size);
  379|       |
  380|  13.8k|#ifdef ENABLE_SM
  381|       |	/* Check, if secure messaging module present. */
  382|  13.8k|	r = sc_card_sm_check(card);
  383|  13.8k|	if (r)   {
  ------------------
  |  Branch (383:6): [True: 0, False: 13.8k]
  ------------------
  384|      0|		sc_log(ctx, "cannot load secure messaging module");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  385|      0|		goto err;
  386|      0|	}
  387|  13.8k|#endif
  388|  13.8k|	*card_out = card;
  389|       |
  390|  13.8k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  13.8k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  13.8k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  13.8k|	int _ret = r; \
  |  |  |  |  155|  13.8k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  13.8k|		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: 13.8k]
  |  |  |  |  ------------------
  |  |  |  |  157|  13.8k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  13.8k|	} 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|  13.8k|	return _ret; \
  |  |  |  |  163|  13.8k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  391|  3.15k|err:
  392|  3.15k|	if (connected)
  ------------------
  |  Branch (392:6): [True: 3.15k, False: 0]
  ------------------
  393|  3.15k|		reader->ops->disconnect(reader);
  394|  3.15k|	if (card != NULL)
  ------------------
  |  Branch (394:6): [True: 3.15k, False: 0]
  ------------------
  395|  3.15k|		sc_card_free(card);
  396|  3.15k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  3.15k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.15k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.15k|	int _ret = r; \
  |  |  |  |  155|  3.15k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.15k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.15k|		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|  3.15k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.15k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.15k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.15k|	} 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|  3.15k|	return _ret; \
  |  |  |  |  163|  3.15k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  397|  3.15k|}
sc_disconnect_card:
  400|  17.0k|{
  401|  17.0k|	sc_context_t *ctx;
  402|       |
  403|  17.0k|	if (!card)
  ------------------
  |  Branch (403:6): [True: 3.15k, False: 13.8k]
  ------------------
  404|  3.15k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  3.15k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  405|       |
  406|  13.8k|	ctx = card->ctx;
  407|  13.8k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  13.8k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  13.8k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  13.8k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  13.8k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 13.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  408|       |
  409|  13.8k|	if (card->ops->finish) {
  ------------------
  |  Branch (409:6): [True: 12.6k, False: 1.21k]
  ------------------
  410|  12.6k|		int r = card->ops->finish(card);
  411|  12.6k|		if (r)
  ------------------
  |  Branch (411:7): [True: 585, False: 12.0k]
  ------------------
  412|    585|			sc_log(ctx, "card driver finish() failed: %s", sc_strerror(r));
  ------------------
  |  |   71|    585|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  413|  12.6k|	}
  414|       |
  415|  13.8k|	if (card->reader->ops->disconnect) {
  ------------------
  |  Branch (415:6): [True: 13.8k, False: 0]
  ------------------
  416|  13.8k|		int r = card->reader->ops->disconnect(card->reader);
  417|  13.8k|		if (r)
  ------------------
  |  Branch (417:7): [True: 0, False: 13.8k]
  ------------------
  418|      0|			sc_log(ctx, "disconnect() failed: %s", sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  419|  13.8k|	}
  420|       |
  421|  13.8k|#ifdef ENABLE_SM
  422|       |	/* release SM related resources */
  423|  13.8k|	sc_card_sm_unload(card);
  424|  13.8k|#endif
  425|       |
  426|  13.8k|	sc_card_free(card);
  427|  13.8k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  13.8k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  13.8k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  13.8k|	int _ret = r; \
  |  |  |  |  155|  13.8k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  13.8k|		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: 13.8k]
  |  |  |  |  ------------------
  |  |  |  |  157|  13.8k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  13.8k|	} 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|  13.8k|	return _ret; \
  |  |  |  |  163|  13.8k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  428|  13.8k|}
sc_lock:
  455|   722k|{
  456|   722k|	int r = 0, r2 = 0;
  457|   722k|	int was_reset = 0;
  458|   722k|	int reader_lock_obtained  = 0;
  459|       |
  460|   722k|	if (card == NULL)
  ------------------
  |  Branch (460:6): [True: 0, False: 722k]
  ------------------
  461|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  462|       |
  463|   722k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|   722k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   722k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   722k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   722k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 722k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|       |
  465|   722k|	r = sc_mutex_lock(card->ctx, card->mutex);
  466|   722k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|   722k|#define SC_SUCCESS				0
  ------------------
  |  Branch (466:6): [True: 0, False: 722k]
  ------------------
  467|      0|		return r;
  468|   722k|	if (card->lock_count == 0) {
  ------------------
  |  Branch (468:6): [True: 315k, False: 407k]
  ------------------
  469|   315k|		if (card->reader->ops->lock != NULL) {
  ------------------
  |  Branch (469:7): [True: 315k, False: 0]
  ------------------
  470|   315k|			r = card->reader->ops->lock(card->reader);
  471|   315k|			while (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   37|   630k|#define SC_ERROR_CARD_RESET			-1106
  ------------------
              			while (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   46|   315k|#define SC_ERROR_READER_REATTACHED		-1115
  ------------------
  |  Branch (471:11): [True: 0, False: 315k]
  |  Branch (471:39): [True: 0, False: 315k]
  ------------------
  472|      0|				if (was_reset++ > 4) /* TODO retry a few times */
  ------------------
  |  Branch (472:9): [True: 0, False: 0]
  ------------------
  473|      0|					break;
  474|      0|				r = card->reader->ops->lock(card->reader);
  475|      0|			}
  476|   315k|			if (r == 0)
  ------------------
  |  Branch (476:8): [True: 315k, False: 0]
  ------------------
  477|   315k|				reader_lock_obtained = 1;
  478|   315k|		}
  479|   315k|	}
  480|   722k|	if (r == 0)
  ------------------
  |  Branch (480:6): [True: 722k, False: 0]
  ------------------
  481|   722k|		card->lock_count++;
  482|       |
  483|   722k|	r2 = sc_mutex_unlock(card->ctx, card->mutex);
  484|   722k|	if (r2 != SC_SUCCESS) {
  ------------------
  |  |   28|   722k|#define SC_SUCCESS				0
  ------------------
  |  Branch (484:6): [True: 0, False: 722k]
  ------------------
  485|      0|		sc_log(card->ctx, "unable to release card->mutex lock");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  486|      0|		r = r != SC_SUCCESS ? r : r2;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (486:7): [True: 0, False: 0]
  ------------------
  487|      0|	}
  488|       |
  489|   722k|	if (r == 0 && was_reset > 0) {
  ------------------
  |  Branch (489:6): [True: 722k, False: 0]
  |  Branch (489:16): [True: 0, False: 722k]
  ------------------
  490|      0|#ifdef ENABLE_SM
  491|      0|		if (card->sm_ctx.ops.open)
  ------------------
  |  Branch (491:7): [True: 0, False: 0]
  ------------------
  492|      0|			card->sm_ctx.ops.open(card);
  493|      0|#endif
  494|      0|	}
  495|       |
  496|       |	/* give card driver a chance to do something when reader lock first obtained */
  497|   722k|	if (r == 0 && reader_lock_obtained == 1  && card->ops->card_reader_lock_obtained) {
  ------------------
  |  Branch (497:6): [True: 722k, False: 0]
  |  Branch (497:16): [True: 315k, False: 407k]
  |  Branch (497:46): [True: 100k, False: 214k]
  ------------------
  498|   100k|		if (SC_SUCCESS != card->ops->card_reader_lock_obtained(card, was_reset))
  ------------------
  |  |   28|   100k|#define SC_SUCCESS				0
  ------------------
  |  Branch (498:7): [True: 1.71k, False: 99.1k]
  ------------------
  499|  1.71k|			sc_log(card->ctx, "card_reader_lock_obtained failed");
  ------------------
  |  |   71|  1.71k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  500|   100k|	}
  501|       |
  502|   722k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|   722k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   722k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   722k|	int _ret = r; \
  |  |  |  |  155|   722k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 722k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   722k|		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: 722k]
  |  |  |  |  ------------------
  |  |  |  |  157|   722k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   722k|	} 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|   722k|	return _ret; \
  |  |  |  |  163|   722k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  503|   722k|}
sc_unlock:
  506|   722k|{
  507|   722k|	int r, r2;
  508|       |
  509|   722k|	if (!card)
  ------------------
  |  Branch (509:6): [True: 0, False: 722k]
  ------------------
  510|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  511|       |
  512|   722k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|   722k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   722k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   722k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   722k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 722k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  513|       |
  514|   722k|	r = sc_mutex_lock(card->ctx, card->mutex);
  515|   722k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|   722k|#define SC_SUCCESS				0
  ------------------
  |  Branch (515:6): [True: 0, False: 722k]
  ------------------
  516|   722k|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  517|       |
  518|   722k|	if (card->lock_count < 1) {
  ------------------
  |  Branch (518:6): [True: 0, False: 722k]
  ------------------
  519|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  520|      0|	}
  521|   722k|	if (--card->lock_count == 0) {
  ------------------
  |  Branch (521:6): [True: 315k, False: 407k]
  ------------------
  522|       |		/* release reader lock */
  523|   315k|		if (card->reader->ops->unlock != NULL)
  ------------------
  |  Branch (523:7): [True: 315k, False: 0]
  ------------------
  524|   315k|			r = card->reader->ops->unlock(card->reader);
  525|   315k|	}
  526|   722k|	r2 = sc_mutex_unlock(card->ctx, card->mutex);
  527|   722k|	if (r2 != SC_SUCCESS) {
  ------------------
  |  |   28|   722k|#define SC_SUCCESS				0
  ------------------
  |  Branch (527:6): [True: 0, False: 722k]
  ------------------
  528|      0|		sc_log(card->ctx, "unable to release lock");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  529|      0|		r = (r == SC_SUCCESS) ? r2 : r;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (529:7): [True: 0, False: 0]
  ------------------
  530|      0|	}
  531|       |
  532|   722k|	return r;
  533|   722k|}
sc_read_binary:
  603|  14.3k|{
  604|  14.3k|	size_t max_le = sc_get_max_recv_size(card);
  605|  14.3k|	size_t todo = count;
  606|  14.3k|	int r;
  607|       |
  608|  14.3k|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (608:6): [True: 0, False: 14.3k]
  |  Branch (608:22): [True: 0, False: 14.3k]
  |  Branch (608:43): [True: 0, False: 14.3k]
  ------------------
  609|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  610|      0|	}
  611|  14.3k|	sc_log(card->ctx, "called; %zu bytes at index %d", count, idx);
  ------------------
  |  |   71|  14.3k|#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|  14.3k|	if (count == 0)
  ------------------
  |  Branch (612:6): [True: 226, False: 14.1k]
  ------------------
  613|  14.3k|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    226|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    226|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    226|	int _ret = r; \
  |  |  |  |  155|    226|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 226, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    226|		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: 226]
  |  |  |  |  ------------------
  |  |  |  |  157|    226|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    226|	} 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|    226|	return _ret; \
  |  |  |  |  163|    226|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  614|       |
  615|  14.1k|#ifdef ENABLE_SM
  616|  14.1k|	if (card->sm_ctx.ops.read_binary)   {
  ------------------
  |  Branch (616:6): [True: 215, False: 13.9k]
  ------------------
  617|    215|		r = card->sm_ctx.ops.read_binary(card, idx, buf, count);
  618|    215|		if (r)
  ------------------
  |  Branch (618:7): [True: 181, False: 34]
  ------------------
  619|    215|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    181|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    181|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    181|	int _ret = r; \
  |  |  |  |  155|    181|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 181, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    181|		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|    181|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 181, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    181|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    181|	} 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|    181|	return _ret; \
  |  |  |  |  163|    181|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  620|    215|	}
  621|  13.9k|#endif
  622|       |
  623|  13.9k|	if (card->ops->read_binary == NULL)
  ------------------
  |  Branch (623:6): [True: 0, False: 13.9k]
  ------------------
  624|  13.9k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|       |
  626|       |	/* lock the card now to avoid deselection of the file */
  627|  13.9k|	r = sc_lock(card);
  628|  13.9k|	LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|  13.9k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  13.9k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  13.9k|	int _ret = (r); \
  |  |  |  |  168|  13.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 13.9k]
  |  |  |  |  ------------------
  |  |  |  |  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|  13.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  629|       |
  630|  47.9k|	while (todo > 0) {
  ------------------
  |  Branch (630:9): [True: 44.6k, False: 3.28k]
  ------------------
  631|  44.6k|		size_t chunk = MIN(todo, max_le);
  ------------------
  |  |   69|  44.6k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 16.6k, False: 27.9k]
  |  |  ------------------
  ------------------
  632|       |
  633|  44.6k|		r = card->ops->read_binary(card, idx, buf, chunk, flags);
  634|  44.6k|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|  40.8k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (634:7): [True: 3.79k, False: 40.8k]
  |  Branch (634:17): [True: 55, False: 40.7k]
  ------------------
  635|  3.85k|			break;
  636|  40.7k|		if (r < 0 && todo != count) {
  ------------------
  |  Branch (636:7): [True: 6.79k, False: 33.9k]
  |  Branch (636:16): [True: 4.70k, False: 2.09k]
  ------------------
  637|       |			/* the last command failed, but previous ones succeeded.
  638|       |			 * Let's just return what we've successfully read. */
  639|  4.70k|			sc_log(card->ctx, "Subsequent read failed with %d, returning what was read successfully.", r);
  ------------------
  |  |   71|  4.70k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  640|  4.70k|			break;
  641|  4.70k|		}
  642|  36.0k|		if (r < 0) {
  ------------------
  |  Branch (642:7): [True: 2.09k, False: 33.9k]
  ------------------
  643|  2.09k|			sc_unlock(card);
  644|  2.09k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  2.09k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.09k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.09k|	int _ret = r; \
  |  |  |  |  155|  2.09k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.09k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.09k|		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|  2.09k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.09k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.09k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.09k|	} 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|  2.09k|	return _ret; \
  |  |  |  |  163|  2.09k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  645|  2.09k|		}
  646|  33.9k|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (646:7): [True: 0, False: 33.9k]
  |  Branch (646:40): [True: 0, False: 33.9k]
  ------------------
  647|       |			/* `idx + r` or `todo - r` would overflow */
  648|      0|			sc_unlock(card);
  649|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OFFSET_TOO_LARGE);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|      0|		}
  651|       |
  652|  33.9k|		todo -= (size_t) r;
  653|  33.9k|		buf  += (size_t) r;
  654|  33.9k|		idx  += (size_t) r;
  655|  33.9k|	}
  656|       |
  657|  11.8k|	sc_unlock(card);
  658|       |
  659|  11.8k|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  164|  11.8k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  11.8k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  11.8k|	int _ret = r; \
  |  |  |  |  155|  11.8k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.07k, False: 10.7k]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.07k|		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: 1.07k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.07k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  10.7k|	} else { \
  |  |  |  |  159|  10.7k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  10.7k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  10.7k|	} \
  |  |  |  |  162|  11.8k|	return _ret; \
  |  |  |  |  163|  11.8k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  660|  11.8k|}
sc_select_file:
  809|   118k|{
  810|   118k|	int r;
  811|   118k|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  812|       |
  813|   118k|	if (card == NULL || in_path == NULL) {
  ------------------
  |  Branch (813:6): [True: 0, False: 118k]
  |  Branch (813:22): [True: 0, False: 118k]
  ------------------
  814|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  815|      0|	}
  816|       |
  817|   118k|	r = sc_path_print(pbuf, sizeof(pbuf), in_path);
  818|   118k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|   118k|#define SC_SUCCESS				0
  ------------------
  |  Branch (818:6): [True: 1.61k, False: 117k]
  ------------------
  819|  1.61k|		pbuf[0] = '\0';
  820|       |
  821|       |	/* FIXME We should be a bit less strict and let the upper layers do
  822|       |	 * the initialization (including reuse of existing file objects). We
  823|       |	 * implemented this here because we are lazy. */
  824|   118k|	if (file != NULL)
  ------------------
  |  Branch (824:6): [True: 67.4k, False: 51.2k]
  ------------------
  825|  67.4k|		*file = NULL;
  826|       |
  827|   118k|	sc_log(card->ctx, "called; type=%d, path=%s", in_path->type, pbuf);
  ------------------
  |  |   71|   118k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  828|   118k|	if (in_path->len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|   118k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (828:6): [True: 0, False: 118k]
  ------------------
  829|   118k|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  830|       |
  831|   118k|	if (in_path->type == SC_PATH_TYPE_PATH) {
  ------------------
  |  |  119|   118k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (831:6): [True: 87.1k, False: 31.4k]
  ------------------
  832|       |		/* Perform a sanity check */
  833|  87.1k|		size_t i;
  834|       |
  835|  87.1k|		if ((in_path->len & 1) != 0)
  ------------------
  |  Branch (835:7): [True: 107, False: 87.0k]
  ------------------
  836|  87.1k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|    107|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    107|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    107|	int _ret = r; \
  |  |  |  |  155|    107|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 107, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    107|		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|    107|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 107, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    107|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    107|	} 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|    107|	return _ret; \
  |  |  |  |  163|    107|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  837|       |
  838|   260k|		for (i = 0; i < in_path->len/2; i++) {
  ------------------
  |  Branch (838:15): [True: 173k, False: 87.0k]
  ------------------
  839|   173k|			u8 p1 = in_path->value[2*i],
  840|   173k|			   p2 = in_path->value[2*i+1];
  841|       |
  842|   173k|			if ((p1 == 0x3F && p2 == 0x00) && i != 0)
  ------------------
  |  Branch (842:9): [True: 70.5k, False: 102k]
  |  Branch (842:23): [True: 65.0k, False: 5.53k]
  |  Branch (842:38): [True: 25, False: 65.0k]
  ------------------
  843|   173k|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     25|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     25|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     25|	int _ret = r; \
  |  |  |  |  155|     25|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 25, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     25|		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|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 25, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     25|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     25|	} 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|     25|	return _ret; \
  |  |  |  |  163|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  844|   173k|		}
  845|  87.0k|	}
  846|   118k|	if (card->ops->select_file == NULL)
  ------------------
  |  Branch (846:6): [True: 0, False: 118k]
  ------------------
  847|   118k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  848|   118k|	r = card->ops->select_file(card, in_path, file);
  849|   118k|	LOG_TEST_RET(card->ctx, r, "'SELECT' error");
  ------------------
  |  |  174|   118k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   118k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   118k|	int _ret = (r); \
  |  |  |  |  168|   118k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 91.1k, False: 27.3k]
  |  |  |  |  ------------------
  |  |  |  |  169|  91.1k|		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|  91.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  91.1k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  91.1k|		return _ret; \
  |  |  |  |  172|  91.1k|	} \
  |  |  |  |  173|   118k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 27.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  850|       |
  851|  27.3k|	if (file) {
  ------------------
  |  Branch (851:6): [True: 15.4k, False: 11.8k]
  ------------------
  852|  15.4k|		if (*file)
  ------------------
  |  Branch (852:7): [True: 15.2k, False: 209]
  ------------------
  853|       |			/* Remember file path */
  854|  15.2k|			(*file)->path = *in_path;
  855|    209|		else
  856|       |			/* FIXME We should be a bit less strict and let the upper layers do
  857|       |			 * the error checking. We implemented this here because we are
  858|       |			 * lazy.  */
  859|    209|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|    209|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  860|  15.4k|	}
  861|       |
  862|  27.3k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  27.3k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  27.3k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  27.3k|	int _ret = r; \
  |  |  |  |  155|  27.3k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 27.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  27.3k|		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|    209|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 209, False: 27.1k]
  |  |  |  |  ------------------
  |  |  |  |  157|  27.3k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  27.3k|	} 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|  27.3k|	return _ret; \
  |  |  |  |  163|  27.3k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  863|  27.3k|}
sc_get_data:
  867|  5.07k|{
  868|  5.07k|	int	r;
  869|       |
  870|  5.07k|	sc_log(card->ctx, "called, tag=%04x", tag);
  ------------------
  |  |   71|  5.07k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  871|  5.07k|	if (card->ops->get_data == NULL)
  ------------------
  |  Branch (871:6): [True: 0, False: 5.07k]
  ------------------
  872|  5.07k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  873|  5.07k|	r = card->ops->get_data(card, tag, buf, len);
  874|       |
  875|  5.07k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  5.07k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.07k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.07k|	int _ret = r; \
  |  |  |  |  155|  5.07k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.56k, False: 1.51k]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.56k|		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|  3.20k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.20k, False: 362]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.56k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.56k|	} else { \
  |  |  |  |  159|  1.51k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.51k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.51k|	} \
  |  |  |  |  162|  5.07k|	return _ret; \
  |  |  |  |  163|  5.07k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  876|  5.07k|}
sc_get_challenge:
  892|  3.25k|{
  893|  3.25k|	int r;
  894|       |
  895|  3.25k|	if (len == 0)
  ------------------
  |  Branch (895:6): [True: 532, False: 2.72k]
  ------------------
  896|    532|		return SC_SUCCESS;
  ------------------
  |  |   28|    532|#define SC_SUCCESS				0
  ------------------
  897|       |
  898|  2.72k|	if (card == NULL || rnd == NULL) {
  ------------------
  |  Branch (898:6): [True: 0, False: 2.72k]
  |  Branch (898:22): [True: 0, False: 2.72k]
  ------------------
  899|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  900|      0|	}
  901|       |
  902|  2.72k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.72k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.72k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.72k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.72k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.72k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  903|       |
  904|  2.72k|	if (card->ops == NULL || card->ops->get_challenge == NULL)
  ------------------
  |  Branch (904:6): [True: 0, False: 2.72k]
  |  Branch (904:27): [True: 3, False: 2.71k]
  ------------------
  905|  2.72k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} 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|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  906|       |
  907|  2.71k|	r = sc_lock(card);
  908|  2.71k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|  2.71k|#define SC_SUCCESS				0
  ------------------
  |  Branch (908:6): [True: 0, False: 2.71k]
  ------------------
  909|  2.71k|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  910|       |
  911|  7.47k|	while (len > 0) {
  ------------------
  |  Branch (911:9): [True: 7.46k, False: 15]
  ------------------
  912|  7.46k|		r = card->ops->get_challenge(card, rnd, len);
  913|  7.46k|		if (r == 0)
  ------------------
  |  Branch (913:7): [True: 74, False: 7.38k]
  ------------------
  914|     74|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     74|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  915|  7.46k|		if (r < 0) {
  ------------------
  |  Branch (915:7): [True: 2.70k, False: 4.75k]
  ------------------
  916|  2.70k|			sc_unlock(card);
  917|  2.70k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  2.70k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.70k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.70k|	int _ret = r; \
  |  |  |  |  155|  2.70k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.70k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.70k|		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|  2.70k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.70k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.70k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.70k|	} 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|  2.70k|	return _ret; \
  |  |  |  |  163|  2.70k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  918|  2.70k|		}
  919|       |
  920|  4.75k|		rnd += (size_t) r;
  921|  4.75k|		len -= (size_t) r;
  922|  4.75k|	}
  923|       |
  924|     15|	sc_unlock(card);
  925|       |
  926|     15|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		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: 15]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     15|	} 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|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  927|     15|}
sc_read_record:
  931|  7.90k|{
  932|  7.90k|	size_t max_le = sc_get_max_recv_size(card);
  933|  7.90k|	size_t todo = count;
  934|  7.90k|	int r;
  935|       |
  936|  7.90k|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (936:6): [True: 0, False: 7.90k]
  |  Branch (936:22): [True: 0, False: 7.90k]
  |  Branch (936:43): [True: 0, False: 7.90k]
  ------------------
  937|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  938|      0|	}
  939|  7.90k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  7.90k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  7.90k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  7.90k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  7.90k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 7.90k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  940|  7.90k|	if (count == 0)
  ------------------
  |  Branch (940:6): [True: 4, False: 7.90k]
  ------------------
  941|  7.90k|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      4|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      4|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      4|	int _ret = r; \
  |  |  |  |  155|      4|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      4|		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: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|      4|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      4|	} 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|      4|	return _ret; \
  |  |  |  |  163|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  942|       |
  943|  7.90k|	if (card->ops->read_record == NULL)
  ------------------
  |  Branch (943:6): [True: 40, False: 7.86k]
  ------------------
  944|  7.90k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     40|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     40|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     40|	int _ret = r; \
  |  |  |  |  155|     40|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 40, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     40|		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|     40|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 40, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     40|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     40|	} 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|     40|	return _ret; \
  |  |  |  |  163|     40|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  945|       |
  946|       |	/* lock the card now to avoid deselection of the file */
  947|  7.86k|	r = sc_lock(card);
  948|  7.86k|	LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|  7.86k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.86k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.86k|	int _ret = (r); \
  |  |  |  |  168|  7.86k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 7.86k]
  |  |  |  |  ------------------
  |  |  |  |  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|  7.86k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7.86k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  949|       |
  950|  16.1k|	while (todo > 0) {
  ------------------
  |  Branch (950:9): [True: 15.8k, False: 325]
  ------------------
  951|  15.8k|		size_t chunk = MIN(todo, max_le);
  ------------------
  |  |   69|  15.8k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 7.26k, False: 8.59k]
  |  |  ------------------
  ------------------
  952|       |
  953|  15.8k|		r = card->ops->read_record(card, rec_nr, idx, buf, chunk, flags);
  954|  15.8k|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|  15.4k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (954:7): [True: 416, False: 15.4k]
  |  Branch (954:17): [True: 26, False: 15.4k]
  ------------------
  955|    442|			break;
  956|  15.4k|		if (r < 0 && todo != count) {
  ------------------
  |  Branch (956:7): [True: 7.09k, False: 8.32k]
  |  Branch (956:16): [True: 5.77k, False: 1.31k]
  ------------------
  957|       |			/* the last command failed, but previous ones succeeded.
  958|       |			 * Let's just return what we've successfully read. */
  959|  5.77k|			sc_log(card->ctx, "Subsequent read failed with %d, returning what was read successfully.", r);
  ------------------
  |  |   71|  5.77k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  960|  5.77k|			break;
  961|  5.77k|		}
  962|  9.64k|		if (r < 0) {
  ------------------
  |  Branch (962:7): [True: 1.31k, False: 8.32k]
  ------------------
  963|  1.31k|			sc_unlock(card);
  964|  1.31k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.31k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.31k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.31k|	int _ret = r; \
  |  |  |  |  155|  1.31k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.31k|		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|  1.31k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.31k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.31k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.31k|	} 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|  1.31k|	return _ret; \
  |  |  |  |  163|  1.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  965|  1.31k|		}
  966|  8.32k|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (966:7): [True: 0, False: 8.32k]
  |  Branch (966:40): [True: 0, False: 8.32k]
  ------------------
  967|       |			/* `idx + r` or `todo - r` would overflow */
  968|      0|			sc_unlock(card);
  969|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OFFSET_TOO_LARGE);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  970|      0|		}
  971|       |
  972|  8.32k|		todo -= (size_t) r;
  973|  8.32k|		buf  += (size_t) r;
  974|  8.32k|		idx  += (size_t) r;
  975|  8.32k|	}
  976|       |
  977|  6.54k|	sc_unlock(card);
  978|       |
  979|  6.54k|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  164|  6.54k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.54k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.54k|	int _ret = r; \
  |  |  |  |  155|  6.54k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 420, False: 6.12k]
  |  |  |  |  ------------------
  |  |  |  |  156|    420|		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: 420]
  |  |  |  |  ------------------
  |  |  |  |  157|    420|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.12k|	} else { \
  |  |  |  |  159|  6.12k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  6.12k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  6.12k|	} \
  |  |  |  |  162|  6.54k|	return _ret; \
  |  |  |  |  163|  6.54k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  980|  6.54k|}
sc_card_ctl:
 1090|   171k|{
 1091|   171k|	int r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|   171k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1092|       |
 1093|   171k|	if (card == NULL) {
  ------------------
  |  Branch (1093:6): [True: 0, False: 171k]
  ------------------
 1094|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1095|      0|	}
 1096|   171k|	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "called with cmd=%lu\n", cmd);
  ------------------
  |  |   70|   171k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1097|       |
 1098|   171k|	if (card->ops->card_ctl != NULL)
  ------------------
  |  Branch (1098:6): [True: 170k, False: 924]
  ------------------
 1099|   170k|		r = card->ops->card_ctl(card, cmd, args);
 1100|       |
 1101|       |	/* suppress "not supported" error messages */
 1102|   171k|	if (r == SC_ERROR_NOT_SUPPORTED) {
  ------------------
  |  |   89|   171k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (1102:6): [True: 35.8k, False: 135k]
  ------------------
 1103|  35.8k|		sc_log(card->ctx, "card_ctl(%lu) not supported", cmd);
  ------------------
  |  |   71|  35.8k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1104|  35.8k|		return r;
 1105|  35.8k|	}
 1106|   135k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|   135k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   135k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   135k|	int _ret = r; \
  |  |  |  |  155|   135k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 88.6k, False: 46.6k]
  |  |  |  |  ------------------
  |  |  |  |  156|  88.6k|		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|  30.4k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 30.4k, False: 58.2k]
  |  |  |  |  ------------------
  |  |  |  |  157|  88.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  88.6k|	} else { \
  |  |  |  |  159|  46.6k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  46.6k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  46.6k|	} \
  |  |  |  |  162|   135k|	return _ret; \
  |  |  |  |  163|   135k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1107|   135k|}
_sc_card_add_algorithm:
 1110|  49.2k|{
 1111|  49.2k|	sc_algorithm_info_t *p;
 1112|       |
 1113|  49.2k|	if (info == NULL) {
  ------------------
  |  Branch (1113:6): [True: 0, False: 49.2k]
  ------------------
 1114|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1115|      0|	}
 1116|  49.2k|	p = (sc_algorithm_info_t *) realloc(card->algorithms, (card->algorithm_count + 1) * sizeof(*info));
 1117|  49.2k|	if (!p) {
  ------------------
  |  Branch (1117:6): [True: 0, False: 49.2k]
  ------------------
 1118|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1119|      0|	}
 1120|  49.2k|	card->algorithms = p;
 1121|  49.2k|	p += card->algorithm_count;
 1122|  49.2k|	card->algorithm_count++;
 1123|  49.2k|	*p = *info;
 1124|  49.2k|	return SC_SUCCESS;
  ------------------
  |  |   28|  49.2k|#define SC_SUCCESS				0
  ------------------
 1125|  49.2k|}
_sc_card_add_symmetric_alg:
 1129|    142|{
 1130|    142|	sc_algorithm_info_t info;
 1131|       |
 1132|    142|	memset(&info, 0, sizeof(info));
 1133|    142|	info.algorithm = algorithm;
 1134|    142|	info.key_length = key_length;
 1135|    142|	info.flags = flags;
 1136|       |
 1137|    142|	return _sc_card_add_algorithm(card, &info);
 1138|    142|}
_sc_card_add_ec_alg:
 1175|  8.51k|{
 1176|  8.51k|	return _sc_card_add_ec_alg_int(card, key_length, flags, ext_flags,
 1177|  8.51k|		curve_oid, SC_ALGORITHM_EC);
  ------------------
  |  |   70|  8.51k|#define SC_ALGORITHM_EC		2
  ------------------
 1178|  8.51k|}
_sc_card_add_eddsa_alg:
 1183|    102|{
 1184|       |	/* For simplicity, share the ec union with the curve information */
 1185|    102|	return _sc_card_add_ec_alg_int(card, key_length, flags, ext_flags,
 1186|    102|		curve_oid, SC_ALGORITHM_EDDSA);
  ------------------
  |  |   72|    102|#define SC_ALGORITHM_EDDSA		4
  ------------------
 1187|    102|}
_sc_card_add_xeddsa_alg:
 1192|    102|{
 1193|       |	/* For simplicity, share the ec union with the curve information */
 1194|    102|	return _sc_card_add_ec_alg_int(card, key_length, flags, ext_flags,
 1195|    102|		curve_oid, SC_ALGORITHM_XEDDSA);
  ------------------
  |  |   73|    102|#define SC_ALGORITHM_XEDDSA		5
  ------------------
 1196|    102|}
sc_card_find_alg:
 1200|    446|{
 1201|    446|	int i;
 1202|       |
 1203|  1.51k|	for (i = 0; i < card->algorithm_count; i++) {
  ------------------
  |  Branch (1203:14): [True: 1.49k, False: 23]
  ------------------
 1204|  1.49k|		sc_algorithm_info_t *info = &card->algorithms[i];
 1205|       |
 1206|  1.49k|		if (param && (info->algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1206:7): [True: 0, False: 1.49k]
  |  Branch (1206:17): [True: 0, False: 0]
  ------------------
 1207|      0|			info->algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1207:4): [True: 0, False: 0]
  ------------------
 1208|      0|			info->algorithm == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1208:4): [True: 0, False: 0]
  ------------------
 1209|      0|			if (sc_compare_oid((struct sc_object_id *)param, &info->u._ec.params.id))
  ------------------
  |  Branch (1209:8): [True: 0, False: 0]
  ------------------
 1210|      0|				return info;
 1211|  1.49k|		} else if (info->algorithm != algorithm) {
  ------------------
  |  Branch (1211:14): [True: 159, False: 1.33k]
  ------------------
 1212|    159|			continue;
 1213|  1.33k|		} else if (info->key_length == key_length)
  ------------------
  |  Branch (1213:14): [True: 423, False: 909]
  ------------------
 1214|    423|			return info;
 1215|  1.49k|	}
 1216|     23|	return NULL;
 1217|    446|}
sc_card_find_ec_alg:
 1221|     32|{
 1222|     32|	return sc_card_find_alg(card, SC_ALGORITHM_EC, key_length, curve_name);
  ------------------
  |  |   70|     32|#define SC_ALGORITHM_EC		2
  ------------------
 1223|     32|}
_sc_card_add_rsa_alg:
 1239|  40.3k|{
 1240|  40.3k|	sc_algorithm_info_t info;
 1241|       |
 1242|  40.3k|	memset(&info, 0, sizeof(info));
 1243|  40.3k|	info.algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|  40.3k|#define SC_ALGORITHM_RSA		0
  ------------------
 1244|  40.3k|	info.key_length = key_length;
 1245|  40.3k|	info.flags = flags;
 1246|       |	/* disable particular PKCS1 v1.5 padding type if also RAW is supported on card */
 1247|  40.3k|	if ((info.flags & (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) == (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) {
  ------------------
  |  |  111|  40.3k|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|  40.3k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|  40.3k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	if ((info.flags & (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) == (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) {
  ------------------
  |  |  102|  40.3k|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	if ((info.flags & (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) == (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) {
  ------------------
  |  |  111|  40.3k|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|  40.3k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|  40.3k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	if ((info.flags & (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) == (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) {
  ------------------
  |  |  102|  40.3k|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  |  Branch (1247:6): [True: 4.46k, False: 35.8k]
  ------------------
 1248|  4.46k|		if (card->ctx->disable_hw_pkcs1_padding & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01)
  ------------------
  |  |  109|  4.46k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (1248:7): [True: 0, False: 4.46k]
  ------------------
 1249|      0|			info.flags &= ~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 */
  ------------------
 1250|  4.46k|		if (card->ctx->disable_hw_pkcs1_padding & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02)
  ------------------
  |  |  110|  4.46k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  |  Branch (1250:7): [True: 4.46k, False: 0]
  ------------------
 1251|  4.46k|			info.flags &= ~SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  110|  4.46k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
 1252|  4.46k|	}
 1253|  40.3k|	info.u._rsa.exponent = exponent;
 1254|       |
 1255|  40.3k|	return _sc_card_add_algorithm(card, &info);
 1256|  40.3k|}
sc_card_find_rsa_alg:
 1259|    414|{
 1260|    414|	return sc_card_find_alg(card, SC_ALGORITHM_RSA, key_length, NULL);
  ------------------
  |  |   69|    414|#define SC_ALGORITHM_RSA		0
  ------------------
 1261|    414|}
_sc_match_atr:
 1332|   377k|{
 1333|   377k|	int res;
 1334|       |
 1335|   377k|	if (card == NULL)
  ------------------
  |  Branch (1335:6): [True: 0, False: 377k]
  ------------------
 1336|      0|		return -1;
 1337|   377k|	res = match_atr_table(card->ctx, table, &card->atr);
 1338|   377k|	if (res < 0)
  ------------------
  |  Branch (1338:6): [True: 367k, False: 10.9k]
  ------------------
 1339|   367k|		return res;
 1340|  10.9k|	if (type_out != NULL)
  ------------------
  |  Branch (1340:6): [True: 10.5k, False: 439]
  ------------------
 1341|  10.5k|		*type_out = table[res].type;
 1342|  10.9k|	return res;
 1343|   377k|}
_sc_match_atr_block:
 1346|  32.0k|{
 1347|  32.0k|	struct sc_card_driver *drv;
 1348|  32.0k|	struct sc_atr_table *table;
 1349|  32.0k|	int res;
 1350|       |
 1351|  32.0k|	if (ctx == NULL)
  ------------------
  |  Branch (1351:6): [True: 0, False: 32.0k]
  ------------------
 1352|      0|		return NULL;
 1353|  32.0k|	if (driver) {
  ------------------
  |  Branch (1353:6): [True: 13.8k, False: 18.1k]
  ------------------
 1354|  13.8k|		drv = driver;
 1355|  13.8k|		table = drv->atr_map;
 1356|  13.8k|		res = match_atr_table(ctx, table, atr);
 1357|  13.8k|		if (res < 0)
  ------------------
  |  Branch (1357:7): [True: 13.8k, False: 0]
  ------------------
 1358|  13.8k|			return NULL;
 1359|      0|		return table[res].card_atr;
 1360|  18.1k|	} else {
 1361|  18.1k|		unsigned int i;
 1362|       |
 1363|   854k|		for (i = 0; ctx->card_drivers[i] != NULL; i++) {
  ------------------
  |  Branch (1363:15): [True: 836k, False: 18.1k]
  ------------------
 1364|   836k|			drv = ctx->card_drivers[i];
 1365|   836k|			table = drv->atr_map;
 1366|   836k|			res = match_atr_table(ctx, table, atr);
 1367|   836k|			if (res < 0)
  ------------------
  |  Branch (1367:8): [True: 836k, False: 0]
  ------------------
 1368|   836k|				continue;
 1369|      0|			return table[res].card_atr;
 1370|   836k|		}
 1371|  18.1k|	}
 1372|  18.1k|	return NULL;
 1373|  32.0k|}
sc_get_conf_block:
 1444|  98.3k|{
 1445|  98.3k|	int i;
 1446|  98.3k|	scconf_block *conf_block = NULL;
 1447|       |
 1448|   196k|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (1448:14): [True: 98.3k, False: 98.3k]
  ------------------
 1449|  98.3k|		scconf_block **blocks;
 1450|       |
 1451|  98.3k|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i], name1, name2);
 1452|  98.3k|		if (blocks != NULL) {
  ------------------
  |  Branch (1452:7): [True: 98.3k, False: 0]
  ------------------
 1453|  98.3k|			conf_block = blocks[0];
 1454|  98.3k|			free(blocks);
 1455|  98.3k|		}
 1456|  98.3k|		if (conf_block != NULL && priority)
  ------------------
  |  Branch (1456:7): [True: 0, False: 98.3k]
  |  Branch (1456:29): [True: 0, False: 0]
  ------------------
 1457|      0|			break;
 1458|  98.3k|	}
 1459|  98.3k|	return conf_block;
 1460|  98.3k|}
sc_clear_ec_params:
 1464|  8.71k|{
 1465|  8.71k|	if (ecp) {
  ------------------
  |  Branch (1465:6): [True: 8.71k, False: 0]
  ------------------
 1466|  8.71k|		free(ecp->named_curve);
 1467|  8.71k|		free(ecp->der.value);
 1468|  8.71k|		memset(ecp, 0, sizeof(struct sc_ec_parameters));
 1469|  8.71k|	}
 1470|  8.71k|	return;
 1471|  8.71k|}
sc_match_atr_block:
 1503|  12.2k|{
 1504|  12.2k|	return _sc_match_atr_block(ctx, driver, atr);
 1505|  12.2k|}
card.c:sc_card_new:
  126|  17.0k|{
  127|  17.0k|	sc_card_t *card;
  128|       |
  129|  17.0k|	if (ctx == NULL)
  ------------------
  |  Branch (129:6): [True: 0, False: 17.0k]
  ------------------
  130|      0|		return NULL;
  131|       |
  132|  17.0k|	card = calloc(1, sizeof(struct sc_card));
  133|  17.0k|	if (card == NULL)
  ------------------
  |  Branch (133:6): [True: 0, False: 17.0k]
  ------------------
  134|      0|		return NULL;
  135|  17.0k|	card->ops = malloc(sizeof(struct sc_card_operations));
  136|  17.0k|	if (card->ops == NULL) {
  ------------------
  |  Branch (136:6): [True: 0, False: 17.0k]
  ------------------
  137|      0|		free(card);
  138|      0|		return NULL;
  139|      0|	}
  140|       |
  141|  17.0k|	card->ctx = ctx;
  142|  17.0k|	if (sc_mutex_create(ctx, &card->mutex) != SC_SUCCESS) {
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
  |  Branch (142:6): [True: 0, False: 17.0k]
  ------------------
  143|      0|		free(card->ops);
  144|      0|		free(card);
  145|      0|		return NULL;
  146|      0|	}
  147|       |
  148|  17.0k|	card->type = -1;
  149|  17.0k|	card->app_count = -1;
  150|       |
  151|  17.0k|	return card;
  152|  17.0k|}
card.c:sc_card_free:
  155|  17.0k|{
  156|  17.0k|	sc_free_apps(card);
  157|  17.0k|	sc_free_ef_atr(card);
  158|       |
  159|  17.0k|	free(card->ops);
  160|       |
  161|  17.0k|	if (card->algorithms != NULL)   {
  ------------------
  |  Branch (161:6): [True: 12.4k, False: 4.54k]
  ------------------
  162|  12.4k|		int i;
  163|  61.7k|		for (i=0; i<card->algorithm_count; i++)   {
  ------------------
  |  Branch (163:13): [True: 49.2k, False: 12.4k]
  ------------------
  164|  49.2k|			struct sc_algorithm_info *info = (card->algorithms + i);
  165|  49.2k|			if (info->algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   70|  98.5k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (165:8): [True: 8.51k, False: 40.7k]
  ------------------
  166|  40.7k|					info->algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|  90.0k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (166:6): [True: 102, False: 40.6k]
  ------------------
  167|  40.6k|					info->algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|  40.6k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (167:6): [True: 102, False: 40.5k]
  ------------------
  168|  8.71k|				sc_clear_ec_params(&info->u._ec.params);
  169|  8.71k|			}
  170|  49.2k|		}
  171|  12.4k|		free(card->algorithms);
  172|       |
  173|  12.4k|		card->algorithms = NULL;
  174|  12.4k|		card->algorithm_count = 0;
  175|  12.4k|	}
  176|       |
  177|  17.0k|	if (card->mutex != NULL) {
  ------------------
  |  Branch (177:6): [True: 0, False: 17.0k]
  ------------------
  178|      0|		int r = sc_mutex_destroy(card->ctx, card->mutex);
  179|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (179:7): [True: 0, False: 0]
  ------------------
  180|      0|			sc_log(card->ctx, "unable to destroy mutex");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  181|      0|	}
  182|  17.0k|	sc_mem_clear(card, sizeof(*card));
  183|  17.0k|	free(card);
  184|  17.0k|}
card.c:_sc_card_add_ec_alg_int:
 1145|  8.71k|{
 1146|  8.71k|	sc_algorithm_info_t info;
 1147|  8.71k|	int r;
 1148|       |
 1149|  8.71k|	memset(&info, 0, sizeof(info));
 1150|  8.71k|	sc_init_oid(&info.u._ec.params.id);
 1151|       |
 1152|  8.71k|	info.algorithm = algorithm;
 1153|  8.71k|	info.key_length = key_length;
 1154|  8.71k|	info.flags = flags;
 1155|       |
 1156|  8.71k|	info.u._ec.ext_flags = ext_flags;
 1157|  8.71k|	if (curve_oid) {
  ------------------
  |  Branch (1157:6): [True: 3.41k, False: 5.29k]
  ------------------
 1158|  3.41k|		info.u._ec.params.id = *curve_oid;
 1159|  3.41k|		r = sc_encode_oid(card->ctx, &info.u._ec.params.id, &info.u._ec.params.der.value, &info.u._ec.params.der.len);
 1160|  3.41k|		LOG_TEST_GOTO_ERR(card->ctx, r, "sc_encode_oid failed");
  ------------------
  |  |  184|  3.41k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  3.41k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  3.41k|	int _ret = (r); \
  |  |  |  |  178|  3.41k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 3.41k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  3.41k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 3.41k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1161|  3.41k|		r = sc_pkcs15_fix_ec_parameters(card->ctx, &info.u._ec.params);
 1162|  3.41k|		LOG_TEST_GOTO_ERR(card->ctx, r, "sc_pkcs15_fix_ec_parameters failed");
  ------------------
  |  |  184|  3.41k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  3.41k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  3.41k|	int _ret = (r); \
  |  |  |  |  178|  3.41k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 3.41k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  3.41k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 3.41k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1163|  3.41k|	}
 1164|       |
 1165|  8.71k|	r = _sc_card_add_algorithm(card, &info);
 1166|  8.71k|	return r;
 1167|      0|err:
 1168|      0|	sc_clear_ec_params(&info.u._ec.params);
 1169|      0|	return r;
 1170|  8.71k|}
card.c:match_atr_table:
 1269|  1.22M|{
 1270|  1.22M|	u8 *card_atr_bin;
 1271|  1.22M|	size_t card_atr_bin_len;
 1272|  1.22M|	char card_atr_hex[3 * SC_MAX_ATR_SIZE];
 1273|  1.22M|	size_t card_atr_hex_len;
 1274|  1.22M|	unsigned int i = 0;
 1275|       |
 1276|  1.22M|	if (ctx == NULL || table == NULL || atr == NULL)
  ------------------
  |  Branch (1276:6): [True: 0, False: 1.22M]
  |  Branch (1276:21): [True: 850k, False: 377k]
  |  Branch (1276:38): [True: 0, False: 377k]
  ------------------
 1277|   850k|		return -1;
 1278|   377k|	card_atr_bin = atr->value;
 1279|   377k|	card_atr_bin_len = atr->len;
 1280|   377k|	sc_bin_to_hex(card_atr_bin, card_atr_bin_len, card_atr_hex, sizeof(card_atr_hex), ':');
 1281|   377k|	card_atr_hex_len = strlen(card_atr_hex);
 1282|       |
 1283|   377k|	sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ATR     : %s", card_atr_hex);
  ------------------
  |  |   70|   377k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1284|       |
 1285|  3.16M|	for (i = 0; table[i].atr != NULL; i++) {
  ------------------
  |  Branch (1285:14): [True: 2.79M, False: 367k]
  ------------------
 1286|  2.79M|		const char *tatr = table[i].atr;
 1287|  2.79M|		const char *matr = table[i].atrmask;
 1288|  2.79M|		size_t tatr_len = strlen(tatr);
 1289|  2.79M|		u8 mbin[SC_MAX_ATR_SIZE], tbin[SC_MAX_ATR_SIZE];
 1290|  2.79M|		size_t mbin_len, tbin_len, s, matr_len;
 1291|  2.79M|		size_t fix_hex_len = card_atr_hex_len;
 1292|  2.79M|		size_t fix_bin_len = card_atr_bin_len;
 1293|       |
 1294|  2.79M|		sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ATR try : %s", tatr);
  ------------------
  |  |   70|  2.79M|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1295|       |
 1296|  2.79M|		if (tatr_len != fix_hex_len) {
  ------------------
  |  Branch (1296:7): [True: 2.71M, False: 82.5k]
  ------------------
 1297|  2.71M|			sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ignored - wrong length");
  ------------------
  |  |   70|  2.71M|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1298|  2.71M|			continue;
 1299|  2.71M|		}
 1300|  82.5k|		if (matr != NULL) {
  ------------------
  |  Branch (1300:7): [True: 21.1k, False: 61.3k]
  ------------------
 1301|  21.1k|			sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ATR mask: %s", matr);
  ------------------
  |  |   70|  21.1k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1302|       |
 1303|  21.1k|			matr_len = strlen(matr);
 1304|  21.1k|			if (tatr_len != matr_len)
  ------------------
  |  Branch (1304:8): [True: 0, False: 21.1k]
  ------------------
 1305|      0|				continue;
 1306|  21.1k|			tbin_len = sizeof(tbin);
 1307|  21.1k|			sc_hex_to_bin(tatr, tbin, &tbin_len);
 1308|  21.1k|			mbin_len = sizeof(mbin);
 1309|  21.1k|			sc_hex_to_bin(matr, mbin, &mbin_len);
 1310|  21.1k|			if (mbin_len != fix_bin_len) {
  ------------------
  |  Branch (1310:8): [True: 0, False: 21.1k]
  ------------------
 1311|      0|				sc_debug(ctx, SC_LOG_DEBUG_MATCH, "length of atr and atr mask do not match - ignored: %s - %s", tatr, matr);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1312|      0|				continue;
 1313|      0|			}
 1314|   421k|			for (s = 0; s < tbin_len; s++) {
  ------------------
  |  Branch (1314:16): [True: 400k, False: 21.1k]
  ------------------
 1315|       |				/* reduce tatr with mask */
 1316|   400k|				tbin[s] = (tbin[s] & mbin[s]);
 1317|       |				/* create copy of card_atr_bin masked) */
 1318|   400k|				mbin[s] = (card_atr_bin[s] & mbin[s]);
 1319|   400k|			}
 1320|  21.1k|			if (memcmp(tbin, mbin, tbin_len) != 0)
  ------------------
  |  Branch (1320:8): [True: 16.2k, False: 4.88k]
  ------------------
 1321|  16.2k|				continue;
 1322|  61.3k|		} else {
 1323|  61.3k|			if (strncasecmp(tatr, card_atr_hex, tatr_len) != 0)
  ------------------
  |  Branch (1323:8): [True: 55.3k, False: 6.05k]
  ------------------
 1324|  55.3k|				continue;
 1325|  61.3k|		}
 1326|  10.9k|		return i;
 1327|  82.5k|	}
 1328|   367k|	return -1;
 1329|   377k|}
card.c:sc_card_sm_unload:
 1510|  13.8k|{
 1511|  13.8k|	if (card->sm_ctx.module.ops.module_cleanup)
  ------------------
  |  Branch (1511:6): [True: 0, False: 13.8k]
  ------------------
 1512|      0|		card->sm_ctx.module.ops.module_cleanup(card->ctx);
 1513|       |
 1514|  13.8k|	if (card->sm_ctx.module.handle)
  ------------------
  |  Branch (1514:6): [True: 0, False: 13.8k]
  ------------------
 1515|      0|		sc_dlclose(card->sm_ctx.module.handle);
 1516|       |	card->sm_ctx.module.handle = NULL;
 1517|  13.8k|	return 0;
 1518|  13.8k|}
card.c:sc_card_sm_check:
 1613|  13.8k|{
 1614|  13.8k|	const char *sm = NULL, *module_name = NULL, *module_path = NULL, *module_data = NULL, *sm_mode = NULL;
 1615|  13.8k|	struct sc_context *ctx = card->ctx;
 1616|  13.8k|	scconf_block *atrblock = NULL, *sm_conf_block = NULL;
 1617|  13.8k|	int rv, ii;
 1618|       |#ifdef _WIN32
 1619|       |	char temp_path[PATH_MAX];
 1620|       |	size_t temp_len = PATH_MAX - 1;
 1621|       |	char expanded_val[PATH_MAX];
 1622|       |	DWORD expanded_len = PATH_MAX;
 1623|       |#endif
 1624|       |
 1625|  13.8k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  13.8k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  13.8k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  13.8k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  13.8k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 13.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1626|       |
 1627|       |	/* get the name of card specific SM configuration section */
 1628|  13.8k|	atrblock = _sc_match_atr_block(ctx, card->driver, &card->atr);
 1629|  13.8k|	if (atrblock == NULL)
  ------------------
  |  Branch (1629:6): [True: 13.8k, False: 0]
  ------------------
 1630|  13.8k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  13.8k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  13.8k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  13.8k|	int _ret = r; \
  |  |  |  |  155|  13.8k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  13.8k|		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: 13.8k]
  |  |  |  |  ------------------
  |  |  |  |  157|  13.8k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  13.8k|	} 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|  13.8k|	return _ret; \
  |  |  |  |  163|  13.8k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1631|      0|	sm = scconf_get_str(atrblock, "secure_messaging", NULL);
 1632|      0|	if (!sm)
  ------------------
  |  Branch (1632:6): [True: 0, False: 0]
  ------------------
 1633|      0|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1634|       |
 1635|       |	/* get SM configuration section by the name */
 1636|      0|	sc_log(ctx, "secure_messaging configuration block '%s'", sm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1637|      0|        for (ii = 0; ctx->conf_blocks[ii]; ii++) {
  ------------------
  |  Branch (1637:22): [True: 0, False: 0]
  ------------------
 1638|      0|		scconf_block **blocks;
 1639|       |
 1640|      0|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[ii], "secure_messaging", sm);
 1641|      0|		if (blocks) {
  ------------------
  |  Branch (1641:7): [True: 0, False: 0]
  ------------------
 1642|      0|			sm_conf_block = blocks[0];
 1643|      0|			free(blocks);
 1644|      0|		}
 1645|      0|		if (sm_conf_block != NULL)
  ------------------
  |  Branch (1645:7): [True: 0, False: 0]
  ------------------
 1646|      0|			break;
 1647|      0|	}
 1648|       |
 1649|      0|	if (!sm_conf_block)
  ------------------
  |  Branch (1649:6): [True: 0, False: 0]
  ------------------
 1650|      0|		LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_CONFIGURATION, "SM configuration block not preset");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1651|       |
 1652|       |	/* check if an external SM module has to be used */
 1653|       |#ifdef _WIN32
 1654|       |	rv = sc_ctx_win32_get_config_value(NULL, "SmDir", "Software\\" OPENSC_VS_FF_COMPANY_NAME "\\OpenSC" OPENSC_ARCH_SUFFIX,
 1655|       |			temp_path, &temp_len);
 1656|       |	if (rv == SC_SUCCESS) {
 1657|       |		temp_path[temp_len] = '\0';
 1658|       |		module_path = temp_path;
 1659|       |	}
 1660|       |	expanded_len = ExpandEnvironmentStringsA(module_path, expanded_val, expanded_len);
 1661|       |	if (0 < expanded_len && expanded_len < sizeof expanded_val)
 1662|       |		module_path = expanded_val;
 1663|       |#else
 1664|      0|	module_path = scconf_get_str(sm_conf_block, "module_path", DEFAULT_SM_MODULE_PATH);
 1665|      0|#endif
 1666|      0|	module_name = scconf_get_str(sm_conf_block, "module_name", DEFAULT_SM_MODULE);
 1667|      0|	sc_log(ctx, "SM module '%s' in  '%s'", module_name, module_path);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1668|      0|	if (!module_name)
  ------------------
  |  Branch (1668:6): [True: 0, False: 0]
  ------------------
 1669|      0|		LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_CONFIGURATION, "Invalid SM configuration: module not defined");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1670|       |
 1671|      0|	rv = sc_card_sm_load(card, module_path, module_name);
 1672|      0|	LOG_TEST_RET(ctx, rv, "Failed to load SM module");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1673|       |
 1674|      0|	strlcpy(card->sm_ctx.module.filename, module_name, sizeof(card->sm_ctx.module.filename));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1675|      0|	strlcpy(card->sm_ctx.config_section, sm, sizeof(card->sm_ctx.config_section));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1676|       |
 1677|       |	/* allocate resources for the external SM module */
 1678|      0|	if (card->sm_ctx.module.ops.module_init)   {
  ------------------
  |  Branch (1678:6): [True: 0, False: 0]
  ------------------
 1679|      0|		module_data = scconf_get_str(sm_conf_block, "module_data", NULL);
 1680|       |
 1681|      0|		rv = card->sm_ctx.module.ops.module_init(ctx, module_data);
 1682|      0|		LOG_TEST_RET(ctx, rv, "Cannot initialize SM module");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1683|      0|	}
 1684|       |
 1685|       |	/* initialize SM session in the case of 'APDU TRANSMIT' SM mode */
 1686|      0|	sm_mode = scconf_get_str(sm_conf_block, "mode", NULL);
 1687|      0|	if (sm_mode && !strcasecmp("Transmit", sm_mode))   {
  ------------------
  |  Branch (1687:6): [True: 0, False: 0]
  |  Branch (1687:17): [True: 0, False: 0]
  ------------------
 1688|      0|		if (!card->sm_ctx.ops.open || !card->sm_ctx.ops.get_sm_apdu || !card->sm_ctx.ops.free_sm_apdu)
  ------------------
  |  Branch (1688:7): [True: 0, False: 0]
  |  Branch (1688:33): [True: 0, False: 0]
  |  Branch (1688:66): [True: 0, False: 0]
  ------------------
 1689|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "'Transmit' SM asked but not supported by card driver");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1690|       |
 1691|      0|		card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|      0|#define SM_MODE_TRANSMIT	0x200
  ------------------
 1692|      0|		rv = card->sm_ctx.ops.open(card);
 1693|      0|		LOG_TEST_RET(ctx, rv, "Cannot initialize SM");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1694|      0|	}
 1695|       |
 1696|      0|	sc_log(ctx, "SM mode:%X", card->sm_ctx.sm_mode);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1697|      0|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, rv);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1698|      0|}

sc_decompress_alloc:
  254|    197|{
  255|    197|	if (in == NULL || out == NULL) {
  ------------------
  |  Branch (255:6): [True: 0, False: 197]
  |  Branch (255:20): [True: 0, False: 197]
  ------------------
  256|      0|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|      0|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  257|      0|	}
  258|       |
  259|    197|	if (method == COMPRESSION_AUTO) {
  ------------------
  |  |   26|    197|#define COMPRESSION_AUTO	0
  ------------------
  |  Branch (259:6): [True: 196, False: 1]
  ------------------
  260|    196|		method = detect_method(in, inLen);
  261|    196|		if (method == COMPRESSION_UNKNOWN) {
  ------------------
  |  |   29|    196|#define COMPRESSION_UNKNOWN (-1)
  ------------------
  |  Branch (261:7): [True: 90, False: 106]
  ------------------
  262|     90|			return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     90|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  263|     90|		}
  264|    196|	}
  265|       |
  266|    107|	switch (method) {
  267|    101|	case COMPRESSION_ZLIB:
  ------------------
  |  |   27|    101|#define COMPRESSION_ZLIB	1
  ------------------
  |  Branch (267:2): [True: 101, False: 6]
  ------------------
  268|    101|		return sc_decompress_zlib_alloc(out, outLen, in, inLen, 0);
  269|      6|	case COMPRESSION_GZIP:
  ------------------
  |  |   28|      6|#define COMPRESSION_GZIP	2
  ------------------
  |  Branch (269:2): [True: 6, False: 101]
  ------------------
  270|      6|		return sc_decompress_zlib_alloc(out, outLen, in, inLen, 1);
  271|      0|	default:
  ------------------
  |  Branch (271:2): [True: 0, False: 107]
  ------------------
  272|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  273|    107|	}
  274|    107|}
compression.c:zerr_to_opensc:
   34|    107|static int zerr_to_opensc(int err) {
   35|    107|	switch(err) {
   36|      0|	case Z_OK:
  ------------------
  |  Branch (36:2): [True: 0, False: 107]
  ------------------
   37|      0|	case Z_STREAM_END:
  ------------------
  |  Branch (37:2): [True: 0, False: 107]
  ------------------
   38|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
   39|     19|	case Z_UNKNOWN:
  ------------------
  |  Branch (39:2): [True: 19, False: 88]
  ------------------
   40|     19|		return SC_ERROR_UNKNOWN;
  ------------------
  |  |  130|     19|#define SC_ERROR_UNKNOWN			-1900
  ------------------
   41|     62|	case Z_DATA_ERROR:
  ------------------
  |  Branch (41:2): [True: 62, False: 45]
  ------------------
   42|     88|	case Z_BUF_ERROR:
  ------------------
  |  Branch (42:2): [True: 26, False: 81]
  ------------------
   43|     88|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     88|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
   44|      0|	case Z_MEM_ERROR:
  ------------------
  |  Branch (44:2): [True: 0, False: 107]
  ------------------
   45|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
   46|      0|	case Z_VERSION_ERROR:
  ------------------
  |  Branch (46:2): [True: 0, False: 107]
  ------------------
   47|      0|	case Z_STREAM_ERROR:
  ------------------
  |  Branch (47:2): [True: 0, False: 107]
  ------------------
   48|       |	/* case Z_NEED_DICT: */
   49|      0|	default:
  ------------------
  |  Branch (49:2): [True: 0, False: 107]
  ------------------
   50|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   51|    107|	}
   52|    107|}
compression.c:detect_method:
   53|    196|static int detect_method(const u8* in, size_t inLen) {
   54|    196|	if (in != NULL && inLen > 1) {
  ------------------
  |  Branch (54:6): [True: 196, False: 0]
  |  Branch (54:20): [True: 168, False: 28]
  ------------------
   55|    168|		if (in[0] == 0x1f && in[1] == 0x8b)
  ------------------
  |  Branch (55:7): [True: 14, False: 154]
  |  Branch (55:24): [True: 6, False: 8]
  ------------------
   56|      6|			return COMPRESSION_GZIP;
  ------------------
  |  |   28|      6|#define COMPRESSION_GZIP	2
  ------------------
   57|       |		/*
   58|       |		 * A zlib stream has the following structure:
   59|       |		 *   0   1
   60|       |		 * +---+---+
   61|       |		 * |CMF|FLG|   (more-->)
   62|       |		 * +---+---+
   63|       |		 *
   64|       |		 * FLG (FLaGs)
   65|       |		 * 	This flag byte is divided as follows:
   66|       |		 *
   67|       |		 * 	bits 0 to 4  FCHECK  (check bits for CMF and FLG)
   68|       |		 * 	bit  5       FDICT   (preset dictionary)
   69|       |		 * 	bits 6 to 7  FLEVEL  (compression level)
   70|       |		 *
   71|       |		 * 	The FCHECK value must be such that CMF and FLG, when viewed as
   72|       |		 * 	a 16-bit unsigned integer stored in MSB order (CMF*256 + FLG),
   73|       |		 * 	is a multiple of 31.
   74|       |		 */
   75|    162|		if ((((uint16_t) in[0])*256 + in[1]) % 31 == 0)
  ------------------
  |  Branch (75:7): [True: 100, False: 62]
  ------------------
   76|    100|			return COMPRESSION_ZLIB;
  ------------------
  |  |   27|    100|#define COMPRESSION_ZLIB	1
  ------------------
   77|    162|	}
   78|     90|	return COMPRESSION_UNKNOWN;
  ------------------
  |  |   29|     90|#define COMPRESSION_UNKNOWN (-1)
  ------------------
   79|    196|}
compression.c:sc_decompress_zlib_alloc:
  185|    107|static int sc_decompress_zlib_alloc(u8** out, size_t* outLen, const u8* in, size_t inLen, int gzip) {
  186|       |	/* Since uncompress does not offer a way to make it uncompress gzip... manually set it up */
  187|    107|	z_stream gz;
  188|    107|	int err;
  189|    107|	int window_size = 15;
  190|    107|	const size_t startSize = inLen < 1024 ? 2048 : inLen * 2;
  ------------------
  |  Branch (190:27): [True: 81, False: 26]
  ------------------
  191|    107|	const size_t blockSize = inLen < 1024 ? 512 : inLen / 2;
  ------------------
  |  Branch (191:27): [True: 81, False: 26]
  ------------------
  192|    107|	size_t bufferSize = startSize;
  193|    107|	if (gzip)
  ------------------
  |  Branch (193:6): [True: 6, False: 101]
  ------------------
  194|      6|		window_size += 0x20;
  195|    107|	memset(&gz, 0, sizeof(gz));
  196|       |
  197|    107|	if (!out || !outLen)
  ------------------
  |  Branch (197:6): [True: 0, False: 107]
  |  Branch (197:14): [True: 0, False: 107]
  ------------------
  198|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  199|       |
  200|    107|	gz.next_in = (u8*)in;
  201|    107|	gz.avail_in = (unsigned)inLen;
  202|       |
  203|    107|	err = inflateInit2(&gz, window_size);
  204|    107|	if (err != Z_OK)
  ------------------
  |  Branch (204:6): [True: 0, False: 107]
  ------------------
  205|      0|		return zerr_to_opensc(err);
  206|       |
  207|    107|	*outLen = 0;
  208|       |
  209|    288|	while (1) {
  ------------------
  |  Branch (209:9): [True: 288, Folded]
  ------------------
  210|       |		/* Setup buffer... */
  211|    288|		size_t num;
  212|    288|		u8* buf = realloc(*out, bufferSize);
  213|    288|		if (!buf) {
  ------------------
  |  Branch (213:7): [True: 0, False: 288]
  ------------------
  214|      0|			free(*out);
  215|      0|			*out = NULL;
  216|      0|			inflateEnd(&gz);
  217|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  218|      0|		}
  219|    288|		*out = buf;
  220|    288|		gz.next_out = buf + *outLen;
  221|    288|		gz.avail_out = (unsigned)(bufferSize - *outLen);
  222|       |
  223|    288|		err = inflate(&gz, Z_FULL_FLUSH);
  224|    288|		if (err != Z_STREAM_END && err != Z_OK) {
  ------------------
  |  Branch (224:7): [True: 288, False: 0]
  |  Branch (224:30): [True: 107, False: 181]
  ------------------
  225|    107|			free(*out);
  226|    107|			*out = NULL;
  227|    107|			break;
  228|    107|		}
  229|    181|		num = *outLen + gz.avail_out;
  230|    181|		if (bufferSize > num) {
  ------------------
  |  Branch (230:7): [True: 177, False: 4]
  ------------------
  231|    177|			*outLen += bufferSize - num;
  232|    177|			bufferSize += bufferSize - num + blockSize;
  233|    177|		}
  234|    181|		if (err == Z_STREAM_END) {
  ------------------
  |  Branch (234:7): [True: 0, False: 181]
  ------------------
  235|      0|			if (*outLen > 0) {
  ------------------
  |  Branch (235:8): [True: 0, False: 0]
  ------------------
  236|       |				/* Shrink it down, if it fails, just use old data */
  237|      0|				buf = realloc(buf, *outLen);
  238|      0|				if (buf) {
  ------------------
  |  Branch (238:9): [True: 0, False: 0]
  ------------------
  239|      0|					*out = buf;
  240|      0|				}
  241|      0|			} else {
  242|      0|				free(*out);
  243|      0|				*out = NULL;
  244|      0|				err = Z_DATA_ERROR;
  245|      0|			}
  246|      0|			break;
  247|      0|		}
  248|    181|	}
  249|    107|	inflateEnd(&gz);
  250|    107|	return zerr_to_opensc(err);
  251|    107|}

_sc_delete_reader:
   85|  17.0k|{
   86|  17.0k|	if (reader == NULL) {
  ------------------
  |  Branch (86:6): [True: 0, False: 17.0k]
  ------------------
   87|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   88|      0|	}
   89|  17.0k|	if (reader->ops->release)
  ------------------
  |  Branch (89:6): [True: 17.0k, False: 0]
  ------------------
   90|  17.0k|			reader->ops->release(reader);
   91|  17.0k|	free(reader->name);
   92|  17.0k|	free(reader->vendor);
   93|  17.0k|	list_delete(&ctx->readers, reader);
   94|  17.0k|	free(reader);
   95|  17.0k|	return SC_SUCCESS;
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
   96|  17.0k|}
sc_ctx_detect_readers:
  785|  17.0k|{
  786|  17.0k|	int r = 0;
  787|  17.0k|	const struct sc_reader_driver *drv = ctx->reader_driver;
  788|       |
  789|  17.0k|	sc_mutex_lock(ctx, ctx->mutex);
  790|       |
  791|  17.0k|	if (drv->ops->detect_readers != NULL)
  ------------------
  |  Branch (791:6): [True: 0, False: 17.0k]
  ------------------
  792|      0|		r = drv->ops->detect_readers(ctx);
  793|       |
  794|  17.0k|	sc_mutex_unlock(ctx, ctx->mutex);
  795|       |
  796|  17.0k|	return r;
  797|  17.0k|}
sc_ctx_get_reader:
  800|  34.0k|{
  801|  34.0k|	return list_get_at(&ctx->readers, i);
  802|  34.0k|}
sc_ctx_get_reader_count:
  815|  51.0k|{
  816|  51.0k|	return list_size(&ctx->readers);
  817|  51.0k|}
sc_context_create:
  949|  17.0k|{
  950|  17.0k|	sc_context_t		*ctx;
  951|  17.0k|	struct _sc_ctx_options	opts;
  952|  17.0k|	int			r;
  953|  17.0k|	char			*driver;
  954|       |
  955|  17.0k|	if (ctx_out == NULL || parm == NULL)
  ------------------
  |  Branch (955:6): [True: 0, False: 17.0k]
  |  Branch (955:25): [True: 0, False: 17.0k]
  ------------------
  956|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  957|       |
  958|  17.0k|	ctx = calloc(1, sizeof(sc_context_t));
  959|  17.0k|	if (ctx == NULL)
  ------------------
  |  Branch (959:6): [True: 0, False: 17.0k]
  ------------------
  960|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  961|  17.0k|	memset(&opts, 0, sizeof(opts));
  962|       |
  963|       |	/* set the application name if set in the parameter options */
  964|  17.0k|	if (parm->app_name != NULL)
  ------------------
  |  Branch (964:6): [True: 17.0k, False: 0]
  ------------------
  965|  17.0k|		ctx->app_name = strdup(parm->app_name);
  966|      0|	else
  967|      0|		ctx->app_name = strdup("default");
  968|  17.0k|	if (ctx->app_name == NULL) {
  ------------------
  |  Branch (968:6): [True: 0, False: 17.0k]
  ------------------
  969|      0|		sc_release_context(ctx);
  970|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  971|      0|	}
  972|       |
  973|  17.0k|	ctx->exe_path = get_exe_path();
  974|  17.0k|	if (ctx->exe_path == NULL) {
  ------------------
  |  Branch (974:6): [True: 0, False: 17.0k]
  ------------------
  975|      0|		sc_release_context(ctx);
  976|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  977|      0|	}
  978|       |
  979|  17.0k|	ctx->flags = parm->flags;
  980|  17.0k|	set_defaults(ctx, &opts);
  981|       |
  982|  17.0k|	if (0 != list_init(&ctx->readers)) {
  ------------------
  |  Branch (982:6): [True: 0, False: 17.0k]
  ------------------
  983|      0|		del_drvs(&opts);
  984|      0|		sc_release_context(ctx);
  985|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  986|      0|	}
  987|  17.0k|	list_attributes_seeker(&ctx->readers, reader_list_seeker);
  988|       |	/* set thread context and create mutex object (if specified) */
  989|  17.0k|	if (parm->thread_ctx != NULL)
  ------------------
  |  Branch (989:6): [True: 17.0k, False: 0]
  ------------------
  990|  17.0k|		ctx->thread_ctx = parm->thread_ctx;
  991|  17.0k|	r = sc_mutex_create(ctx, &ctx->mutex);
  992|  17.0k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
  |  Branch (992:6): [True: 0, False: 17.0k]
  ------------------
  993|      0|		del_drvs(&opts);
  994|      0|		sc_release_context(ctx);
  995|      0|		return r;
  996|      0|	}
  997|       |
  998|       |#if defined(ENABLE_OPENSSL) && defined(OPENSSL_SECURE_MALLOC_SIZE) && !defined(LIBRESSL_VERSION_NUMBER)
  999|       |	if (!CRYPTO_secure_malloc_initialized()) {
 1000|       |		CRYPTO_secure_malloc_init(OPENSSL_SECURE_MALLOC_SIZE, OPENSSL_SECURE_MALLOC_SIZE/8);
 1001|       |	}
 1002|       |#endif
 1003|       |
 1004|  17.0k|	process_config_file(ctx, &opts);
 1005|       |
 1006|       |	/* overwrite with caller's parameters if explicitly given */
 1007|  17.0k|	if (parm->debug) {
  ------------------
  |  Branch (1007:6): [True: 0, False: 17.0k]
  ------------------
 1008|      0|		ctx->debug = parm->debug;
 1009|      0|	}
 1010|  17.0k|	if (parm->debug_file) {
  ------------------
  |  Branch (1010:6): [True: 0, False: 17.0k]
  ------------------
 1011|      0|		if (ctx->debug_file && (ctx->debug_file != stderr && ctx->debug_file != stdout))
  ------------------
  |  Branch (1011:7): [True: 0, False: 0]
  |  Branch (1011:27): [True: 0, False: 0]
  |  Branch (1011:56): [True: 0, False: 0]
  ------------------
 1012|      0|			fclose(ctx->debug_file);
 1013|      0|		ctx->debug_file = parm->debug_file;
 1014|      0|	}
 1015|       |
 1016|  17.0k|	sc_log(ctx, "==================================="); /* first thing in the log */
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1017|  17.0k|	sc_log(ctx, "OpenSC version: %s", sc_get_version());
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1018|  17.0k|	sc_log(ctx, "Configured for %s (%s)", ctx->app_name, ctx->exe_path);
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1019|       |
 1020|       |#ifdef USE_OPENSSL3_LIBCTX
 1021|       |	r = sc_openssl3_init(ctx);
 1022|       |	if (r != SC_SUCCESS) {
 1023|       |		del_drvs(&opts);
 1024|       |		sc_release_context(ctx);
 1025|       |		return r;
 1026|       |	}
 1027|       |#endif
 1028|       |
 1029|       |#ifdef ENABLE_PCSC
 1030|       |	ctx->reader_driver = sc_get_pcsc_driver();
 1031|       |#elif defined(ENABLE_CRYPTOTOKENKIT)
 1032|       |	ctx->reader_driver = sc_get_cryptotokenkit_driver();
 1033|       |#elif defined(ENABLE_CTAPI)
 1034|       |	ctx->reader_driver = sc_get_ctapi_driver();
 1035|       |#elif defined(ENABLE_OPENCT)
 1036|       |	ctx->reader_driver = sc_get_openct_driver();
 1037|       |#else
 1038|       |	ctx->reader_driver = sc_get_empty_driver();
 1039|       |#endif
 1040|       |
 1041|  17.0k|	r = ctx->reader_driver->ops->init(ctx);
 1042|  17.0k|	if (r != SC_SUCCESS)   {
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1042:6): [True: 0, False: 17.0k]
  ------------------
 1043|      0|		del_drvs(&opts);
 1044|      0|		sc_release_context(ctx);
 1045|      0|		return r;
 1046|      0|	}
 1047|       |
 1048|  17.0k|	driver = getenv("OPENSC_DRIVER");
 1049|  17.0k|	if (driver) {
  ------------------
  |  Branch (1049:6): [True: 0, False: 17.0k]
  ------------------
 1050|      0|		scconf_list *list = NULL;
 1051|      0|		scconf_list_add(&list, driver);
 1052|      0|		set_drivers(&opts, list);
 1053|      0|		scconf_list_destroy(list);
 1054|      0|	}
 1055|       |
 1056|  17.0k|	load_card_drivers(ctx, &opts);
 1057|  17.0k|	load_card_atrs(ctx);
 1058|       |
 1059|  17.0k|	del_drvs(&opts);
 1060|  17.0k|	sc_ctx_detect_readers(ctx);
 1061|  17.0k|	*ctx_out = ctx;
 1062|       |
 1063|  17.0k|	return SC_SUCCESS;
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
 1064|  17.0k|}
sc_cancel:
 1078|  17.0k|{
 1079|  17.0k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  17.0k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  17.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  17.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  17.0k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 17.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1080|  17.0k|	if (ctx->reader_driver->ops->cancel != NULL)
  ------------------
  |  Branch (1080:6): [True: 0, False: 17.0k]
  ------------------
 1081|      0|		return ctx->reader_driver->ops->cancel(ctx);
 1082|       |
 1083|  17.0k|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  17.0k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1084|  17.0k|}
sc_wait_for_event:
 1088|  35.3k|{
 1089|  35.3k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  35.3k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  35.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  35.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  35.3k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 35.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1090|  35.3k|	if (ctx->reader_driver->ops->wait_for_event != NULL)
  ------------------
  |  Branch (1090:6): [True: 0, False: 35.3k]
  ------------------
 1091|      0|		return ctx->reader_driver->ops->wait_for_event(ctx, event_mask, event_reader, event, timeout, reader_states);
 1092|       |
 1093|  35.3k|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  35.3k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1094|  35.3k|}
sc_release_context:
 1097|  17.0k|{
 1098|  17.0k|	unsigned int i;
 1099|       |
 1100|  17.0k|	if (ctx == NULL) {
  ------------------
  |  Branch (1100:6): [True: 0, False: 17.0k]
  ------------------
 1101|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1102|      0|	}
 1103|  17.0k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  17.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  17.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  17.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 17.0k]
  |  |  ------------------
  ------------------
 1104|  34.0k|	while (list_size(&ctx->readers)) {
  ------------------
  |  Branch (1104:9): [True: 17.0k, False: 17.0k]
  ------------------
 1105|  17.0k|		sc_reader_t *rdr = (sc_reader_t *) list_get_at(&ctx->readers, 0);
 1106|  17.0k|		_sc_delete_reader(ctx, rdr);
 1107|  17.0k|	}
 1108|       |
 1109|  17.0k|	if (ctx->reader_driver != NULL && ctx->reader_driver->ops->finish != NULL)
  ------------------
  |  Branch (1109:6): [True: 17.0k, False: 0]
  |  Branch (1109:36): [True: 0, False: 17.0k]
  ------------------
 1110|      0|		ctx->reader_driver->ops->finish(ctx);
 1111|       |
 1112|   800k|	for (i = 0; ctx->card_drivers[i]; i++) {
  ------------------
  |  Branch (1112:14): [True: 783k, False: 17.0k]
  ------------------
 1113|   783k|		struct sc_card_driver *drv = ctx->card_drivers[i];
 1114|       |
 1115|   783k|		if (drv->atr_map)
  ------------------
  |  Branch (1115:7): [True: 0, False: 783k]
  ------------------
 1116|      0|			_sc_free_atr(ctx, drv);
 1117|   783k|		if (drv->dll)
  ------------------
  |  Branch (1117:7): [True: 0, False: 783k]
  ------------------
 1118|      0|			sc_dlclose(drv->dll);
 1119|   783k|	}
 1120|       |#ifdef USE_OPENSSL3_LIBCTX
 1121|       |	sc_openssl3_deinit(ctx);
 1122|       |#endif
 1123|  17.0k|	if (ctx->preferred_language != NULL)
  ------------------
  |  Branch (1123:6): [True: 0, False: 17.0k]
  ------------------
 1124|      0|		free(ctx->preferred_language);
 1125|  17.0k|	if (ctx->mutex != NULL) {
  ------------------
  |  Branch (1125:6): [True: 0, False: 17.0k]
  ------------------
 1126|      0|		int r = sc_mutex_destroy(ctx, ctx->mutex);
 1127|      0|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1127:7): [True: 0, False: 0]
  ------------------
 1128|      0|			sc_log(ctx, "unable to destroy mutex");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1129|      0|			return r;
 1130|      0|		}
 1131|      0|	}
 1132|  17.0k|	if (ctx->conf != NULL)
  ------------------
  |  Branch (1132:6): [True: 17.0k, False: 0]
  ------------------
 1133|  17.0k|		scconf_free(ctx->conf);
 1134|  17.0k|	if (ctx->debug_file && (ctx->debug_file != stdout && ctx->debug_file != stderr))
  ------------------
  |  Branch (1134:6): [True: 17.0k, False: 0]
  |  Branch (1134:26): [True: 17.0k, False: 0]
  |  Branch (1134:55): [True: 0, False: 17.0k]
  ------------------
 1135|      0|		fclose(ctx->debug_file);
 1136|  17.0k|	free(ctx->debug_filename);
 1137|  17.0k|	free(ctx->app_name);
 1138|  17.0k|	free(ctx->exe_path);
 1139|  17.0k|	list_destroy(&ctx->readers);
 1140|  17.0k|	sc_mem_clear(ctx, sizeof(*ctx));
 1141|  17.0k|	free(ctx);
 1142|  17.0k|	return SC_SUCCESS;
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
 1143|  17.0k|}
ctx.c:load_card_atrs:
  633|  17.0k|{
  634|  17.0k|	struct sc_card_driver *driver;
  635|  17.0k|	scconf_block **blocks;
  636|  17.0k|	int i, j, k;
  637|       |
  638|  34.0k|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (638:14): [True: 17.0k, False: 17.0k]
  ------------------
  639|  17.0k|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i], "card_atr", NULL);
  640|  17.0k|		if (!blocks)
  ------------------
  |  Branch (640:7): [True: 0, False: 17.0k]
  ------------------
  641|      0|			continue;
  642|  17.0k|		for (j = 0; blocks[j] != NULL; j++) {
  ------------------
  |  Branch (642:15): [True: 0, False: 17.0k]
  ------------------
  643|      0|			scconf_block *b = blocks[j];
  644|      0|			char *atr = b->name->data;
  645|      0|			const scconf_list *list;
  646|      0|			struct sc_atr_table t;
  647|      0|			const char *dname;
  648|       |
  649|      0|			driver = NULL;
  650|       |
  651|      0|			if (strlen(atr) < 4)
  ------------------
  |  Branch (651:8): [True: 0, False: 0]
  ------------------
  652|      0|				continue;
  653|       |
  654|       |			/* The interesting part. If there's no card
  655|       |			 * driver assigned for the ATR, add it to
  656|       |			 * the default driver. This will reduce the
  657|       |			 * amount of code required to process things
  658|       |			 * related to card_atr blocks in situations,
  659|       |			 * where the code is not exactly related to
  660|       |			 * card driver settings, but for example
  661|       |			 * forcing a protocol at the reader driver.
  662|       |			 */
  663|      0|			dname = scconf_get_str(b, "driver", "default");
  664|       |
  665|       |			/* Find the card driver structure according to dname */
  666|      0|			for (k = 0; ctx->card_drivers[k] != NULL; k++) {
  ------------------
  |  Branch (666:16): [True: 0, False: 0]
  ------------------
  667|      0|				driver = ctx->card_drivers[k];
  668|      0|				if (!strcmp(dname, driver->short_name))
  ------------------
  |  Branch (668:9): [True: 0, False: 0]
  ------------------
  669|      0|					break;
  670|      0|				driver = NULL;
  671|      0|			}
  672|       |
  673|      0|			if (!driver)
  ------------------
  |  Branch (673:8): [True: 0, False: 0]
  ------------------
  674|      0|				continue;
  675|       |
  676|      0|			memset(&t, 0, sizeof(struct sc_atr_table));
  677|      0|			t.atr = atr;
  678|      0|			t.atrmask = (char *) scconf_get_str(b, "atrmask", NULL);
  679|      0|			t.name = (char *) scconf_get_str(b, "name", NULL);
  680|      0|			t.type = scconf_get_int(b, "type", SC_CARD_TYPE_UNKNOWN);
  681|      0|			list = scconf_find_list(b, "flags");
  682|      0|			while (list != NULL) {
  ------------------
  |  Branch (682:11): [True: 0, False: 0]
  ------------------
  683|      0|				unsigned int flags = 0;
  684|       |
  685|      0|				if (!list->data) {
  ------------------
  |  Branch (685:9): [True: 0, False: 0]
  ------------------
  686|      0|					list = list->next;
  687|      0|					continue;
  688|      0|				}
  689|       |
  690|      0|				if (!strcmp(list->data, "rng"))
  ------------------
  |  Branch (690:9): [True: 0, False: 0]
  ------------------
  691|      0|					flags = SC_CARD_FLAG_RNG;
  ------------------
  |  |  536|      0|#define SC_CARD_FLAG_RNG		0x00000002
  ------------------
  692|      0|				else if (!strcmp(list->data, "keep_alive"))
  ------------------
  |  Branch (692:14): [True: 0, False: 0]
  ------------------
  693|      0|					flags = SC_CARD_FLAG_KEEP_ALIVE;
  ------------------
  |  |  537|      0|#define SC_CARD_FLAG_KEEP_ALIVE	0x00000004
  ------------------
  694|      0|				else if (sscanf(list->data, "%x", &flags) != 1)
  ------------------
  |  Branch (694:14): [True: 0, False: 0]
  ------------------
  695|      0|					flags = 0;
  696|       |
  697|      0|				t.flags |= flags;
  698|      0|				list = list->next;
  699|      0|			}
  700|      0|			t.card_atr = b;
  701|      0|			_sc_add_atr(ctx, driver, &t);
  702|      0|		}
  703|  17.0k|		free(blocks);
  704|  17.0k|	}
  705|  17.0k|	return SC_SUCCESS;
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
  706|  17.0k|}
ctx.c:get_exe_path:
  914|  17.0k|{
  915|       |	/* Find the executable's path which runs this code.
  916|       |	 * See https://github.com/gpakosz/whereami/ for
  917|       |	 * potentially more platforms */
  918|  17.0k|	char exe_path[PATH_MAX] = "unknown executable path";
  919|  17.0k|	int path_found = 0;
  920|       |
  921|       |#if   defined(_WIN32)
  922|       |	if (0 < GetModuleFileNameA(NULL, exe_path, sizeof exe_path))
  923|       |		path_found = 1;
  924|       |#elif defined(__APPLE__)
  925|       |	if (0 < proc_pidpath(getpid(), exe_path, sizeof exe_path))
  926|       |		path_found = 1;
  927|       |#elif defined(__linux__) || defined(__CYGWIN__)
  928|  17.0k|	if (NULL != realpath("/proc/self/exe", exe_path))
  ------------------
  |  Branch (928:6): [True: 17.0k, False: 0]
  ------------------
  929|  17.0k|		path_found = 1;
  930|  17.0k|#endif
  931|       |
  932|       |#if defined(HAVE_GETPROGNAME)
  933|       |	if (!path_found) {
  934|       |		/* getprogname is unreliable and typically only returns the basename.
  935|       |		 * However, this should be enough for our purposes */
  936|       |		const char *prog = getprogname();
  937|       |		if (prog)
  938|       |			strlcpy(exe_path, prog, sizeof exe_path);
  939|       |	}
  940|       |#else
  941|       |	/* avoid warning "set but not used" */
  942|  17.0k|	(void) path_found;
  943|  17.0k|#endif
  944|       |
  945|  17.0k|	return strdup(exe_path);
  946|  17.0k|}
ctx.c:set_defaults:
  325|  17.0k|{
  326|  17.0k|	ctx->debug = 0;
  327|  17.0k|	if (ctx->debug_file && (ctx->debug_file != stderr && ctx->debug_file != stdout))
  ------------------
  |  Branch (327:6): [True: 0, False: 17.0k]
  |  Branch (327:26): [True: 0, False: 0]
  |  Branch (327:55): [True: 0, False: 0]
  ------------------
  328|      0|		fclose(ctx->debug_file);
  329|  17.0k|	ctx->debug_file = stderr;
  330|  17.0k|	ctx->flags = 0;
  331|       |	ctx->forced_driver = NULL;
  332|  17.0k|	add_internal_drvs(opts);
  333|  17.0k|}
ctx.c:add_internal_drvs:
  299|  34.0k|{
  300|  34.0k|	const struct _sc_driver_entry *lst;
  301|  34.0k|	int i;
  302|       |
  303|  34.0k|	lst = internal_card_drivers;
  304|  34.0k|	i = 0;
  305|  1.43M|	while (lst[i].name != NULL) {
  ------------------
  |  Branch (305:9): [True: 1.39M, False: 34.0k]
  ------------------
  306|  1.39M|		add_drv(opts, lst[i].name);
  307|  1.39M|		i++;
  308|  1.39M|	}
  309|  34.0k|}
ctx.c:add_drv:
  281|  1.48M|{
  282|  1.48M|	struct _sc_driver_entry *lst;
  283|  1.48M|	int *cp, max, i;
  284|       |
  285|  1.48M|	lst = opts->cdrv;
  286|  1.48M|	cp = &opts->ccount;
  287|  1.48M|	max = SC_MAX_CARD_DRIVERS;
  ------------------
  |  |   31|  1.48M|#define SC_MAX_CARD_DRIVERS		48
  ------------------
  288|  1.48M|	if (*cp == max) /* No space for more drivers... */
  ------------------
  |  Branch (288:6): [True: 0, False: 1.48M]
  ------------------
  289|      0|		return;
  290|  33.0M|	for (i = 0; i < *cp; i++)
  ------------------
  |  Branch (290:14): [True: 31.5M, False: 1.48M]
  ------------------
  291|  31.5M|		if (strcmp(name, lst[i].name) == 0)
  ------------------
  |  Branch (291:7): [True: 0, False: 31.5M]
  ------------------
  292|      0|			return;
  293|  1.48M|	lst[*cp].name = strdup(name);
  294|       |
  295|  1.48M|	*cp = *cp + 1;
  296|  1.48M|}
ctx.c:del_drvs:
  267|  34.0k|{
  268|  34.0k|	struct _sc_driver_entry *lst;
  269|  34.0k|	int *cp, i;
  270|       |
  271|  34.0k|	lst = opts->cdrv;
  272|  34.0k|	cp = &opts->ccount;
  273|       |
  274|  1.51M|	for (i = 0; i < *cp; i++) {
  ------------------
  |  Branch (274:14): [True: 1.48M, False: 34.0k]
  ------------------
  275|  1.48M|		free((void *)lst[i].name);
  276|  1.48M|	}
  277|  34.0k|	*cp = 0;
  278|  34.0k|}
ctx.c:process_config_file:
  709|  17.0k|{
  710|  17.0k|	int i, r, count = 0;
  711|  17.0k|	scconf_block **blocks;
  712|  17.0k|	const char *conf_path = NULL;
  713|  17.0k|	const char *debug = NULL;
  714|       |#ifdef _WIN32
  715|       |	char temp_path[PATH_MAX];
  716|       |	size_t temp_len;
  717|       |#endif
  718|       |
  719|       |	/* Takes effect even when no config around */
  720|  17.0k|	debug = getenv("OPENSC_DEBUG");
  721|  17.0k|	if (debug)
  ------------------
  |  Branch (721:6): [True: 0, False: 17.0k]
  ------------------
  722|      0|		ctx->debug = atoi(debug);
  723|       |
  724|  17.0k|	memset(ctx->conf_blocks, 0, sizeof(ctx->conf_blocks));
  725|       |#ifdef _WIN32
  726|       |	temp_len = PATH_MAX-1;
  727|       |	r = sc_ctx_win32_get_config_value("OPENSC_CONF", "ConfigFile", "Software\\" OPENSC_VS_FF_COMPANY_NAME "\\OpenSC" OPENSC_ARCH_SUFFIX,
  728|       |			temp_path, &temp_len);
  729|       |	if (r)   {
  730|       |		sc_log(ctx, "process_config_file doesn't find opensc config file. Please set the registry key.");
  731|       |		return;
  732|       |	}
  733|       |	temp_path[temp_len] = '\0';
  734|       |	conf_path = temp_path;
  735|       |#else
  736|  17.0k|	conf_path = getenv("OPENSC_CONF");
  737|  17.0k|	if (!conf_path)
  ------------------
  |  Branch (737:6): [True: 17.0k, False: 0]
  ------------------
  738|  17.0k|		conf_path = OPENSC_CONF_PATH;
  739|  17.0k|#endif
  740|  17.0k|	ctx->conf = scconf_new(conf_path);
  741|  17.0k|	if (ctx->conf == NULL)
  ------------------
  |  Branch (741:6): [True: 0, False: 17.0k]
  ------------------
  742|      0|		return;
  743|  17.0k|	r = scconf_parse(ctx->conf);
  744|  17.0k|#define OPENSC_CONFIG_STRING "app default { card_drivers = old, internal; }"
  745|  17.0k|#ifdef OPENSC_CONFIG_STRING
  746|       |	/* Parse the string if config file didn't exist */
  747|  17.0k|	if (r < 0)
  ------------------
  |  Branch (747:6): [True: 17.0k, False: 0]
  ------------------
  748|  17.0k|		r = scconf_parse_string(ctx->conf, OPENSC_CONFIG_STRING);
  ------------------
  |  |  744|  17.0k|#define OPENSC_CONFIG_STRING "app default { card_drivers = old, internal; }"
  ------------------
  749|  17.0k|#endif
  750|  17.0k|	if (r < 1) {
  ------------------
  |  Branch (750:6): [True: 0, False: 17.0k]
  ------------------
  751|       |		/* A negative return value means the config file isn't
  752|       |		 * there, which is not an error. Nevertheless log this
  753|       |		 * fact. */
  754|      0|		if (r < 0)
  ------------------
  |  Branch (754:7): [True: 0, False: 0]
  ------------------
  755|      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__
  |  |  ------------------
  ------------------
  756|      0|		else
  757|      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__
  |  |  ------------------
  ------------------
  758|      0|		scconf_free(ctx->conf);
  759|      0|		ctx->conf = NULL;
  760|      0|		return;
  761|      0|	}
  762|       |	/* needs to be after the log file is known */
  763|  17.0k|	sc_log(ctx, "Used configuration file '%s'", conf_path);
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  764|  17.0k|	blocks = scconf_find_blocks(ctx->conf, NULL, "app", ctx->exe_path);
  765|  17.0k|	if (blocks && blocks[0])
  ------------------
  |  Branch (765:6): [True: 17.0k, False: 0]
  |  Branch (765:16): [True: 0, False: 17.0k]
  ------------------
  766|      0|		ctx->conf_blocks[count++] = blocks[0];
  767|  17.0k|	free(blocks);
  768|  17.0k|	blocks = scconf_find_blocks(ctx->conf, NULL, "app", ctx->app_name);
  769|  17.0k|	if (blocks && blocks[0])
  ------------------
  |  Branch (769:6): [True: 17.0k, False: 0]
  |  Branch (769:16): [True: 0, False: 17.0k]
  ------------------
  770|      0|		ctx->conf_blocks[count++] = blocks[0];
  771|  17.0k|	free(blocks);
  772|  17.0k|	if (strcmp(ctx->app_name, "default") != 0) {
  ------------------
  |  Branch (772:6): [True: 17.0k, False: 0]
  ------------------
  773|  17.0k|		blocks = scconf_find_blocks(ctx->conf, NULL, "app", "default");
  774|  17.0k|		if (blocks && blocks[0])
  ------------------
  |  Branch (774:7): [True: 17.0k, False: 0]
  |  Branch (774:17): [True: 17.0k, False: 0]
  ------------------
  775|  17.0k|			ctx->conf_blocks[count] = blocks[0];
  776|  17.0k|		free(blocks);
  777|  17.0k|	}
  778|       |	/* Above we add 3 blocks at most, but conf_blocks has 4 elements,
  779|       |	 * so at least one is NULL */
  780|  34.0k|	for (i = 0; ctx->conf_blocks[i]; i++)
  ------------------
  |  Branch (780:14): [True: 17.0k, False: 17.0k]
  ------------------
  781|  17.0k|		load_parameters(ctx, ctx->conf_blocks[i], opts);
  782|  17.0k|}
ctx.c:load_parameters:
  388|  17.0k|{
  389|  17.0k|	int err = 0;
  390|  17.0k|	const scconf_list *list;
  391|  17.0k|	const char *val;
  392|  17.0k|	int debug;
  393|  17.0k|	const char *disable_hw_pkcs1_padding;
  394|       |#ifdef _WIN32
  395|       |	char expanded_val[PATH_MAX];
  396|       |	DWORD expanded_len;
  397|       |#endif
  398|       |
  399|  17.0k|	debug = scconf_get_int(block, "debug", ctx->debug);
  400|  17.0k|	if (debug > ctx->debug)
  ------------------
  |  Branch (400:6): [True: 0, False: 17.0k]
  ------------------
  401|      0|		ctx->debug = debug;
  402|       |
  403|  17.0k|	val = scconf_get_str(block, "debug_file", NULL);
  404|  17.0k|	if (val)   {
  ------------------
  |  Branch (404:6): [True: 0, False: 17.0k]
  ------------------
  405|       |#ifdef _WIN32
  406|       |		expanded_len = PATH_MAX;
  407|       |		expanded_len = ExpandEnvironmentStringsA(val, expanded_val, expanded_len);
  408|       |		if (0 < expanded_len && expanded_len < sizeof expanded_val)
  409|       |			val = expanded_val;
  410|       |#endif
  411|      0|		sc_ctx_log_to_file(ctx, val);
  412|      0|	}
  413|  17.0k|	else if (ctx->debug)   {
  ------------------
  |  Branch (413:11): [True: 0, False: 17.0k]
  ------------------
  414|      0|		sc_ctx_log_to_file(ctx, NULL);
  415|      0|	}
  416|       |
  417|  17.0k|	if (scconf_get_bool (block, "disable_popups",
  ------------------
  |  Branch (417:6): [True: 0, False: 17.0k]
  ------------------
  418|  17.0k|				ctx->flags & SC_CTX_FLAG_DISABLE_POPUPS))
  ------------------
  |  |  861|  17.0k|#define SC_CTX_FLAG_DISABLE_POPUPS			0x00000010
  ------------------
  419|      0|		ctx->flags |= SC_CTX_FLAG_DISABLE_POPUPS;
  ------------------
  |  |  861|      0|#define SC_CTX_FLAG_DISABLE_POPUPS			0x00000010
  ------------------
  420|       |
  421|  17.0k|	if (scconf_get_bool (block, "disable_colors",
  ------------------
  |  Branch (421:6): [True: 0, False: 17.0k]
  ------------------
  422|  17.0k|				ctx->flags & SC_CTX_FLAG_DISABLE_COLORS))
  ------------------
  |  |  862|  17.0k|#define SC_CTX_FLAG_DISABLE_COLORS			0x00000020
  ------------------
  423|      0|		ctx->flags |= SC_CTX_FLAG_DISABLE_COLORS;
  ------------------
  |  |  862|      0|#define SC_CTX_FLAG_DISABLE_COLORS			0x00000020
  ------------------
  424|       |
  425|  17.0k|	if (scconf_get_bool (block, "enable_default_driver",
  ------------------
  |  Branch (425:6): [True: 0, False: 17.0k]
  ------------------
  426|  17.0k|				ctx->flags & SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER))
  ------------------
  |  |  860|  17.0k|#define SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER	0x00000008
  ------------------
  427|      0|		ctx->flags |= SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER;
  ------------------
  |  |  860|      0|#define SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER	0x00000008
  ------------------
  428|       |
  429|  17.0k|	list = scconf_find_list(block, "card_drivers");
  430|  17.0k|	set_drivers(opts, list);
  431|       |
  432|       |	/* Disable PKCS#1 v1.5 type 2 (for decryption) depadding on card by default */
  433|  17.0k|	disable_hw_pkcs1_padding = "decipher";
  434|  17.0k|	ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  110|  17.0k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  435|  17.0k|	disable_hw_pkcs1_padding = scconf_get_str(block, "disable_hw_pkcs1_padding", disable_hw_pkcs1_padding);
  436|  17.0k|	if (0 == strcmp(disable_hw_pkcs1_padding, "no")) {
  ------------------
  |  Branch (436:6): [True: 0, False: 17.0k]
  ------------------
  437|      0|		ctx->disable_hw_pkcs1_padding = 0;
  438|  17.0k|	} else if (0 == strcmp(disable_hw_pkcs1_padding, "sign")) {
  ------------------
  |  Branch (438:13): [True: 0, False: 17.0k]
  ------------------
  439|      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 */
  ------------------
  440|  17.0k|	} else if (0 == strcmp(disable_hw_pkcs1_padding, "decipher")) {
  ------------------
  |  Branch (440:13): [True: 17.0k, False: 0]
  ------------------
  441|  17.0k|		ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  110|  17.0k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  442|  17.0k|	} else if (0 == strcmp(disable_hw_pkcs1_padding, "both")) {
  ------------------
  |  Branch (442:13): [True: 0, False: 0]
  ------------------
  443|      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 */
  ------------------
  444|      0|	}
  445|       |
  446|       |#ifdef USE_OPENSSL3_LIBCTX
  447|       |	val = scconf_get_str(block, "openssl_config", NULL);
  448|       |	if (val != NULL) {
  449|       |		ctx->openssl_config = strdup(val);
  450|       |	}
  451|       |#endif
  452|       |
  453|  17.0k|	return err;
  454|  17.0k|}
ctx.c:set_drivers:
  371|  17.0k|{
  372|  17.0k|	const char *s_internal = "internal", *s_old = "old";
  373|  17.0k|	if (list != NULL)
  ------------------
  |  Branch (373:6): [True: 17.0k, False: 0]
  ------------------
  374|  17.0k|		del_drvs(opts);
  375|  51.0k|	while (list != NULL) {
  ------------------
  |  Branch (375:9): [True: 34.0k, False: 17.0k]
  ------------------
  376|  34.0k|		if (strcmp(list->data, s_internal) == 0)
  ------------------
  |  Branch (376:7): [True: 17.0k, False: 17.0k]
  ------------------
  377|  17.0k|			add_internal_drvs(opts);
  378|  17.0k|		else if (strcmp(list->data, s_old) == 0)
  ------------------
  |  Branch (378:12): [True: 17.0k, False: 0]
  ------------------
  379|  17.0k|			add_old_drvs(opts);
  380|      0|		else
  381|      0|			add_drv(opts, list->data);
  382|  34.0k|		list = list->next;
  383|  34.0k|	}
  384|  17.0k|}
ctx.c:add_old_drvs:
  312|  17.0k|{
  313|  17.0k|	const struct _sc_driver_entry *lst;
  314|  17.0k|	int i;
  315|       |
  316|  17.0k|	lst = old_card_drivers;
  317|  17.0k|	i = 0;
  318|   102k|	while (lst[i].name != NULL) {
  ------------------
  |  Branch (318:9): [True: 85.1k, False: 17.0k]
  ------------------
  319|  85.1k|		add_drv(opts, lst[i].name);
  320|  85.1k|		i++;
  321|  85.1k|	}
  322|  17.0k|}
ctx.c:load_card_drivers:
  567|  17.0k|{
  568|  17.0k|	const struct _sc_driver_entry *ent;
  569|  17.0k|	int drv_count;
  570|  17.0k|	int i;
  571|       |
  572|  17.0k|	for (drv_count = 0; ctx->card_drivers[drv_count] != NULL; drv_count++)
  ------------------
  |  Branch (572:22): [True: 0, False: 17.0k]
  ------------------
  573|      0|		;
  574|       |
  575|   800k|	for (i = 0; i < opts->ccount; i++) {
  ------------------
  |  Branch (575:14): [True: 783k, False: 17.0k]
  ------------------
  576|   783k|		struct sc_card_driver *(*func)(void) = NULL;
  577|   783k|		struct sc_card_driver *(**tfunc)(void) = &func;
  578|   783k|		void *dll = NULL;
  579|   783k|		int  j;
  580|       |
  581|   783k|		if (drv_count >= SC_MAX_CARD_DRIVERS - 1)   {
  ------------------
  |  |   31|   783k|#define SC_MAX_CARD_DRIVERS		48
  ------------------
  |  Branch (581:7): [True: 0, False: 783k]
  ------------------
  582|      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)
  |  |  ------------------
  |  |  |  |  582|      0|			sc_log(ctx, "Not more then %i card drivers allowed.", SC_MAX_CARD_DRIVERS);
  |  |  |  |  ------------------
  |  |  |  |  |  |   31|      0|#define SC_MAX_CARD_DRIVERS		48
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|      0|			break;
  584|      0|		}
  585|       |
  586|   783k|		ent = &opts->cdrv[i];
  587|  18.2M|		for (j = 0; internal_card_drivers[j].name != NULL; j++) {
  ------------------
  |  Branch (587:15): [True: 18.1M, False: 85.1k]
  ------------------
  588|  18.1M|			if (strcmp(ent->name, internal_card_drivers[j].name) == 0) {
  ------------------
  |  Branch (588:8): [True: 698k, False: 17.4M]
  ------------------
  589|   698k|				func = (struct sc_card_driver *(*)(void)) internal_card_drivers[j].func;
  590|   698k|				break;
  591|   698k|			}
  592|  18.1M|		}
  593|   783k|		if (func == NULL) {
  ------------------
  |  Branch (593:7): [True: 85.1k, False: 698k]
  ------------------
  594|   255k|			for (j = 0; old_card_drivers[j].name != NULL; j++) {
  ------------------
  |  Branch (594:16): [True: 255k, False: 0]
  ------------------
  595|   255k|				if (strcmp(ent->name, old_card_drivers[j].name) == 0) {
  ------------------
  |  Branch (595:9): [True: 85.1k, False: 170k]
  ------------------
  596|  85.1k|					func = (struct sc_card_driver *(*)(void)) old_card_drivers[j].func;
  597|  85.1k|					break;
  598|  85.1k|				}
  599|   255k|			}
  600|  85.1k|		}
  601|       |		/* if not initialized assume external module */
  602|   783k|		if (func == NULL)
  ------------------
  |  Branch (602:7): [True: 0, False: 783k]
  ------------------
  603|      0|			*(void **)(tfunc) = load_dynamic_driver(ctx, &dll, ent->name);
  604|       |		/* if still null, assume driver not found */
  605|   783k|		if (func == NULL) {
  ------------------
  |  Branch (605:7): [True: 0, False: 783k]
  ------------------
  606|      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__
  |  |  ------------------
  ------------------
  607|      0|			if (dll)
  ------------------
  |  Branch (607:8): [True: 0, False: 0]
  ------------------
  608|      0|				sc_dlclose(dll);
  609|      0|			continue;
  610|      0|		}
  611|       |
  612|   783k|		ctx->card_drivers[drv_count] = func();
  613|   783k|		if (ctx->card_drivers[drv_count] == NULL) {
  ------------------
  |  Branch (613:7): [True: 0, False: 783k]
  ------------------
  614|      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__
  |  |  ------------------
  ------------------
  615|      0|			continue;
  616|      0|		}
  617|       |
  618|   783k|		ctx->card_drivers[drv_count]->dll = dll;
  619|   783k|		ctx->card_drivers[drv_count]->atr_map = NULL;
  620|   783k|		ctx->card_drivers[drv_count]->natrs = 0;
  621|       |
  622|   783k|		load_card_driver_options(ctx, ctx->card_drivers[drv_count]);
  623|       |
  624|       |		/* Ensure that the list is always terminated by NULL */
  625|   783k|		ctx->card_drivers[drv_count + 1] = NULL;
  626|       |
  627|   783k|		drv_count++;
  628|   783k|	}
  629|  17.0k|	return SC_SUCCESS;
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
  630|  17.0k|}
ctx.c:load_card_driver_options:
  546|   783k|{
  547|   783k|	scconf_block **blocks, *blk;
  548|   783k|	int i;
  549|       |
  550|  1.56M|	for (i = 0; ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (550:14): [True: 783k, False: 783k]
  ------------------
  551|   783k|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i],
  552|   783k|				"card_driver", driver->short_name);
  553|   783k|		if (!blocks)
  ------------------
  |  Branch (553:7): [True: 0, False: 783k]
  ------------------
  554|      0|			continue;
  555|   783k|		blk = blocks[0];
  556|   783k|		free(blocks);
  557|       |
  558|   783k|		if (blk == NULL)
  ------------------
  |  Branch (558:7): [True: 783k, False: 0]
  ------------------
  559|   783k|			continue;
  560|       |
  561|       |		/* no options at the moment */
  562|   783k|	}
  563|   783k|	return SC_SUCCESS;
  ------------------
  |  |   28|   783k|#define SC_SUCCESS				0
  ------------------
  564|   783k|}

dnie_get_cwa_provider:
 1287|    622|{
 1288|       |
 1289|    622|	cwa_provider_t *res = cwa_get_default_provider(card);
 1290|    622|	if (!res)
  ------------------
  |  Branch (1290:6): [True: 0, False: 622]
  ------------------
 1291|      0|		return NULL;
 1292|       |
 1293|       |	/* set up proper data */
 1294|       |
 1295|       |	/* pre and post operations */
 1296|    622|	res->cwa_create_pre_ops = dnie_create_pre_ops;
 1297|       |
 1298|       |	/* Get ICC intermediate CA  path */
 1299|    622|	res->cwa_get_icc_intermediate_ca_cert = dnie_get_icc_intermediate_ca_cert;
 1300|       |	/* Get ICC certificate path */
 1301|    622|	res->cwa_get_icc_cert = dnie_get_icc_cert;
 1302|       |
 1303|       |	/* Obtain RSA public key from RootCA */
 1304|    622|	res->cwa_get_root_ca_pubkey = dnie_get_root_ca_pubkey;
 1305|       |	/* Obtain RSA IFD private key */
 1306|    622|	res->cwa_get_ifd_privkey = dnie_get_ifd_privkey;
 1307|       |
 1308|       |	/* Retrieve CVC intermediate CA certificate and length */
 1309|    622|	res->cwa_get_cvc_ca_cert = dnie_get_cvc_ca_cert;
 1310|       |	/* Retrieve CVC IFD certificate and length */
 1311|    622|	res->cwa_get_cvc_ifd_cert = dnie_get_cvc_ifd_cert;
 1312|       |
 1313|       |	/* Get public key references for Root CA to validate intermediate CA cert */
 1314|    622|	res->cwa_get_root_ca_pubkey_ref = dnie_get_root_ca_pubkey_ref;
 1315|       |
 1316|       |	/* Get public key reference for IFD intermediate CA certificate */
 1317|    622|	res->cwa_get_intermediate_ca_pubkey_ref = dnie_get_intermediate_ca_pubkey_ref;
 1318|       |
 1319|       |	/* Get public key reference for IFD CVC certificate */
 1320|    622|	res->cwa_get_ifd_pubkey_ref = dnie_get_ifd_pubkey_ref;
 1321|       |
 1322|       |	/* Get ICC private key reference */
 1323|    622|	res->cwa_get_icc_privkey_ref = dnie_get_icc_privkey_ref;
 1324|       |
 1325|       |	/* Get IFD Serial Number */
 1326|    622|	res->cwa_get_sn_ifd = dnie_get_sn_ifd;
 1327|       |
 1328|       |	/* Get ICC Serial Number */
 1329|    622|	res->cwa_get_sn_icc = dnie_get_sn_icc;
 1330|       |
 1331|    622|	return res;
 1332|    622|}
dnie_format_apdu:
 1372|  6.07k|{
 1373|  6.07k|	sc_format_apdu(card, apdu, cse, ins, p1, p2);
 1374|  6.07k|	apdu->le = le;
 1375|  6.07k|	apdu->lc = lc;
 1376|  6.07k|	if (resp != NULL) {
  ------------------
  |  Branch (1376:6): [True: 6.07k, False: 0]
  ------------------
 1377|  6.07k|		apdu->resp = resp;
 1378|  6.07k|		apdu->resplen = resplen;
 1379|  6.07k|	}
 1380|  6.07k|	if (data != NULL) {
  ------------------
  |  Branch (1380:6): [True: 5.83k, False: 241]
  ------------------
 1381|  5.83k|		apdu->data = data;
 1382|  5.83k|		apdu->datalen = datalen;
 1383|  5.83k|	}
 1384|  6.07k|}

cwa_create_secure_channel:
 1097|  1.21k|{
 1098|  1.21k|	u8 *cert = NULL;
 1099|  1.21k|	size_t certlen;
 1100|       |
 1101|  1.21k|	int res = SC_SUCCESS;
  ------------------
  |  |   28|  1.21k|#define SC_SUCCESS				0
  ------------------
 1102|  1.21k|	char *msg = "Success";
 1103|       |
 1104|       |	/* data to get and parse certificates */
 1105|  1.21k|	X509 *icc_cert = NULL;
 1106|  1.21k|	X509 *ca_cert = NULL;
 1107|  1.21k|	EVP_PKEY *icc_pubkey = NULL;
 1108|  1.21k|	EVP_PKEY *ifd_privkey = NULL;
 1109|  1.21k|	sc_context_t *ctx = NULL;
 1110|  1.21k|	struct sm_cwa_session * sm = &card->sm_ctx.info.session.cwa;
 1111|  1.21k|	u8 sig[128];
 1112|       |
 1113|       |	/* several buffer and buffer pointers */
 1114|  1.21k|	u8 *buffer = NULL;
 1115|  1.21k|	size_t bufferlen;
 1116|  1.21k|	u8 *tlv = NULL;		/* buffer to compose TLV messages */
 1117|  1.21k|	size_t tlvlen = 0;
 1118|  1.21k|	u8 rndbuf[16]; /* 8 RND.IFD + 8 SN.IFD */
 1119|       |
 1120|       |	/* preliminary checks */
 1121|  1.21k|	if (!card || !card->ctx )
  ------------------
  |  Branch (1121:6): [True: 0, False: 1.21k]
  |  Branch (1121:15): [True: 0, False: 1.21k]
  ------------------
 1122|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1123|  1.21k|	if (!provider)
  ------------------
  |  Branch (1123:6): [True: 0, False: 1.21k]
  ------------------
 1124|      0|		return SC_ERROR_SM_NOT_INITIALIZED;
  ------------------
  |  |  120|      0|#define SC_ERROR_SM_NOT_INITIALIZED		-1605
  ------------------
 1125|       |	/* commodity vars */
 1126|  1.21k|	ctx = card->ctx;
 1127|       |
 1128|  1.21k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.21k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.21k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.21k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.21k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.21k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1129|       |
 1130|       |	/* check requested initialization method */
 1131|  1.21k|	switch (flag) {
 1132|  1.21k|	case CWA_SM_OFF:	/* disable SM */
  ------------------
  |  |   31|  1.21k|#define CWA_SM_OFF        0x00	/** Disable SM channel */
  ------------------
  |  Branch (1132:2): [True: 1.21k, False: 0]
  ------------------
 1133|  1.21k|		card->sm_ctx.sm_mode = SM_MODE_NONE;
  ------------------
  |  |   43|  1.21k|#define SM_MODE_NONE		0x0
  ------------------
 1134|  1.21k|		sc_log(ctx, "Setting CWA SM status to none");
  ------------------
  |  |   71|  1.21k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1135|       |		/* request the Master File to provoke an SM error and close the channel */
 1136|  1.21k|		res = sc_select_file(card, sc_get_mf_path(), NULL);
 1137|  1.21k|		if (res == SC_ERROR_SM)
  ------------------
  |  |  115|  1.21k|#define SC_ERROR_SM				-1600
  ------------------
  |  Branch (1137:7): [True: 33, False: 1.18k]
  ------------------
 1138|     33|			res = SC_SUCCESS;
  ------------------
  |  |   28|     33|#define SC_SUCCESS				0
  ------------------
 1139|  1.21k|		LOG_FUNC_RETURN(ctx, res);
  ------------------
  |  |  164|  1.21k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.21k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.21k|	int _ret = r; \
  |  |  |  |  155|  1.21k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.21k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.21k|		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|    612|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 612, False: 605]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.21k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.21k|	} 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|  1.21k|	return _ret; \
  |  |  |  |  163|  1.21k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1140|      0|	case CWA_SM_ON:	/* force sm initialization process */
  ------------------
  |  |   32|      0|#define CWA_SM_ON         0x01	/** Enable SM channel */
  ------------------
  |  Branch (1140:2): [True: 0, False: 1.21k]
  ------------------
 1141|      0|		sc_log(ctx, "CWA SM initialization requested");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1142|      0|		break;
 1143|      0|	default:
  ------------------
  |  Branch (1143:2): [True: 0, False: 1.21k]
  ------------------
 1144|      0|		sc_log(ctx, "Invalid provided SM initialization flag");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1145|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1146|  1.21k|	}
 1147|       |
 1148|       |	/* OK: lets start process */
 1149|       |
 1150|       |	/* call provider pre-operation method */
 1151|      0|	sc_log(ctx, "CreateSecureChannel pre-operations");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1152|      0|	if (provider->cwa_create_pre_ops) {
  ------------------
  |  Branch (1152:6): [True: 0, False: 0]
  ------------------
 1153|      0|		res = provider->cwa_create_pre_ops(card, provider);
 1154|      0|		if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1154:7): [True: 0, False: 0]
  ------------------
 1155|      0|			msg = "Create SM: provider pre_ops() failed";
 1156|      0|			sc_log(ctx, "%s", msg);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1157|      0|			goto csc_end;
 1158|      0|		}
 1159|      0|	}
 1160|       |
 1161|       |	/* retrieve icc serial number */
 1162|      0|	sc_log(ctx, "Retrieve ICC serial number");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1163|      0|	if (provider->cwa_get_sn_icc) {
  ------------------
  |  Branch (1163:6): [True: 0, False: 0]
  ------------------
 1164|      0|		res = provider->cwa_get_sn_icc(card);
 1165|      0|		if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1165:7): [True: 0, False: 0]
  ------------------
 1166|      0|			msg = "Retrieve ICC failed";
 1167|      0|			sc_log(ctx, "%s", msg);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1168|      0|			goto csc_end;
 1169|      0|		}
 1170|      0|	} else {
 1171|      0|		msg = "Don't know how to obtain ICC serial number";
 1172|      0|		sc_log(ctx, "%s", msg);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1173|      0|		res = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1174|      0|		goto csc_end;
 1175|      0|	}
 1176|       |
 1177|       |	/*
 1178|       |	 * Notice that this code inverts ICC and IFD certificate standard
 1179|       |	 * checking sequence.
 1180|       |	 */
 1181|       |
 1182|       |	/* Read Intermediate CA from card */
 1183|      0|	if (!provider->cwa_get_icc_intermediate_ca_cert) {
  ------------------
  |  Branch (1183:6): [True: 0, False: 0]
  ------------------
 1184|      0|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1185|      0|		       "Step 8.4.1.6: Skip Retrieving ICC intermediate CA");
 1186|      0|		ca_cert = NULL;
 1187|      0|	} else {
 1188|      0|		sc_log(ctx, "Step 8.4.1.7: Retrieving ICC intermediate CA");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1189|      0|		res =
 1190|      0|		    provider->cwa_get_icc_intermediate_ca_cert(card, &ca_cert);
 1191|      0|		if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1191:7): [True: 0, False: 0]
  ------------------
 1192|      0|			msg =
 1193|      0|			    "Cannot get ICC intermediate CA certificate from provider";
 1194|      0|			goto csc_end;
 1195|      0|		}
 1196|      0|	}
 1197|       |
 1198|       |	/* Read ICC certificate from card */
 1199|      0|	sc_log(ctx, "Step 8.4.1.8: Retrieve ICC certificate");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1200|      0|	res = provider->cwa_get_icc_cert(card, &icc_cert);
 1201|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1201:6): [True: 0, False: 0]
  ------------------
 1202|      0|		msg = "Cannot get ICC certificate from provider";
 1203|      0|		goto csc_end;
 1204|      0|	}
 1205|       |
 1206|       |	/* Verify icc Card certificate chain */
 1207|       |	/* Notice that Some implementations doesn't verify cert chain
 1208|       |	 * but simply verifies that icc_cert is a valid certificate */
 1209|      0|	if (ca_cert) {
  ------------------
  |  Branch (1209:6): [True: 0, False: 0]
  ------------------
 1210|      0|		sc_log(ctx, "Verifying ICC certificate chain");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1211|      0|		res =
 1212|      0|		    cwa_verify_icc_certificates(card, provider, ca_cert,
 1213|      0|						icc_cert);
 1214|      0|		if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1214:7): [True: 0, False: 0]
  ------------------
 1215|      0|			res = SC_ERROR_SM_AUTHENTICATION_FAILED;
  ------------------
  |  |  121|      0|#define SC_ERROR_SM_AUTHENTICATION_FAILED	-1606
  ------------------
 1216|      0|			msg = "Icc Certificates verification failed";
 1217|      0|			goto csc_end;
 1218|      0|		}
 1219|      0|	} else {
 1220|      0|		sc_log(ctx, "Cannot verify Certificate chain. skip step");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1221|      0|	}
 1222|       |
 1223|       |	/* Extract public key from ICC certificate */
 1224|      0|	if (!(icc_pubkey = X509_get_pubkey(icc_cert))) {
  ------------------
  |  Branch (1224:6): [True: 0, False: 0]
  ------------------
 1225|      0|		res = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1226|      0|		sc_log_openssl(ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1227|      0|		msg = "Cannot extract public key from ICC certificate";
 1228|      0|		goto csc_end;
 1229|      0|	}
 1230|       |
 1231|       |	/* Select Root CA in card for ifd certificate verification */
 1232|      0|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1233|      0|	       "Step 8.4.1.2: Select Root CA in card for IFD cert verification");
 1234|      0|	res = provider->cwa_get_root_ca_pubkey_ref(card, &buffer, &bufferlen);
 1235|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1235:6): [True: 0, False: 0]
  ------------------
 1236|      0|		msg = "Cannot get Root CA key reference from provider";
 1237|      0|		goto csc_end;
 1238|      0|	}
 1239|      0|	tlvlen = 0;
 1240|      0|	tlv = calloc(10 + bufferlen, sizeof(u8));
 1241|      0|	if (!tlv) {
  ------------------
  |  Branch (1241:6): [True: 0, False: 0]
  ------------------
 1242|      0|		msg = "calloc error";
 1243|      0|		res = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1244|      0|		goto csc_end;
 1245|      0|	}
 1246|      0|	res = cwa_compose_tlv(card, 0x83, bufferlen, buffer, &tlv, &tlvlen);
 1247|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1247:6): [True: 0, False: 0]
  ------------------
 1248|      0|		msg = "Cannot compose tlv for setting Root CA key reference";
 1249|      0|		goto csc_end;
 1250|      0|	}
 1251|      0|	res = cwa_set_security_env(card, 0x81, 0xB6, tlv, tlvlen);
 1252|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1252:6): [True: 0, False: 0]
  ------------------
 1253|      0|		msg = "Select Root CA key ref failed";
 1254|      0|		goto csc_end;
 1255|      0|	}
 1256|       |
 1257|       |	/* Send IFD intermediate CA in CVC format C_CV_CA */
 1258|      0|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1259|      0|	       "Step 8.4.1.3: Send CVC IFD intermediate CA Cert for ICC verification");
 1260|      0|	res = provider->cwa_get_cvc_ca_cert(card, &cert, &certlen);
 1261|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1261:6): [True: 0, False: 0]
  ------------------
 1262|      0|		msg = "Get CVC CA cert from provider failed";
 1263|      0|		goto csc_end;
 1264|      0|	}
 1265|      0|	res = cwa_verify_cvc_certificate(card, cert, certlen);
 1266|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1266:6): [True: 0, False: 0]
  ------------------
 1267|      0|		msg = "Verify CVC CA failed";
 1268|      0|		goto csc_end;
 1269|      0|	}
 1270|       |
 1271|       |	/* select public key reference for sent IFD intermediate CA certificate */
 1272|      0|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1273|      0|	       "Step 8.4.1.4: Select Intermediate CA pubkey ref for ICC verification");
 1274|      0|	res =
 1275|      0|	    provider->cwa_get_intermediate_ca_pubkey_ref(card, &buffer,
 1276|      0|							 &bufferlen);
 1277|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1277:6): [True: 0, False: 0]
  ------------------
 1278|      0|		msg = "Cannot get intermediate CA key reference from provider";
 1279|      0|		goto csc_end;
 1280|      0|	}
 1281|      0|	tlvlen = 0;
 1282|      0|	free(tlv);
 1283|      0|	tlv = calloc(10 + bufferlen, sizeof(u8));
 1284|      0|	if (!tlv) {
  ------------------
  |  Branch (1284:6): [True: 0, False: 0]
  ------------------
 1285|      0|		msg = "calloc error";
 1286|      0|		res = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1287|      0|		goto csc_end;
 1288|      0|	}
 1289|      0|	res = cwa_compose_tlv(card, 0x83, bufferlen, buffer, &tlv, &tlvlen);
 1290|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1290:6): [True: 0, False: 0]
  ------------------
 1291|      0|		msg =
 1292|      0|		    "Cannot compose tlv for setting intermediate CA key reference";
 1293|      0|		goto csc_end;
 1294|      0|	}
 1295|      0|	res = cwa_set_security_env(card, 0x81, 0xB6, tlv, tlvlen);
 1296|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1296:6): [True: 0, False: 0]
  ------------------
 1297|      0|		msg = "Select CVC CA pubk failed";
 1298|      0|		goto csc_end;
 1299|      0|	}
 1300|       |
 1301|       |	/* Send IFD certificate in CVC format C_CV_IFD */
 1302|      0|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1303|      0|	       "Step 8.4.1.5: Send CVC IFD Certificate for ICC verification");
 1304|      0|	res = provider->cwa_get_cvc_ifd_cert(card, &cert, &certlen);
 1305|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1305:6): [True: 0, False: 0]
  ------------------
 1306|      0|		msg = "Get CVC IFD cert from provider failed";
 1307|      0|		goto csc_end;
 1308|      0|	}
 1309|      0|	res = cwa_verify_cvc_certificate(card, cert, certlen);
 1310|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1310:6): [True: 0, False: 0]
  ------------------
 1311|      0|		msg = "Verify CVC IFD failed";
 1312|      0|		goto csc_end;
 1313|      0|	}
 1314|       |
 1315|       |	/* remember that this code changes IFD and ICC Cert verification steps */
 1316|       |
 1317|       |	/* select public key of ifd certificate and icc private key */
 1318|      0|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1319|      0|	       "Step 8.4.1.9: Send IFD pubk and ICC privk key references for Internal Auth");
 1320|      0|	res = provider->cwa_get_ifd_pubkey_ref(card, &buffer, &bufferlen);
 1321|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1321:6): [True: 0, False: 0]
  ------------------
 1322|      0|		msg = "Cannot get ifd public key reference from provider";
 1323|      0|		goto csc_end;
 1324|      0|	}
 1325|      0|	tlvlen = 0;
 1326|      0|	free(tlv);
 1327|      0|	tlv = calloc(10 + bufferlen, sizeof(u8));
 1328|      0|	if (!tlv) {
  ------------------
  |  Branch (1328:6): [True: 0, False: 0]
  ------------------
 1329|      0|		msg = "calloc error";
 1330|      0|		res = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1331|      0|		goto csc_end;
 1332|      0|	}
 1333|      0|	res = cwa_compose_tlv(card, 0x83, bufferlen, buffer, &tlv, &tlvlen);
 1334|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1334:6): [True: 0, False: 0]
  ------------------
 1335|      0|		msg = "Cannot compose tlv for setting ifd pubkey reference";
 1336|      0|		goto csc_end;
 1337|      0|	}
 1338|      0|	res = provider->cwa_get_icc_privkey_ref(card, &buffer, &bufferlen);
 1339|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1339:6): [True: 0, False: 0]
  ------------------
 1340|      0|		msg = "Cannot get icc private key reference from provider";
 1341|      0|		goto csc_end;
 1342|      0|	}
 1343|       |	/* add this tlv to old one; do not call calloc */
 1344|      0|	res = cwa_compose_tlv(card, 0x84, bufferlen, buffer, &tlv, &tlvlen);
 1345|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1345:6): [True: 0, False: 0]
  ------------------
 1346|      0|		msg = "Cannot compose tlv for setting ifd pubkey reference";
 1347|      0|		goto csc_end;
 1348|      0|	}
 1349|       |
 1350|      0|	res = cwa_set_security_env(card, 0xC1, 0xA4, tlv, tlvlen);
 1351|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1351:6): [True: 0, False: 0]
  ------------------
 1352|      0|		msg = "Select CVC IFD pubk failed";
 1353|      0|		goto csc_end;
 1354|      0|	}
 1355|       |
 1356|       |	/* Internal (Card) authentication (let the card verify sent ifd certs)
 1357|       |	   SN.IFD equals 8 lsb bytes of ifd.pubk ref according cwa14890 sec 8.4.1 */
 1358|      0|	sc_log(ctx, "Step 8.4.1.10: Perform Internal authentication");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1359|      0|	res = provider->cwa_get_sn_ifd(card);
 1360|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1360:6): [True: 0, False: 0]
  ------------------
 1361|      0|		msg = "Cannot get ifd serial number from provider";
 1362|      0|		goto csc_end;
 1363|      0|	}
 1364|       |	/* generate 8 random bytes */
 1365|      0|	if (RAND_bytes(sm->ifd.rnd, 8) != 1) {
  ------------------
  |  Branch (1365:6): [True: 0, False: 0]
  ------------------
 1366|      0|		msg = "Cannot generate random data";
 1367|      0|		res = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1368|      0|		goto csc_end;
 1369|      0|	}
 1370|      0|	memcpy(rndbuf, sm->ifd.rnd, 8);	/* insert RND.IFD into rndbuf */
 1371|      0|	memcpy(rndbuf + 8, sm->ifd.sn, 8);	/* insert SN.IFD into rndbuf */
 1372|      0|	res = cwa_internal_auth(card, sig, 128, rndbuf, 16);
 1373|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1373:6): [True: 0, False: 0]
  ------------------
 1374|      0|		msg = "Internal auth cmd failed";
 1375|      0|		goto csc_end;
 1376|      0|	}
 1377|       |
 1378|       |	/* retrieve ifd private key from provider */
 1379|      0|	res = provider->cwa_get_ifd_privkey(card, &ifd_privkey);
 1380|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1380:6): [True: 0, False: 0]
  ------------------
 1381|      0|		msg = "Cannot retrieve IFD private key from provider";
 1382|      0|		res = SC_ERROR_SM_NO_SESSION_KEYS;
  ------------------
  |  |  118|      0|#define SC_ERROR_SM_NO_SESSION_KEYS		-1603
  ------------------
 1383|      0|		goto csc_end;
 1384|      0|	}
 1385|       |
 1386|       |	/* verify received signature */
 1387|      0|	sc_log(ctx, "Verify Internal Auth command response");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1388|      0|	res = cwa_verify_internal_auth(card, icc_pubkey,	/* evaluated icc public key */
 1389|      0|				       ifd_privkey,	/* evaluated from DGP's Manual Annex 3 Data */
 1390|      0|				       rndbuf,	/* RND.IFD || SN.IFD */
 1391|      0|				       16,	/* rndbuf length; should be 16 */
 1392|      0|				       sig, 128
 1393|      0|	    );
 1394|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1394:6): [True: 0, False: 0]
  ------------------
 1395|      0|		msg = "Internal Auth Verify failed";
 1396|      0|		goto csc_end;
 1397|      0|	}
 1398|       |
 1399|       |	/* get challenge: retrieve 8 random bytes from card */
 1400|      0|	sc_log(ctx, "Step 8.4.1.11: Prepare External Auth: Get Challenge");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1401|      0|	res = sc_get_challenge(card, sm->icc.rnd, sizeof(sm->icc.rnd));
 1402|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1402:6): [True: 0, False: 0]
  ------------------
 1403|      0|		msg = "Get Challenge failed";
 1404|      0|		goto csc_end;
 1405|      0|	}
 1406|       |
 1407|       |	/* compose signature data for external auth */
 1408|      0|	res = cwa_prepare_external_auth(card, icc_pubkey, ifd_privkey, sig, 128);
 1409|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1409:6): [True: 0, False: 0]
  ------------------
 1410|      0|		msg = "Prepare external auth failed";
 1411|      0|		goto csc_end;
 1412|      0|	}
 1413|       |
 1414|       |	/* External (IFD)  authentication */
 1415|      0|	sc_log(ctx, "Step 8.4.1.12: Perform External (IFD) Authentication");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1416|      0|	res = cwa_external_auth(card, sig, 128);
 1417|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1417:6): [True: 0, False: 0]
  ------------------
 1418|      0|		msg = "External auth cmd failed";
 1419|      0|		goto csc_end;
 1420|      0|	}
 1421|       |
 1422|       |	/* Session key generation */
 1423|      0|	sc_log(ctx, "Step 8.4.2: Compute Session Keys");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1424|      0|	res = cwa_compute_session_keys(card);
 1425|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1425:6): [True: 0, False: 0]
  ------------------
 1426|      0|		msg = "Session Key generation failed";
 1427|      0|		goto csc_end;
 1428|      0|	}
 1429|       |
 1430|       |	/* call provider post-operation method */
 1431|      0|	sc_log(ctx, "CreateSecureChannel post-operations");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1432|      0|	if (provider->cwa_create_post_ops) {
  ------------------
  |  Branch (1432:6): [True: 0, False: 0]
  ------------------
 1433|      0|		res = provider->cwa_create_post_ops(card, provider);
 1434|      0|		if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1434:7): [True: 0, False: 0]
  ------------------
 1435|      0|			sc_log(ctx, "Create SM: provider post_ops() failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1436|      0|			goto csc_end;
 1437|      0|		}
 1438|      0|	}
 1439|       |
 1440|       |	/* arriving here means ok: cleanup */
 1441|      0|	res = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1442|      0| csc_end:
 1443|      0|	free(tlv);
 1444|      0|	X509_free(icc_cert);
 1445|      0|	X509_free(ca_cert);
 1446|      0|	EVP_PKEY_free(icc_pubkey);
 1447|      0|	EVP_PKEY_free(ifd_privkey);
 1448|       |	/* setup SM state according result */
 1449|      0|	if (res != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1449:6): [True: 0, False: 0]
  ------------------
 1450|      0|		sc_log(ctx, "%s", msg);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1451|      0|		card->sm_ctx.sm_mode = SM_MODE_NONE;
  ------------------
  |  |   43|      0|#define SM_MODE_NONE		0x0
  ------------------
 1452|      0|	} else {
 1453|      0|		card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|      0|#define SM_MODE_TRANSMIT	0x200
  ------------------
 1454|      0|	}
 1455|      0|	LOG_FUNC_RETURN(ctx, res);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1456|      0|}
cwa_get_default_provider:
 2168|    622|{
 2169|    622|	cwa_provider_t *res = NULL;
 2170|    622|	if (!card || !card->ctx)
  ------------------
  |  Branch (2170:6): [True: 0, False: 622]
  |  Branch (2170:15): [True: 0, False: 622]
  ------------------
 2171|      0|		return NULL;
 2172|    622|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    622|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    622|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    622|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    622|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 622]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2173|    622|	res = calloc(1, sizeof(cwa_provider_t));
 2174|    622|	if (!res) {
  ------------------
  |  Branch (2174:6): [True: 0, False: 622]
  ------------------
 2175|      0|		sc_log(card->ctx, "Cannot allocate space for cwa_provider");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2176|      0|		return NULL;
 2177|      0|	}
 2178|    622|	memcpy(res, &default_cwa_provider, sizeof(cwa_provider_t));
 2179|    622|	return res;
 2180|    622|}

sc_enum_apps:
  162|  13.8k|{
  163|  13.8k|	struct sc_context *ctx = card->ctx;
  164|  13.8k|	sc_path_t path;
  165|  13.8k|	int ef_structure;
  166|  13.8k|	size_t file_size, jj;
  167|  13.8k|	int r, ii, idx;
  168|  13.8k|	struct sc_file *ef_dir = NULL;
  169|       |
  170|  13.8k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  13.8k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  13.8k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  13.8k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  13.8k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 13.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|       |
  172|  13.8k|	sc_free_apps(card);
  173|  13.8k|	card->app_count = 0;
  174|       |
  175|  13.8k|	sc_format_path("3F002F00", &path);
  176|  13.8k|	r = sc_select_file(card, &path, &ef_dir);
  177|  13.8k|	if (r < 0)
  ------------------
  |  Branch (177:6): [True: 10.3k, False: 3.57k]
  ------------------
  178|  10.3k|		sc_file_free(ef_dir);
  179|  13.8k|	LOG_TEST_RET(ctx, r, "Cannot select EF.DIR file");
  ------------------
  |  |  174|  13.8k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  13.8k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  13.8k|	int _ret = (r); \
  |  |  |  |  168|  13.8k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10.3k, False: 3.57k]
  |  |  |  |  ------------------
  |  |  |  |  169|  10.3k|		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|  10.3k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  10.3k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  10.3k|		return _ret; \
  |  |  |  |  172|  10.3k|	} \
  |  |  |  |  173|  13.8k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.57k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  180|       |
  181|  3.57k|	if (ef_dir->type != SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|  3.57k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (181:6): [True: 1.12k, False: 2.44k]
  ------------------
  182|  1.12k|		sc_file_free(ef_dir);
  183|  1.12k|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_CARD, "EF(DIR) is not a working EF.");
  ------------------
  |  |  174|  1.12k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.12k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.12k|	int _ret = (r); \
  |  |  |  |  168|  1.12k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.12k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.12k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.12k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.12k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.12k|		return _ret; \
  |  |  |  |  172|  1.12k|	} \
  |  |  |  |  173|  1.12k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  184|  1.12k|	}
  185|       |
  186|  2.44k|	ef_structure = ef_dir->ef_structure;
  187|  2.44k|	file_size = ef_dir->size;
  188|  2.44k|	sc_file_free(ef_dir);
  189|  2.44k|	if (ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|  2.44k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (189:6): [True: 1.23k, False: 1.21k]
  ------------------
  190|  1.23k|		u8 *buf = NULL, *p;
  191|  1.23k|		size_t bufsize;
  192|       |
  193|  1.23k|		if (file_size == 0)
  ------------------
  |  Branch (193:7): [True: 40, False: 1.19k]
  ------------------
  194|  1.23k|			LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  164|     40|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     40|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     40|	int _ret = r; \
  |  |  |  |  155|     40|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 40, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     40|		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: 40]
  |  |  |  |  ------------------
  |  |  |  |  157|     40|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     40|	} 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|     40|	return _ret; \
  |  |  |  |  163|     40|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|  1.19k|		if (file_size > MAX_FILE_SIZE)
  ------------------
  |  |  220|  1.19k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (195:7): [True: 18, False: 1.17k]
  ------------------
  196|  1.19k|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|     18|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     18|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     18|	int _ret = r; \
  |  |  |  |  155|     18|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     18|		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|     18|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     18|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     18|	} 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|     18|	return _ret; \
  |  |  |  |  163|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  197|       |
  198|  1.17k|		buf = malloc(file_size);
  199|  1.17k|		if (buf == NULL)
  ------------------
  |  Branch (199:7): [True: 0, False: 1.17k]
  ------------------
  200|  1.17k|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|  1.17k|		p = buf;
  202|  1.17k|		r = sc_read_binary(card, 0, buf, file_size, 0);
  203|  1.17k|		if (r < 0) {
  ------------------
  |  Branch (203:7): [True: 186, False: 987]
  ------------------
  204|    186|			free(buf);
  205|    186|			LOG_TEST_RET(ctx, r, "sc_read_binary() failed");
  ------------------
  |  |  174|    186|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    186|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    186|	int _ret = (r); \
  |  |  |  |  168|    186|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 186, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    186|		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|    186|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    186|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    186|		return _ret; \
  |  |  |  |  172|    186|	} \
  |  |  |  |  173|    186|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  206|    186|		}
  207|    987|		bufsize = r;
  208|  2.84k|		while (bufsize > 0) {
  ------------------
  |  Branch (208:10): [True: 2.28k, False: 562]
  ------------------
  209|  2.28k|			if (card->app_count == SC_MAX_CARD_APPS) {
  ------------------
  |  |   33|  2.28k|#define SC_MAX_CARD_APPS		8
  ------------------
  |  Branch (209:8): [True: 2, False: 2.27k]
  ------------------
  210|      2|				sc_log(ctx, "Too many applications on card");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  211|      2|				break;
  212|      2|			}
  213|  2.27k|			r = parse_dir_record(card, &p, &bufsize, -1);
  214|  2.27k|			if (r)
  ------------------
  |  Branch (214:8): [True: 423, False: 1.85k]
  ------------------
  215|    423|				break;
  216|  2.27k|		}
  217|    987|		if (buf)
  ------------------
  |  Branch (217:7): [True: 987, False: 0]
  ------------------
  218|    987|			free(buf);
  219|       |
  220|    987|	}
  221|  1.21k|	else {	/* record structure */
  222|  1.21k|		unsigned char buf[256], *p;
  223|  1.21k|		unsigned int rec_nr;
  224|  1.21k|		size_t rec_size;
  225|       |
  226|       |		/* Arbitrary set '16' as maximal number of records to check out:
  227|       |		 * to avoid endless loop because of some incomplete cards/drivers */
  228|  4.77k|		for (rec_nr = 1; rec_nr < 16; rec_nr++) {
  ------------------
  |  Branch (228:20): [True: 4.75k, False: 19]
  ------------------
  229|  4.75k|			r = sc_read_record(card, rec_nr, 0, buf, sizeof(buf), SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1298|  4.75k|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  230|  4.75k|			if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|  4.75k|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (230:8): [True: 1, False: 4.75k]
  ------------------
  231|      1|				break;
  232|  4.75k|			LOG_TEST_RET(ctx, r, "read_record() failed");
  ------------------
  |  |  174|  4.75k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.75k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.75k|	int _ret = (r); \
  |  |  |  |  168|  4.75k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.18k, False: 3.56k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.18k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.18k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.18k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.18k|		return _ret; \
  |  |  |  |  172|  1.18k|	} \
  |  |  |  |  173|  4.75k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.56k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|       |
  234|  3.56k|			if (card->app_count == SC_MAX_CARD_APPS) {
  ------------------
  |  |   33|  3.56k|#define SC_MAX_CARD_APPS		8
  ------------------
  |  Branch (234:8): [True: 10, False: 3.55k]
  ------------------
  235|     10|				sc_log(ctx, "Too many applications on card");
  ------------------
  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  236|     10|				break;
  237|     10|			}
  238|       |
  239|  3.55k|			rec_size = r;
  240|  3.55k|			p = buf;
  241|  3.55k|			parse_dir_record(card, &p, &rec_size, (int)rec_nr);
  242|  3.55k|		}
  243|  1.21k|	}
  244|       |
  245|       |	/* Move known PKCS#15 applications to the head of the list */
  246|  2.99k|	for (ii=0, idx=0; ii<card->app_count; ii++)   {
  ------------------
  |  Branch (246:20): [True: 1.98k, False: 1.01k]
  ------------------
  247|  16.7k|		for (jj=0; jj < sizeof(apps)/sizeof(apps[0]); jj++) {
  ------------------
  |  Branch (247:14): [True: 14.9k, False: 1.76k]
  ------------------
  248|  14.9k|			if (apps[jj].aid_len != card->app[ii]->aid.len)
  ------------------
  |  Branch (248:8): [True: 14.6k, False: 357]
  ------------------
  249|  14.6k|				continue;
  250|    357|			if (memcmp(apps[jj].aid, card->app[ii]->aid.value, apps[jj].aid_len))
  ------------------
  |  Branch (250:8): [True: 140, False: 217]
  ------------------
  251|    140|				continue;
  252|    217|			break;
  253|    357|		}
  254|       |
  255|  1.98k|		if (ii != idx && jj < sizeof(apps)/sizeof(apps[0]))   {
  ------------------
  |  Branch (255:7): [True: 1.20k, False: 775]
  |  Branch (255:20): [True: 201, False: 1.00k]
  ------------------
  256|    201|			struct sc_app_info *tmp = card->app[idx];
  257|       |
  258|    201|			card->app[idx] = card->app[ii];
  259|    201|			card->app[ii] = tmp;
  260|    201|			idx++;
  261|    201|		}
  262|  1.98k|	}
  263|       |
  264|  1.01k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.01k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.01k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.01k|	int _ret = r; \
  |  |  |  |  155|  1.01k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.01k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.01k|		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: 1.01k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.01k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.01k|	} 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|  1.01k|	return _ret; \
  |  |  |  |  163|  1.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  265|  1.01k|}
sc_free_apps:
  268|  30.9k|{
  269|  30.9k|	int	i;
  270|       |
  271|  35.2k|	for (i = 0; i < card->app_count; i++) {
  ------------------
  |  Branch (271:14): [True: 4.33k, False: 30.9k]
  ------------------
  272|  4.33k|		free(card->app[i]->label);
  273|  4.33k|		free(card->app[i]->ddo.value);
  274|  4.33k|		free(card->app[i]);
  275|  4.33k|	}
  276|  30.9k|	card->app_count = -1;
  277|  30.9k|}
dir.c:parse_dir_record:
   64|  5.83k|{
   65|  5.83k|	struct sc_context *ctx = card->ctx;
   66|  5.83k|	struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2];
   67|  5.83k|	scconf_block *conf_block = NULL;
   68|  5.83k|	sc_app_info_t *app = NULL;
   69|  5.83k|	struct sc_aid aid;
   70|  5.83k|	u8 label[128], path[128], ddo[128];
   71|  5.83k|	size_t label_len = sizeof(label) - 1, path_len = sizeof(path), ddo_len = sizeof(ddo);
   72|  5.83k|	int r;
   73|       |
   74|  5.83k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  5.83k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.83k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.83k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.83k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.83k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   75|  5.83k|	aid.len = sizeof(aid.value);
   76|       |
   77|  5.83k|	memset(label, 0, sizeof(label));
   78|  5.83k|	sc_copy_asn1_entry(c_asn1_dirrecord, asn1_dirrecord);
   79|  5.83k|	sc_copy_asn1_entry(c_asn1_dir, asn1_dir);
   80|  5.83k|	sc_format_asn1_entry(asn1_dir + 0, asn1_dirrecord, NULL, 0);
   81|  5.83k|	sc_format_asn1_entry(asn1_dirrecord + 0, aid.value, &aid.len, 0);
   82|  5.83k|	sc_format_asn1_entry(asn1_dirrecord + 1, label, &label_len, 0);
   83|  5.83k|	sc_format_asn1_entry(asn1_dirrecord + 2, path, &path_len, 0);
   84|  5.83k|	sc_format_asn1_entry(asn1_dirrecord + 3, ddo, &ddo_len, 0);
   85|       |
   86|  5.83k|	r = sc_asn1_decode(ctx, asn1_dir, *buf, *buflen, (const u8 **) buf, buflen);
   87|  5.83k|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|  5.83k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (87:6): [True: 262, False: 5.57k]
  ------------------
   88|  5.83k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    262|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    262|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    262|	int _ret = r; \
  |  |  |  |  155|    262|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 262, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    262|		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|    262|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 262, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    262|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    262|	} 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|    262|	return _ret; \
  |  |  |  |  163|    262|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   89|  5.57k|	LOG_TEST_RET(ctx, r, "EF(DIR) parsing failed");
  ------------------
  |  |  174|  5.57k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  5.57k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  5.57k|	int _ret = (r); \
  |  |  |  |  168|  5.57k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.23k, False: 4.33k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.23k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.23k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.23k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.23k|		return _ret; \
  |  |  |  |  172|  1.23k|	} \
  |  |  |  |  173|  5.57k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   90|       |
   91|  4.33k|	conf_block = sc_get_conf_block(ctx, "framework", "pkcs15", 1);
   92|  4.33k|	if (conf_block)   {
  ------------------
  |  Branch (92:6): [True: 0, False: 4.33k]
  ------------------
   93|      0|		scconf_block **blocks = NULL;
   94|      0|		char aid_str[SC_MAX_AID_STRING_SIZE];
   95|      0|		int ignore_app = 0;
   96|       |
   97|      0|		sc_bin_to_hex(aid.value, aid.len, aid_str, sizeof(aid_str), 0);
   98|      0|		blocks = scconf_find_blocks(card->ctx->conf, conf_block, "application", aid_str);
   99|      0|		if (blocks)   {
  ------------------
  |  Branch (99:7): [True: 0, False: 0]
  ------------------
  100|      0|			ignore_app = (blocks[0] && scconf_get_bool(blocks[0], "disable", 0));
  ------------------
  |  Branch (100:18): [True: 0, False: 0]
  |  Branch (100:31): [True: 0, False: 0]
  ------------------
  101|      0|			free(blocks);
  102|      0|		 }
  103|       |
  104|      0|		if (ignore_app)   {
  ------------------
  |  Branch (104:7): [True: 0, False: 0]
  ------------------
  105|      0|			sc_log(ctx, "Application '%s' ignored", aid_str);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  106|      0|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|      0|		}
  108|      0|	}
  109|       |
  110|  4.33k|	app = calloc(1, sizeof(struct sc_app_info));
  111|  4.33k|	if (app == NULL)
  ------------------
  |  Branch (111:6): [True: 0, False: 4.33k]
  ------------------
  112|  4.33k|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|       |
  114|  4.33k|	memcpy(&app->aid, &aid, sizeof(struct sc_aid));
  115|       |
  116|  4.33k|	if (asn1_dirrecord[1].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|  4.33k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (116:6): [True: 96, False: 4.24k]
  ------------------
  117|     96|		app->label = strdup((char *) label);
  118|  4.24k|	else
  119|  4.24k|		app->label = NULL;
  120|       |
  121|  4.33k|	if (asn1_dirrecord[2].flags & SC_ASN1_PRESENT && path_len > 0) {
  ------------------
  |  |  147|  8.67k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (121:6): [True: 577, False: 3.76k]
  |  Branch (121:51): [True: 524, False: 53]
  ------------------
  122|       |		/* application path present: ignore AID */
  123|    524|		if (path_len > SC_MAX_PATH_SIZE) {
  ------------------
  |  |   47|    524|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (123:7): [True: 2, False: 522]
  ------------------
  124|      2|			free(app->label);
  125|      2|			free(app);
  126|      2|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "Application path is too long.");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  127|      2|		}
  128|    522|		memcpy(app->path.value, path, path_len);
  129|    522|		app->path.len = path_len;
  130|    522|		app->path.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|    522|#define SC_PATH_TYPE_PATH		2
  ------------------
  131|    522|	}
  132|  3.81k|	else {
  133|       |		/* application path not present: use AID as application path */
  134|  3.81k|		memcpy(app->path.value, aid.value, aid.len);
  135|  3.81k|		app->path.len = aid.len;
  136|  3.81k|		app->path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  3.81k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  137|  3.81k|	}
  138|       |
  139|  4.33k|	if (asn1_dirrecord[3].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|  4.33k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (139:6): [True: 505, False: 3.83k]
  ------------------
  140|    505|		app->ddo.value = malloc(ddo_len);
  141|    505|		if (app->ddo.value == NULL) {
  ------------------
  |  Branch (141:7): [True: 0, False: 505]
  ------------------
  142|      0|			free(app->label);
  143|      0|			free(app);
  144|      0|			LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot allocate DDO value");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  145|      0|		}
  146|    505|		memcpy(app->ddo.value, ddo, ddo_len);
  147|    505|		app->ddo.len = ddo_len;
  148|  3.83k|	} else {
  149|  3.83k|		app->ddo.value = NULL;
  150|  3.83k|		app->ddo.len = 0;
  151|  3.83k|	}
  152|       |
  153|  4.33k|	app->rec_nr = rec_nr;
  154|  4.33k|	card->app[card->app_count] = app;
  155|  4.33k|	card->app_count++;
  156|       |
  157|  4.33k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  4.33k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.33k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.33k|	int _ret = r; \
  |  |  |  |  155|  4.33k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.33k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.33k|		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: 4.33k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.33k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.33k|	} 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|  4.33k|	return _ret; \
  |  |  |  |  163|  4.33k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|  4.33k|}

sc_parse_ef_atr:
  134|  1.89k|{
  135|  1.89k|	struct sc_context *ctx = card->ctx;
  136|  1.89k|	struct sc_path path;
  137|  1.89k|	struct sc_file *file = NULL;
  138|  1.89k|	int rv;
  139|  1.89k|	unsigned char *buf = NULL;
  140|  1.89k|	size_t size;
  141|  1.89k|	size_t off = 0;
  142|       |
  143|  1.89k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.89k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.89k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.89k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.89k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.89k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|       |
  145|  1.89k|	sc_format_path("3F002F01", &path);
  146|  1.89k|	rv = sc_select_file(card, &path, &file);
  147|  1.89k|	LOG_TEST_GOTO_ERR(ctx, rv, "Cannot select EF(ATR) file");
  ------------------
  |  |  184|  1.89k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.89k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.89k|	int _ret = (r); \
  |  |  |  |  178|  1.89k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 883, False: 1.01k]
  |  |  |  |  ------------------
  |  |  |  |  179|    883|		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|    883|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    883|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    883|		goto err; \
  |  |  |  |  182|    883|	} \
  |  |  |  |  183|  1.89k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.01k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  148|       |
  149|  1.01k|	if (file->size) {
  ------------------
  |  Branch (149:6): [True: 96, False: 915]
  ------------------
  150|     96|		size = file->size;
  151|    915|	} else {
  152|    915|		size = 1024;
  153|    915|	}
  154|  1.01k|	buf = malloc(size);
  155|  1.01k|	if (!buf) {
  ------------------
  |  Branch (155:6): [True: 0, False: 1.01k]
  ------------------
  156|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  157|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Memory allocation error");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|      0|	}
  159|  1.01k|	rv = sc_read_binary(card, 0, buf, size, 0);
  160|  1.01k|	LOG_TEST_GOTO_ERR(ctx, rv, "Cannot read EF(ATR) file");
  ------------------
  |  |  184|  1.01k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.01k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.01k|	int _ret = (r); \
  |  |  |  |  178|  1.01k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 172, False: 839]
  |  |  |  |  ------------------
  |  |  |  |  179|    172|		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|    172|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    172|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    172|		goto err; \
  |  |  |  |  182|    172|	} \
  |  |  |  |  183|  1.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 839]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|       |
  162|       |	/* Workaround: Some cards seem to have a buggy storage of the EF.ATR */
  163|    839|	if ((card->type == SC_CARD_TYPE_IASECC_CPX) ||
  ------------------
  |  Branch (163:6): [True: 92, False: 747]
  ------------------
  164|    747|	    (card->type == SC_CARD_TYPE_IASECC_CPXCL)) {
  ------------------
  |  Branch (164:6): [True: 12, False: 735]
  ------------------
  165|       |		/* Let's keep the first byte */
  166|    104|		if ((rv > 1) &&
  ------------------
  |  Branch (166:7): [True: 101, False: 3]
  ------------------
  167|    101|		    (buf[0] == ISO7816_II_CATEGORY_TLV))
  ------------------
  |  |   28|    101|#define ISO7816_II_CATEGORY_TLV		0x80
  ------------------
  |  Branch (167:7): [True: 1, False: 100]
  ------------------
  168|      1|			off++;
  169|    104|	}
  170|    839|	rv = sc_parse_ef_atr_content(card, buf + off, rv - off);
  171|    839|	LOG_TEST_GOTO_ERR(ctx, rv, "EF(ATR) parse error");
  ------------------
  |  |  184|    839|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    839|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    839|	int _ret = (r); \
  |  |  |  |  178|    839|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 17, False: 822]
  |  |  |  |  ------------------
  |  |  |  |  179|     17|		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|     17|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     17|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     17|		goto err; \
  |  |  |  |  182|     17|	} \
  |  |  |  |  183|    839|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 822]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  172|       |
  173|    822|	rv = SC_SUCCESS;
  ------------------
  |  |   28|    822|#define SC_SUCCESS				0
  ------------------
  174|       |
  175|  1.89k|err:
  176|  1.89k|	sc_file_free(file);
  177|  1.89k|	free(buf);
  178|  1.89k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  1.89k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.89k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.89k|	int _ret = r; \
  |  |  |  |  155|  1.89k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.89k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.89k|		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|  1.07k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.07k, False: 822]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.89k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.89k|	} 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|  1.89k|	return _ret; \
  |  |  |  |  163|  1.89k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  179|  1.89k|}
sc_free_ef_atr:
  182|  17.0k|{
  183|  17.0k|	if (card->ef_atr)
  ------------------
  |  Branch (183:6): [True: 847, False: 16.1k]
  ------------------
  184|    847|		free(card->ef_atr);
  185|       |	card->ef_atr = NULL;
  186|  17.0k|}
ef-atr.c:sc_parse_ef_atr_content:
   35|    839|{
   36|    839|	struct sc_context *ctx = card->ctx;
   37|    839|	const unsigned char *tag = NULL;
   38|    839|	size_t taglen;
   39|    839|	struct sc_ef_atr ef_atr;
   40|       |
   41|    839|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    839|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    839|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    839|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    839|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 839]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   42|       |
   43|    839|	memset(&ef_atr, 0, sizeof(struct sc_ef_atr));
   44|       |
   45|    839|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_CARD_SERVICE, &taglen);
  ------------------
  |  |   31|    839|#define ISO7816_TAG_II_CARD_SERVICE		0x43
  ------------------
   46|    839|	if (tag && taglen >= 1)   {
  ------------------
  |  Branch (46:6): [True: 11, False: 828]
  |  Branch (46:13): [True: 10, False: 1]
  ------------------
   47|     10|		ef_atr.card_service = *tag;
   48|     10|		sc_log(ctx, "EF.ATR: card service 0x%X", ef_atr.card_service);
  ------------------
  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   49|     10|	}
   50|       |
   51|    839|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_PRE_ISSUING, &taglen);
  ------------------
  |  |   34|    839|#define ISO7816_TAG_II_PRE_ISSUING		0x46
  ------------------
   52|    839|	if (tag) {
  ------------------
  |  Branch (52:6): [True: 636, False: 203]
  ------------------
   53|    636|		size_t len = taglen > sizeof(ef_atr.pre_issuing) ? sizeof(ef_atr.pre_issuing) : taglen;
  ------------------
  |  Branch (53:16): [True: 633, False: 3]
  ------------------
   54|       |
   55|    636|		memcpy(ef_atr.pre_issuing, tag, len);
   56|    636|		ef_atr.pre_issuing_len = len;
   57|       |
   58|    636|		sc_log(ctx, "EF.ATR: Pre-Issuing data '%s'", sc_dump_hex(ef_atr.pre_issuing, ef_atr.pre_issuing_len));
  ------------------
  |  |   71|    636|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   59|    636|	}
   60|       |
   61|    839|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_CARD_CAPABILITIES, &taglen);
  ------------------
  |  |   35|    839|#define ISO7816_TAG_II_CARD_CAPABILITIES	0x47
  ------------------
   62|    839|	if (tag && taglen >= 3) {
  ------------------
  |  Branch (62:6): [True: 33, False: 806]
  |  Branch (62:13): [True: 29, False: 4]
  ------------------
   63|     29|		ef_atr.df_selection =  *(tag + 0);
   64|     29|		ef_atr.unit_size = *(tag + 1);
   65|     29|		ef_atr.card_capabilities = *(tag + 2);
   66|     29|		sc_log(ctx, "EF.ATR: DF selection %X, unit_size %zX, card caps %X",
  ------------------
  |  |   71|     29|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   67|     29|				ef_atr.df_selection, ef_atr.unit_size, ef_atr.card_capabilities);
   68|     29|	}
   69|       |
   70|    839|	if (ef_atr.card_capabilities & ISO7816_CAP_EXTENDED_LENGTH_INFO) {
  ------------------
  |  |   45|    839|#define ISO7816_CAP_EXTENDED_LENGTH_INFO	0x20
  ------------------
  |  Branch (70:6): [True: 29, False: 810]
  ------------------
   71|       |		/* Extended Length Information in EF.ATR/INFO */
   72|     29|		tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_EXTENDED_LENGTH, &taglen);
  ------------------
  |  |   41|     29|#define ISO7816_TAG_II_EXTENDED_LENGTH		0x7F66
  ------------------
   73|     29|		if (tag && taglen >= 8) {
  ------------------
  |  Branch (73:7): [True: 27, False: 2]
  |  Branch (73:14): [True: 25, False: 2]
  ------------------
   74|       |			/* The command- and response-APDU size limitations are defined by
   75|       |			 * two integers, each nested in a DO'02'.
   76|       |			 * We skip parsing the nested DOs and jump directly to the numbers */
   77|     25|			ef_atr.max_command_apdu = bebytes2ushort(tag + 2);
   78|     25|			ef_atr.max_response_apdu = bebytes2ushort(tag + 6);
   79|     25|			sc_log(ctx, "EF.ATR: Biggest command APDU %zu bytes, response APDU %zu",
  ------------------
  |  |   71|     25|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   80|     25|					ef_atr.max_command_apdu, ef_atr.max_response_apdu);
   81|     25|		}
   82|     29|	}
   83|       |
   84|    839|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_AID, &taglen);
  ------------------
  |  |   36|    839|#define ISO7816_TAG_II_AID			0x4F
  ------------------
   85|    839|	if (tag) {
  ------------------
  |  Branch (85:6): [True: 31, False: 808]
  ------------------
   86|     31|		if (taglen > sizeof(ef_atr.aid.value))
  ------------------
  |  Branch (86:7): [True: 1, False: 30]
  ------------------
   87|     31|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid MF AID size");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   88|     30|		memcpy(ef_atr.aid.value, tag, taglen);
   89|     30|		ef_atr.aid.len = taglen;
   90|     30|		sc_log(ctx, "EF.ATR: AID '%s'", sc_dump_hex(ef_atr.aid.value, ef_atr.aid.len));
  ------------------
  |  |   71|     30|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   91|     30|	}
   92|       |
   93|       |	/* IAS/ECC specific issuer data: contains the max send/recv buffer sizes in plain and SM modes */
   94|    838|	tag = sc_asn1_find_tag(ctx, buf, buflen, IASECC_TAG_II_IO_BUFFER_SIZES, &taglen);
  ------------------
  |  |   48|    838|#define IASECC_TAG_II_IO_BUFFER_SIZES		0xE0
  ------------------
   95|    838|	if (tag) {
  ------------------
  |  Branch (95:6): [True: 656, False: 182]
  ------------------
   96|    656|		size_t len = taglen > sizeof(ef_atr.issuer_data) ? sizeof(ef_atr.issuer_data) : taglen;
  ------------------
  |  Branch (96:16): [True: 42, False: 614]
  ------------------
   97|       |
   98|    656|		memcpy(ef_atr.issuer_data, tag, len);
   99|    656|		ef_atr.issuer_data_len = len;
  100|       |
  101|    656|		sc_log(ctx, "EF.ATR: Issuer data '%s'", sc_dump_hex(ef_atr.issuer_data, ef_atr.issuer_data_len));
  ------------------
  |  |   71|    656|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  102|    656|	}
  103|       |
  104|    838|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_ALLOCATION_SCHEME, &taglen);
  ------------------
  |  |   37|    838|#define ISO7816_TAG_II_ALLOCATION_SCHEME        0x78
  ------------------
  105|    838|	if (tag)   {
  ------------------
  |  Branch (105:6): [True: 69, False: 769]
  ------------------
  106|     69|		sc_log(ctx, "EF.ATR: DER encoded OID %s", sc_dump_hex(tag, taglen));
  ------------------
  |  |   71|     69|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  107|     69|		tag = sc_asn1_find_tag(ctx, tag, taglen, SC_ASN1_TAG_OBJECT, &taglen);
  ------------------
  |  |  200|     69|#define SC_ASN1_TAG_OBJECT		6
  ------------------
  108|     69|		if (tag)   {
  ------------------
  |  Branch (108:7): [True: 25, False: 44]
  ------------------
  109|     25|			sc_log(ctx, "EF.ATR: OID %s", sc_dump_hex(tag, taglen));
  ------------------
  |  |   71|     25|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  110|     25|			if(sc_asn1_decode_object_id(tag, taglen, &ef_atr.allocation_oid))
  ------------------
  |  Branch (110:7): [True: 16, False: 9]
  ------------------
  111|     25|				LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ASN1_OBJECT);
  ------------------
  |  |  164|     16|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     16|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     16|	int _ret = r; \
  |  |  |  |  155|     16|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     16|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     16|	} 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|     16|	return _ret; \
  |  |  |  |  163|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  112|     25|		}
  113|     69|	}
  114|       |
  115|    822|	tag = sc_asn1_find_tag(ctx, buf, buflen, ISO7816_TAG_II_STATUS_SW, &taglen);
  ------------------
  |  |   39|    822|#define ISO7816_TAG_II_STATUS_SW		0x82
  ------------------
  116|    822|	if (tag && taglen == 2)   {
  ------------------
  |  Branch (116:6): [True: 5, False: 817]
  |  Branch (116:13): [True: 1, False: 4]
  ------------------
  117|      1|		ef_atr.status = *(tag + 0) * 0x100 + *(tag + 1);
  118|      1|		sc_log(ctx, "EF.ATR: status word 0x%X", ef_atr.status);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  119|      1|	}
  120|       |
  121|    822|	if (!card->ef_atr)
  ------------------
  |  Branch (121:6): [True: 805, False: 17]
  ------------------
  122|    805|		card->ef_atr = calloc(1, sizeof(struct sc_ef_atr));
  123|       |
  124|    822|	if (!card->ef_atr)
  ------------------
  |  Branch (124:6): [True: 0, False: 822]
  ------------------
  125|    822|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  126|       |
  127|    822|	memcpy(card->ef_atr, &ef_atr, sizeof(struct sc_ef_atr));
  128|       |
  129|    822|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    822|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    822|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    822|	int _ret = r; \
  |  |  |  |  155|    822|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 822, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    822|		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: 822]
  |  |  |  |  ------------------
  |  |  |  |  157|    822|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    822|	} 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|    822|	return _ret; \
  |  |  |  |  163|    822|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|    822|}

sc_parse_ef_gdo:
   92|    948|{
   93|    948|	struct sc_context *ctx;
   94|    948|	struct sc_path path;
   95|    948|	struct sc_file *file;
   96|    948|	unsigned char *gdo = NULL;
   97|    948|	size_t gdo_len = 0;
   98|    948|	int r;
   99|       |
  100|    948|	if (!card)
  ------------------
  |  Branch (100:6): [True: 0, False: 948]
  ------------------
  101|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  102|       |
  103|    948|	ctx = card->ctx;
  104|       |
  105|    948|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    948|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    948|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    948|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    948|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 948]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  106|       |
  107|    948|	sc_format_path("3F002F02", &path);
  108|    948|	r = sc_select_file(card, &path, &file);
  109|    948|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot select EF(GDO) file");
  ------------------
  |  |  184|    948|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    948|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    948|	int _ret = (r); \
  |  |  |  |  178|    948|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 589, False: 359]
  |  |  |  |  ------------------
  |  |  |  |  179|    589|		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|    589|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    589|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    589|		goto err; \
  |  |  |  |  182|    589|	} \
  |  |  |  |  183|    948|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 359]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|       |
  111|    359|	if (file->size) {
  ------------------
  |  Branch (111:6): [True: 4, False: 355]
  ------------------
  112|      4|		gdo_len = file->size;
  113|    355|	} else {
  114|    355|		gdo_len = 64;
  115|    355|	}
  116|    359|	gdo = malloc(gdo_len);
  117|    359|	if (!gdo) {
  ------------------
  |  Branch (117:6): [True: 0, False: 359]
  ------------------
  118|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  119|      0|		goto err;
  120|      0|	}
  121|       |
  122|    359|	r = sc_read_binary(card, 0, gdo, gdo_len, 0);
  123|    359|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot read EF(GDO) file");
  ------------------
  |  |  184|    359|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    359|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    359|	int _ret = (r); \
  |  |  |  |  178|    359|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 15, False: 344]
  |  |  |  |  ------------------
  |  |  |  |  179|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     15|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     15|		goto err; \
  |  |  |  |  182|     15|	} \
  |  |  |  |  183|    359|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 344]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  124|       |
  125|    344|	r = sc_parse_ef_gdo_content(gdo, r, iccsn, iccsn_len, chn, chn_len);
  126|       |
  127|    948|err:
  128|    948|	sc_file_free(file);
  129|    948|	free(gdo);
  130|       |
  131|    948|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    948|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    948|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    948|	int _ret = r; \
  |  |  |  |  155|    948|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 948, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    948|		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|    615|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 615, False: 333]
  |  |  |  |  ------------------
  |  |  |  |  157|    948|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    948|	} 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|    948|	return _ret; \
  |  |  |  |  163|    948|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|    948|}
ef-gdo.c:sc_parse_ef_gdo_content:
   33|    344|{
   34|    344|	int r = SC_SUCCESS, iccsn_found = 0, chn_found = 0;
  ------------------
  |  |   28|    344|#define SC_SUCCESS				0
  ------------------
   35|    344|	const unsigned char *p = gdo;
   36|    344|	size_t left = gdo_len;
   37|       |
   38|    693|	while (left >= 2) {
  ------------------
  |  Branch (38:9): [True: 425, False: 268]
  ------------------
   39|    425|		unsigned int cla, tag;
   40|    425|		size_t tag_len;
   41|       |
   42|    425|		r = sc_asn1_read_tag(&p, left, &cla, &tag, &tag_len);
   43|    425|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    425|#define SC_SUCCESS				0
  ------------------
  |  Branch (43:7): [True: 19, False: 406]
  ------------------
   44|     19|			if (r == SC_ERROR_ASN1_END_OF_CONTENTS) {
  ------------------
  |  |   84|     19|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (44:8): [True: 8, False: 11]
  ------------------
   45|       |				/* not enough data */
   46|      8|				r = SC_SUCCESS;
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
   47|      8|			}
   48|     19|			break;
   49|     19|		}
   50|    406|		if (p == NULL) {
  ------------------
  |  Branch (50:7): [True: 57, False: 349]
  ------------------
   51|       |			/* done parsing */
   52|     57|			break;
   53|     57|		}
   54|       |
   55|    349|		if (cla == SC_ASN1_TAG_APPLICATION) {
  ------------------
  |  |  186|    349|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
  |  Branch (55:7): [True: 199, False: 150]
  ------------------
   56|    199|			switch (tag) {
  ------------------
  |  Branch (56:12): [True: 148, False: 51]
  ------------------
   57|    114|				case 0x1A:
  ------------------
  |  Branch (57:5): [True: 114, False: 85]
  ------------------
   58|    114|					iccsn_found = 1;
   59|    114|					if (iccsn && iccsn_len) {
  ------------------
  |  Branch (59:10): [True: 114, False: 0]
  |  Branch (59:19): [True: 114, False: 0]
  ------------------
   60|    114|						memcpy(iccsn, p, MIN(tag_len, *iccsn_len));
  ------------------
  |  |   69|    114|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 73, False: 41]
  |  |  ------------------
  ------------------
   61|    114|						*iccsn_len = MIN(tag_len, *iccsn_len);
  ------------------
  |  |   69|    114|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 73, False: 41]
  |  |  ------------------
  ------------------
   62|    114|					}
   63|    114|					break;
   64|     34|				case 0x1F20:
  ------------------
  |  Branch (64:5): [True: 34, False: 165]
  ------------------
   65|     34|					chn_found = 1;
   66|     34|					if (chn && chn_len) {
  ------------------
  |  Branch (66:10): [True: 0, False: 34]
  |  Branch (66:17): [True: 0, False: 0]
  ------------------
   67|      0|						memcpy(chn, p, MIN(tag_len, *chn_len));
  ------------------
  |  |   69|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   68|      0|						*chn_len = MIN(tag_len, *chn_len);
  ------------------
  |  |   69|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
   69|      0|					}
   70|     34|					break;
   71|    199|			}
   72|    199|		}
   73|       |
   74|    349|		p += tag_len;
   75|    349|		left = gdo_len - (p - gdo);
   76|    349|	}
   77|       |
   78|    344|	if (!iccsn_found && iccsn_len)
  ------------------
  |  Branch (78:6): [True: 273, False: 71]
  |  Branch (78:22): [True: 273, False: 0]
  ------------------
   79|    273|		*iccsn_len = 0;
   80|    344|	if (!chn_found && chn_len)
  ------------------
  |  Branch (80:6): [True: 338, False: 6]
  |  Branch (80:20): [True: 0, False: 338]
  ------------------
   81|      0|		*chn_len = 0;
   82|       |
   83|    344|	return r;
   84|    344|}

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

gp_select_aid:
   50|  1.59k|{
   51|  1.59k|	int rv;
   52|  1.59k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.59k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.59k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.59k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.59k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.59k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|  1.59k|	rv = iso7816_select_aid(card, aid->value, aid->len, NULL, NULL);
   54|  1.59k|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|  1.59k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.59k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.59k|	int _ret = r; \
  |  |  |  |  155|  1.59k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.59k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.59k|		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|     73|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 73, False: 1.52k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.59k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.59k|	} 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|  1.59k|	return _ret; \
  |  |  |  |  163|  1.59k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|  1.59k|}
gp_select_card_manager:
   60|  1.57k|{
   61|  1.57k|	int rv;
   62|       |
   63|  1.57k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.57k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.57k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.57k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.57k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.57k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|  1.57k|	rv = gp_select_aid(card, &gp_card_manager);
   65|  1.57k|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|  1.57k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.57k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.57k|	int _ret = r; \
  |  |  |  |  155|  1.57k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.57k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.57k|		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|     54|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 54, False: 1.52k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.57k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.57k|	} 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|  1.57k|	return _ret; \
  |  |  |  |  163|  1.57k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   66|  1.57k|}
gp_select_isd_rid:
   71|     21|{
   72|     21|	int rv;
   73|       |
   74|     21|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     21|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     21|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     21|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     21|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   75|     21|	rv = gp_select_aid(card, &gp_isd_rid);
   76|     21|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|     21|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     21|	int _ret = r; \
  |  |  |  |  155|     21|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     21|		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|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 19, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     21|	} 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|     21|	return _ret; \
  |  |  |  |  163|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   77|     21|}
gp_get_cplc_data:
   82|    722|{
   83|    722|	size_t len = sizeof(global_platform_cplc_data_t);
   84|    722|	u8 *receive_buf = (u8 *)cplc_data;
   85|    722|	struct sc_apdu apdu;
   86|    722|	int rc;
   87|       |
   88|    722|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, ISO7816_INS_GET_DATA, 0x9f, 0x7f);
  ------------------
  |  |  292|    722|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
              	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, ISO7816_INS_GET_DATA, 0x9f, 0x7f);
  ------------------
  |  |   34|    722|#define ISO7816_INS_GET_DATA    0xca
  ------------------
   89|    722|	apdu.cla = GLOBAL_PLATFORM_CLASS;
  ------------------
  |  |   31|    722|#define GLOBAL_PLATFORM_CLASS   0x80
  ------------------
   90|    722|	apdu.resp = receive_buf;
   91|    722|	apdu.resplen = len;
   92|    722|	apdu.le = len;
   93|       |
   94|    722|	rc = sc_transmit_apdu(card, &apdu);
   95|    722|	if (rc < 0)
  ------------------
  |  Branch (95:6): [True: 5, False: 717]
  ------------------
   96|    722|		LOG_FUNC_RETURN(card->ctx, rc);
  ------------------
  |  |  164|      5|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      5|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      5|	int _ret = r; \
  |  |  |  |  155|      5|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      5|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      5|	} 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|      5|	return _ret; \
  |  |  |  |  163|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   97|       |
   98|    717|	rc = sc_check_sw(card, apdu.sw1, apdu.sw2);
   99|    717|	if (rc < 0)
  ------------------
  |  Branch (99:6): [True: 8, False: 709]
  ------------------
  100|    717|		LOG_FUNC_RETURN(card->ctx, rc);
  ------------------
  |  |  164|      8|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      8|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      8|	int _ret = r; \
  |  |  |  |  155|      8|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      8|	} 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|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|       |
  102|       |	/* We expect this will fill the whole structure in the argument.
  103|       |	 * If we got something else, report error */
  104|    709|	if ((size_t)apdu.resplen < sizeof(global_platform_cplc_data_t)) {
  ------------------
  |  Branch (104:6): [True: 2, False: 707]
  ------------------
  105|      2|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_CORRUPTED_DATA);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  106|      2|	}
  107|    707|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|    707|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    707|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    707|	int _ret = r; \
  |  |  |  |  155|    707|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 707]
  |  |  |  |  ------------------
  |  |  |  |  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|    707|	} else { \
  |  |  |  |  159|    707|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    707|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    707|	} \
  |  |  |  |  162|    707|	return _ret; \
  |  |  |  |  163|    707|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  108|    707|}

iasecc_sdo_free_fields:
  150|    258|{
  151|    258|	if (sdo == NULL) {
  ------------------
  |  Branch (151:6): [True: 0, False: 258]
  ------------------
  152|      0|		return;
  153|      0|	}
  154|       |
  155|    258|	free(sdo->docp.tries_maximum.value);
  156|    258|	free(sdo->docp.tries_remaining.value);
  157|    258|	free(sdo->docp.usage_remaining.value);
  158|    258|	free(sdo->docp.non_repudiation.value);
  159|    258|	free(sdo->docp.acls_contact.value);
  160|    258|	free(sdo->docp.acls_contactless.value);
  161|    258|	free(sdo->docp.size.value);
  162|    258|	free(sdo->docp.name.value);
  163|    258|	free(sdo->docp.issuer_data.value);
  164|       |
  165|    258|	if (sdo->sdo_class == IASECC_SDO_CLASS_RSA_PUBLIC)   {
  ------------------
  |  |  101|    258|#define IASECC_SDO_CLASS_RSA_PUBLIC	0x20
  ------------------
  |  Branch (165:6): [True: 0, False: 258]
  ------------------
  166|      0|		free(sdo->data.pub_key.n.value);
  167|      0|		free(sdo->data.pub_key.e.value);
  168|      0|		free(sdo->data.pub_key.compulsory.value);
  169|      0|		free(sdo->data.pub_key.chr.value);
  170|      0|		free(sdo->data.pub_key.cha.value);
  171|      0|	}
  172|    258|	else if (sdo->sdo_class == IASECC_SDO_CLASS_RSA_PRIVATE)   {
  ------------------
  |  |  100|    258|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  |  Branch (172:11): [True: 0, False: 258]
  ------------------
  173|      0|		free(sdo->data.prv_key.p.value);
  174|      0|		free(sdo->data.prv_key.q.value);
  175|      0|		free(sdo->data.prv_key.iqmp.value);
  176|      0|		free(sdo->data.prv_key.dmp1.value);
  177|      0|		free(sdo->data.prv_key.dmq1.value);
  178|      0|		free(sdo->data.prv_key.compulsory.value);
  179|      0|	}
  180|    258|	else if (sdo->sdo_class == IASECC_SDO_CLASS_CHV)   {
  ------------------
  |  |   98|    258|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
  |  Branch (180:11): [True: 158, False: 100]
  ------------------
  181|    158|		free(sdo->data.chv.size_max.value);
  182|    158|		free(sdo->data.chv.size_min.value);
  183|    158|		free(sdo->data.chv.value.value);
  184|    158|	}
  185|       |	/* invalidate all the other members too */
  186|    258|	memset(sdo, 0, sizeof(struct iasecc_sdo));
  187|    258|}
iasecc_se_get_crt:
  254|     14|{
  255|     14|	struct sc_context *ctx = card->ctx;
  256|     14|	int ii;
  257|       |
  258|     14|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     14|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     14|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     14|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     14|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  259|     14|	if (!se || !crt)
  ------------------
  |  Branch (259:6): [True: 0, False: 14]
  |  Branch (259:13): [True: 0, False: 14]
  ------------------
  260|     14|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  261|     14|	sc_log(ctx, "CRT search template: %X:%X:%X, refs %X:%X:...",
  ------------------
  |  |   71|     14|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  262|     14|			crt->tag, crt->algo, crt->usage, crt->refs[0], crt->refs[1]);
  263|       |
  264|     84|	for (ii=0; ii<SC_MAX_CRTS_IN_SE && se->crts[ii].tag; ii++)   {
  ------------------
  |  |   50|    168|#define SC_MAX_CRTS_IN_SE		12
  ------------------
  |  Branch (264:13): [True: 80, False: 4]
  |  Branch (264:37): [True: 70, False: 10]
  ------------------
  265|     70|		if (crt->tag != se->crts[ii].tag)
  ------------------
  |  Branch (265:7): [True: 60, False: 10]
  ------------------
  266|     60|			continue;
  267|     10|		if (crt->algo && crt->algo != se->crts[ii].algo)
  ------------------
  |  Branch (267:7): [True: 0, False: 10]
  |  Branch (267:20): [True: 0, False: 0]
  ------------------
  268|      0|			continue;
  269|     10|		if (crt->usage && crt->usage != se->crts[ii].usage)
  ------------------
  |  Branch (269:7): [True: 10, False: 0]
  |  Branch (269:21): [True: 10, False: 0]
  ------------------
  270|     10|			continue;
  271|      0|		if (crt->refs[0] && crt->refs[0] != se->crts[ii].refs[0])
  ------------------
  |  Branch (271:7): [True: 0, False: 0]
  |  Branch (271:23): [True: 0, False: 0]
  ------------------
  272|      0|			continue;
  273|       |
  274|      0|		memcpy(crt, &se->crts[ii], sizeof(*crt));
  275|       |
  276|      0|		sc_log(ctx, "iasecc_se_get_crt() found CRT with refs %X:%X:...",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  277|      0|				se->crts[ii].refs[0], se->crts[ii].refs[1]);
  278|      0|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  279|      0|	}
  280|       |
  281|     14|	sc_log(ctx, "iasecc_se_get_crt() CRT is not found");
  ------------------
  |  |   71|     14|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  282|     14|	return SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|     14|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  283|     14|}
iasecc_se_parse:
  317|    119|{
  318|    119|	struct sc_context *ctx = card->ctx;
  319|    119|	size_t size, offs;
  320|    119|	int size_size;
  321|    119|	int rv;
  322|       |
  323|    119|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    119|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    119|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    119|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    119|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 119]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  324|    119|	sc_log(ctx, "data_len %zu", data_len);
  ------------------
  |  |   71|    119|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  325|       |
  326|    119|	if (data_len < 1)
  ------------------
  |  Branch (326:6): [True: 8, False: 111]
  ------------------
  327|    119|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      8|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      8|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      8|	int _ret = r; \
  |  |  |  |  155|      8|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      8|	} 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|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  328|       |
  329|    111|	if (*data == IASECC_SDO_TEMPLATE_TAG)   {
  ------------------
  |  |   29|    111|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
  |  Branch (329:6): [True: 43, False: 68]
  ------------------
  330|     43|		size_size = iasecc_parse_size(data + 1, data_len - 1, &size);
  331|     43|		LOG_TEST_RET(ctx, size_size, "parse error: invalid size data of IASECC_SDO_TEMPLATE");
  ------------------
  |  |  174|     43|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     43|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     43|	int _ret = (r); \
  |  |  |  |  168|     43|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 40]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|     43|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 40]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  332|       |
  333|     40|		if (data_len < size + size_size + 1)
  ------------------
  |  Branch (333:7): [True: 9, False: 31]
  ------------------
  334|     40|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      9|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      9|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      9|	int _ret = r; \
  |  |  |  |  155|      9|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      9|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      9|	} 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|      9|	return _ret; \
  |  |  |  |  163|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  335|       |
  336|     31|		data += size_size + 1;
  337|     31|		data_len = size;
  338|     31|		sc_log(ctx, "IASECC_SDO_TEMPLATE: size %zu, size_size %d", size, size_size);
  ------------------
  |  |   71|     31|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  339|       |
  340|     31|		if (data_len < 3)
  ------------------
  |  Branch (340:7): [True: 14, False: 17]
  ------------------
  341|     31|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} 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|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  342|       |
  343|     17|		if (*data != IASECC_SDO_TAG_HEADER)
  ------------------
  |  |   27|     17|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
  |  Branch (343:7): [True: 7, False: 10]
  ------------------
  344|     17|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      7|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      7|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      7|	int _ret = r; \
  |  |  |  |  155|      7|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      7|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      7|	} 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|      7|	return _ret; \
  |  |  |  |  163|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  345|       |
  346|     10|		if ((*(data + 1) & 0x7F) != IASECC_SDO_CLASS_SE)
  ------------------
  |  |  102|     10|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
  |  Branch (346:7): [True: 5, False: 5]
  ------------------
  347|     10|			 LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      5|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      5|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      5|	int _ret = r; \
  |  |  |  |  155|      5|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      5|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      5|	} 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|      5|	return _ret; \
  |  |  |  |  163|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  348|       |
  349|      5|		size_size = iasecc_parse_size(data + 3, data_len - 3, &size);
  350|      5|		LOG_TEST_RET(ctx, size_size, "parse error: invalid SDO SE data size");
  ------------------
  |  |  174|      5|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      5|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      5|	int _ret = (r); \
  |  |  |  |  168|      5|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|       |
  352|      3|		if (data_len != size + size_size + 3)
  ------------------
  |  Branch (352:7): [True: 2, False: 1]
  ------------------
  353|      3|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalid SDO SE data size");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  354|       |
  355|      1|		data += 3 + size_size;
  356|      1|		data_len = size;
  357|      1|		sc_log(ctx, "IASECC_SDO_TEMPLATE SE: size %zu, size_size %d", size, size_size);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  358|      1|	}
  359|       |
  360|     69|	if (*data != IASECC_SDO_CLASS_SE)   {
  ------------------
  |  |  102|     69|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
  |  Branch (360:6): [True: 14, False: 55]
  ------------------
  361|     14|		sc_log(ctx, "Invalid SE tag 0x%X; data length %zu", *data, data_len);
  ------------------
  |  |   71|     14|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  362|     14|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} 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|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|     14|	}
  364|       |
  365|     55|	size_size = iasecc_parse_size(data + 1, data_len - 1, &size);
  366|     55|	LOG_TEST_RET(ctx, size_size, "parse error: invalid size data");
  ------------------
  |  |  174|     55|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     55|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     55|	int _ret = (r); \
  |  |  |  |  168|     55|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 52]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|     55|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 52]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  367|       |
  368|     52|	if (data_len != size + size_size + 1)
  ------------------
  |  Branch (368:6): [True: 6, False: 46]
  ------------------
  369|     52|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalid SE data size");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  370|       |
  371|     46|	offs = 1 + size_size;
  372|    621|	for (; offs < data_len;)   {
  ------------------
  |  Branch (372:9): [True: 607, False: 14]
  ------------------
  373|    607|		rv = iasecc_crt_parse(card, data + offs, data_len - offs, se);
  374|    607|		LOG_TEST_RET(ctx, rv, "parse error: invalid SE data");
  ------------------
  |  |  174|    607|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    607|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    607|	int _ret = (r); \
  |  |  |  |  168|    607|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 32, False: 575]
  |  |  |  |  ------------------
  |  |  |  |  169|     32|		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|     32|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     32|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     32|		return _ret; \
  |  |  |  |  172|     32|	} \
  |  |  |  |  173|    607|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 575]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  375|       |
  376|    575|		offs += rv;
  377|    575|	}
  378|       |
  379|     14|	if (offs != data_len)
  ------------------
  |  Branch (379:6): [True: 0, False: 14]
  ------------------
  380|     14|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: not totally parsed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|       |
  382|     14|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		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: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} 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|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  383|     14|}
iasecc_sdo_parse:
  755|    264|{
  756|    264|	struct sc_context *ctx = card->ctx;
  757|    264|	size_t size, offs;
  758|    264|	int size_size;
  759|    264|	int rv;
  760|       |
  761|    264|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    264|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    264|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    264|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    264|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 264]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  762|       |
  763|    264|	if (data == NULL || data_len < 2)
  ------------------
  |  Branch (763:6): [True: 0, False: 264]
  |  Branch (763:22): [True: 30, False: 234]
  ------------------
  764|    264|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|     30|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     30|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     30|	int _ret = r; \
  |  |  |  |  155|     30|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 30, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     30|		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|     30|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 30, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     30|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     30|	} 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|     30|	return _ret; \
  |  |  |  |  163|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  765|       |
  766|    234|	if (*data == IASECC_SDO_TEMPLATE_TAG)   {
  ------------------
  |  |   29|    234|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
  |  Branch (766:6): [True: 34, False: 200]
  ------------------
  767|     34|		size_size = iasecc_parse_size(data + 1, data_len - 1, &size);
  768|     34|		LOG_TEST_RET(ctx, size_size, "parse error: invalid size data of IASECC_SDO_TEMPLATE");
  ------------------
  |  |  174|     34|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     34|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     34|	int _ret = (r); \
  |  |  |  |  168|     34|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  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|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  769|       |
  770|     32|		if (data_len < (size_t)(size_size + 1)) {
  ------------------
  |  Branch (770:7): [True: 0, False: 32]
  ------------------
  771|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  772|      0|		}
  773|     32|		data += size_size + 1;
  774|     32|		data_len -= (size_size + 1);
  775|     32|		if (size > data_len) {
  ------------------
  |  Branch (775:7): [True: 21, False: 11]
  ------------------
  776|     21|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|     21|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     21|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     21|	int _ret = r; \
  |  |  |  |  155|     21|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     21|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     21|	} 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|     21|	return _ret; \
  |  |  |  |  163|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  777|     21|		}
  778|     11|		data_len = size;
  779|     11|		sc_log(ctx, "IASECC_SDO_TEMPLATE: size %zu, size_size %d", size, size_size);
  ------------------
  |  |   71|     11|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  780|     11|	}
  781|       |
  782|    211|	if (data_len < 4 || *data != IASECC_SDO_TAG_HEADER)
  ------------------
  |  |   27|    207|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
  |  Branch (782:6): [True: 4, False: 207]
  |  Branch (782:22): [True: 28, False: 179]
  ------------------
  783|    211|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|     32|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     32|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     32|	int _ret = r; \
  |  |  |  |  155|     32|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     32|		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|     32|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     32|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     32|	} 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|     32|	return _ret; \
  |  |  |  |  163|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  784|       |
  785|    179|	if (sdo->sdo_class != (*(data + 1) & 0x7F))
  ------------------
  |  Branch (785:6): [True: 1, False: 178]
  ------------------
  786|    179|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  787|       |
  788|    178|	if (sdo->sdo_ref != (*(data + 2) & 0x3F))
  ------------------
  |  Branch (788:6): [True: 1, False: 177]
  ------------------
  789|    178|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  790|       |
  791|    177|	size_size = iasecc_parse_size(data + 3, data_len - 3, &size);
  792|    177|	LOG_TEST_RET(ctx, size_size, "parse error: invalid size data");
  ------------------
  |  |  174|    177|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    177|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    177|	int _ret = (r); \
  |  |  |  |  168|    177|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 175]
  |  |  |  |  ------------------
  |  |  |  |  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|    177|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 175]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  793|       |
  794|    175|	if (data_len != size + size_size + 3)
  ------------------
  |  Branch (794:6): [True: 16, False: 159]
  ------------------
  795|    175|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalid SDO data size");
  ------------------
  |  |  174|     16|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     16|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     16|	int _ret = (r); \
  |  |  |  |  168|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     16|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     16|		return _ret; \
  |  |  |  |  172|     16|	} \
  |  |  |  |  173|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  796|       |
  797|    159|	sc_log(ctx, "sz %zu, sz_size %d", size, size_size);
  ------------------
  |  |   71|    159|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  798|       |
  799|    159|	offs = 3 + size_size;
  800|    263|	for (; offs < data_len;)   {
  ------------------
  |  Branch (800:9): [True: 258, False: 5]
  ------------------
  801|    258|		rv = iasecc_sdo_parse_data(card, data + offs, data_len - offs, sdo);
  802|    258|		if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    258|#define SC_SUCCESS				0
  ------------------
  |  Branch (802:7): [True: 258, False: 0]
  ------------------
  803|    258|			iasecc_sdo_free_fields(card, sdo);
  804|    258|			LOG_TEST_RET(ctx, rv, "parse error: invalid SDO data");
  ------------------
  |  |  174|    258|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    258|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    258|	int _ret = (r); \
  |  |  |  |  168|    258|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 154, False: 104]
  |  |  |  |  ------------------
  |  |  |  |  169|    154|		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|    154|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    154|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    154|		return _ret; \
  |  |  |  |  172|    154|	} \
  |  |  |  |  173|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 104]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  805|    258|		}
  806|       |
  807|    104|		offs += rv;
  808|    104|	}
  809|       |
  810|      5|	if (offs != data_len)
  ------------------
  |  Branch (810:6): [True: 0, False: 5]
  ------------------
  811|      5|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: not totally parsed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  812|       |
  813|      5|	sc_log(ctx, "docp.acls_contact.size %zu, docp.size.size %zu",
  ------------------
  |  |   71|      5|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  814|      5|			sdo->docp.acls_contact.size, sdo->docp.size.size);
  815|       |
  816|      5|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      5|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      5|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      5|	int _ret = r; \
  |  |  |  |  155|      5|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      5|		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: 5]
  |  |  |  |  ------------------
  |  |  |  |  157|      5|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      5|	} 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|      5|	return _ret; \
  |  |  |  |  163|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  817|      5|}
iasecc_docp_copy:
 1327|     14|{
 1328|     14|	int rv;
 1329|       |
 1330|     14|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     14|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     14|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     14|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     14|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1331|     14|	if (!in || !out)
  ------------------
  |  Branch (1331:6): [True: 0, False: 14]
  |  Branch (1331:13): [True: 0, False: 14]
  ------------------
 1332|     14|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1333|       |
 1334|     14|	memset(out, 0, sizeof(struct iasecc_sdo_docp));
 1335|       |
 1336|     14|	rv = iasecc_tlv_copy(ctx, &in->name, &out->name);
 1337|     14|	LOG_TEST_RET(ctx, rv, "TLV copy error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1338|       |
 1339|     14|	rv = iasecc_tlv_copy(ctx, &in->tries_maximum, &out->tries_maximum);
 1340|     14|	LOG_TEST_RET(ctx, rv, "TLV copy error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1341|       |
 1342|     14|	rv = iasecc_tlv_copy(ctx, &in->tries_remaining, &out->tries_remaining);
 1343|     14|	LOG_TEST_RET(ctx, rv, "TLV copy error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1344|       |
 1345|     14|	rv = iasecc_tlv_copy(ctx, &in->usage_maximum, &out->usage_maximum);
 1346|     14|	LOG_TEST_RET(ctx, rv, "TLV copy error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1347|       |
 1348|     14|	rv = iasecc_tlv_copy(ctx, &in->usage_remaining, &out->usage_remaining);
 1349|     14|	LOG_TEST_RET(ctx, rv, "TLV copy error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1350|       |
 1351|     14|	rv = iasecc_tlv_copy(ctx, &in->non_repudiation, &out->non_repudiation);
 1352|     14|	LOG_TEST_RET(ctx, rv, "TLV copy error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1353|       |
 1354|     14|	rv = iasecc_tlv_copy(ctx, &in->size, &out->size);
 1355|     14|	LOG_TEST_RET(ctx, rv, "TLV copy error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1356|       |
 1357|     14|	rv = iasecc_tlv_copy(ctx, &in->acls_contact, &out->acls_contact);
 1358|     14|	LOG_TEST_RET(ctx, rv, "TLV copy error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1359|       |
 1360|     14|	rv = iasecc_tlv_copy(ctx, &in->acls_contactless, &out->acls_contactless);
 1361|     14|	LOG_TEST_RET(ctx, rv, "TLV copy error");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  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|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1362|       |
 1363|     14|	out->amb = in->amb;
 1364|     14|	memcpy(out->scbs, in->scbs, sizeof(out->scbs));
 1365|       |
 1366|     14|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		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: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} 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|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1367|     14|}
iasecc-sdo.c:iasecc_parse_acls:
   44|     47|{
   45|     47|	struct sc_context *ctx = card->ctx;
   46|     47|	struct iasecc_extended_tlv *acls = &docp->acls_contact;
   47|     47|	int ii;
   48|     47|	size_t offs;
   49|     47|	unsigned char mask = 0x40;
   50|       |
   51|     47|	if (flags)
  ------------------
  |  Branch (51:6): [True: 0, False: 47]
  ------------------
   52|      0|		acls = &docp->acls_contactless;
   53|       |
   54|     47|	if (!acls->size)
  ------------------
  |  Branch (54:6): [True: 3, False: 44]
  ------------------
   55|     47|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} 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|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|       |
   57|     44|	docp->amb = *(acls->value + 0);
   58|     44|	memset(docp->scbs, 0xFF, sizeof(docp->scbs));
   59|    327|	for (ii=0, offs = 1; ii<7; ii++, mask >>= 1)
  ------------------
  |  Branch (59:23): [True: 289, False: 38]
  ------------------
   60|    289|		if (mask & docp->amb) {
  ------------------
  |  Branch (60:7): [True: 21, False: 268]
  ------------------
   61|     21|			if (offs >= acls->size) {
  ------------------
  |  Branch (61:8): [True: 6, False: 15]
  ------------------
   62|      6|				LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   63|      6|			}
   64|     15|			docp->scbs[ii] = *(acls->value + offs++);
   65|     15|		}
   66|       |
   67|     38|	sc_log(ctx, "iasecc_parse_docp() SCBs %02X:%02X:%02X:%02X:%02X:%02X:%02X",
  ------------------
  |  |   71|     38|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   68|     38|			docp->scbs[0],docp->scbs[1],docp->scbs[2],docp->scbs[3],
   69|     38|			docp->scbs[4],docp->scbs[5],docp->scbs[6]);
   70|     38|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     38|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     38|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     38|	int _ret = r; \
  |  |  |  |  155|     38|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 38, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     38|		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: 38]
  |  |  |  |  ------------------
  |  |  |  |  157|     38|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     38|	} 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|     38|	return _ret; \
  |  |  |  |  163|     38|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   71|     38|}
iasecc-sdo.c:iasecc_crt_parse:
  200|    607|{
  201|    607|	struct sc_context *ctx = card->ctx;
  202|    607|	struct sc_crt crt;
  203|    607|	int ii, offs, len, parsed_len = -1;
  204|       |
  205|    607|	sc_log(ctx, "iasecc_crt_parse(0x%X) called", *data);
  ------------------
  |  |   71|    607|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  206|       |
  207|    607|	if (data_len < 2)
  ------------------
  |  Branch (207:6): [True: 1, False: 606]
  ------------------
  208|    607|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  209|       |
  210|    606|	memset(&crt, 0, sizeof(crt));
  211|    606|	crt.tag = *(data + 0);
  212|    606|	len = *(data + 1);
  213|       |
  214|    751|	for(offs = 2; offs < len + 2; offs += 3)   {
  ------------------
  |  Branch (214:16): [True: 175, False: 576]
  ------------------
  215|    175|		if ((size_t) offs + 2 >= data_len)
  ------------------
  |  Branch (215:7): [True: 5, False: 170]
  ------------------
  216|    175|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      5|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      5|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      5|	int _ret = r; \
  |  |  |  |  155|      5|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      5|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      5|	} 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|      5|	return _ret; \
  |  |  |  |  163|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|    170|		sc_log(ctx, "iasecc_crt_parse(0x%X) CRT %X -> %X", *data, *(data + offs), *(data + offs + 2));
  ------------------
  |  |   71|    170|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  218|    170|		if (*(data + offs) == IASECC_CRT_TAG_USAGE)   {
  ------------------
  |  |  111|    170|#define IASECC_CRT_TAG_USAGE		0x95
  ------------------
  |  Branch (218:7): [True: 85, False: 85]
  ------------------
  219|     85|			crt.usage = *(data + offs + 2);
  220|     85|		}
  221|     85|		else if (*(data + offs) == IASECC_CRT_TAG_REFERENCE)   {
  ------------------
  |  |  112|     85|#define IASECC_CRT_TAG_REFERENCE	0x83
  ------------------
  |  Branch (221:12): [True: 60, False: 25]
  ------------------
  222|     60|			int nn_refs = sizeof(crt.refs) / sizeof(crt.refs[0]);
  223|       |
  224|    225|			for (ii=0; ii<nn_refs && crt.refs[ii]; ii++)
  ------------------
  |  Branch (224:15): [True: 223, False: 2]
  |  Branch (224:29): [True: 165, False: 58]
  ------------------
  225|    165|				;
  226|     60|			if (ii == nn_refs)
  ------------------
  |  Branch (226:8): [True: 2, False: 58]
  ------------------
  227|     60|				LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  228|       |
  229|     58|			crt.refs[ii] = *(data + offs + 2);
  230|     58|		}
  231|     25|		else if (*(data + offs) == IASECC_CRT_TAG_ALGO)   {
  ------------------
  |  |  113|     25|#define IASECC_CRT_TAG_ALGO		0x80
  ------------------
  |  Branch (231:12): [True: 2, False: 23]
  ------------------
  232|      2|			crt.algo = *(data + offs + 2);
  233|      2|		}
  234|     23|		else   {
  235|     23|			LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     23|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     23|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     23|	int _ret = r; \
  |  |  |  |  155|     23|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     23|		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|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 23, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     23|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     23|	} 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|     23|	return _ret; \
  |  |  |  |  163|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|     23|		}
  237|    170|	}
  238|       |
  239|  1.90k|	for (ii=0; ii<SC_MAX_CRTS_IN_SE; ii++)
  ------------------
  |  |   50|  1.90k|#define SC_MAX_CRTS_IN_SE		12
  ------------------
  |  Branch (239:13): [True: 1.90k, False: 1]
  ------------------
  240|  1.90k|		if (!se->crts[ii].tag)
  ------------------
  |  Branch (240:7): [True: 575, False: 1.32k]
  ------------------
  241|    575|			break;
  242|       |
  243|    576|	if (ii==SC_MAX_CRTS_IN_SE)
  ------------------
  |  |   50|    576|#define SC_MAX_CRTS_IN_SE		12
  ------------------
  |  Branch (243:6): [True: 1, False: 575]
  ------------------
  244|    576|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "iasecc_crt_parse() error: too much CRTs in SE");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  245|       |
  246|    575|	memcpy(&se->crts[ii], &crt, sizeof(crt));
  247|    575|	parsed_len = len + 2;
  248|    575|	LOG_FUNC_RETURN(ctx, parsed_len);
  ------------------
  |  |  164|    575|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    575|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    575|	int _ret = r; \
  |  |  |  |  155|    575|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 575]
  |  |  |  |  ------------------
  |  |  |  |  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|    575|	} else { \
  |  |  |  |  159|    575|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    575|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    575|	} \
  |  |  |  |  162|    575|	return _ret; \
  |  |  |  |  163|    575|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  249|    575|}
iasecc-sdo.c:iasecc_parse_size:
  388|  1.09k|{
  389|  1.09k|	if (data_len > 0 && *data < 0x80) {
  ------------------
  |  Branch (389:6): [True: 1.09k, False: 7]
  |  Branch (389:22): [True: 980, False: 111]
  ------------------
  390|    980|		*out = *data;
  391|    980|		return 1;
  392|    980|	}
  393|    118|	else if (data_len > 1 && *data == 0x81) {
  ------------------
  |  Branch (393:11): [True: 107, False: 11]
  |  Branch (393:27): [True: 35, False: 72]
  ------------------
  394|     35|		*out = *(data + 1);
  395|     35|		return 2;
  396|     35|	}
  397|     83|	else if (data_len > 2 && *data == 0x82) {
  ------------------
  |  Branch (397:11): [True: 70, False: 13]
  |  Branch (397:27): [True: 51, False: 19]
  ------------------
  398|     51|		*out = *(data + 1) * 0x100 + *(data + 2);
  399|     51|		return 3;
  400|     51|	}
  401|       |
  402|     32|	return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     32|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  403|  1.09k|}
iasecc-sdo.c:iasecc_sdo_parse_data:
  667|    258|{
  668|    258|	struct sc_context *ctx = card->ctx;
  669|    258|	struct iasecc_extended_tlv tlv;
  670|    258|	int tlv_size, rv;
  671|       |
  672|    258|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    258|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    258|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    258|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    258|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  673|    258|	sc_log(ctx, "iasecc_sdo_parse_data() class %X; ref %X", sdo->sdo_class, sdo->sdo_ref);
  ------------------
  |  |   71|    258|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  674|       |
  675|    258|	tlv_size = iasecc_parse_get_tlv(card, data, data_len, &tlv);
  676|    258|	LOG_TEST_RET(ctx, tlv_size, "parse error: get TLV");
  ------------------
  |  |  174|    258|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    258|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    258|	int _ret = (r); \
  |  |  |  |  168|    258|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 246]
  |  |  |  |  ------------------
  |  |  |  |  169|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     12|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     12|		return _ret; \
  |  |  |  |  172|     12|	} \
  |  |  |  |  173|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 246]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  677|       |
  678|    246|	sc_log(ctx, "iasecc_sdo_parse_data() tlv.tag 0x%X", tlv.tag);
  ------------------
  |  |   71|    246|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  679|    246|	if (tlv.tag == IASECC_DOCP_TAG)   {
  ------------------
  |  |   31|    246|#define IASECC_DOCP_TAG				0xA0
  ------------------
  |  Branch (679:6): [True: 79, False: 167]
  ------------------
  680|     79|		sc_log(ctx, "iasecc_sdo_parse_data() parse IASECC_DOCP_TAG: 0x%X; size %zu",
  ------------------
  |  |   71|     79|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  681|     79|				tlv.tag, tlv.size);
  682|     79|		rv = iasecc_parse_docp(card, tlv.value, tlv.size, sdo);
  683|     79|		sc_log(ctx, "iasecc_sdo_parse_data() parsed IASECC_DOCP_TAG rv %i", rv);
  ------------------
  |  |   71|     79|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  684|     79|		free(tlv.value);
  685|     79|		LOG_TEST_RET(ctx, rv, "parse error: cannot parse DOCP");
  ------------------
  |  |  174|     79|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     79|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     79|	int _ret = (r); \
  |  |  |  |  168|     79|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 69, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  169|     69|		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|     69|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     69|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     69|		return _ret; \
  |  |  |  |  172|     69|	} \
  |  |  |  |  173|     79|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  686|     79|	}
  687|    167|	else if (tlv.tag == IASECC_DOCP_TAG_NON_REPUDIATION)   {
  ------------------
  |  |   37|    167|#define IASECC_DOCP_TAG_NON_REPUDIATION 		0x9E
  ------------------
  |  Branch (687:11): [True: 14, False: 153]
  ------------------
  688|     14|		free(sdo->docp.non_repudiation.value);
  689|     14|		sdo->docp.non_repudiation = tlv;
  690|     14|	}
  691|    153|	else if (tlv.tag == IASECC_DOCP_TAG_USAGE_REMAINING)   {
  ------------------
  |  |   36|    153|#define IASECC_DOCP_TAG_USAGE_REMAINING		0x9D
  ------------------
  |  Branch (691:11): [True: 21, False: 132]
  ------------------
  692|     21|		free(sdo->docp.usage_remaining.value);
  693|     21|		sdo->docp.usage_remaining = tlv;
  694|     21|	}
  695|    132|	else if (tlv.tag == IASECC_DOCP_TAG_TRIES_MAXIMUM)   {
  ------------------
  |  |   33|    132|#define IASECC_DOCP_TAG_TRIES_MAXIMUM		0x9A
  ------------------
  |  Branch (695:11): [True: 32, False: 100]
  ------------------
  696|     32|		free(sdo->docp.tries_maximum.value);
  697|     32|		sdo->docp.tries_maximum = tlv;
  698|     32|	}
  699|    100|	else if (tlv.tag == IASECC_DOCP_TAG_TRIES_REMAINING)   {
  ------------------
  |  |   34|    100|#define IASECC_DOCP_TAG_TRIES_REMAINING		0x9B
  ------------------
  |  Branch (699:11): [True: 20, False: 80]
  ------------------
  700|     20|		free(sdo->docp.tries_remaining.value);
  701|     20|		sdo->docp.tries_remaining = tlv;
  702|     20|	}
  703|     80|	else if (tlv.tag == IASECC_SDO_CHV_TAG)   {
  ------------------
  |  |   63|     80|#define IASECC_SDO_CHV_TAG		0x7F41
  ------------------
  |  Branch (703:11): [True: 33, False: 47]
  ------------------
  704|     33|		if (sdo->sdo_class != IASECC_SDO_CLASS_CHV) {
  ------------------
  |  |   98|     33|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
  |  Branch (704:7): [True: 1, False: 32]
  ------------------
  705|      1|			free(tlv.value);
  706|      1|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: IASECC_SDO_CHV_TAG tag in non User CHV SDO");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  707|      1|		}
  708|       |
  709|     32|		rv = iasecc_parse_chv(card, tlv.value, tlv.size, &sdo->data.chv);
  710|     32|		free(tlv.value);
  711|     32|		LOG_TEST_RET(ctx, rv, "parse error: cannot parse SDO CHV data");
  ------------------
  |  |  174|     32|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     32|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     32|	int _ret = (r); \
  |  |  |  |  168|     32|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 25, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  169|     25|		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|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     25|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     25|		return _ret; \
  |  |  |  |  172|     25|	} \
  |  |  |  |  173|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  712|     32|	}
  713|     47|	else if (tlv.tag == IASECC_SDO_PUBKEY_TAG)   {
  ------------------
  |  |   76|     47|#define IASECC_SDO_PUBKEY_TAG			0x7F49
  ------------------
  |  Branch (713:11): [True: 1, False: 46]
  ------------------
  714|      1|		if (sdo->sdo_class != IASECC_SDO_CLASS_RSA_PUBLIC) {
  ------------------
  |  |  101|      1|#define IASECC_SDO_CLASS_RSA_PUBLIC	0x20
  ------------------
  |  Branch (714:7): [True: 1, False: 0]
  ------------------
  715|      1|			free(tlv.value);
  716|      1|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: SDO_PUBLIC_KEY tag in non PUBLIC_KEY SDO");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  717|      1|		}
  718|       |
  719|      0|		rv = iasecc_parse_pubkey(card, tlv.value, tlv.size, &sdo->data.pub_key);
  720|      0|		free(tlv.value);
  721|      0|		LOG_TEST_RET(ctx, rv, "parse error: cannot parse SDO PUBLIC KEY data");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  722|      0|	}
  723|     46|	else if (tlv.tag == IASECC_SDO_PRVKEY_TAG)   {
  ------------------
  |  |   68|     46|#define IASECC_SDO_PRVKEY_TAG			0x7F48
  ------------------
  |  Branch (723:11): [True: 2, False: 44]
  ------------------
  724|      2|		if (sdo->sdo_class != IASECC_SDO_CLASS_RSA_PRIVATE) {
  ------------------
  |  |  100|      2|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  |  Branch (724:7): [True: 2, False: 0]
  ------------------
  725|      2|			free(tlv.value);
  726|      2|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: SDO_PRIVATE_KEY tag in non PRIVATE_KEY SDO");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  727|      2|		}
  728|       |
  729|      0|		rv = iasecc_parse_prvkey(card, tlv.value, tlv.size, &sdo->data.prv_key);
  730|      0|		free(tlv.value);
  731|      0|		LOG_TEST_RET(ctx, rv, "parse error: cannot parse SDO PRIVATE KEY data");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  732|      0|	}
  733|     44|	else if (tlv.tag == IASECC_SDO_KEYSET_TAG)   {
  ------------------
  |  |   83|     44|#define IASECC_SDO_KEYSET_TAG			0xA2
  ------------------
  |  Branch (733:11): [True: 1, False: 43]
  ------------------
  734|      1|		if (sdo->sdo_class != IASECC_SDO_CLASS_KEYSET) {
  ------------------
  |  |   99|      1|#define IASECC_SDO_CLASS_KEYSET		0x0A
  ------------------
  |  Branch (734:7): [True: 1, False: 0]
  ------------------
  735|      1|			free(tlv.value);
  736|      1|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: SDO_KEYSET tag in non KEYSET SDO");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  737|      1|		}
  738|       |
  739|      0|		rv = iasecc_parse_keyset(card, tlv.value, tlv.size, &sdo->data.keyset);
  740|      0|		free(tlv.value);
  741|      0|		LOG_TEST_RET(ctx, rv, "parse error: cannot parse SDO KEYSET data");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|      0|	}
  743|     43|	else   {
  744|     43|		sc_log(ctx, "iasecc_sdo_parse_data() non supported tag 0x%X", tlv.tag);
  ------------------
  |  |   71|     43|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  745|     43|		free(tlv.value);
  746|     43|		LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     43|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     43|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     43|	int _ret = r; \
  |  |  |  |  155|     43|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 43, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     43|		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|     43|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 43, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     43|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     43|	} 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|     43|	return _ret; \
  |  |  |  |  163|     43|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|     43|	}
  748|       |
  749|    104|	return tlv_size;
  750|    246|}
iasecc-sdo.c:iasecc_parse_get_tlv:
  408|    785|{
  409|    785|	struct sc_context *ctx = card->ctx;
  410|    785|	int size_len, tag_len;
  411|       |
  412|    785|	memset(tlv, 0, sizeof(*tlv));
  413|    785|	sc_log(ctx, "iasecc_parse_get_tlv() called for tag 0x%X", *data);
  ------------------
  |  |   71|    785|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  414|    785|	if (data_len < 1)
  ------------------
  |  Branch (414:6): [True: 0, False: 785]
  ------------------
  415|    785|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|    785|	if ((*data == 0x7F) || (*data == 0x5F))   {
  ------------------
  |  Branch (416:6): [True: 66, False: 719]
  |  Branch (416:25): [True: 9, False: 710]
  ------------------
  417|     75|		if (data_len < 2)
  ------------------
  |  Branch (417:7): [True: 1, False: 74]
  ------------------
  418|     75|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  419|     74|		tlv->tag = *data * 0x100 + *(data + 1);
  420|     74|		tag_len = 2;
  421|     74|	}
  422|    710|	else   {
  423|    710|		tlv->tag = *data;
  424|    710|		tag_len = 1;
  425|    710|	}
  426|       |
  427|    784|	sc_log(ctx, "iasecc_parse_get_tlv() tlv->tag 0x%X", tlv->tag);
  ------------------
  |  |   71|    784|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  428|    784|	size_len = iasecc_parse_size(data + tag_len, data_len - tag_len, &tlv->size);
  429|    784|	LOG_TEST_RET(ctx, size_len, "parse error: invalid size data");
  ------------------
  |  |  174|    784|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    784|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    784|	int _ret = (r); \
  |  |  |  |  168|    784|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 20, False: 764]
  |  |  |  |  ------------------
  |  |  |  |  169|     20|		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|     20|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     20|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     20|		return _ret; \
  |  |  |  |  172|     20|	} \
  |  |  |  |  173|    784|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 764]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  430|    764|	if (tag_len + size_len + tlv->size > data_len) {
  ------------------
  |  Branch (430:6): [True: 20, False: 744]
  ------------------
  431|     20|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|     20|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     20|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     20|	int _ret = r; \
  |  |  |  |  155|     20|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     20|		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|     20|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     20|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     20|	} 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|     20|	return _ret; \
  |  |  |  |  163|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|     20|	}
  433|       |
  434|    744|	tlv->value = calloc(1, tlv->size);
  435|    744|	if (!tlv->value)
  ------------------
  |  Branch (435:6): [True: 0, False: 744]
  ------------------
  436|    744|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  437|    744|	memcpy(tlv->value, data + size_len + tag_len, tlv->size);
  438|       |
  439|    744|	tlv->on_card = 1;
  440|       |
  441|    744|	sc_log(ctx, "iasecc_parse_get_tlv() parsed %zu bytes", tag_len + size_len + tlv->size);
  ------------------
  |  |   71|    744|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  442|    744|	return (int)(tag_len + size_len + tlv->size);
  443|    744|}
iasecc-sdo.c:iasecc_parse_docp:
  594|    115|{
  595|    115|	struct sc_context *ctx = card->ctx;
  596|    115|	size_t offs = 0;
  597|    115|	int rv;
  598|       |
  599|    115|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    115|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    115|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    115|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    115|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  600|    399|	while(offs < data_len)   {
  ------------------
  |  Branch (600:8): [True: 352, False: 47]
  ------------------
  601|    352|		struct iasecc_extended_tlv tlv;
  602|       |
  603|    352|		rv = iasecc_parse_get_tlv(card, data + offs, data_len - offs, &tlv);
  604|    352|		LOG_TEST_RET(ctx, rv, "iasecc_parse_get_tlv() get and parse TLV error");
  ------------------
  |  |  174|    352|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    352|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    352|	int _ret = (r); \
  |  |  |  |  168|    352|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 19, False: 333]
  |  |  |  |  ------------------
  |  |  |  |  169|     19|		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|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     19|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     19|		return _ret; \
  |  |  |  |  172|     19|	} \
  |  |  |  |  173|    352|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 333]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  605|       |
  606|    333|		sc_log(ctx, "iasecc_parse_docp() parse_get_tlv returned %i; tag %X; size %zu",
  ------------------
  |  |   71|    333|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  607|    333|				rv, tlv.tag, tlv.size);
  608|       |
  609|    333|		if (tlv.tag == IASECC_DOCP_TAG_ACLS)   {
  ------------------
  |  |   39|    333|#define IASECC_DOCP_TAG_ACLS			0xA1
  ------------------
  |  Branch (609:7): [True: 36, False: 297]
  ------------------
  610|     36|			int _rv = iasecc_parse_docp(card, tlv.value, tlv.size, sdo);
  611|     36|			free(tlv.value);
  612|     36|			LOG_TEST_RET(ctx, _rv, "parse error: cannot parse DOCP");
  ------------------
  |  |  174|     36|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     36|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     36|	int _ret = (r); \
  |  |  |  |  168|     36|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 28]
  |  |  |  |  ------------------
  |  |  |  |  169|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      8|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      8|		return _ret; \
  |  |  |  |  172|      8|	} \
  |  |  |  |  173|     36|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|     36|		}
  614|    297|		else if (tlv.tag == IASECC_DOCP_TAG_ACLS_CONTACT)   {
  ------------------
  |  |   40|    297|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
  |  Branch (614:12): [True: 63, False: 234]
  ------------------
  615|     63|			free(sdo->docp.acls_contact.value);
  616|     63|			sdo->docp.acls_contact = tlv;
  617|     63|		}
  618|    234|		else if (tlv.tag == IASECC_DOCP_TAG_ACLS_CONTACTLESS)   {
  ------------------
  |  |   41|    234|#define IASECC_DOCP_TAG_ACLS_CONTACTLESS	0x9C
  ------------------
  |  Branch (618:12): [True: 18, False: 216]
  ------------------
  619|     18|			free(sdo->docp.acls_contactless.value);
  620|     18|			sdo->docp.acls_contactless = tlv;
  621|     18|		}
  622|    216|		else if (tlv.tag == IASECC_DOCP_TAG_SIZE)   {
  ------------------
  |  |   38|    216|#define IASECC_DOCP_TAG_SIZE			0x80
  ------------------
  |  Branch (622:12): [True: 38, False: 178]
  ------------------
  623|     38|			free(sdo->docp.size.value);
  624|     38|			sdo->docp.size = tlv;
  625|     38|		}
  626|    178|		else if (tlv.tag == IASECC_DOCP_TAG_NAME)   {
  ------------------
  |  |   32|    178|#define IASECC_DOCP_TAG_NAME			0x84
  ------------------
  |  Branch (626:12): [True: 22, False: 156]
  ------------------
  627|     22|			free(sdo->docp.name.value);
  628|     22|			sdo->docp.name = tlv;
  629|     22|		}
  630|    156|		else if (tlv.tag == IASECC_DOCP_TAG_ISSUER_DATA)   {
  ------------------
  |  |   43|    156|#define IASECC_DOCP_TAG_ISSUER_DATA		0x85
  ------------------
  |  Branch (630:12): [True: 15, False: 141]
  ------------------
  631|     15|			free(sdo->docp.issuer_data.value);
  632|     15|			sdo->docp.issuer_data = tlv;
  633|     15|		}
  634|    141|		else if (tlv.tag == IASECC_DOCP_TAG_NON_REPUDIATION)   {
  ------------------
  |  |   37|    141|#define IASECC_DOCP_TAG_NON_REPUDIATION 		0x9E
  ------------------
  |  Branch (634:12): [True: 17, False: 124]
  ------------------
  635|     17|			free(sdo->docp.non_repudiation.value);
  636|     17|			sdo->docp.non_repudiation = tlv;
  637|     17|		}
  638|    124|		else if (tlv.tag == IASECC_DOCP_TAG_USAGE_REMAINING)   {
  ------------------
  |  |   36|    124|#define IASECC_DOCP_TAG_USAGE_REMAINING		0x9D
  ------------------
  |  Branch (638:12): [True: 24, False: 100]
  ------------------
  639|     24|			free(sdo->docp.usage_remaining.value);
  640|     24|			sdo->docp.usage_remaining = tlv;
  641|     24|		}
  642|    100|		else if (tlv.tag == IASECC_DOCP_TAG_TRIES_MAXIMUM)   {
  ------------------
  |  |   33|    100|#define IASECC_DOCP_TAG_TRIES_MAXIMUM		0x9A
  ------------------
  |  Branch (642:12): [True: 17, False: 83]
  ------------------
  643|     17|			free(sdo->docp.tries_maximum.value);
  644|     17|			sdo->docp.tries_maximum = tlv;
  645|     17|		}
  646|     83|		else if (tlv.tag == IASECC_DOCP_TAG_TRIES_REMAINING)   {
  ------------------
  |  |   34|     83|#define IASECC_DOCP_TAG_TRIES_REMAINING		0x9B
  ------------------
  |  Branch (646:12): [True: 42, False: 41]
  ------------------
  647|     42|			free(sdo->docp.tries_remaining.value);
  648|     42|			sdo->docp.tries_remaining = tlv;
  649|     42|		}
  650|     41|		else   {
  651|     41|			free(tlv.value);
  652|     41|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "iasecc_parse_get_tlv() parse error: non DOCP tag");
  ------------------
  |  |  174|     41|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     41|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     41|	int _ret = (r); \
  |  |  |  |  168|     41|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 41, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     41|		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|     41|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     41|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     41|		return _ret; \
  |  |  |  |  172|     41|	} \
  |  |  |  |  173|     41|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|     41|		}
  654|       |
  655|    284|		offs += rv;
  656|    284|	}
  657|       |
  658|     47|	rv = iasecc_parse_acls(card, &sdo->docp, 0);
  659|     47|	LOG_TEST_RET(ctx, rv, "Cannot parse ACLs in DOCP");
  ------------------
  |  |  174|     47|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     47|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     47|	int _ret = (r); \
  |  |  |  |  168|     47|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 38]
  |  |  |  |  ------------------
  |  |  |  |  169|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      9|		return _ret; \
  |  |  |  |  172|      9|	} \
  |  |  |  |  173|     47|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  660|       |
  661|     38|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     38|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     38|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     38|	int _ret = r; \
  |  |  |  |  155|     38|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 38, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     38|		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: 38]
  |  |  |  |  ------------------
  |  |  |  |  157|     38|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     38|	} 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|     38|	return _ret; \
  |  |  |  |  163|     38|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|     38|}
iasecc-sdo.c:iasecc_parse_chv:
  448|     32|{
  449|     32|	struct sc_context *ctx = card->ctx;
  450|     32|	size_t offs = 0;
  451|     32|	int rv;
  452|       |
  453|     32|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     32|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     32|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     32|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     32|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|    182|	while(offs < data_len)   {
  ------------------
  |  Branch (454:8): [True: 175, False: 7]
  ------------------
  455|    175|		struct iasecc_extended_tlv tlv;
  456|       |
  457|    175|		rv = iasecc_parse_get_tlv(card, data + offs, data_len - offs, &tlv);
  458|    175|		LOG_TEST_RET(ctx, rv, "iasecc_parse_chv() get and parse TLV error");
  ------------------
  |  |  174|    175|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    175|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    175|	int _ret = (r); \
  |  |  |  |  168|    175|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 165]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|    175|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 165]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  459|       |
  460|    165|		sc_log(ctx, "iasecc_parse_chv() get and parse TLV returned %i; tag %X; size %zu",
  ------------------
  |  |   71|    165|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  461|    165|				rv, tlv.tag, tlv.size);
  462|       |
  463|    165|		if (tlv.tag == IASECC_SDO_CHV_TAG_SIZE_MAX) {
  ------------------
  |  |   64|    165|#define IASECC_SDO_CHV_TAG_SIZE_MAX	0x80
  ------------------
  |  Branch (463:7): [True: 42, False: 123]
  ------------------
  464|     42|			free(chv->size_max.value);
  465|     42|			chv->size_max = tlv;
  466|    123|		} else if (tlv.tag == IASECC_SDO_CHV_TAG_SIZE_MIN) {
  ------------------
  |  |   65|    123|#define IASECC_SDO_CHV_TAG_SIZE_MIN	0x81
  ------------------
  |  Branch (466:14): [True: 67, False: 56]
  ------------------
  467|     67|			free(chv->size_min.value);
  468|     67|			chv->size_min = tlv;
  469|     67|		} else if (tlv.tag == IASECC_SDO_CHV_TAG_VALUE) {
  ------------------
  |  |   66|     56|#define IASECC_SDO_CHV_TAG_VALUE	0x82
  ------------------
  |  Branch (469:14): [True: 41, False: 15]
  ------------------
  470|     41|			free(chv->value.value);
  471|     41|			chv->value = tlv;
  472|     41|		} else {
  473|     15|			free(tlv.value);
  474|     15|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "parse error: non CHV SDO tag");
  ------------------
  |  |  174|     15|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     15|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     15|	int _ret = (r); \
  |  |  |  |  168|     15|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     15|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     15|		return _ret; \
  |  |  |  |  172|     15|	} \
  |  |  |  |  173|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  475|     15|		}
  476|       |
  477|    150|		offs += rv;
  478|    150|	}
  479|       |
  480|      7|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      7|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      7|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      7|	int _ret = r; \
  |  |  |  |  155|      7|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      7|		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: 7]
  |  |  |  |  ------------------
  |  |  |  |  157|      7|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      7|	} 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|      7|	return _ret; \
  |  |  |  |  163|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|      7|}
iasecc-sdo.c:iasecc_tlv_copy:
 1304|    126|{
 1305|    126|	if (!in || !out)
  ------------------
  |  Branch (1305:6): [True: 0, False: 126]
  |  Branch (1305:13): [True: 0, False: 126]
  ------------------
 1306|    126|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1307|       |
 1308|    126|	memset(out, 0, sizeof(struct iasecc_extended_tlv));
 1309|    126|	out->tag = in->tag;
 1310|    126|	out->parent_tag = in->parent_tag;
 1311|    126|	out->on_card = in->on_card;
 1312|    126|	if (in->value && in->size)   {
  ------------------
  |  Branch (1312:6): [True: 0, False: 126]
  |  Branch (1312:19): [True: 0, False: 0]
  ------------------
 1313|      0|		out->value = calloc(1, in->size);
 1314|      0|		if (!out->value)
  ------------------
  |  Branch (1314:7): [True: 0, False: 0]
  ------------------
 1315|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1316|       |
 1317|      0|		memcpy(out->value, in->value, in->size);
 1318|      0|		out->size = in->size;
 1319|      0|	}
 1320|       |
 1321|    126|	return SC_SUCCESS;
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
 1322|    126|}

iasecc_sm_initialize:
  270|    153|{
  271|    153|	struct sc_context *ctx = card->ctx;
  272|    153|#ifdef ENABLE_SM
  273|    153|	struct sm_info *sm_info = &card->sm_ctx.info;
  274|    153|	struct sm_cwa_session *cwa_session = &sm_info->session.cwa;
  275|    153|	struct sc_remote_data rdata;
  276|    153|	int rv;
  277|       |
  278|    153|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    153|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    153|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    153|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    153|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  279|       |
  280|    153|	strlcpy(sm_info->config_section, card->sm_ctx.config_section, sizeof(sm_info->config_section));
  ------------------
  |  |   43|    153|#define strlcpy _strlcpy
  ------------------
  281|    153|	sm_info->cmd = cmd;
  282|    153|	sm_info->serialnr = card->serialnr;
  283|    153|	sm_info->card_type = card->type;
  284|    153|	sm_info->sm_type = SM_TYPE_CWA14890;
  ------------------
  |  |   39|    153|#define SM_TYPE_CWA14890	0x400
  ------------------
  285|       |
  286|    153|	rv = iasecc_sm_se_mutual_authentication(card, se_num);
  287|    153|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() MUTUAL AUTHENTICATION failed");
  ------------------
  |  |  174|    153|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    153|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    153|	int _ret = (r); \
  |  |  |  |  168|    153|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 153, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    153|		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|    153|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    153|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    153|		return _ret; \
  |  |  |  |  172|    153|	} \
  |  |  |  |  173|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  288|       |
  289|      0|	rv = sc_get_challenge(card, cwa_session->card_challenge, SM_SMALL_CHALLENGE_LEN);
  ------------------
  |  |   85|      0|#define SM_SMALL_CHALLENGE_LEN	8
  ------------------
  290|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() GET CHALLENGE failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|       |
  292|      0|	sc_remote_data_init(&rdata);
  293|       |
  294|      0|	rv = sm_save_sc_context(card, sm_info);
  295|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() cannot save current context");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  296|       |
  297|      0|	if (!card->sm_ctx.module.ops.initialize)
  ------------------
  |  Branch (297:6): [True: 0, False: 0]
  ------------------
  298|      0|		LOG_TEST_RET(ctx, SC_ERROR_SM_NOT_INITIALIZED, "iasecc_sm_initialize() no SM module");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  299|      0|	rv = card->sm_ctx.module.ops.initialize(ctx, sm_info, &rdata);
  300|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() INITIALIZE failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|       |
  302|       |
  303|      0|	if (rdata.length == 1)   {
  ------------------
  |  Branch (303:6): [True: 0, False: 0]
  ------------------
  304|      0|		rdata.data->flags |= SC_REMOTE_APDU_FLAG_RETURN_ANSWER;
  ------------------
  |  |  386|      0|#define SC_REMOTE_APDU_FLAG_RETURN_ANSWER	0x02
  ------------------
  305|      0|		rdata.data->apdu.flags &= ~SC_APDU_FLAGS_NO_GET_RESP;
  ------------------
  |  |  308|      0|#define SC_APDU_FLAGS_NO_GET_RESP	0x00000002UL
  ------------------
  306|      0|	}
  307|      0|	else   {
  308|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "TODO: SM init with more then one APDU");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  309|      0|	}
  310|       |
  311|      0|	cwa_session->mdata_len = sizeof(cwa_session->mdata);
  312|      0|	rv = iasecc_sm_transmit_apdus (card, &rdata, cwa_session->mdata, &cwa_session->mdata_len);
  313|      0|	if (rv == SC_ERROR_PIN_CODE_INCORRECT)
  ------------------
  |  |   64|      0|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (313:6): [True: 0, False: 0]
  ------------------
  314|      0|		sc_log(ctx, "SM initialization failed, %i tries left", (rdata.data + rdata.length - 1)->apdu.sw2 & 0x0F);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  315|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() transmit APDUs failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  316|       |
  317|      0|	rdata.free(&rdata);
  318|       |
  319|      0|	sc_log(ctx, "MA data(len:%zu) '%s'", cwa_session->mdata_len,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  320|      0|			sc_dump_hex(cwa_session->mdata, cwa_session->mdata_len));
  321|      0|	if (cwa_session->mdata_len != 0x48)
  ------------------
  |  Branch (321:6): [True: 0, False: 0]
  ------------------
  322|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "iasecc_sm_initialize() invalid MUTUAL AUTHENTICATE result data");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  323|       |
  324|      0|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  325|       |#else
  326|       |	LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "built without support of Secure-Messaging");
  327|       |	return SC_ERROR_NOT_SUPPORTED;
  328|       |#endif
  329|      0|}
iasecc_sm_read_binary:
  586|    153|{
  587|    153|	struct sc_context *ctx = card->ctx;
  588|    153|#ifdef ENABLE_SM
  589|    153|	struct sm_info *sm_info = &card->sm_ctx.info;
  590|    153|	struct sc_remote_data rdata;
  591|    153|	struct iasecc_sm_cmd_update_binary cmd_data;
  592|    153|	int rv;
  593|       |
  594|    153|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    153|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    153|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    153|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    153|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  595|    153|	sc_log(ctx, "SM read binary: acl:%X, offs:%zu, count:%zu", se_num, offs, count);
  ------------------
  |  |   71|    153|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  596|       |
  597|    153|	rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_READ);
  ------------------
  |  |   56|    153|#define SM_CMD_FILE_READ		0x201
  ------------------
  598|    153|	LOG_TEST_RET(ctx, rv, "iasecc_sm_read_binary() SM INITIALIZE failed");
  ------------------
  |  |  174|    153|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    153|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    153|	int _ret = (r); \
  |  |  |  |  168|    153|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 153, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    153|		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|    153|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    153|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    153|		return _ret; \
  |  |  |  |  172|    153|	} \
  |  |  |  |  173|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  599|       |
  600|      0|	cmd_data.offs = offs;
  601|      0|	cmd_data.count = count;
  602|      0|	sm_info->cmd_data = &cmd_data;
  603|       |
  604|      0|	sc_remote_data_init(&rdata);
  605|      0|	rv = iasecc_sm_cmd(card, &rdata);
  606|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_read_binary() SM 'READ BINARY' failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  607|       |
  608|      0|	sc_log(ctx, "IAS/ECC decode answer() rdata length %i", rdata.length);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  609|       |
  610|      0|	rv = sm_release (card, &rdata, buff, count);
  611|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_read_binary() SM release failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|       |
  613|      0|	rdata.free(&rdata);
  614|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  615|       |#else
  616|       |	LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "built without support of Secure-Messaging");
  617|       |	return SC_ERROR_NOT_SUPPORTED;
  618|       |#endif
  619|      0|}
iasecc-sm.c:iasecc_sm_se_mutual_authentication:
  222|    153|{
  223|    153|	struct sc_context *ctx = card->ctx;
  224|    153|	struct sm_info *sm_info = &card->sm_ctx.info;
  225|    153|	struct iasecc_se_info se;
  226|    153|	struct sc_crt *crt =  &sm_info->session.cwa.params.crt_at;
  227|    153|	struct sc_apdu apdu;
  228|    153|	unsigned char sbuf[0x100];
  229|    153|	int rv, offs;
  230|       |
  231|    153|	memset(&se, 0, sizeof(se));
  232|       |
  233|    153|	se.reference = se_num;
  234|    153|	crt->usage = IASECC_UQB_AT_MUTUAL_AUTHENTICATION;
  ------------------
  |  |  127|    153|#define IASECC_UQB_AT_MUTUAL_AUTHENTICATION	0xC0
  ------------------
  235|    153|	crt->tag = IASECC_CRT_TAG_AT;
  ------------------
  |  |  104|    153|#define IASECC_CRT_TAG_AT	0xA4
  ------------------
  236|       |
  237|    153|	rv = iasecc_se_get_info(card, &se);
  238|    153|	LOG_TEST_RET(ctx, rv, "Get SE info error");
  ------------------
  |  |  174|    153|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    153|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    153|	int _ret = (r); \
  |  |  |  |  168|    153|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 139, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  169|    139|		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|    139|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    139|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    139|		return _ret; \
  |  |  |  |  172|    139|	} \
  |  |  |  |  173|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  239|       |
  240|     14|	rv = iasecc_se_get_crt(card, &se, crt);
  241|     14|	sc_file_free(se.df);
  242|     14|	LOG_TEST_RET(ctx, rv, "Cannot get authentication CRT");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|       |
  244|       |	/* MSE SET Mutual Authentication SK scheme */
  245|      0|	offs = 0;
  246|      0|	sbuf[offs++] = IASECC_CRT_TAG_ALGO;
  ------------------
  |  |  113|      0|#define IASECC_CRT_TAG_ALGO		0x80
  ------------------
  247|      0|	sbuf[offs++] = 0x01;
  248|      0|	sbuf[offs++] = crt->algo;
  249|      0|	sbuf[offs++] = IASECC_CRT_TAG_REFERENCE;
  ------------------
  |  |  112|      0|#define IASECC_CRT_TAG_REFERENCE	0x83
  ------------------
  250|      0|	sbuf[offs++] = 0x01;
  251|      0|	sbuf[offs++] = crt->refs[0];
  252|       |
  253|      0|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0xC1, 0xA4);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  254|      0|	apdu.data = sbuf;
  255|      0|	apdu.datalen = offs;
  256|      0|	apdu.lc = offs;
  257|       |
  258|      0|	rv = sc_transmit_apdu(card, &apdu);
  259|      0|	LOG_TEST_RET(ctx, rv, "SM set SE mutual auth.: APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|      0|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  261|      0|	LOG_TEST_RET(ctx, rv, "SM set SE mutual auth.: set SE error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|       |
  263|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  264|      0|}

iso7816_fixup_transceive_length:
   35|  45.1k|{
   36|  45.1k|	if (card == NULL || apdu == NULL) {
  ------------------
  |  Branch (36:6): [True: 0, False: 45.1k]
  |  Branch (36:22): [True: 0, False: 45.1k]
  ------------------
   37|      0|		return;
   38|      0|	}
   39|       |
   40|  45.1k|	if (apdu->lc > sc_get_max_send_size(card)) {
  ------------------
  |  Branch (40:6): [True: 993, False: 44.1k]
  ------------------
   41|       |		/* The lower layers will automatically do chaining */
   42|    993|		apdu->flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|    993|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
   43|    993|	}
   44|       |
   45|  45.1k|	if (apdu->le > sc_get_max_recv_size(card)) {
  ------------------
  |  Branch (45:6): [True: 3.92k, False: 41.2k]
  ------------------
   46|       |		/* The lower layers will automatically do a GET RESPONSE, if possible.
   47|       |		 * All other workarounds must be carried out by the upper layers. */
   48|  3.92k|		apdu->le = sc_get_max_recv_size(card);
   49|  3.92k|	}
   50|  45.1k|}
encode_do_data:
  176|  7.76k|{
  177|  7.76k|	unsigned char offset_buffer[2];
  178|  7.76k|	size_t offset_buffer_len = sizeof offset_buffer;
  179|  7.76k|	struct sc_asn1_entry asn1_do_data[sizeof c_asn1_do_data / sizeof *c_asn1_do_data];
  180|  7.76k|	sc_copy_asn1_entry(c_asn1_do_data, asn1_do_data);
  181|       |
  182|  7.76k|	if (idx > 0xFFFF)
  ------------------
  |  Branch (182:6): [True: 0, False: 7.76k]
  ------------------
  183|  7.76k|		LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "Offset beyond 0xFFFF not supported");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  184|  7.76k|	offset_buffer[0] = (u8) (idx >> 8);
  185|  7.76k|	offset_buffer[1] = (u8) (idx & 0x00FF);
  186|  7.76k|	sc_format_asn1_entry(asn1_do_data + 0, offset_buffer, &offset_buffer_len, 1);
  187|       |
  188|  7.76k|	if (data && data_len) {
  ------------------
  |  Branch (188:6): [True: 0, False: 7.76k]
  |  Branch (188:14): [True: 0, False: 0]
  ------------------
  189|      0|		sc_format_asn1_entry(asn1_do_data + 1, (void *) &data, &data_len, 1);
  190|  7.76k|	} else {
  191|  7.76k|		sc_format_asn1_entry(asn1_do_data + 1, NULL, NULL, 0);
  192|  7.76k|	}
  193|       |
  194|  7.76k|	LOG_TEST_RET(ctx,
  ------------------
  |  |  174|  7.76k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.76k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.76k|	int _ret = (r); \
  |  |  |  |  168|  7.76k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 7.76k]
  |  |  |  |  ------------------
  |  |  |  |  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|  7.76k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7.76k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|  7.76k|			sc_asn1_encode(ctx, asn1_do_data, out, outlen),
  196|  7.76k|			"sc_asn1_encode() failed");
  197|       |
  198|  7.76k|	return SC_SUCCESS;
  ------------------
  |  |   28|  7.76k|#define SC_SUCCESS				0
  ------------------
  199|  7.76k|}
decode_do_data:
  204|  4.88k|{
  205|  4.88k|	struct sc_asn1_entry asn1_do_data[sizeof c_asn1_do_data / sizeof *c_asn1_do_data];
  206|  4.88k|	sc_copy_asn1_entry(c_asn1_do_data, asn1_do_data);
  207|       |
  208|  4.88k|	sc_format_asn1_entry(asn1_do_data + 0, NULL, NULL, 0);
  209|  4.88k|	sc_format_asn1_entry(asn1_do_data + 1, out, outlen, 0);
  210|       |
  211|  4.88k|	LOG_TEST_RET(ctx,
  ------------------
  |  |  174|  4.88k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.88k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.88k|	int _ret = (r); \
  |  |  |  |  168|  4.88k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 132, False: 4.75k]
  |  |  |  |  ------------------
  |  |  |  |  169|    132|		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|    132|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    132|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    132|		return _ret; \
  |  |  |  |  172|    132|	} \
  |  |  |  |  173|  4.88k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.75k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  212|  4.75k|			sc_asn1_decode(ctx, asn1_do_data, encoded_data, encoded_data_len, NULL, NULL),
  213|  4.75k|			"sc_asn1_decode() failed");
  214|       |
  215|  4.75k|	if (!(asn1_do_data[1].flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|  4.75k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (215:6): [True: 2.53k, False: 2.22k]
  ------------------
  216|  2.53k|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  2.53k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  217|       |
  218|  2.22k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.22k|#define SC_SUCCESS				0
  ------------------
  219|  4.75k|}
iso7816_build_pin_apdu:
 1196|  2.11k|{
 1197|  2.11k|	int r, len = 0, pad = 0, use_pin_pad = 0, ins, p1 = 0;
 1198|  2.11k|	int cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  2.11k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1199|       |
 1200|  2.11k|	switch (data->pin_type) {
 1201|  2.09k|	case SC_AC_CHV:
  ------------------
  |  |  151|  2.09k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1201:2): [True: 2.09k, False: 21]
  ------------------
 1202|       |		/* fall through */
 1203|  2.09k|	case SC_AC_SESSION:
  ------------------
  |  |  159|  2.09k|#define SC_AC_SESSION			0x00000100 /* Session PIN */
  ------------------
  |  Branch (1203:2): [True: 0, False: 2.11k]
  ------------------
 1204|  2.11k|	case SC_AC_CONTEXT_SPECIFIC:
  ------------------
  |  |  160|  2.11k|#define SC_AC_CONTEXT_SPECIFIC		0x00000200 /* Context specific login */
  ------------------
  |  Branch (1204:2): [True: 21, False: 2.09k]
  ------------------
 1205|  2.11k|		break;
 1206|      0|	default:
  ------------------
  |  Branch (1206:2): [True: 0, False: 2.11k]
  ------------------
 1207|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1208|  2.11k|	}
 1209|       |
 1210|  2.11k|	if (data->flags & SC_PIN_CMD_NEED_PADDING)
  ------------------
  |  |  422|  2.11k|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  |  Branch (1210:6): [True: 356, False: 1.75k]
  ------------------
 1211|    356|		pad = 1;
 1212|  2.11k|	if (data->flags & SC_PIN_CMD_USE_PINPAD)
  ------------------
  |  |  421|  2.11k|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (1212:6): [True: 0, False: 2.11k]
  ------------------
 1213|      0|		use_pin_pad = 1;
 1214|       |
 1215|  2.11k|	data->pin1.offset = 5;
 1216|       |
 1217|  2.11k|	switch (data->cmd) {
 1218|    265|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|    265|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1218:2): [True: 265, False: 1.84k]
  ------------------
 1219|    265|		ins = 0x20;
 1220|       |		/* detect overloaded APDU with SC_PIN_CMD_GET_INFO */
 1221|    265|		if (data->pin1.len == 0 && !use_pin_pad)
  ------------------
  |  Branch (1221:7): [True: 0, False: 265]
  |  Branch (1221:30): [True: 0, False: 0]
  ------------------
 1222|      0|			return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      0|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
 1223|    265|		if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
  ------------------
  |  Branch (1223:7): [True: 13, False: 252]
  ------------------
 1224|     13|			return r;
 1225|    252|		len = r;
 1226|    252|		break;
 1227|     63|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|     63|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1227:2): [True: 63, False: 2.05k]
  ------------------
 1228|     63|		ins = 0x24;
 1229|     63|		if (data->pin1.len != 0 || (use_pin_pad && !( data->flags & SC_PIN_CMD_IMPLICIT_CHANGE))) {
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
  |  Branch (1229:7): [True: 62, False: 1]
  |  Branch (1229:31): [True: 0, False: 1]
  |  Branch (1229:46): [True: 0, False: 0]
  ------------------
 1230|     62|			if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
  ------------------
  |  Branch (1230:8): [True: 3, False: 59]
  ------------------
 1231|      3|				return r;
 1232|     59|			len += r;
 1233|     59|		}
 1234|      1|		else {
 1235|       |			/* implicit test */
 1236|      1|			p1 = 1;
 1237|      1|		}
 1238|       |
 1239|     60|		data->pin2.offset = data->pin1.offset + len;
 1240|     60|		if ((r = sc_build_pin(buf+len, buf_len-len, &data->pin2, pad)) < 0)
  ------------------
  |  Branch (1240:7): [True: 0, False: 60]
  ------------------
 1241|      0|			return r;
 1242|       |		/* Special case - where provided the old PIN on the command line
 1243|       |		 * but expect the new one to be entered on the keypad.
 1244|       |		 */
 1245|     60|		if (data->pin1.len && data->pin2.len == 0) {
  ------------------
  |  Branch (1245:7): [True: 59, False: 1]
  |  Branch (1245:25): [True: 0, False: 59]
  ------------------
 1246|      0|			sc_log(card->ctx, "Special case - initial pin provided - but new pin asked on keypad");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1247|      0|			data->flags |= SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
 1248|      0|		};
 1249|     60|		len += r;
 1250|     60|		break;
 1251|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1251:2): [True: 0, False: 2.11k]
  ------------------
 1252|      0|		ins = 0x2C;
 1253|      0|		if (data->pin1.len != 0 || (use_pin_pad && !( data->flags & SC_PIN_CMD_IMPLICIT_CHANGE))) {
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
  |  Branch (1253:7): [True: 0, False: 0]
  |  Branch (1253:31): [True: 0, False: 0]
  |  Branch (1253:46): [True: 0, False: 0]
  ------------------
 1254|      0|			if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
  ------------------
  |  Branch (1254:8): [True: 0, False: 0]
  ------------------
 1255|      0|				return r;
 1256|      0|			len += r;
 1257|      0|		} else {
 1258|      0|			p1 |= 0x02;
 1259|      0|		}
 1260|       |
 1261|      0|		if (data->pin2.len != 0 || use_pin_pad) {
  ------------------
  |  Branch (1261:7): [True: 0, False: 0]
  |  Branch (1261:30): [True: 0, False: 0]
  ------------------
 1262|      0|			data->pin2.offset = data->pin1.offset + len;
 1263|      0|			if ((r = sc_build_pin(buf+len, buf_len-len, &data->pin2, pad)) < 0)
  ------------------
  |  Branch (1263:8): [True: 0, False: 0]
  ------------------
 1264|      0|				return r;
 1265|      0|			len += r;
 1266|      0|		} else {
 1267|      0|			p1 |= 0x01;
 1268|      0|		}
 1269|      0|		if (p1 == 0x03) {
  ------------------
  |  Branch (1269:7): [True: 0, False: 0]
  ------------------
 1270|       |			/* No data to send or to receive */
 1271|      0|			cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 1272|      0|		}
 1273|      0|		break;
 1274|  1.78k|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  418|  1.78k|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1274:2): [True: 1.78k, False: 328]
  ------------------
 1275|  1.78k|		ins = 0x20;
 1276|       |		/* No data to send or to receive */
 1277|  1.78k|		cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|  1.78k|#define SC_APDU_CASE_1			0x01
  ------------------
 1278|  1.78k|		break;
 1279|      0|	default:
  ------------------
  |  Branch (1279:2): [True: 0, False: 2.11k]
  ------------------
 1280|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1281|  2.11k|	}
 1282|       |
 1283|  2.09k|	sc_format_apdu(card, apdu, cse, ins, p1, data->pin_reference);
 1284|  2.09k|	apdu->lc = len;
 1285|  2.09k|	apdu->datalen = len;
 1286|  2.09k|	apdu->data = buf;
 1287|  2.09k|	apdu->resplen = 0;
 1288|       |
 1289|  2.09k|	return 0;
 1290|  2.11k|}
iso7816_select_aid:
 1408|  15.7k|{
 1409|  15.7k|	struct sc_context *ctx = card->ctx;
 1410|  15.7k|	struct sc_apdu apdu;
 1411|  15.7k|	int rv;
 1412|       |
 1413|  15.7k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  15.7k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  15.7k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  15.7k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 15.7k]
  |  |  ------------------
  ------------------
 1414|       |
 1415|  15.7k|	sc_format_apdu(card, &apdu, resp == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, 0xA4, 0x04, resp == NULL ? 0x0C : 0x00);
  ------------------
  |  |  293|  7.45k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
              	sc_format_apdu(card, &apdu, resp == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, 0xA4, 0x04, resp == NULL ? 0x0C : 0x00);
  ------------------
  |  |  294|  8.31k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (1415:30): [True: 7.45k, False: 8.31k]
  |  Branch (1415:102): [True: 7.45k, False: 8.31k]
  ------------------
 1416|  15.7k|	apdu.lc = reqlen;
 1417|  15.7k|	apdu.data = req;
 1418|  15.7k|	apdu.datalen = reqlen;
 1419|  15.7k|	apdu.resp = resp;
 1420|  15.7k|	apdu.resplen = resp == NULL ? 0 : *resplen;
  ------------------
  |  Branch (1420:17): [True: 7.45k, False: 8.31k]
  ------------------
 1421|  15.7k|	apdu.le = resp == NULL ? 0 : 256;
  ------------------
  |  Branch (1421:12): [True: 7.45k, False: 8.31k]
  ------------------
 1422|       |
 1423|  15.7k|	rv = sc_transmit_apdu(card, &apdu);
 1424|  15.7k|	if (resplen)
  ------------------
  |  Branch (1424:6): [True: 8.31k, False: 7.45k]
  ------------------
 1425|  8.31k|		*resplen = apdu.resplen;
 1426|  15.7k|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  15.7k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  15.7k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  15.7k|	int _ret = (r); \
  |  |  |  |  168|  15.7k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 136, False: 15.6k]
  |  |  |  |  ------------------
  |  |  |  |  169|    136|		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|    136|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    136|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    136|		return _ret; \
  |  |  |  |  172|    136|	} \
  |  |  |  |  173|  15.7k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 15.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1427|       |
 1428|  15.6k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1429|  15.6k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  15.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  15.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  15.6k|	int _ret = r; \
  |  |  |  |  155|  15.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  15.6k|		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|  10.7k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10.7k, False: 4.92k]
  |  |  |  |  ------------------
  |  |  |  |  157|  15.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  15.6k|	} 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|  15.6k|	return _ret; \
  |  |  |  |  163|  15.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1430|  15.6k|}
sc_get_iso7816_driver:
 1498|   612k|{
 1499|   612k|	return &iso_driver;
 1500|   612k|}
iso7816.c:no_match:
 1444|  8.63k|{
 1445|  8.63k|	return 0;
 1446|  8.63k|}
iso7816.c:iso7816_read_record:
  224|  15.2k|{
  225|  15.2k|	struct sc_apdu apdu;
  226|  15.2k|	int r;
  227|       |	/* XXX maybe use some bigger buffer */
  228|  15.2k|	unsigned char resp[SC_MAX_APDU_RESP_SIZE];
  229|  15.2k|	unsigned char *encoded_data = NULL, *decoded_data = NULL;
  230|  15.2k|	size_t encoded_data_len = 0, decoded_data_len = 0;
  231|       |
  232|  15.2k|	if (rec_nr > 0xFF)
  ------------------
  |  Branch (232:6): [True: 1, False: 15.2k]
  ------------------
  233|  15.2k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|       |
  235|  15.2k|	if (idx == 0) {
  ------------------
  |  Branch (235:6): [True: 7.48k, False: 7.76k]
  ------------------
  236|  7.48k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xB2, rec_nr, 0);
  ------------------
  |  |  301|  7.48k|#define SC_APDU_CASE_2			0x22
  ------------------
  237|  7.48k|		apdu.le = count;
  238|  7.48k|		apdu.resplen = count;
  239|  7.48k|		apdu.resp = buf;
  240|  7.76k|	} else {
  241|  7.76k|		r = encode_do_data(card->ctx, idx, NULL, 0, &encoded_data, &encoded_data_len);
  242|  7.76k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Could not encode data objects");
  ------------------
  |  |  184|  7.76k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  7.76k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  7.76k|	int _ret = (r); \
  |  |  |  |  178|  7.76k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 7.76k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  7.76k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 7.76k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|       |
  244|  7.76k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0xB3, rec_nr, 0);
  ------------------
  |  |  303|  7.76k|#define SC_APDU_CASE_4			0x24
  ------------------
  245|  7.76k|		apdu.lc = encoded_data_len;
  246|  7.76k|		apdu.datalen = encoded_data_len;
  247|  7.76k|		apdu.data = encoded_data;
  248|  7.76k|		apdu.le = sizeof resp;
  249|  7.76k|		apdu.resplen = sizeof resp;
  250|  7.76k|		apdu.resp = resp;
  251|  7.76k|	}
  252|  15.2k|	apdu.p2 = (flags & SC_RECORD_EF_ID_MASK) << 3;
  ------------------
  |  | 1293|  15.2k|#define SC_RECORD_EF_ID_MASK		0x0001FUL
  ------------------
  253|  15.2k|	if (flags & SC_RECORD_BY_REC_NR)
  ------------------
  |  | 1298|  15.2k|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (253:6): [True: 15.2k, False: 0]
  ------------------
  254|  15.2k|		apdu.p2 |= 0x04;
  255|       |
  256|  15.2k|	iso7816_fixup_transceive_length(card, &apdu);
  257|  15.2k|	r = sc_transmit_apdu(card, &apdu);
  258|  15.2k|	LOG_TEST_GOTO_ERR(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  184|  15.2k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  15.2k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  15.2k|	int _ret = (r); \
  |  |  |  |  178|  15.2k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 706, False: 14.5k]
  |  |  |  |  ------------------
  |  |  |  |  179|    706|		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|    706|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    706|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    706|		goto err; \
  |  |  |  |  182|    706|	} \
  |  |  |  |  183|  15.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 14.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  259|  14.5k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  260|  14.5k|	LOG_TEST_GOTO_ERR(card->ctx, r, "Card returned error");
  ------------------
  |  |  184|  14.5k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  14.5k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  14.5k|	int _ret = (r); \
  |  |  |  |  178|  14.5k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3.41k, False: 11.1k]
  |  |  |  |  ------------------
  |  |  |  |  179|  3.41k|		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|  3.41k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  3.41k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  3.41k|		goto err; \
  |  |  |  |  182|  3.41k|	} \
  |  |  |  |  183|  14.5k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 11.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  261|       |
  262|  11.1k|	if (idx == 0) {
  ------------------
  |  Branch (262:6): [True: 6.24k, False: 4.88k]
  ------------------
  263|  6.24k|		r = (int)apdu.resplen;
  264|  6.24k|	} else {
  265|  4.88k|		r = decode_do_data(card->ctx, apdu.resp, apdu.resplen,
  266|  4.88k|				&decoded_data, &decoded_data_len);
  267|  4.88k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Could not decode data objects");
  ------------------
  |  |  184|  4.88k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.88k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.88k|	int _ret = (r); \
  |  |  |  |  178|  4.88k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 2.66k, False: 2.22k]
  |  |  |  |  ------------------
  |  |  |  |  179|  2.66k|		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.66k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  2.66k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  2.66k|		goto err; \
  |  |  |  |  182|  2.66k|	} \
  |  |  |  |  183|  4.88k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.22k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  268|  2.22k|		if (decoded_data_len <= count) {
  ------------------
  |  Branch (268:7): [True: 1.92k, False: 297]
  ------------------
  269|  1.92k|			count = decoded_data_len;
  270|  1.92k|		}
  271|  2.22k|		memcpy(buf, decoded_data, count);
  272|  2.22k|		r = (int)count;
  273|  2.22k|	}
  274|       |
  275|  15.2k|err:
  276|  15.2k|	free(encoded_data);
  277|  15.2k|	free(decoded_data);
  278|  15.2k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  15.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  15.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  15.2k|	int _ret = r; \
  |  |  |  |  155|  15.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7.16k, False: 8.08k]
  |  |  |  |  ------------------
  |  |  |  |  156|  7.16k|		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|  6.77k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6.77k, False: 384]
  |  |  |  |  ------------------
  |  |  |  |  157|  7.16k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  8.08k|	} else { \
  |  |  |  |  159|  8.08k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  8.08k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  8.08k|	} \
  |  |  |  |  162|  15.2k|	return _ret; \
  |  |  |  |  163|  15.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  279|  15.2k|}
iso7816.c:iso7816_select_file:
  642|  54.3k|{
  643|  54.3k|	struct sc_context *ctx;
  644|  54.3k|	struct sc_apdu apdu;
  645|  54.3k|	unsigned char buf[SC_MAX_APDU_BUFFER_SIZE];
  646|  54.3k|	unsigned char pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  647|  54.3k|	int r, pathtype;
  648|  54.3k|	size_t pathlen;
  649|  54.3k|	int select_mf = 0;
  650|  54.3k|	struct sc_file *file = NULL;
  651|  54.3k|	const u8 *buffer;
  652|  54.3k|	size_t buffer_len;
  653|  54.3k|	unsigned int cla, tag;
  654|       |
  655|  54.3k|	if (card == NULL || in_path == NULL) {
  ------------------
  |  Branch (655:6): [True: 0, False: 54.3k]
  |  Branch (655:22): [True: 0, False: 54.3k]
  ------------------
  656|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  657|      0|	}
  658|  54.3k|	ctx = card->ctx;
  659|  54.3k|	memcpy(path, in_path->value, in_path->len);
  660|  54.3k|	pathlen = in_path->len;
  661|  54.3k|	pathtype = in_path->type;
  662|       |
  663|  54.3k|	if (in_path->aid.len) {
  ------------------
  |  Branch (663:6): [True: 2.68k, False: 51.6k]
  ------------------
  664|  2.68k|		if (!pathlen) {
  ------------------
  |  Branch (664:7): [True: 1.55k, False: 1.13k]
  ------------------
  665|  1.55k|			memcpy(path, in_path->aid.value, in_path->aid.len);
  666|  1.55k|			pathlen = in_path->aid.len;
  667|  1.55k|			pathtype = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  1.55k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  668|  1.55k|		} else {
  669|       |			/* First, select the application */
  670|  1.13k|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
  ------------------
  |  |  293|  1.13k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  671|  1.13k|			apdu.data = in_path->aid.value;
  672|  1.13k|			apdu.datalen = in_path->aid.len;
  673|  1.13k|			apdu.lc = in_path->aid.len;
  674|       |
  675|  1.13k|			r = sc_transmit_apdu(card, &apdu);
  676|  1.13k|			LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.13k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.13k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.13k|	int _ret = (r); \
  |  |  |  |  168|  1.13k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 18, False: 1.11k]
  |  |  |  |  ------------------
  |  |  |  |  169|     18|		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|     18|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     18|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     18|		return _ret; \
  |  |  |  |  172|     18|	} \
  |  |  |  |  173|  1.13k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.11k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  677|  1.11k|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  678|  1.11k|			if (r)
  ------------------
  |  Branch (678:8): [True: 743, False: 375]
  ------------------
  679|  1.11k|				LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    743|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    743|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    743|	int _ret = r; \
  |  |  |  |  155|    743|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 743, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    743|		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|    743|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 743, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    743|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    743|	} 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|    743|	return _ret; \
  |  |  |  |  163|    743|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  680|       |
  681|    375|			if (pathtype == SC_PATH_TYPE_PATH
  ------------------
  |  |  119|    750|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (681:8): [True: 375, False: 0]
  ------------------
  682|      0|					|| pathtype == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (682:9): [True: 0, False: 0]
  ------------------
  683|    375|				pathtype = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|    375|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  684|    375|		}
  685|  2.68k|	}
  686|       |
  687|  53.6k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  294|  53.6k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  688|       |
  689|  53.6k|	switch (pathtype) {
  690|  9.04k|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|  9.04k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (690:2): [True: 9.04k, False: 44.5k]
  ------------------
  691|  9.04k|		apdu.p1 = 0;
  692|  9.04k|		if (pathlen != 2)
  ------------------
  |  Branch (692:7): [True: 0, False: 9.04k]
  ------------------
  693|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  694|  9.04k|		break;
  695|  24.4k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  24.4k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (695:2): [True: 24.4k, False: 29.1k]
  ------------------
  696|  24.4k|		apdu.p1 = 4;
  697|  24.4k|		break;
  698|  19.6k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  19.6k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (698:2): [True: 19.6k, False: 33.9k]
  ------------------
  699|  19.6k|		apdu.p1 = 8;
  700|  19.6k|		if (pathlen >= 2 && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (700:7): [True: 19.0k, False: 631]
  |  Branch (700:23): [True: 13.9k, False: 5.07k]
  ------------------
  701|  13.9k|			if (pathlen == 2) {	/* only 3F00 supplied */
  ------------------
  |  Branch (701:8): [True: 3.59k, False: 10.3k]
  ------------------
  702|  3.59k|				select_mf = 1;
  703|  3.59k|				apdu.p1 = 0;
  704|  3.59k|				break;
  705|  3.59k|			}
  706|  10.3k|			path += 2;
  707|  10.3k|			pathlen -= 2;
  708|  10.3k|		}
  709|  16.0k|		break;
  710|  16.0k|	case SC_PATH_TYPE_FROM_CURRENT:
  ------------------
  |  |  122|    375|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (710:2): [True: 375, False: 53.2k]
  ------------------
  711|    375|		apdu.p1 = 9;
  712|    375|		break;
  713|     72|	case SC_PATH_TYPE_PARENT:
  ------------------
  |  |  123|     72|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (713:2): [True: 72, False: 53.5k]
  ------------------
  714|     72|		apdu.p1 = 3;
  715|     72|		pathlen = 0;
  716|     72|		apdu.cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|     72|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  717|     72|		break;
  718|      0|	default:
  ------------------
  |  Branch (718:2): [True: 0, False: 53.6k]
  ------------------
  719|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|  53.6k|	}
  721|  53.6k|	apdu.lc = pathlen;
  722|  53.6k|	apdu.data = path;
  723|  53.6k|	apdu.datalen = pathlen;
  724|       |
  725|  53.6k|	if (file_out != NULL) {
  ------------------
  |  Branch (725:6): [True: 33.3k, False: 20.2k]
  ------------------
  726|  33.3k|		apdu.p2 = 0;		/* first record, return FCI */
  727|  33.3k|		apdu.resp = buf;
  728|  33.3k|		apdu.resplen = sizeof(buf);
  729|  33.3k|		apdu.le = sc_get_max_recv_size(card) < 256 ? sc_get_max_recv_size(card) : 256;
  ------------------
  |  Branch (729:13): [True: 1.42k, False: 31.9k]
  ------------------
  730|  33.3k|	}
  731|  20.2k|	else {
  732|  20.2k|		apdu.p2 = 0x0C;		/* first record, return nothing */
  733|  20.2k|		apdu.cse = (apdu.lc == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
              		apdu.cse = (apdu.lc == 0) ? SC_APDU_CASE_1 : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  40.4k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (733:14): [True: 0, False: 20.2k]
  ------------------
  734|  20.2k|	}
  735|       |
  736|  53.6k|	r = sc_transmit_apdu(card, &apdu);
  737|  53.6k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  53.6k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  53.6k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  53.6k|	int _ret = (r); \
  |  |  |  |  168|  53.6k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.09k, False: 52.5k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.09k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.09k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.09k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.09k|		return _ret; \
  |  |  |  |  172|  1.09k|	} \
  |  |  |  |  173|  53.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 52.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  738|  52.5k|	if (file_out == NULL) {
  ------------------
  |  Branch (738:6): [True: 20.2k, False: 32.3k]
  ------------------
  739|       |		/* For some cards 'SELECT' can be only with request to return FCI/FCP. */
  740|  20.2k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  741|  20.2k|		if (apdu.sw1 == 0x6A && apdu.sw2 == 0x86)   {
  ------------------
  |  Branch (741:7): [True: 144, False: 20.0k]
  |  Branch (741:27): [True: 42, False: 102]
  ------------------
  742|     42|			apdu.p2 = 0x00;
  743|     42|			if (sc_transmit_apdu(card, &apdu) == SC_SUCCESS)
  ------------------
  |  |   28|     42|#define SC_SUCCESS				0
  ------------------
  |  Branch (743:8): [True: 18, False: 24]
  ------------------
  744|     18|				r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  745|     42|		}
  746|  20.2k|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (746:7): [True: 0, False: 20.2k]
  ------------------
  747|  20.2k|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  748|  20.2k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  20.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  20.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  20.2k|	int _ret = r; \
  |  |  |  |  155|  20.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 20.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  20.2k|		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|  14.2k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 14.2k, False: 6.00k]
  |  |  |  |  ------------------
  |  |  |  |  157|  20.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  20.2k|	} 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|  20.2k|	return _ret; \
  |  |  |  |  163|  20.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  749|  20.2k|	}
  750|       |
  751|  32.3k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  752|  32.3k|	if (r)
  ------------------
  |  Branch (752:6): [True: 18.2k, False: 14.0k]
  ------------------
  753|  32.3k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  18.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  18.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  18.2k|	int _ret = r; \
  |  |  |  |  155|  18.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 18.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  18.2k|		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|  18.2k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 18.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  18.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  18.2k|	} 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|  18.2k|	return _ret; \
  |  |  |  |  163|  18.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|       |
  755|  14.0k|	if (file_out && (apdu.resplen == 0))   {
  ------------------
  |  Branch (755:6): [True: 14.0k, False: 0]
  |  Branch (755:18): [True: 2.14k, False: 11.8k]
  ------------------
  756|       |		/* For some cards 'SELECT' MF or DF_NAME do not return FCI. */
  757|  2.14k|		if (select_mf || pathtype == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  1.84k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (757:7): [True: 300, False: 1.84k]
  |  Branch (757:20): [True: 1.46k, False: 382]
  ------------------
  758|  1.76k|			file = sc_file_new();
  759|  1.76k|			if (file == NULL)
  ------------------
  |  Branch (759:8): [True: 0, False: 1.76k]
  ------------------
  760|  1.76k|				LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  761|  1.76k|			file->path = *in_path;
  762|       |
  763|  1.76k|			*file_out = file;
  764|  1.76k|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.76k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.76k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.76k|	int _ret = r; \
  |  |  |  |  155|  1.76k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.76k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.76k|		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: 1.76k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.76k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.76k|	} 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|  1.76k|	return _ret; \
  |  |  |  |  163|  1.76k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  765|  1.76k|		}
  766|  2.14k|	}
  767|       |
  768|  12.2k|	if (apdu.resplen < 2)
  ------------------
  |  Branch (768:6): [True: 583, False: 11.6k]
  ------------------
  769|  12.2k|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    583|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    583|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    583|	int _ret = r; \
  |  |  |  |  155|    583|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 583, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    583|		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|    583|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 583, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    583|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    583|	} 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|    583|	return _ret; \
  |  |  |  |  163|    583|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  770|  11.6k|	switch (apdu.resp[0]) {
  771|  9.76k|	case ISO7816_TAG_FCI:
  ------------------
  |  |   15|  9.76k|#define ISO7816_TAG_FCI			0x6F
  ------------------
  |  Branch (771:2): [True: 9.76k, False: 1.93k]
  ------------------
  772|  11.4k|	case ISO7816_TAG_FCP:
  ------------------
  |  |   17|  11.4k|#define ISO7816_TAG_FCP			0x62
  ------------------
  |  Branch (772:2): [True: 1.67k, False: 10.0k]
  ------------------
  773|  11.4k|		file = sc_file_new();
  774|  11.4k|		if (file == NULL)
  ------------------
  |  Branch (774:7): [True: 0, False: 11.4k]
  ------------------
  775|  11.4k|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  776|  11.4k|		file->path = *in_path;
  777|  11.4k|		if (card->ops->process_fci == NULL) {
  ------------------
  |  Branch (777:7): [True: 0, False: 11.4k]
  ------------------
  778|      0|			sc_file_free(file);
  779|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  780|      0|		}
  781|  11.4k|		buffer = apdu.resp;
  782|  11.4k|		r = sc_asn1_read_tag(&buffer, apdu.resplen, &cla, &tag, &buffer_len);
  783|  11.4k|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|  11.4k|#define SC_SUCCESS				0
  ------------------
  |  Branch (783:7): [True: 10.3k, False: 1.12k]
  ------------------
  784|  10.3k|			card->ops->process_fci(card, file, buffer, buffer_len);
  785|  11.4k|		*file_out = file;
  786|  11.4k|		break;
  787|     62|	case 0x00: /* proprietary coding */
  ------------------
  |  Branch (787:2): [True: 62, False: 11.6k]
  ------------------
  788|     62|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     62|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     62|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     62|	int _ret = r; \
  |  |  |  |  155|     62|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 62, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     62|		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|     62|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 62, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     62|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     62|	} 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|     62|	return _ret; \
  |  |  |  |  163|     62|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  789|    192|	default:
  ------------------
  |  Branch (789:2): [True: 192, False: 11.4k]
  ------------------
  790|    192|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    192|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    192|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    192|	int _ret = r; \
  |  |  |  |  155|    192|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 192, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    192|		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|    192|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 192, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    192|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    192|	} 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|    192|	return _ret; \
  |  |  |  |  163|    192|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  791|  11.6k|	}
  792|       |
  793|  11.4k|	return SC_SUCCESS;
  ------------------
  |  |   28|  11.4k|#define SC_SUCCESS				0
  ------------------
  794|  11.6k|}
iso7816.c:iso7816_get_response:
  917|  99.0k|{
  918|  99.0k|	struct sc_apdu apdu = {0};
  919|  99.0k|	int r;
  920|  99.0k|	size_t rlen;
  921|       |
  922|       |	/* request at most max_recv_size bytes */
  923|  99.0k|	if (*count > sc_get_max_recv_size(card))
  ------------------
  |  Branch (923:6): [True: 2.90k, False: 96.1k]
  ------------------
  924|  2.90k|		rlen = sc_get_max_recv_size(card);
  925|  96.1k|	else
  926|  96.1k|		rlen = *count;
  927|       |
  928|  99.0k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xC0, 0x00, 0x00);
  ------------------
  |  |  301|  99.0k|#define SC_APDU_CASE_2			0x22
  ------------------
  929|  99.0k|	apdu.le      = rlen;
  930|  99.0k|	apdu.resplen = rlen;
  931|  99.0k|	apdu.resp    = buf;
  932|       |	/* don't call GET RESPONSE recursively */
  933|  99.0k|	apdu.flags  |= SC_APDU_FLAGS_NO_GET_RESP;
  ------------------
  |  |  308|  99.0k|#define SC_APDU_FLAGS_NO_GET_RESP	0x00000002UL
  ------------------
  934|       |
  935|  99.0k|	r = sc_transmit_apdu(card, &apdu);
  936|  99.0k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  99.0k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  99.0k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  99.0k|	int _ret = (r); \
  |  |  |  |  168|  99.0k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 440, False: 98.6k]
  |  |  |  |  ------------------
  |  |  |  |  169|    440|		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|    440|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    440|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    440|		return _ret; \
  |  |  |  |  172|    440|	} \
  |  |  |  |  173|  99.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 98.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  937|       |
  938|  98.6k|	*count = apdu.resplen;
  939|       |
  940|  98.6k|	if (apdu.resplen == 0) {
  ------------------
  |  Branch (940:6): [True: 4.89k, False: 93.7k]
  ------------------
  941|  4.89k|		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|  4.89k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.89k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.89k|	int _ret = r; \
  |  |  |  |  155|  4.89k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.89k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.89k|		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|  2.91k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.91k, False: 1.98k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.89k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.89k|	} 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|  4.89k|	return _ret; \
  |  |  |  |  163|  4.89k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  942|  4.89k|	}
  943|  93.7k|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (943:6): [True: 26.7k, False: 66.9k]
  |  Branch (943:26): [True: 26.4k, False: 384]
  ------------------
  944|  26.4k|		r = 0;					/* no more data to read */
  945|  67.3k|	else if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (945:11): [True: 63.0k, False: 4.27k]
  ------------------
  946|  63.0k|		r = apdu.sw2 == 0 ? 256 : apdu.sw2;	/* more data to read    */
  ------------------
  |  Branch (946:7): [True: 1.98k, False: 61.0k]
  ------------------
  947|  4.27k|	else if (apdu.sw1 == 0x62 && apdu.sw2 == 0x82)
  ------------------
  |  Branch (947:11): [True: 760, False: 3.51k]
  |  Branch (947:31): [True: 693, False: 67]
  ------------------
  948|    693|		r = 0; /* Le not reached but file/record ended */
  949|  3.58k|	else
  950|  3.58k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  951|       |
  952|  93.7k|	return r;
  953|  98.6k|}
iso7816.c:iso7816_get_challenge:
  799|  4.42k|{
  800|  4.42k|	int r;
  801|  4.42k|	struct sc_apdu apdu;
  802|       |
  803|  4.42k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x84, 0x00, 0x00);
  ------------------
  |  |  301|  4.42k|#define SC_APDU_CASE_2			0x22
  ------------------
  804|  4.42k|	apdu.le = len;
  805|  4.42k|	apdu.resp = rnd;
  806|  4.42k|	apdu.resplen = len;
  807|       |
  808|  4.42k|	r = sc_transmit_apdu(card, &apdu);
  809|  4.42k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  4.42k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.42k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.42k|	int _ret = (r); \
  |  |  |  |  168|  4.42k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 4.41k]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|  4.42k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.41k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  810|       |
  811|  4.41k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  812|  4.41k|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE failed");
  ------------------
  |  |  174|  4.41k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.41k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.41k|	int _ret = (r); \
  |  |  |  |  168|  4.41k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.38k, False: 3.03k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.38k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.38k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.38k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.38k|		return _ret; \
  |  |  |  |  172|  1.38k|	} \
  |  |  |  |  173|  4.41k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  813|       |
  814|  3.03k|	if (len < apdu.resplen) {
  ------------------
  |  Branch (814:6): [True: 0, False: 3.03k]
  ------------------
  815|      0|		return (int) len;
  816|      0|	}
  817|       |
  818|  3.03k|	return (int) apdu.resplen;
  819|  3.03k|}
iso7816.c:iso7816_restore_security_env:
 1089|      7|{
 1090|      7|	struct sc_apdu apdu;
 1091|      7|	int r;
 1092|       |
 1093|      7|	if (card == NULL) {
  ------------------
  |  Branch (1093:6): [True: 0, False: 7]
  ------------------
 1094|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1095|      0|	}
 1096|       |
 1097|      7|	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x22, 0xF3, se_num);
  ------------------
  |  |  291|      7|#define SC_APDU_CASE_1			0x01
  ------------------
 1098|       |
 1099|      7|	r = sc_transmit_apdu(card, &apdu);
 1100|      7|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1101|      6|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1102|      6|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1103|       |
 1104|      5|	return r;
 1105|      6|}
iso7816.c:iso7816_set_security_env:
  994|     60|{
  995|     60|	struct sc_apdu apdu;
  996|     60|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
  997|     60|	u8 *p;
  998|     60|	int r, locked = 0;
  999|       |
 1000|     60|	if (card == NULL || env == NULL) {
  ------------------
  |  Branch (1000:6): [True: 0, False: 60]
  |  Branch (1000:22): [True: 0, False: 60]
  ------------------
 1001|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1002|      0|	}
 1003|     60|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x41, 0);
  ------------------
  |  |  293|     60|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1004|     60|	switch (env->operation) {
 1005|      0|	case SC_SEC_OPERATION_AUTHENTICATE:
  ------------------
  |  |   49|      0|#define SC_SEC_OPERATION_AUTHENTICATE	0x0003
  ------------------
  |  Branch (1005:2): [True: 0, False: 60]
  ------------------
 1006|      0|		apdu.p2 = 0xA4;
 1007|      0|		break;
 1008|     22|	case SC_SEC_OPERATION_DECIPHER:
  ------------------
  |  |   47|     22|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
  |  Branch (1008:2): [True: 22, False: 38]
  ------------------
 1009|     22|	case SC_SEC_OPERATION_DERIVE:
  ------------------
  |  |   50|     22|#define SC_SEC_OPERATION_DERIVE         0x0004
  ------------------
  |  Branch (1009:2): [True: 0, False: 60]
  ------------------
 1010|     22|		apdu.p2 = 0xB8;
 1011|     22|		break;
 1012|     38|	case SC_SEC_OPERATION_SIGN:
  ------------------
  |  |   48|     38|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  |  Branch (1012:2): [True: 38, False: 22]
  ------------------
 1013|     38|		apdu.p2 = 0xB6;
 1014|     38|		break;
 1015|      0|	default:
  ------------------
  |  Branch (1015:2): [True: 0, False: 60]
  ------------------
 1016|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1017|     60|	}
 1018|     60|	p = sbuf;
 1019|     60|	if (env->flags & SC_SEC_ENV_ALG_REF_PRESENT) {
  ------------------
  |  |   56|     60|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
  |  Branch (1019:6): [True: 60, False: 0]
  ------------------
 1020|     60|		*p++ = 0x80;	/* algorithm reference */
 1021|     60|		*p++ = 0x01;
 1022|     60|		*p++ = env->algorithm_ref & 0xFF;
 1023|     60|	}
 1024|     60|	if (env->flags & SC_SEC_ENV_FILE_REF_PRESENT) {
  ------------------
  |  |   57|     60|#define SC_SEC_ENV_FILE_REF_PRESENT	0x0002
  ------------------
  |  Branch (1024:6): [True: 0, False: 60]
  ------------------
 1025|      0|		if (env->file_ref.len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|      0|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (1025:7): [True: 0, False: 0]
  ------------------
 1026|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1027|      0|		if (sizeof(sbuf) - (p - sbuf) < env->file_ref.len + 2)
  ------------------
  |  Branch (1027:7): [True: 0, False: 0]
  ------------------
 1028|      0|			return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      0|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
 1029|       |
 1030|      0|		*p++ = 0x81;
 1031|      0|		*p++ = (u8) env->file_ref.len;
 1032|      0|		memcpy(p, env->file_ref.value, env->file_ref.len);
 1033|      0|		p += env->file_ref.len;
 1034|      0|	}
 1035|     60|	if (env->flags & SC_SEC_ENV_KEY_REF_PRESENT) {
  ------------------
  |  |   58|     60|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
  |  Branch (1035:6): [True: 60, False: 0]
  ------------------
 1036|     60|		if (sizeof(sbuf) - (p - sbuf) < env->key_ref_len + 2)
  ------------------
  |  Branch (1036:7): [True: 0, False: 60]
  ------------------
 1037|      0|			return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      0|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
 1038|       |
 1039|     60|		if (env->flags & SC_SEC_ENV_KEY_REF_SYMMETRIC)
  ------------------
  |  |   59|     60|#define SC_SEC_ENV_KEY_REF_SYMMETRIC	0x0008
  ------------------
  |  Branch (1039:7): [True: 0, False: 60]
  ------------------
 1040|      0|			*p++ = 0x83;
 1041|     60|		else
 1042|     60|			*p++ = 0x84;
 1043|     60|		if (env->key_ref_len > SC_MAX_KEYREF_SIZE)
  ------------------
  |  |   53|     60|#define SC_MAX_KEYREF_SIZE		8
  ------------------
  |  Branch (1043:7): [True: 0, False: 60]
  ------------------
 1044|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1045|     60|		*p++ = env->key_ref_len & 0xFF;
 1046|     60|		memcpy(p, env->key_ref, env->key_ref_len);
 1047|     60|		p += env->key_ref_len;
 1048|     60|	}
 1049|     60|	r = (int)(p - sbuf);
 1050|     60|	apdu.lc = r;
 1051|     60|	apdu.datalen = r;
 1052|     60|	apdu.data = sbuf;
 1053|     60|	if (se_num > 0) {
  ------------------
  |  Branch (1053:6): [True: 0, False: 60]
  ------------------
 1054|      0|		r = sc_lock(card);
 1055|      0|		LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1056|      0|		locked = 1;
 1057|      0|	}
 1058|     60|	if (apdu.datalen != 0) {
  ------------------
  |  Branch (1058:6): [True: 60, False: 0]
  ------------------
 1059|     60|		r = sc_transmit_apdu(card, &apdu);
 1060|     60|		if (r) {
  ------------------
  |  Branch (1060:7): [True: 1, False: 59]
  ------------------
 1061|      1|			sc_log(card->ctx, "%s: APDU transmit failed", sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1062|      1|			goto err;
 1063|      1|		}
 1064|     59|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1065|     59|		if (r) {
  ------------------
  |  Branch (1065:7): [True: 18, False: 41]
  ------------------
 1066|     18|			sc_log(card->ctx, "%s: Card returned error", sc_strerror(r));
  ------------------
  |  |   71|     18|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1067|     18|			goto err;
 1068|     18|		}
 1069|     59|	}
 1070|     41|	if (se_num <= 0) {
  ------------------
  |  Branch (1070:6): [True: 41, False: 0]
  ------------------
 1071|     41|		r = SC_SUCCESS;
  ------------------
  |  |   28|     41|#define SC_SUCCESS				0
  ------------------
 1072|     41|		goto err;
 1073|     41|	}
 1074|      0|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0xF2, se_num);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1075|      0|	r = sc_transmit_apdu(card, &apdu);
 1076|      0|	sc_unlock(card);
 1077|      0|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1078|       |
 1079|      0|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
 1080|     60|err:
 1081|     60|	if (locked)
  ------------------
  |  Branch (1081:6): [True: 0, False: 60]
  ------------------
 1082|      0|		sc_unlock(card);
 1083|     60|	return r;
 1084|      0|}
iso7816.c:iso7816_compute_signature:
 1112|      5|{
 1113|      5|	int r;
 1114|      5|	struct sc_apdu apdu;
 1115|       |
 1116|      5|	if (card == NULL || data == NULL || out == NULL) {
  ------------------
  |  Branch (1116:6): [True: 0, False: 5]
  |  Branch (1116:22): [True: 0, False: 5]
  |  Branch (1116:38): [True: 0, False: 5]
  ------------------
 1117|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1118|      0|	}
 1119|      5|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      5|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      5|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      5|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      5|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1120|      5|	sc_log(card->ctx, "ISO7816 compute signature: in-len %zu, out-len %zu", datalen, outlen);
  ------------------
  |  |   71|      5|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1121|       |
 1122|       |	/* INS: 0x2A  PERFORM SECURITY OPERATION
 1123|       |	 * P1:  0x9E  Resp: Digital Signature
 1124|       |	 * P2:  0x9A  Cmd: Input for Digital Signature */
 1125|      5|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x2A, 0x9E, 0x9A);
  ------------------
  |  |  303|      5|#define SC_APDU_CASE_4			0x24
  ------------------
 1126|      5|	apdu.resp = out;
 1127|      5|	apdu.resplen = outlen;
 1128|      5|	apdu.le = outlen;
 1129|       |
 1130|      5|	apdu.data = data;
 1131|      5|	apdu.lc = datalen;
 1132|      5|	apdu.datalen = datalen;
 1133|       |
 1134|      5|	iso7816_fixup_transceive_length(card, &apdu);
 1135|      5|	r = sc_transmit_apdu(card, &apdu);
 1136|      5|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|      5|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      5|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      5|	int _ret = (r); \
  |  |  |  |  168|      5|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1137|      4|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (1137:6): [True: 3, False: 1]
  |  Branch (1137:26): [True: 2, False: 1]
  ------------------
 1138|      4|		LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} else { \
  |  |  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      1|	} \
  |  |  |  |  162|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1139|       |
 1140|      2|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1141|      2|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1142|       |
 1143|      0|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1144|      0|}
iso7816.c:iso7816_check_sw:
  110|   413k|{
  111|   413k|	const int err_count = sizeof(iso7816_errors)/sizeof(iso7816_errors[0]);
  112|   413k|	int i;
  113|       |
  114|       |	/* Handle special cases here */
  115|   413k|	if (sw1 == 0x6C) {
  ------------------
  |  Branch (115:6): [True: 257, False: 413k]
  ------------------
  116|    257|		sc_log(card->ctx, "Wrong length; correct length is %d", sw2);
  ------------------
  |  |   71|    257|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  117|    257|		return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|    257|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  118|    257|	}
  119|   413k|	if (sw1 == 0x90 && sw2 == 0x00)
  ------------------
  |  Branch (119:6): [True: 143k, False: 270k]
  |  Branch (119:21): [True: 136k, False: 6.68k]
  ------------------
  120|   136k|		return SC_SUCCESS;
  ------------------
  |  |   28|   136k|#define SC_SUCCESS				0
  ------------------
  121|   277k|	if (sw1 == 0x63U && (sw2 & ~0x0fU) == 0xc0U) {
  ------------------
  |  Branch (121:6): [True: 2.53k, False: 274k]
  |  Branch (121:22): [True: 146, False: 2.38k]
  ------------------
  122|    146|		sc_log(card->ctx, "PIN not verified (remaining tries: %d)", (sw2 & 0x0f));
  ------------------
  |  |   71|    146|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  123|    146|		return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|    146|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  124|    146|	}
  125|  11.3M|	for (i = 0; i < err_count; i++)   {
  ------------------
  |  Branch (125:14): [True: 11.2M, False: 29.3k]
  ------------------
  126|  11.2M|		if (iso7816_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (126:7): [True: 247k, False: 11.0M]
  ------------------
  127|   247k|			sc_log(card->ctx, "%s", iso7816_errors[i].errorstr);
  ------------------
  |  |   71|   247k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  128|   247k|			return iso7816_errors[i].errorno;
  129|   247k|		}
  130|  11.2M|	}
  131|       |
  132|  29.3k|	sc_log(card->ctx, "Unknown SWs; SW1=%02X, SW2=%02X", sw1, sw2);
  ------------------
  |  |   71|  29.3k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  133|  29.3k|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|  29.3k|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  134|   276k|}
iso7816.c:iso7816_process_fci:
  635|  9.72k|{
  636|  9.72k|	return iso7816_process_fci_nested(card, file, buf, buflen, 0);
  637|  9.72k|}
iso7816.c:iso7816_process_fci_nested:
  432|  11.2k|{
  433|  11.2k|	struct sc_context *ctx = card->ctx;
  434|  11.2k|	const unsigned char *p, *end;
  435|  11.2k|	unsigned int cla = 0, tag = 0;
  436|  11.2k|	size_t length;
  437|       |
  438|  11.2k|	file->status = SC_FILE_STATUS_UNKNOWN;
  ------------------
  |  |  254|  11.2k|#define SC_FILE_STATUS_UNKNOWN		0xff /* if tag 0x8A is missing, there is no information about LCSB */
  ------------------
  439|       |
  440|  11.2k|	for (p = buf, length = buflen, end = buf + buflen;
  441|  30.9k|			p < end;
  ------------------
  |  Branch (441:4): [True: 27.8k, False: 3.05k]
  ------------------
  442|  27.8k|			p += length, length = end - p) {
  443|       |
  444|  27.8k|		if (SC_SUCCESS != sc_asn1_read_tag(&p, length, &cla, &tag, &length)
  ------------------
  |  |   28|  27.8k|#define SC_SUCCESS				0
  ------------------
  |  Branch (444:7): [True: 5.02k, False: 22.8k]
  ------------------
  445|  22.8k|				|| p == NULL) {
  ------------------
  |  Branch (445:8): [True: 3.14k, False: 19.6k]
  ------------------
  446|  8.17k|			break;
  447|  8.17k|		}
  448|  19.6k|		switch (cla | tag) {
  ------------------
  |  Branch (448:11): [True: 15.9k, False: 3.77k]
  ------------------
  449|  1.59k|			case 0x81:
  ------------------
  |  Branch (449:4): [True: 1.59k, False: 18.0k]
  ------------------
  450|  1.59k|				if (file->size != 0) {
  ------------------
  |  Branch (450:9): [True: 85, False: 1.50k]
  ------------------
  451|       |					/* don't overwrite existing file size excluding structural information */
  452|     85|					break;
  453|     85|				}
  454|       |				/* fall through */
  455|  5.41k|			case 0x80:
  ------------------
  |  Branch (455:4): [True: 3.90k, False: 15.7k]
  ------------------
  456|       |				/* determine the file size */
  457|  5.41k|				file->size = 0;
  458|  5.41k|				if (p && length <= sizeof(size_t)) {
  ------------------
  |  Branch (458:9): [True: 5.41k, False: 0]
  |  Branch (458:14): [True: 5.32k, False: 93]
  ------------------
  459|  5.32k|					size_t size = 0, i;
  460|  17.4k|					for (i = 0; i < length; i++) {
  ------------------
  |  Branch (460:18): [True: 12.1k, False: 5.32k]
  ------------------
  461|  12.1k|						size <<= 8;
  462|  12.1k|						size |= p[i];
  463|  12.1k|					}
  464|  5.32k|					if (size > MAX_FILE_SIZE) {
  ------------------
  |  |  220|  5.32k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (464:10): [True: 783, False: 4.53k]
  ------------------
  465|    783|						file->size = MAX_FILE_SIZE;
  ------------------
  |  |  220|    783|#define MAX_FILE_SIZE 65535
  ------------------
  466|    783|						sc_log(ctx, "  file size truncated, encoded length: %zu", size);
  ------------------
  |  |   71|    783|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  467|  4.53k|					} else {
  468|  4.53k|						file->size = size;
  469|  4.53k|					}
  470|  5.32k|				}
  471|       |
  472|  5.41k|				sc_log(ctx, "  bytes in file: %zu", file->size);
  ------------------
  |  |   71|  5.41k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  473|  5.41k|				break;
  474|       |
  475|  3.27k|			case 0x82:
  ------------------
  |  Branch (475:4): [True: 3.27k, False: 16.4k]
  ------------------
  476|  3.27k|				if (length > 0) {
  ------------------
  |  Branch (476:9): [True: 2.95k, False: 323]
  ------------------
  477|  2.95k|					unsigned char byte = p[0];
  478|  2.95k|					const char *type;
  479|       |
  480|  2.95k|					file->shareable = byte & 0x40 ? 1 : 0;
  ------------------
  |  Branch (480:24): [True: 445, False: 2.51k]
  ------------------
  481|  2.95k|					sc_log(ctx, "  shareable: %s", (byte & 0x40) ? "yes" : "no");
  ------------------
  |  |   71|  5.91k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 445, False: 2.51k]
  |  |  ------------------
  ------------------
  482|  2.95k|					file->ef_structure = byte & 0x07;
  483|  2.95k|					switch ((byte >> 3) & 7) {
  484|  1.93k|						case 0:
  ------------------
  |  Branch (484:7): [True: 1.93k, False: 1.01k]
  ------------------
  485|  1.93k|							type = "working EF";
  486|  1.93k|							file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|  1.93k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  487|  1.93k|							break;
  488|    193|						case 1:
  ------------------
  |  Branch (488:7): [True: 193, False: 2.76k]
  ------------------
  489|    193|							type = "internal EF";
  490|    193|							file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|    193|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  491|    193|							break;
  492|    450|						case 7:
  ------------------
  |  Branch (492:7): [True: 450, False: 2.50k]
  ------------------
  493|    450|							type = "DF";
  494|    450|							file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    450|#define SC_FILE_TYPE_DF			0x04
  ------------------
  495|    450|							break;
  496|    375|						default:
  ------------------
  |  Branch (496:7): [True: 375, False: 2.58k]
  ------------------
  497|    375|							file->type = SC_FILE_TYPE_UNKNOWN;
  ------------------
  |  |  213|    375|#define SC_FILE_TYPE_UNKNOWN		0x00
  ------------------
  498|    375|							type = "unknown";
  499|    375|							break;
  500|  2.95k|					}
  501|  2.95k|					sc_log(ctx, "  type: %s", type);
  ------------------
  |  |   71|  2.95k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  502|  2.95k|					sc_log(ctx, "  EF structure: %d", byte & 0x07);
  ------------------
  |  |   71|  2.95k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  503|  2.95k|					sc_log(ctx, "  tag 0x82: 0x%02x", byte);
  ------------------
  |  |   71|  2.95k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  504|       |
  505|       |					/* if possible, get additional information for non-DFs */
  506|  2.95k|					if (file->type != SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|  2.95k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (506:10): [True: 2.50k, False: 450]
  ------------------
  507|       |						/* max. record length for fixed- & variable-sized records */
  508|  2.50k|						if (length > 2 && byte & 0x06) {
  ------------------
  |  Branch (508:11): [True: 485, False: 2.02k]
  |  Branch (508:25): [True: 302, False: 183]
  ------------------
  509|    302|							file->record_length = (length > 3)
  ------------------
  |  Branch (509:30): [True: 229, False: 73]
  ------------------
  510|    302|								? bebytes2ushort(p+2)
  511|    302|								: p[2];
  512|    302|							sc_log(ctx, "  record length: %zu", file->record_length);
  ------------------
  |  |   71|    302|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  513|    302|						}
  514|       |
  515|       |						/* number of records */
  516|  2.50k|						if (length > 4) {
  ------------------
  |  Branch (516:11): [True: 358, False: 2.14k]
  ------------------
  517|    358|							file->record_count = (length > 5)
  ------------------
  |  Branch (517:29): [True: 199, False: 159]
  ------------------
  518|    358|								? bebytes2ushort(p+4)
  519|    358|								: p[4];
  520|    358|							sc_log(ctx, "  records: %zu", file->record_count);
  ------------------
  |  |   71|    358|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  521|    358|						}
  522|  2.50k|					}
  523|       |
  524|  2.95k|					if (SC_SUCCESS != sc_file_set_type_attr(file, p, length))
  ------------------
  |  |   28|  2.95k|#define SC_SUCCESS				0
  ------------------
  |  Branch (524:10): [True: 0, False: 2.95k]
  ------------------
  525|      0|						sc_log(ctx, "Warning: Could not set file attributes");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  526|  2.95k|				}
  527|  3.27k|				break;
  528|       |
  529|  3.27k|			case 0x83:
  ------------------
  |  Branch (529:4): [True: 704, False: 18.9k]
  ------------------
  530|    704|				if (length == 2) {
  ------------------
  |  Branch (530:9): [True: 447, False: 257]
  ------------------
  531|    447|					file->id = (p[0] << 8) | p[1];
  532|    447|					sc_log(ctx, "  file identifier: 0x%02X%02X", p[0], p[1]);
  ------------------
  |  |   71|    447|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  533|    447|				}
  534|    704|				break;
  535|       |
  536|    700|			case 0x84:
  ------------------
  |  Branch (536:4): [True: 700, False: 18.9k]
  ------------------
  537|    700|				if (length > 0 && length <= 16) {
  ------------------
  |  Branch (537:9): [True: 501, False: 199]
  |  Branch (537:23): [True: 482, False: 19]
  ------------------
  538|    482|					memcpy(file->name, p, length);
  539|    482|					file->namelen = length;
  540|       |
  541|    482|					sc_log_hex(ctx, "  File name:", file->name, file->namelen);
  ------------------
  |  |  129|    482|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    482|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  542|    482|					if (!file->type)
  ------------------
  |  Branch (542:10): [True: 143, False: 339]
  ------------------
  543|    143|						file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    143|#define SC_FILE_TYPE_DF			0x04
  ------------------
  544|    482|				}
  545|    700|				break;
  546|       |
  547|    653|			case 0x85:
  ------------------
  |  Branch (547:4): [True: 653, False: 19.0k]
  ------------------
  548|    858|			case 0xA5:
  ------------------
  |  Branch (548:4): [True: 205, False: 19.4k]
  ------------------
  549|    858|				if (SC_SUCCESS != sc_file_set_prop_attr(file, p, length)) {
  ------------------
  |  |   28|    858|#define SC_SUCCESS				0
  ------------------
  |  Branch (549:9): [True: 0, False: 858]
  ------------------
  550|      0|					sc_log(ctx, "Warning: Could not set proprietary file properties");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  551|      0|				}
  552|    858|				break;
  553|       |
  554|  1.43k|			case 0x86:
  ------------------
  |  Branch (554:4): [True: 1.43k, False: 18.2k]
  ------------------
  555|  1.43k|				if (SC_SUCCESS != sc_file_set_sec_attr(file, p, length)) {
  ------------------
  |  |   28|  1.43k|#define SC_SUCCESS				0
  ------------------
  |  Branch (555:9): [True: 0, False: 1.43k]
  ------------------
  556|      0|					sc_log(ctx, "Warning: Could not set file security properties");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  557|      0|				}
  558|  1.43k|				break;
  559|       |
  560|    311|			case 0x88:
  ------------------
  |  Branch (560:4): [True: 311, False: 19.3k]
  ------------------
  561|    311|				if (length == 1) {
  ------------------
  |  Branch (561:9): [True: 77, False: 234]
  ------------------
  562|     77|					file->sid = *p;
  563|     77|					sc_log(ctx, "  short file identifier: 0x%02X", *p);
  ------------------
  |  |   71|     77|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  564|     77|				}
  565|    311|				break;
  566|       |
  567|  1.61k|			case 0x8A:
  ------------------
  |  Branch (567:4): [True: 1.61k, False: 18.0k]
  ------------------
  568|  1.61k|				if (length == 1) {
  ------------------
  |  Branch (568:9): [True: 1.40k, False: 211]
  ------------------
  569|  1.40k|					switch (p[0]) {
  570|     68|						case 0:
  ------------------
  |  Branch (570:7): [True: 68, False: 1.33k]
  ------------------
  571|     68|							file->status =SC_FILE_STATUS_NO_INFO;
  ------------------
  |  |  243|     68|#define SC_FILE_STATUS_NO_INFO		0x04 /* ISO7816-4: No information given, (0) */
  ------------------
  572|     68|							break;
  573|     69|						case 1:
  ------------------
  |  Branch (573:7): [True: 69, False: 1.33k]
  ------------------
  574|     69|							file->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|     69|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  575|     69|							break;
  576|     66|						case 3:
  ------------------
  |  Branch (576:7): [True: 66, False: 1.33k]
  ------------------
  577|     66|							file->status = SC_FILE_STATUS_INITIALISATION;
  ------------------
  |  |  242|     66|#define SC_FILE_STATUS_INITIALISATION	0x03 /* ISO7816-4: Initialisation state, (3) */
  ------------------
  578|     66|							break;
  579|     67|						case 4:
  ------------------
  |  Branch (579:7): [True: 67, False: 1.33k]
  ------------------
  580|    133|						case 6:
  ------------------
  |  Branch (580:7): [True: 66, False: 1.33k]
  ------------------
  581|    133|							file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|    133|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  582|    133|							break;
  583|    332|						case 5:
  ------------------
  |  Branch (583:7): [True: 332, False: 1.07k]
  ------------------
  584|    399|						case 7:
  ------------------
  |  Branch (584:7): [True: 67, False: 1.33k]
  ------------------
  585|    399|							file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|    399|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  586|    399|							break;
  587|     67|						case 12:
  ------------------
  |  Branch (587:7): [True: 67, False: 1.33k]
  ------------------
  588|    133|						case 13:
  ------------------
  |  Branch (588:7): [True: 66, False: 1.33k]
  ------------------
  589|    199|						case 14:
  ------------------
  |  Branch (589:7): [True: 66, False: 1.33k]
  ------------------
  590|    265|						case 15:
  ------------------
  |  Branch (590:7): [True: 66, False: 1.33k]
  ------------------
  591|    265|							file->status = SC_FILE_STATUS_TERMINATION;
  ------------------
  |  |  244|    265|#define SC_FILE_STATUS_TERMINATION	0x0c /* ISO7816-4: Termination state (12,13,14,15) */
  ------------------
  592|    265|							break;
  593|     66|						case 2:
  ------------------
  |  Branch (593:7): [True: 66, False: 1.33k]
  ------------------
  594|     66|							file->status = SC_FILE_STATUS_RFU_2;
  ------------------
  |  |  248|     66|#define SC_FILE_STATUS_RFU_2		0x07 /* ISO7816-4: (0x02) */
  ------------------
  595|     66|							break;
  596|     66|						case 8:
  ------------------
  |  Branch (596:7): [True: 66, False: 1.33k]
  ------------------
  597|     66|							file->status = SC_FILE_STATUS_RFU_8;
  ------------------
  |  |  249|     66|#define SC_FILE_STATUS_RFU_8		0x08 /* ISO7816-4: (0x08) */
  ------------------
  598|     66|							break;
  599|     66|						case 9:
  ------------------
  |  Branch (599:7): [True: 66, False: 1.33k]
  ------------------
  600|     66|							file->status = SC_FILE_STATUS_RFU_9;
  ------------------
  |  |  250|     66|#define SC_FILE_STATUS_RFU_9		0x09 /* ISO7816-4: (0x09) */
  ------------------
  601|     66|							break;
  602|     66|						case 10:
  ------------------
  |  Branch (602:7): [True: 66, False: 1.33k]
  ------------------
  603|     66|							file->status = SC_FILE_STATUS_RFU_10;
  ------------------
  |  |  251|     66|#define SC_FILE_STATUS_RFU_10		0x0a /* ISO7816-4: (0x0a) */
  ------------------
  604|     66|							break;
  605|     67|						case 11:
  ------------------
  |  Branch (605:7): [True: 67, False: 1.33k]
  ------------------
  606|     67|							file->status = SC_FILE_STATUS_RFU_11;
  ------------------
  |  |  252|     67|#define SC_FILE_STATUS_RFU_11		0x0b /* ISO7816-4: (0x0b) */
  ------------------
  607|     67|							break;
  608|     71|						default:
  ------------------
  |  Branch (608:7): [True: 71, False: 1.33k]
  ------------------
  609|     71|							file->status = SC_FILE_STATUS_PROPRIETARY;
  ------------------
  |  |  245|     71|#define SC_FILE_STATUS_PROPRIETARY	0xf0 /* ISO7816-4: codes > 15 */
  ------------------
  610|  1.40k|					}
  611|  1.40k|				}
  612|  1.61k|				break;
  613|       |
  614|  1.61k|			case 0x62:
  ------------------
  |  Branch (614:4): [True: 1.12k, False: 18.5k]
  ------------------
  615|  1.21k|			case 0x64:
  ------------------
  |  Branch (615:4): [True: 90, False: 19.5k]
  ------------------
  616|  1.50k|			case 0x6F:
  ------------------
  |  Branch (616:4): [True: 287, False: 19.3k]
  ------------------
  617|       |				/* allow nested FCP/FMD/FCI templates */
  618|  1.50k|				if (depth >= ISO7816_MAX_FCI_TEMPLATE_NESTING) {
  ------------------
  |  |  427|  1.50k|#define ISO7816_MAX_FCI_TEMPLATE_NESTING 32
  ------------------
  |  Branch (618:9): [True: 0, False: 1.50k]
  ------------------
  619|      0|					sc_log(ctx, "FCP/FMD/FCI template nesting too deep, skipping");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  620|      0|					break;
  621|      0|				}
  622|  1.50k|				iso7816_process_fci_nested(card, file, p, length, depth + 1);
  623|  19.6k|		}
  624|  19.6k|	}
  625|       |
  626|  11.2k|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|  11.2k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  627|       |
  628|  11.2k|	return SC_SUCCESS;
  ------------------
  |  |   28|  11.2k|#define SC_SUCCESS				0
  ------------------
  629|  11.2k|}
iso7816.c:iso7816_pin_cmd:
 1295|  2.61k|{
 1296|  2.61k|	struct sc_apdu local_apdu, *apdu;
 1297|  2.61k|	int r;
 1298|  2.61k|	u8  sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1299|       |
 1300|  2.61k|	data->pin1.tries_left = -1;
 1301|       |
 1302|       |	/* Many cards do support PIN status queries, but some cards don't and
 1303|       |	 * mistakenly count the command as a failed PIN attempt, so for now we
 1304|       |	 * allow cards with this flag.  In future this may be reduced to a
 1305|       |	 * blocklist, subject to testing more cards. */
 1306|  2.61k|	if (data->cmd == SC_PIN_CMD_GET_INFO &&
  ------------------
  |  |  418|  5.22k|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1306:6): [True: 2.28k, False: 328]
  ------------------
 1307|  2.28k|	    !(card->caps & SC_CARD_CAP_ISO7816_PIN_INFO)) {
  ------------------
  |  |  553|  2.28k|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  |  Branch (1307:6): [True: 499, False: 1.78k]
  ------------------
 1308|    499|		sc_log(card->ctx, "Card does not support PIN status queries");
  ------------------
  |  |   71|    499|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1309|    499|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    499|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1310|    499|	}
 1311|       |
 1312|       |	/* See if we've been called from another card driver, which is
 1313|       |	 * passing an APDU to us (this allows to write card drivers
 1314|       |	 * whose PIN functions behave "mostly like ISO" except in some
 1315|       |	 * special circumstances.
 1316|       |	 */
 1317|  2.11k|	if (data->apdu == NULL) {
  ------------------
  |  Branch (1317:6): [True: 2.11k, False: 1]
  ------------------
 1318|  2.11k|		r = iso7816_build_pin_apdu(card, &local_apdu, data, sbuf, sizeof(sbuf));
 1319|  2.11k|		if (r < 0)
  ------------------
  |  Branch (1319:7): [True: 16, False: 2.09k]
  ------------------
 1320|     16|			return r;
 1321|  2.09k|		data->apdu = &local_apdu;
 1322|  2.09k|	}
 1323|  2.09k|	apdu = data->apdu;
 1324|       |
 1325|  2.09k|	if (!(data->flags & SC_PIN_CMD_USE_PINPAD) || data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  421|  2.09k|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
              	if (!(data->flags & SC_PIN_CMD_USE_PINPAD) || data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  418|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1325:6): [True: 2.09k, False: 0]
  |  Branch (1325:48): [True: 0, False: 0]
  ------------------
 1326|       |		/* Transmit the APDU to the card */
 1327|  2.09k|		r = sc_transmit_apdu(card, apdu);
 1328|       |
 1329|       |		/* Clear the buffer - it may contain pins */
 1330|  2.09k|		sc_mem_clear(sbuf, sizeof(sbuf));
 1331|  2.09k|	}
 1332|      0|	else {
 1333|       |		/* Call the reader driver to collect
 1334|       |		 * the PIN and pass on the APDU to the card */
 1335|      0|		if (data->pin1.offset == 0) {
  ------------------
  |  Branch (1335:7): [True: 0, False: 0]
  ------------------
 1336|      0|			sc_log(card->ctx, "Card driver didn't set PIN offset");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1337|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1338|      0|		}
 1339|      0|		if (card->reader && card->reader->ops && card->reader->ops->perform_verify) {
  ------------------
  |  Branch (1339:7): [True: 0, False: 0]
  |  Branch (1339:23): [True: 0, False: 0]
  |  Branch (1339:44): [True: 0, False: 0]
  ------------------
 1340|      0|			r = card->reader->ops->perform_verify(card->reader, data);
 1341|       |			/* sw1/sw2 filled in by reader driver */
 1342|      0|		}
 1343|      0|		else {
 1344|      0|			sc_log(card->ctx, "Card reader driver does not support "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1345|      0|					"PIN entry through reader key pad");
 1346|      0|			r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1347|      0|		}
 1348|      0|	}
 1349|       |
 1350|       |	/* Don't pass references to local variables up to the caller. */
 1351|  2.09k|	if (data->apdu == &local_apdu)
  ------------------
  |  Branch (1351:6): [True: 2.09k, False: 1]
  ------------------
 1352|  2.09k|		data->apdu = NULL;
 1353|       |
 1354|  2.09k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.09k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.09k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.09k|	int _ret = (r); \
  |  |  |  |  168|  2.09k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 17, False: 2.08k]
  |  |  |  |  ------------------
  |  |  |  |  169|     17|		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|     17|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     17|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     17|		return _ret; \
  |  |  |  |  172|     17|	} \
  |  |  |  |  173|  2.09k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.08k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1355|  2.08k|	r = sc_check_sw(card, apdu->sw1, apdu->sw2);
 1356|       |
 1357|  2.08k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  2.08k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1357:6): [True: 963, False: 1.11k]
  ------------------
 1358|    963|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  432|    963|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
 1359|  1.11k|	} else if (r == SC_ERROR_PIN_CODE_INCORRECT) {
  ------------------
  |  |   64|  1.11k|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (1359:13): [True: 15, False: 1.10k]
  ------------------
 1360|     15|		data->pin1.tries_left = apdu->sw2 & 0xF;
 1361|     15|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  431|     15|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 1362|     15|		if (data->cmd == SC_PIN_CMD_GET_INFO)
  ------------------
  |  |  418|     15|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1362:7): [True: 12, False: 3]
  ------------------
 1363|     12|			r = SC_SUCCESS;
  ------------------
  |  |   28|     12|#define SC_SUCCESS				0
  ------------------
 1364|  1.10k|	} else if (r == SC_ERROR_AUTH_METHOD_BLOCKED) {
  ------------------
  |  |   62|  1.10k|#define SC_ERROR_AUTH_METHOD_BLOCKED		-1212
  ------------------
  |  Branch (1364:13): [True: 2, False: 1.10k]
  ------------------
 1365|      2|		data->pin1.tries_left = 0;
 1366|      2|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  431|      2|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 1367|      2|		if (data->cmd == SC_PIN_CMD_GET_INFO)
  ------------------
  |  |  418|      2|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1367:7): [True: 1, False: 1]
  ------------------
 1368|      1|			r = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1369|      2|	}
 1370|       |
 1371|  2.08k|	return r;
 1372|  2.09k|}
iso7816.c:iso7816_get_data:
 1376|    200|{
 1377|    200|	int                             r, cse;
 1378|    200|	struct sc_apdu                  apdu;
 1379|       |
 1380|    200|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    200|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    200|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    200|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 200]
  |  |  ------------------
  ------------------
 1381|       |
 1382|    200|	if (buf && len)
  ------------------
  |  Branch (1382:6): [True: 200, False: 0]
  |  Branch (1382:13): [True: 200, False: 0]
  ------------------
 1383|    200|		cse = SC_APDU_CASE_2;
  ------------------
  |  |  301|    200|#define SC_APDU_CASE_2			0x22
  ------------------
 1384|      0|	else
 1385|      0|		cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 1386|       |
 1387|    200|	sc_format_apdu(card, &apdu, cse, 0xCA, (tag >> 8) & 0xff, tag & 0xff);
 1388|    200|	apdu.le = len;
 1389|    200|	apdu.resp = buf;
 1390|    200|	apdu.resplen = len;
 1391|    200|	r = sc_transmit_apdu(card, &apdu);
 1392|    200|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    200|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    200|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    200|	int _ret = (r); \
  |  |  |  |  168|    200|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 195]
  |  |  |  |  ------------------
  |  |  |  |  169|      5|		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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      5|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      5|		return _ret; \
  |  |  |  |  172|      5|	} \
  |  |  |  |  173|    200|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 195]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1393|       |
 1394|    195|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1395|    195|	LOG_TEST_RET(card->ctx, r, "GET_DATA returned error");
  ------------------
  |  |  174|    195|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    195|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    195|	int _ret = (r); \
  |  |  |  |  168|    195|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 66, False: 129]
  |  |  |  |  ------------------
  |  |  |  |  169|     66|		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|     66|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     66|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     66|		return _ret; \
  |  |  |  |  172|     66|	} \
  |  |  |  |  173|    195|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 129]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1396|       |
 1397|    129|	if (apdu.resplen > len)
  ------------------
  |  Branch (1397:6): [True: 0, False: 129]
  ------------------
 1398|      0|		r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 1399|    129|	else
 1400|    129|		r = (int)apdu.resplen;
 1401|       |
 1402|    129|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    129|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    129|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    129|	int _ret = r; \
  |  |  |  |  155|    129|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12, False: 117]
  |  |  |  |  ------------------
  |  |  |  |  156|     12|		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: 12]
  |  |  |  |  ------------------
  |  |  |  |  157|     12|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    117|	} else { \
  |  |  |  |  159|    117|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    117|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    117|	} \
  |  |  |  |  162|    129|	return _ret; \
  |  |  |  |  163|    129|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1403|    129|}
iso7816.c:iso7816_read_binary:
  139|  29.8k|{
  140|  29.8k|	struct sc_context *ctx = card->ctx;
  141|  29.8k|	struct sc_apdu apdu;
  142|  29.8k|	int r;
  143|       |
  144|  29.8k|	if (idx > 0x7FFF) {
  ------------------
  |  Branch (144:6): [True: 10, False: 29.8k]
  ------------------
  145|     10|		sc_log(ctx, "invalid EF offset: 0x%X > 0x7FFF", idx);
  ------------------
  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  146|     10|		return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|     10|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
  147|     10|	}
  148|       |
  149|  29.8k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xB0, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  301|  29.8k|#define SC_APDU_CASE_2			0x22
  ------------------
  150|  29.8k|	apdu.le = count;
  151|  29.8k|	apdu.resplen = count;
  152|  29.8k|	apdu.resp = buf;
  153|       |
  154|  29.8k|	iso7816_fixup_transceive_length(card, &apdu);
  155|  29.8k|	r = sc_transmit_apdu(card, &apdu);
  156|  29.8k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  29.8k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  29.8k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  29.8k|	int _ret = (r); \
  |  |  |  |  168|  29.8k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 843, False: 29.0k]
  |  |  |  |  ------------------
  |  |  |  |  169|    843|		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|    843|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    843|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    843|		return _ret; \
  |  |  |  |  172|    843|	} \
  |  |  |  |  173|  29.8k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 29.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  157|       |
  158|  29.0k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  159|  29.0k|	if (r == SC_ERROR_FILE_END_REACHED || r == SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   69|  58.0k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
              	if (r == SC_ERROR_FILE_END_REACHED || r == SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   55|  28.6k|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (159:6): [True: 440, False: 28.6k]
  |  Branch (159:40): [True: 97, False: 28.5k]
  ------------------
  160|  29.0k|		LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  164|    537|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    537|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    537|	int _ret = r; \
  |  |  |  |  155|    537|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 98, False: 439]
  |  |  |  |  ------------------
  |  |  |  |  156|     98|		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: 98]
  |  |  |  |  ------------------
  |  |  |  |  157|     98|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    439|	} else { \
  |  |  |  |  159|    439|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    439|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    439|	} \
  |  |  |  |  162|    537|	return _ret; \
  |  |  |  |  163|    537|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|  28.5k|	LOG_TEST_RET(ctx, r, "Check SW error");
  ------------------
  |  |  174|  28.5k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  28.5k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  28.5k|	int _ret = (r); \
  |  |  |  |  168|  28.5k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4.42k, False: 24.0k]
  |  |  |  |  ------------------
  |  |  |  |  169|  4.42k|		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|  4.42k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  4.42k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  4.42k|		return _ret; \
  |  |  |  |  172|  4.42k|	} \
  |  |  |  |  173|  28.5k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|       |
  163|  24.0k|	LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  164|  24.0k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  24.0k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  24.0k|	int _ret = r; \
  |  |  |  |  155|  24.0k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.55k, False: 21.5k]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.55k|		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: 2.55k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.55k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  21.5k|	} else { \
  |  |  |  |  159|  21.5k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  21.5k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  21.5k|	} \
  |  |  |  |  162|  24.0k|	return _ret; \
  |  |  |  |  163|  24.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|  24.0k|}

sc_do_log:
   57|  17.1M|{
   58|  17.1M|	va_list ap;
   59|       |
   60|  17.1M|	va_start(ap, format);
   61|  17.1M|	sc_do_log_va(ctx, level, file, line, func, 0, format, ap);
   62|       |	va_end(ap);
   63|  17.1M|}
sc_do_log_color:
   66|  3.57M|{
   67|  3.57M|	va_list ap;
   68|       |
   69|  3.57M|	va_start(ap, format);
   70|  3.57M|	sc_do_log_va(ctx, level, file, line, func, color, format, ap);
   71|       |	va_end(ap);
   72|  3.57M|}
sc_do_log_openssl:
   76|     37|{
   77|     37|	BIO *bio = NULL;
   78|     37|	int length, rc;
   79|     37|	char *buffer = NULL;
   80|       |
   81|     37|	if ((bio = BIO_new(BIO_s_mem())) == NULL) {
  ------------------
  |  Branch (81:6): [True: 0, False: 37]
  ------------------
   82|      0|		sc_do_log(ctx, level, file, line, func, "Cannot log OpenSSL error");
   83|      0|		goto end;
   84|      0|	}
   85|     37|	ERR_print_errors(bio);
   86|       |
   87|     37|	length = BIO_pending(bio);
   88|     37|	if (length <= 0) {
  ------------------
  |  Branch (88:6): [True: 1, False: 36]
  ------------------
   89|       |		/* no error? */
   90|      1|		goto end;
   91|      1|	}
   92|       |	/* trailing null byte */
   93|     36|	buffer = malloc(length + 1);
   94|     36|	if (buffer == NULL) {
  ------------------
  |  Branch (94:6): [True: 0, False: 36]
  ------------------
   95|      0|		sc_do_log(ctx, level, file, line, func, "No memory!");
   96|      0|		goto end;
   97|      0|	}
   98|     36|	rc = BIO_read(bio, buffer, length);
   99|     36|	buffer[length] = '\0';
  100|     36|	if (rc <= 0) {
  ------------------
  |  Branch (100:6): [True: 0, False: 36]
  ------------------
  101|      0|		sc_do_log(ctx, level, file, line, func, "Cannot read OpenSSL error");
  102|      0|		goto end;
  103|      0|	}
  104|       |
  105|     36|	sc_do_log(ctx, level, file, line, func, "OpenSSL error\n%s", buffer);
  106|     37|end:
  107|     37|	free(buffer);
  108|     37|	BIO_free(bio);
  109|     37|}
_sc_debug:
  204|  68.1k|{
  205|  68.1k|	va_list ap;
  206|       |
  207|  68.1k|	va_start(ap, format);
  208|  68.1k|	sc_do_log_va(ctx, level, NULL, 0, NULL, 0, format, ap);
  209|       |	va_end(ap);
  210|  68.1k|}
_sc_debug_hex:
  342|   477k|{
  343|   477k|	size_t blen;
  344|   477k|	char *buf;
  345|   477k|	const char *truncated = "";
  346|       |
  347|   477k|	if (len > SC_MAX_EXT_APDU_BUFFER_SIZE) {
  ------------------
  |  |   37|   477k|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
  |  Branch (347:6): [True: 0, False: 477k]
  ------------------
  348|      0|		len = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|      0|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
  349|      0|		truncated = "truncated to ";
  350|      0|	}
  351|   477k|	blen = len * 5 + 128;
  352|       |
  353|   477k|	buf = malloc(blen);
  354|   477k|	if (buf == NULL)
  ------------------
  |  Branch (354:6): [True: 0, False: 477k]
  ------------------
  355|      0|		return;
  356|       |
  357|   477k|	sc_hex_dump(data, len, buf, blen);
  358|       |
  359|   477k|	if (label)
  ------------------
  |  Branch (359:6): [True: 477k, False: 0]
  ------------------
  360|   477k|		sc_do_log(ctx, type, file, line, func, "\n%s (%s%zu byte%s):\n%s",
  361|   477k|				label, truncated, len, len == 1 ? "" : "s", buf);
  ------------------
  |  Branch (361:28): [True: 1.19k, False: 475k]
  ------------------
  362|      0|	else
  363|      0|		sc_do_log(ctx, type, file, line, func, "%s%zu byte%s:\n%s",
  364|      0|				truncated, len, len == 1 ? "" : "s", buf);
  ------------------
  |  Branch (364:21): [True: 0, False: 0]
  ------------------
  365|       |
  366|   477k|	free(buf);
  367|   477k|}
sc_hex_dump:
  370|   477k|{
  371|   477k|	char *p = buf;
  372|   477k|	size_t p_len = len;
  373|   477k|	int lines = 0;
  374|       |
  375|   477k|	if (buf == NULL || (in == NULL && count != 0)) {
  ------------------
  |  Branch (375:6): [True: 0, False: 477k]
  |  Branch (375:22): [True: 230, False: 476k]
  |  Branch (375:36): [True: 0, False: 230]
  ------------------
  376|      0|		return;
  377|      0|	}
  378|   477k|	buf[0] = 0;
  379|   477k|	if ((count * 5) > len)
  ------------------
  |  Branch (379:6): [True: 0, False: 477k]
  ------------------
  380|      0|		return;
  381|  4.00M|	while (count) {
  ------------------
  |  Branch (381:9): [True: 3.52M, False: 477k]
  ------------------
  382|  3.52M|		char ascbuf[17];
  383|  3.52M|		size_t i;
  384|       |
  385|  55.7M|		for (i = 0; i < count && i < 16; i++) {
  ------------------
  |  Branch (385:15): [True: 55.4M, False: 380k]
  |  Branch (385:28): [True: 52.2M, False: 3.14M]
  ------------------
  386|  52.2M|			sprintf(p, "%02X ", *in);
  387|  52.2M|			if (isprint(*in))
  ------------------
  |  Branch (387:8): [True: 27.5M, False: 24.7M]
  ------------------
  388|  27.5M|				ascbuf[i] = *in;
  389|  24.7M|			else
  390|  24.7M|				ascbuf[i] = '.';
  391|  52.2M|			p += 3;
  392|  52.2M|			p_len -= 3;
  393|  52.2M|			in++;
  394|  52.2M|		}
  395|  3.52M|		count -= i;
  396|  3.52M|		ascbuf[i] = 0;
  397|  5.47M|		for (; i < 16 && lines; i++) {
  ------------------
  |  Branch (397:10): [True: 2.14M, False: 3.32M]
  |  Branch (397:20): [True: 1.95M, False: 194k]
  ------------------
  398|  1.95M|			strlcat(p, "   ", p_len);
  399|  1.95M|			p += 3;
  400|  1.95M|			p_len -= 3;
  401|  1.95M|		}
  402|  3.52M|		snprintf(p, p_len, "%s\n", ascbuf);
  403|  3.52M|		p += strlen(ascbuf) + 1;
  404|  3.52M|		p_len -= strlen(ascbuf) - 1;
  405|  3.52M|		lines++;
  406|  3.52M|	}
  407|   477k|}
sc_dump_hex:
  411|   228k|{
  412|   228k|	static char dump_buf[0x1000];
  413|   228k|	size_t ii, size = sizeof(dump_buf) - 0x10;
  414|   228k|	size_t offs = 0;
  415|       |
  416|   228k|	memset(dump_buf, 0, sizeof(dump_buf));
  417|   228k|	if (in == NULL)
  ------------------
  |  Branch (417:6): [True: 0, False: 228k]
  ------------------
  418|      0|		return dump_buf;
  419|       |
  420|  1.40M|	for (ii=0; ii<count; ii++) {
  ------------------
  |  Branch (420:13): [True: 1.18M, False: 228k]
  ------------------
  421|  1.18M|		if (ii && !(ii%16))   {
  ------------------
  |  Branch (421:7): [True: 1.08M, False: 95.5k]
  |  Branch (421:13): [True: 18.0k, False: 1.06M]
  ------------------
  422|  18.0k|			if (!(ii%48))
  ------------------
  |  Branch (422:8): [True: 3.28k, False: 14.7k]
  ------------------
  423|  3.28k|				snprintf(dump_buf + offs, size - offs, "\n");
  424|  14.7k|			else
  425|  14.7k|				snprintf(dump_buf + offs, size - offs, " ");
  426|  18.0k|			offs = strlen(dump_buf);
  427|  18.0k|		}
  428|       |
  429|  1.18M|		snprintf(dump_buf + offs, size - offs, "%02X", *(in + ii));
  430|  1.18M|		offs += 2;
  431|       |
  432|  1.18M|		if (offs > size)
  ------------------
  |  Branch (432:7): [True: 0, False: 1.18M]
  ------------------
  433|      0|			break;
  434|  1.18M|	}
  435|       |
  436|   228k|	if (ii<count)
  ------------------
  |  Branch (436:6): [True: 0, False: 228k]
  ------------------
  437|      0|		snprintf(dump_buf + offs, sizeof(dump_buf) - offs, "....\n");
  438|       |
  439|   228k|	return dump_buf;
  440|   228k|}
sc_dump_oid:
  444|  10.5k|{
  445|  10.5k|	static char dump_buf[SC_MAX_OBJECT_ID_OCTETS * 20];
  446|  10.5k|        size_t ii;
  447|       |
  448|  10.5k|	memset(dump_buf, 0, sizeof(dump_buf));
  449|  10.5k|	if (oid)
  ------------------
  |  Branch (449:6): [True: 10.5k, False: 0]
  ------------------
  450|  76.9k|		for (ii=0; ii<SC_MAX_OBJECT_ID_OCTETS && oid->value[ii] != -1; ii++)
  ------------------
  |  |   46|   153k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (450:14): [True: 76.9k, False: 0]
  |  Branch (450:44): [True: 66.3k, False: 10.5k]
  ------------------
  451|  66.3k|			snprintf(dump_buf + strlen(dump_buf), sizeof(dump_buf) - strlen(dump_buf), "%s%i", (ii ? "." : ""), oid->value[ii]);
  ------------------
  |  Branch (451:88): [True: 55.7k, False: 10.5k]
  ------------------
  452|       |
  453|  10.5k|	return dump_buf;
  454|  10.5k|}
log.c:sc_do_log_va:
  123|  20.8M|{
  124|       |#ifdef _WIN32
  125|       |	SYSTEMTIME st;
  126|       |#else
  127|  20.8M|	struct tm *tm;
  128|  20.8M|	struct timeval tv;
  129|  20.8M|	char time_string[40];
  130|  20.8M|#endif
  131|       |
  132|  20.8M|	if (!ctx || ctx->debug < level)
  ------------------
  |  Branch (132:6): [True: 225, False: 20.8M]
  |  Branch (132:14): [True: 20.8M, False: 0]
  ------------------
  133|  20.8M|		return;
  134|       |
  135|       |#ifdef _WIN32
  136|       |	/* In Windows, file handles can not be shared between DLL-s, each DLL has a
  137|       |	 * separate file handle table. Make sure we always have a valid file
  138|       |	 * descriptor. */
  139|       |	if (sc_ctx_log_to_file(ctx, ctx->debug_filename) < 0)
  140|       |		return;
  141|       |#endif
  142|      0|	if (ctx->debug_file == NULL)
  ------------------
  |  Branch (142:6): [True: 0, False: 0]
  ------------------
  143|      0|		return;
  144|       |
  145|       |#ifdef _WIN32
  146|       |	GetLocalTime(&st);
  147|       |	sc_color_fprintf(SC_COLOR_FG_GREEN|SC_COLOR_BOLD,
  148|       |			ctx, ctx->debug_file,
  149|       |			"P:%lu; T:%lu",
  150|       |			(unsigned long)GetCurrentProcessId(),
  151|       |			(unsigned long)GetCurrentThreadId());
  152|       |	sc_color_fprintf(SC_COLOR_FG_GREEN,
  153|       |			ctx, ctx->debug_file,
  154|       |			" %i-%02i-%02i %02i:%02i:%02i.%03i",
  155|       |			st.wYear, st.wMonth, st.wDay,
  156|       |			st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
  157|       |#else
  158|      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
  ------------------
  159|      0|			ctx, ctx->debug_file,
  160|      0|			"P:%lu; T:0x%lu",
  161|      0|			(unsigned long)getpid(),
  162|      0|			(unsigned long)pthread_self());
  163|      0|	gettimeofday (&tv, NULL);
  164|      0|	tm = localtime (&tv.tv_sec);
  165|      0|	strftime (time_string, sizeof(time_string), "%H:%M:%S", tm);
  166|      0|	sc_color_fprintf(SC_COLOR_FG_GREEN,
  ------------------
  |  |   45|      0|#define SC_COLOR_FG_GREEN		0x0002
  ------------------
  167|      0|			ctx, ctx->debug_file,
  168|      0|			" %s.%03ld",
  169|      0|			time_string,
  170|      0|			(long)tv.tv_usec / 1000);
  171|      0|#endif
  172|       |
  173|      0|	sc_color_fprintf(SC_COLOR_FG_YELLOW,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
  174|      0|			ctx, ctx->debug_file,
  175|      0|			" [");
  176|      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
  ------------------
  177|      0|			ctx, ctx->debug_file,
  178|      0|			"%s",
  179|      0|			ctx->app_name);
  180|      0|	sc_color_fprintf(SC_COLOR_FG_YELLOW,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
  181|      0|			ctx, ctx->debug_file,
  182|      0|			"] ");
  183|       |
  184|      0|	if (file != NULL) {
  ------------------
  |  Branch (184:6): [True: 0, False: 0]
  ------------------
  185|      0|		sc_color_fprintf(SC_COLOR_FG_YELLOW,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
  186|      0|				ctx, ctx->debug_file,
  187|      0|				"%s:%d:%s: ",
  188|      0|				file, line, func ? func : "");
  ------------------
  |  Branch (188:17): [True: 0, False: 0]
  ------------------
  189|      0|	}
  190|       |
  191|      0|	sc_color_fprintf_va(color, ctx, ctx->debug_file, format, args);
  192|      0|	if (strlen(format) == 0 || format[strlen(format) - 1] != '\n')
  ------------------
  |  Branch (192:6): [True: 0, False: 0]
  |  Branch (192:29): [True: 0, False: 0]
  ------------------
  193|      0|		sc_color_fprintf(color, ctx, ctx->debug_file, "\n");
  194|      0|	fflush(ctx->debug_file);
  195|       |
  196|       |#ifdef _WIN32
  197|       |	if (ctx->debug_file && (ctx->debug_file != stderr && ctx->debug_file != stdout))
  198|       |		fclose(ctx->debug_file);
  199|       |	ctx->debug_file = NULL;
  200|       |#endif
  201|      0|}

mscfs_new:
   44|    797|mscfs_t *mscfs_new(void) {
   45|    797|	mscfs_t *fs = malloc(sizeof(mscfs_t));
   46|    797|	if (!fs)
  ------------------
  |  Branch (46:6): [True: 0, False: 797]
  ------------------
   47|      0|		return NULL;
   48|    797|	memset(fs, 0, sizeof(mscfs_t));
   49|    797|	memcpy(fs->currentPath, "\x3F\x00", 2);
   50|    797|	return fs;
   51|    797|}
mscfs_free:
   53|    797|void mscfs_free(mscfs_t *fs) {
   54|    797|	mscfs_clear_cache(fs);
   55|    797|	free(fs);
   56|    797|}
mscfs_clear_cache:
   58|  3.39k|void mscfs_clear_cache(mscfs_t* fs) {
   59|  3.39k|	if(!fs->cache.array) {
  ------------------
  |  Branch (59:5): [True: 3.01k, False: 374]
  ------------------
   60|  3.01k|		return;
   61|  3.01k|	}
   62|    374|	free(fs->cache.array);
   63|       |	fs->cache.array = NULL;
   64|    374|	fs->cache.totalSize = 0;
   65|    374|	fs->cache.size = 0;
   66|    374|}
mscfs_push_file:
   82|  37.8k|{
   83|  37.8k|	mscfs_cache_t *cache = &fs->cache;
   84|  37.8k|	if (cache->size >= MAX_FILES)
  ------------------
  |  |   80|  37.8k|#define MAX_FILES 10000
  ------------------
  |  Branch (84:6): [True: 1, False: 37.8k]
  ------------------
   85|      1|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      1|#define SC_ERROR_INTERNAL			-1400
  ------------------
   86|  37.8k|	if(!cache->array || cache->size == cache->totalSize) {
  ------------------
  |  Branch (86:5): [True: 374, False: 37.5k]
  |  Branch (86:22): [True: 280, False: 37.2k]
  ------------------
   87|    654|		int length = cache->totalSize + MSCFS_CACHE_INCREMENT;
  ------------------
  |  |   34|    654|#define MSCFS_CACHE_INCREMENT 128
  ------------------
   88|    654|		mscfs_file_t *oldArray;
   89|    654|		cache->totalSize = length;
   90|    654|		oldArray = cache->array;
   91|    654|		cache->array = malloc(sizeof(mscfs_file_t) * length);
   92|    654|		if(!cache->array)
  ------------------
  |  Branch (92:6): [True: 0, False: 654]
  ------------------
   93|      0|			return MSCFS_NO_MEMORY;
  ------------------
  |  |   31|      0|#define MSCFS_NO_MEMORY  	SC_ERROR_OUT_OF_MEMORY
  |  |  ------------------
  |  |  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  |  |  ------------------
  ------------------
   94|    654|		if(oldArray) {
  ------------------
  |  Branch (94:6): [True: 280, False: 374]
  ------------------
   95|    280|			memcpy(cache->array, oldArray, sizeof(mscfs_file_t) * cache->size);
   96|    280|			free(oldArray);
   97|    280|		}
   98|    654|	}
   99|  37.8k|	cache->array[cache->size] = *file;
  100|  37.8k|	cache->size++;
  101|  37.8k|	return SC_SUCCESS;
  ------------------
  |  |   28|  37.8k|#define SC_SUCCESS				0
  ------------------
  102|  37.8k|}
mscfs_update_cache:
  104|  2.59k|int mscfs_update_cache(mscfs_t* fs) {
  105|  2.59k|	mscfs_file_t file;
  106|  2.59k|	int r;
  107|  2.59k|	mscfs_clear_cache(fs);
  108|  2.59k|	r = fs->listFile(&file, 1, fs->udata);
  109|  2.59k|	if(r == 0)
  ------------------
  |  Branch (109:5): [True: 83, False: 2.51k]
  ------------------
  110|     83|		return 0;
  111|  2.51k|	else if(r < 0)
  ------------------
  |  Branch (111:10): [True: 2.09k, False: 413]
  ------------------
  112|  2.09k|		return r;
  113|  38.5k|	while(1) {
  ------------------
  |  Branch (113:8): [True: 38.5k, Folded]
  ------------------
  114|  38.5k|		if(!mscfs_is_ignored(fs, file.objectId)) {
  ------------------
  |  Branch (114:6): [True: 37.8k, False: 622]
  ------------------
  115|       |			/* Check if its a directory in the root */
  116|  37.8k|			u8* oid = file.objectId.id;
  117|  37.8k|			if(oid[2] == 0 && oid[3] == 0) {
  ------------------
  |  Branch (117:7): [True: 25.9k, False: 11.9k]
  |  Branch (117:22): [True: 10.4k, False: 15.4k]
  ------------------
  118|  10.4k|				oid[2] = oid[0];
  119|  10.4k|				oid[3] = oid[1];
  120|  10.4k|				oid[0] = 0x3F;
  121|  10.4k|				oid[1] = 0x00;
  122|  10.4k|				file.ef = 0;
  123|  27.4k|			} else  {
  124|  27.4k|				file.ef = 1; /* File is a working elementary file */
  125|  27.4k|			}
  126|       |
  127|  37.8k|			r = mscfs_push_file(fs, &file);
  128|  37.8k|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|  37.8k|#define SC_SUCCESS				0
  ------------------
  |  Branch (128:8): [True: 1, False: 37.8k]
  ------------------
  129|      1|				return r;
  130|  37.8k|		}
  131|  38.5k|		r = fs->listFile(&file, 0, fs->udata);
  132|  38.5k|		if(r == 0)
  ------------------
  |  Branch (132:6): [True: 206, False: 38.3k]
  ------------------
  133|    206|			break;
  134|  38.3k|		else if(r < 0)
  ------------------
  |  Branch (134:11): [True: 206, False: 38.0k]
  ------------------
  135|    206|			return r;
  136|  38.5k|	}
  137|    206|	return fs->cache.size;
  138|    413|}
mscfs_check_cache:
  141|  4.91k|{
  142|  4.91k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  4.91k|#define SC_SUCCESS				0
  ------------------
  143|  4.91k|	if(!fs->cache.array) {
  ------------------
  |  Branch (143:5): [True: 2.59k, False: 2.32k]
  ------------------
  144|  2.59k|		r = mscfs_update_cache(fs);
  145|  2.59k|	}
  146|  4.91k|	return r;
  147|  4.91k|}
mscfs_lookup_path:
  150|  1.53k|{
  151|  1.53k|	u8* oid = objectId->id;
  152|  1.53k|	if ((pathlen & 1) != 0) /* not divisible by 2 */
  ------------------
  |  Branch (152:6): [True: 417, False: 1.11k]
  ------------------
  153|    417|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   32|    417|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|    417|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  154|  1.11k|	if(isDirectory) {
  ------------------
  |  Branch (154:5): [True: 0, False: 1.11k]
  ------------------
  155|       |		/* Directory must be right next to root */
  156|      0|		if ((pathlen == 4 && 0 == memcmp(path, "\x3F\x00", 2)) ||
  ------------------
  |  Branch (156:8): [True: 0, False: 0]
  |  Branch (156:24): [True: 0, False: 0]
  ------------------
  157|      0|		    (pathlen == 2 && 0 == memcmp(fs->currentPath, "\x3F\x00", 2))) {
  ------------------
  |  Branch (157:8): [True: 0, False: 0]
  |  Branch (157:24): [True: 0, False: 0]
  ------------------
  158|      0|			oid[0] = path[pathlen - 2];
  159|      0|			oid[1] = path[pathlen - 1];
  160|      0|			oid[2] = oid[3] = 0;
  161|      0|		} else {
  162|      0|			return MSCFS_INVALID_ARGS;
  ------------------
  |  |   32|      0|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  163|      0|		}
  164|      0|	}
  165|  1.11k|	oid[0] = fs->currentPath[0];
  166|  1.11k|	oid[1] = fs->currentPath[1];
  167|       |	/* Chop off the root in the path */
  168|  1.11k|	if(pathlen > 2 && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (168:5): [True: 939, False: 176]
  |  Branch (168:20): [True: 891, False: 48]
  ------------------
  169|    891|		path += 2;
  170|    891|		pathlen -= 2;
  171|    891|		oid[0] = 0x3F;
  172|    891|		oid[1] = 0x00;
  173|    891|	}
  174|       |	/* Limit to a single directory */
  175|  1.11k|	if(pathlen > 4)
  ------------------
  |  Branch (175:5): [True: 13, False: 1.10k]
  ------------------
  176|     13|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   32|     13|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|     13|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  177|       |	/* Reset to root */
  178|  1.10k|	if(pathlen == 2 && 0 == memcmp(path, "\x3F\x00", 2)) {
  ------------------
  |  Branch (178:5): [True: 752, False: 350]
  |  Branch (178:21): [True: 16, False: 736]
  ------------------
  179|     16|		oid[0] = oid[2] = path[0];
  180|     16|		oid[1] = oid[3] = path[1];
  181|  1.08k|	} else if(pathlen == 2) { /* Path preserved for current-path */
  ------------------
  |  Branch (181:12): [True: 736, False: 350]
  ------------------
  182|    736|		oid[2] = path[0];
  183|    736|		oid[3] = path[1];
  184|    736|	} else if(pathlen == 4) {
  ------------------
  |  Branch (184:12): [True: 340, False: 10]
  ------------------
  185|    340|		oid[0] = path[0];
  186|    340|		oid[1] = path[1];
  187|    340|		oid[2] = path[2];
  188|    340|		oid[3] = path[3];
  189|    340|	}
  190|       |
  191|  1.10k|	return 0;
  192|  1.11k|}
mscfs_check_selection:
  206|    376|{
  207|    376|	if(fs->currentPath[0] == 0 && fs->currentPath[1] == 0)
  ------------------
  |  Branch (207:5): [True: 0, False: 376]
  |  Branch (207:32): [True: 0, False: 0]
  ------------------
  208|      0|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   32|      0|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  209|    376|	if(requiredItem == 1 && fs->currentFile[0] == 0 && fs->currentFile[1] == 0)
  ------------------
  |  Branch (209:5): [True: 0, False: 376]
  |  Branch (209:26): [True: 0, False: 0]
  |  Branch (209:53): [True: 0, False: 0]
  ------------------
  210|      0|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   32|      0|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  211|    376|	return 0;
  212|    376|}
mscfs_loadFileInfo:
  215|  1.53k|{
  216|  1.53k|	msc_id fullPath = {{0, 0, 0, 0}};
  217|  1.53k|	int x, rc;
  218|  1.53k|	if (fs == NULL || path == NULL || file_data == NULL)
  ------------------
  |  Branch (218:6): [True: 0, False: 1.53k]
  |  Branch (218:20): [True: 0, False: 1.53k]
  |  Branch (218:36): [True: 0, False: 1.53k]
  ------------------
  219|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  220|  1.53k|	rc = mscfs_lookup_path(fs, path, pathlen, &fullPath, 0);
  221|  1.53k|	if (rc != SC_SUCCESS) {
  ------------------
  |  |   28|  1.53k|#define SC_SUCCESS				0
  ------------------
  |  Branch (221:6): [True: 430, False: 1.10k]
  ------------------
  222|    430|		return rc;
  223|    430|	}
  224|       |
  225|       |	/* Obtain file information while checking if it exists */
  226|  1.10k|	rc = mscfs_check_cache(fs);
  227|  1.10k|	if (rc < 0)
  ------------------
  |  Branch (227:6): [True: 24, False: 1.07k]
  ------------------
  228|     24|		return rc;
  229|  1.07k|	if(idx) *idx = -1;
  ------------------
  |  Branch (229:5): [True: 1.07k, False: 0]
  ------------------
  230|  65.1k|	for(x = 0; x < fs->cache.size; x++) {
  ------------------
  |  Branch (230:13): [True: 64.4k, False: 709]
  ------------------
  231|  64.4k|		*file_data = &fs->cache.array[x];
  232|  64.4k|		if (*file_data) {
  ------------------
  |  Branch (232:7): [True: 64.4k, False: 0]
  ------------------
  233|  64.4k|			msc_id objectId;
  234|  64.4k|			objectId = (*file_data)->objectId;
  235|  64.4k|			if(0 == memcmp(objectId.id, fullPath.id, 4)) {
  ------------------
  |  Branch (235:7): [True: 369, False: 64.0k]
  ------------------
  236|    369|				if (idx)
  ------------------
  |  Branch (236:9): [True: 369, False: 0]
  ------------------
  237|    369|					*idx = x;
  238|    369|				break;
  239|    369|			}
  240|  64.0k|			*file_data = NULL;
  241|  64.0k|		}
  242|  64.4k|	}
  243|  1.07k|	if(*file_data == NULL && (0 == memcmp("\x3F\x00\x00\x00", fullPath.id, 4) || 0 == memcmp("\x3F\x00\x50\x15", fullPath.id, 4 ) || 0 == memcmp("\x3F\x00\x3F\x00", fullPath.id, 4))) {
  ------------------
  |  Branch (243:5): [True: 709, False: 369]
  |  Branch (243:28): [True: 22, False: 687]
  |  Branch (243:79): [True: 314, False: 373]
  |  Branch (243:131): [True: 16, False: 357]
  ------------------
  244|    352|		static mscfs_file_t ROOT_FILE;
  245|    352|		ROOT_FILE.ef = 0;
  246|    352|		ROOT_FILE.size = 0;
  247|       |		/* Faked Root ID */
  248|    352|		ROOT_FILE.objectId = rootId;
  249|       |
  250|    352|		ROOT_FILE.read = 0;
  251|    352|		ROOT_FILE.write = 0x02; /* User Pin access */
  252|    352|		ROOT_FILE.delete = 0x02;
  253|       |
  254|    352|		*file_data = &ROOT_FILE;
  255|    352|		if(idx) *idx = -2;
  ------------------
  |  Branch (255:6): [True: 352, False: 0]
  ------------------
  256|    726|	} else if(*file_data == NULL) {
  ------------------
  |  Branch (256:12): [True: 357, False: 369]
  ------------------
  257|    357|		return MSCFS_FILE_NOT_FOUND;
  ------------------
  |  |   33|    357|#define MSCFS_FILE_NOT_FOUND 	SC_ERROR_FILE_NOT_FOUND
  |  |  ------------------
  |  |  |  |   51|    357|#define SC_ERROR_FILE_NOT_FOUND			-1201
  |  |  ------------------
  ------------------
  258|    357|	}
  259|       |
  260|    721|	return 0;
  261|  1.07k|}
muscle-filesystem.c:mscfs_is_ignored:
   69|  38.5k|{
   70|  38.5k|	int ignored = 0;
   71|  38.5k|	const u8** ptr = ignoredFiles;
   72|   114k|	while(ptr && *ptr && !ignored) {
  ------------------
  |  Branch (72:8): [True: 114k, False: 0]
  |  Branch (72:15): [True: 77.0k, False: 37.9k]
  |  Branch (72:23): [True: 76.4k, False: 603]
  ------------------
   73|  76.4k|		if(0 == memcmp(objectId.id, *ptr, 4))
  ------------------
  |  Branch (73:6): [True: 622, False: 75.7k]
  ------------------
   74|    622|			ignored = 1;
   75|  76.4k|		ptr++;
   76|  76.4k|	}
   77|  38.5k|	return ignored;
   78|  38.5k|}

msc_list_objects:
   37|  41.1k|int msc_list_objects(sc_card_t* card, u8 next, mscfs_file_t* file) {
   38|  41.1k|	sc_apdu_t apdu;
   39|  41.1k|	u8 fileData[14];
   40|  41.1k|	int r;
   41|       |
   42|  41.1k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x58, next, 0x00);
  ------------------
  |  |  301|  41.1k|#define SC_APDU_CASE_2			0x22
  ------------------
   43|  41.1k|	apdu.le = 14;
   44|  41.1k|	apdu.resplen = 14;
   45|  41.1k|	apdu.resp = fileData;
   46|  41.1k|	r = sc_transmit_apdu(card, &apdu);
   47|  41.1k|	if (r)
  ------------------
  |  Branch (47:6): [True: 24, False: 41.0k]
  ------------------
   48|     24|		return r;
   49|       |
   50|  41.0k|	if(apdu.sw1 == 0x9C && apdu.sw2 == 0x12) {
  ------------------
  |  Branch (50:5): [True: 178, False: 40.9k]
  |  Branch (50:25): [True: 32, False: 146]
  ------------------
   51|     32|		return 0;
   52|     32|	}
   53|  41.0k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
   54|  41.0k|	if (r)
  ------------------
  |  Branch (54:6): [True: 2.26k, False: 38.7k]
  ------------------
   55|  2.26k|		return r;
   56|  38.7k|	if(apdu.resplen == 0) /* No more left */
  ------------------
  |  Branch (56:5): [True: 257, False: 38.5k]
  ------------------
   57|    257|		return 0;
   58|  38.5k|	if (apdu.resplen != 14) {
  ------------------
  |  Branch (58:6): [True: 18, False: 38.5k]
  ------------------
   59|     18|		sc_log(card->ctx, "expected 14 bytes, got %zu.\n", apdu.resplen);
  ------------------
  |  |   71|     18|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   60|     18|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     18|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
   61|     18|	}
   62|  38.5k|	memcpy(file->objectId.id, fileData, 4);
   63|  38.5k|	file->size = bebytes2ulong(fileData + 4);
   64|  38.5k|	file->read = bebytes2ushort(fileData + 8);
   65|  38.5k|	file->write = bebytes2ushort(fileData + 10);
   66|  38.5k|	file->delete = bebytes2ushort(fileData + 12);
   67|       |
   68|  38.5k|	return 1;
   69|  38.5k|}
msc_partial_read_object:
   72|    376|{
   73|    376|	u8 buffer[9];
   74|    376|	sc_apdu_t apdu;
   75|    376|	int r;
   76|       |
   77|    376|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x56, 0x00, 0x00);
  ------------------
  |  |  294|    376|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
   78|       |
   79|    376|	sc_log(card->ctx, "READ: Offset: %x\tLength: %zu\n", offset, dataLength);
  ------------------
  |  |   71|    376|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   80|    376|	memcpy(buffer, objectId.id, 4);
   81|    376|	ulong2bebytes(buffer + 4, offset);
   82|    376|	buffer[8] = (u8)dataLength;
   83|    376|	apdu.data = buffer;
   84|    376|	apdu.datalen = 9;
   85|    376|	apdu.lc = 9;
   86|    376|	apdu.le = dataLength;
   87|    376|	apdu.resplen = dataLength;
   88|    376|	apdu.resp = data;
   89|    376|	r = sc_transmit_apdu(card, &apdu);
   90|    376|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    376|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    376|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    376|	int _ret = (r); \
  |  |  |  |  168|    376|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 362]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|    376|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 362]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|    362|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00 && dataLength <= apdu.resplen)
  ------------------
  |  Branch (91:6): [True: 282, False: 80]
  |  Branch (91:26): [True: 278, False: 4]
  |  Branch (91:46): [True: 267, False: 11]
  ------------------
   92|    267|		return (int)dataLength;
   93|     95|	if (apdu.sw1 == 0x9C) {
  ------------------
  |  Branch (93:6): [True: 12, False: 83]
  ------------------
   94|     12|		if (apdu.sw2 == 0x07) {
  ------------------
  |  Branch (94:7): [True: 1, False: 11]
  ------------------
   95|      1|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      1|	int _ret = r; \
  |  |  155|      1|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  163|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
   96|     11|		} else if (apdu.sw2 == 0x06) {
  ------------------
  |  Branch (96:14): [True: 1, False: 10]
  ------------------
   97|      1|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_ALLOWED);
  ------------------
  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      1|	int _ret = r; \
  |  |  155|      1|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  163|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
   98|     10|		} else if (apdu.sw2 == 0x0F) {
  ------------------
  |  Branch (98:14): [True: 1, False: 9]
  ------------------
   99|       |			/* GUESSED */
  100|      1|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      1|	int _ret = r; \
  |  |  155|      1|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  ------------------
  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  ------------------
  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  163|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  101|      1|		}
  102|     12|	}
  103|     92|	sc_log(card->ctx,
  ------------------
  |  |   71|     92|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  104|     92|		"got strange SWs: 0x%02X 0x%02X\n", apdu.sw1, apdu.sw2);
  105|     92|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  153|     92|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     92|	int _ret = r; \
  |  |  155|     92|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 92, False: 0]
  |  |  ------------------
  |  |  156|     92|		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|     92|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 92, False: 0]
  |  |  ------------------
  |  |  157|     92|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     92|	} 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|     92|	return _ret; \
  |  |  163|     92|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  106|     92|}
msc_read_object:
  109|    376|{
  110|    376|	int r = 0;
  111|    376|	unsigned int i;
  112|    376|	size_t max_read_unit = MSC_MAX_READ;
  ------------------
  |  |   35|    376|#define MSC_MAX_READ (card->max_recv_size > 0 ? card->max_recv_size : 255)
  |  |  ------------------
  |  |  |  Branch (35:23): [True: 376, False: 0]
  |  |  ------------------
  ------------------
  113|       |
  114|    643|	for (i = 0; i < dataLength; i += r) {
  ------------------
  |  Branch (114:14): [True: 376, False: 267]
  ------------------
  115|    376|		r = msc_partial_read_object(card, objectId, offset + i, data + i, MIN(dataLength - i, max_read_unit));
  ------------------
  |  |   69|    376|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 167, False: 209]
  |  |  ------------------
  ------------------
  116|    376|		LOG_TEST_RET(card->ctx, r, "Error in partial object read");
  ------------------
  |  |  174|    376|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    376|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    376|	int _ret = (r); \
  |  |  |  |  168|    376|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 109, False: 267]
  |  |  |  |  ------------------
  |  |  |  |  169|    109|		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|    109|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    109|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    109|		return _ret; \
  |  |  |  |  172|    109|	} \
  |  |  |  |  173|    376|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 267]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  117|    267|		if (r == 0)
  ------------------
  |  Branch (117:7): [True: 0, False: 267]
  ------------------
  118|      0|			break;
  119|    267|	}
  120|    267|	return (int)dataLength;
  121|    376|}
msc_select_applet:
  256|  7.54k|{
  257|  7.54k|	sc_apdu_t apdu;
  258|  7.54k|	int r;
  259|       |
  260|  7.54k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
  ------------------
  |  |  293|  7.54k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  261|  7.54k|	apdu.lc = appletIdLength;
  262|  7.54k|	apdu.data = appletId;
  263|  7.54k|	apdu.datalen = appletIdLength;
  264|  7.54k|	apdu.resplen = 0;
  265|  7.54k|	apdu.le = 0;
  266|       |
  267|  7.54k|	r = sc_transmit_apdu(card, &apdu);
  268|  7.54k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  7.54k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.54k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.54k|	int _ret = (r); \
  |  |  |  |  168|  7.54k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 39, False: 7.50k]
  |  |  |  |  ------------------
  |  |  |  |  169|     39|		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|     39|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     39|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     39|		return _ret; \
  |  |  |  |  172|     39|	} \
  |  |  |  |  173|  7.54k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7.50k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  269|  7.50k|	if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (269:5): [True: 808, False: 6.70k]
  |  Branch (269:25): [True: 797, False: 11]
  ------------------
  270|    797|		return 1;
  271|       |
  272|  6.71k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,  SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  153|  6.71k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  6.71k|	int _ret = r; \
  |  |  155|  6.71k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 6.71k, False: 0]
  |  |  ------------------
  |  |  156|  6.71k|		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|  6.71k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 6.71k, False: 0]
  |  |  ------------------
  |  |  157|  6.71k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  6.71k|	} 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|  6.71k|	return _ret; \
  |  |  163|  6.71k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  273|  6.71k|}
msc_get_challenge:
  434|     35|{
  435|     35|	sc_apdu_t apdu;
  436|     35|	int r, location, cse;
  437|     35|	size_t len;
  438|     35|	u8 *buffer, *ptr;
  439|       |
  440|     35|	location = (dataLength < MSC_MAX_READ) ? 1 : 2; /* 1 == APDU, 2 == (seed in 0xFFFFFFFE, out in 0xFFFFFFFF) */
  ------------------
  |  |   35|     35|#define MSC_MAX_READ (card->max_recv_size > 0 ? card->max_recv_size : 255)
  |  |  ------------------
  |  |  |  Branch (35:23): [True: 35, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (440:13): [True: 34, False: 1]
  ------------------
  441|     35|	cse = (location == 1) ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  294|     34|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              	cse = (location == 1) ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|     36|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (441:8): [True: 34, False: 1]
  ------------------
  442|     35|	len = seedLength + 4;
  443|       |
  444|     35|	if (seedLength >= MSC_MAX_SEND - 4 || dataLength >= MSC_MAX_READ - 9)/* Output buffer doesn't seem to operate as desired.... nobody can read/delete */
  ------------------
  |  |   36|     35|#define MSC_MAX_SEND (card->max_send_size > 0 ? card->max_send_size : 255)
  |  |  ------------------
  |  |  |  Branch (36:23): [True: 35, False: 0]
  |  |  ------------------
  ------------------
              	if (seedLength >= MSC_MAX_SEND - 4 || dataLength >= MSC_MAX_READ - 9)/* Output buffer doesn't seem to operate as desired.... nobody can read/delete */
  ------------------
  |  |   35|     35|#define MSC_MAX_READ (card->max_recv_size > 0 ? card->max_recv_size : 255)
  |  |  ------------------
  |  |  |  Branch (35:23): [True: 35, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (444:6): [True: 0, False: 35]
  |  Branch (444:40): [True: 1, False: 34]
  ------------------
  445|     35|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|       |
  447|     34|	buffer = malloc(len);
  448|     34|	if(!buffer) LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (448:5): [True: 0, False: 34]
  ------------------
  449|     34|	ptr = buffer;
  450|     34|	ushort2bebytes(ptr, dataLength);
  451|     34|	ptr+=2;
  452|     34|	ushort2bebytes(ptr, seedLength);
  453|     34|	ptr+=2;
  454|     34|	if(seedLength > 0) {
  ------------------
  |  Branch (454:5): [True: 0, False: 34]
  ------------------
  455|      0|		memcpy(ptr, seedData, seedLength);
  456|      0|	}
  457|     34|	sc_format_apdu(card, &apdu, cse, 0x62, 0x00, location);
  458|     34|	apdu.data = buffer;
  459|     34|	apdu.datalen = len;
  460|     34|	apdu.lc = len;
  461|       |
  462|     34|	if(location == 1) {
  ------------------
  |  Branch (462:5): [True: 34, False: 0]
  ------------------
  463|     34|		u8* outputBuffer = malloc(dataLength + 2);
  464|     34|		if(outputBuffer == NULL) {
  ------------------
  |  Branch (464:6): [True: 0, False: 34]
  ------------------
  465|      0|			free(buffer);
  466|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|     34|		};
  468|     34|		apdu.le = dataLength + 2;
  469|     34|		apdu.resp = outputBuffer;
  470|     34|		apdu.resplen = dataLength + 2;
  471|     34|	}
  472|     34|	r = sc_transmit_apdu(card, &apdu);
  473|     34|	if(location == 1) {
  ------------------
  |  Branch (473:5): [True: 34, False: 0]
  ------------------
  474|     34|		memcpy(outputData, apdu.resp + 2, dataLength);
  475|     34|		free(apdu.resp);
  476|     34|	}
  477|     34|	free(buffer);
  478|     34|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     34|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     34|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     34|	int _ret = (r); \
  |  |  |  |  168|     34|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  479|     33|	if(location == 1) {
  ------------------
  |  Branch (479:5): [True: 33, False: 0]
  ------------------
  480|     33|		if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (480:6): [True: 2, False: 31]
  |  Branch (480:26): [True: 1, False: 1]
  ------------------
  481|      1|			return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  482|     32|		} else {
  483|     32|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  484|     32|			if (r) {
  ------------------
  |  Branch (484:8): [True: 32, False: 0]
  ------------------
  485|     32|				if (card->ctx->debug >= 2) {
  ------------------
  |  Branch (485:9): [True: 0, False: 32]
  ------------------
  486|      0|					sc_log(card->ctx,  "got strange SWs: 0x%02X 0x%02X\n",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  487|      0|					     apdu.sw1, apdu.sw2);
  488|      0|				}
  489|     32|				LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     32|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     32|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     32|	int _ret = r; \
  |  |  |  |  155|     32|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     32|		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|     32|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 32, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     32|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     32|	} 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|     32|	return _ret; \
  |  |  |  |  163|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  490|     32|			}
  491|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  492|      0|		}
  493|     33|	} else {
  494|      0|		if(apdu.sw1 != 0x90 || apdu.sw2 != 0x00) {
  ------------------
  |  Branch (494:6): [True: 0, False: 0]
  |  Branch (494:26): [True: 0, False: 0]
  ------------------
  495|      0|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  496|      0|			if (r) {
  ------------------
  |  Branch (496:8): [True: 0, False: 0]
  ------------------
  497|      0|				if (card->ctx->debug >= 2) {
  ------------------
  |  Branch (497:9): [True: 0, False: 0]
  ------------------
  498|      0|					sc_log(card->ctx,  "got strange SWs: 0x%02X 0x%02X\n",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  499|      0|					     apdu.sw1, apdu.sw2);
  500|      0|				}
  501|      0|				LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  502|      0|			}
  503|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  504|      0|		}
  505|      0|		r = msc_read_object(card, inputId, 2, outputData, dataLength);
  506|      0|		if(r < 0)
  ------------------
  |  Branch (506:6): [True: 0, False: 0]
  ------------------
  507|      0|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  508|      0|		msc_delete_object(card, inputId,0);
  509|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  510|      0|	}
  511|     33|}

sc_pkcs1_strip_02_padding_constant_time:
  154|     70|{
  155|     70|	unsigned int i = 0;
  156|     70|	u8 *msg, *msg_orig = NULL;
  157|     70|	unsigned int good, found_zero_byte, mask, tmp_outlen;
  158|     70|	unsigned int zero_index = 0, msg_index, mlen = -1, len = 0;
  159|     70|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     70|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     70|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     70|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     70|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 70]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|       |
  161|     70|	if (data == NULL || data_len <= 0 || data_len > n ||
  ------------------
  |  Branch (161:6): [True: 0, False: 70]
  |  Branch (161:22): [True: 3, False: 67]
  |  Branch (161:39): [True: 21, False: 46]
  ------------------
  162|     46|			n < SC_PKCS1_PADDING_MIN_SIZE || out_len == NULL)
  ------------------
  |  |   40|    116|#define SC_PKCS1_PADDING_MIN_SIZE 11
  ------------------
  |  Branch (162:4): [True: 0, False: 46]
  |  Branch (162:37): [True: 0, False: 46]
  ------------------
  163|     70|		LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  164|     24|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     24|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     24|	int _ret = r; \
  |  |  |  |  155|     24|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 24, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     24|		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|     24|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 24, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     24|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     24|	} 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|     24|	return _ret; \
  |  |  |  |  163|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|       |
  165|     46|	tmp_outlen = *out_len;
  166|     46|	msg = msg_orig = calloc(n, sizeof(u8));
  167|     46|	if (msg == NULL)
  ------------------
  |  Branch (167:6): [True: 0, False: 46]
  ------------------
  168|     46|		LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  169|       |
  170|       |	/*
  171|       |	 * We can not check length of input data straight away and still we need to read
  172|       |	 * from input even when the input is not as long as needed to keep the time constant.
  173|       |	 * If data has wrong size, it is padded by zeroes from left and the following checks
  174|       |	 * do not pass.
  175|       |	 */
  176|     46|	len = data_len;
  177|  13.4k|	for (data += len, msg += n, i = 0; i < n; i++) {
  ------------------
  |  Branch (177:37): [True: 13.4k, False: 46]
  ------------------
  178|  13.4k|		mask = ~constant_time_is_zero(len);
  179|  13.4k|		len -= 1 & mask;
  180|  13.4k|		data -= 1 & mask;
  181|  13.4k|		*--msg = *data & mask;
  182|  13.4k|	}
  183|       |	// check first byte to be 0x00
  184|     46|	good = constant_time_is_zero(msg[0]);
  185|       |	// check second byte to be 0x02
  186|     46|	good &= constant_time_eq(msg[1], 2);
  187|       |
  188|       |	// find zero byte after random data in padding
  189|     46|	found_zero_byte = 0;
  190|  13.3k|	for (i = 2; i < n; i++) {
  ------------------
  |  Branch (190:14): [True: 13.3k, False: 46]
  ------------------
  191|  13.3k|		unsigned int equals0 = constant_time_is_zero(msg[i]);
  192|  13.3k|		zero_index = constant_time_select(~found_zero_byte & equals0, i, zero_index);
  193|  13.3k|		found_zero_byte |= equals0;
  194|  13.3k|	}
  195|       |
  196|       |	// zero_index stands for index of last found zero
  197|     46|	good &= constant_time_ge(zero_index, 2 + 8);
  198|       |
  199|       |	// start of the actual message in data
  200|     46|	msg_index = zero_index + 1;
  201|       |
  202|       |	// length of message
  203|     46|	mlen = data_len - msg_index;
  204|       |
  205|       |	// check that message fits into out buffer
  206|     46|	good &= constant_time_ge(tmp_outlen, mlen);
  207|       |
  208|       |	// move the result in-place by |num|-SC_PKCS1_PADDING_MIN_SIZE-|mlen| bytes to the left.
  209|     46|	tmp_outlen = constant_time_select(constant_time_lt(n - SC_PKCS1_PADDING_MIN_SIZE, tmp_outlen),
  ------------------
  |  |   40|     46|#define SC_PKCS1_PADDING_MIN_SIZE 11
  ------------------
  210|     46|			n - SC_PKCS1_PADDING_MIN_SIZE, tmp_outlen);
  ------------------
  |  |   40|     46|#define SC_PKCS1_PADDING_MIN_SIZE 11
  ------------------
  211|    427|	for (msg_index = 1; msg_index < n - SC_PKCS1_PADDING_MIN_SIZE; msg_index <<= 1) {
  ------------------
  |  |   40|    427|#define SC_PKCS1_PADDING_MIN_SIZE 11
  ------------------
  |  Branch (211:22): [True: 381, False: 46]
  ------------------
  212|    381|		mask = ~constant_time_eq(msg_index & (n - SC_PKCS1_PADDING_MIN_SIZE - mlen), 0);
  ------------------
  |  |   40|    381|#define SC_PKCS1_PADDING_MIN_SIZE 11
  ------------------
  213|  93.6k|		for (i = SC_PKCS1_PADDING_MIN_SIZE; i < n - msg_index; i++)
  ------------------
  |  |   40|    381|#define SC_PKCS1_PADDING_MIN_SIZE 11
  ------------------
  |  Branch (213:39): [True: 93.2k, False: 381]
  ------------------
  214|  93.2k|			msg[i] = constant_time_select_8(mask, msg[i + msg_index], msg[i]);
  215|    381|	}
  216|       |	// move message into out buffer, if good
  217|  4.15k|	for (i = 0; i < tmp_outlen; i++) {
  ------------------
  |  Branch (217:14): [True: 4.11k, False: 46]
  ------------------
  218|  4.11k|		unsigned int msg_index;
  219|       |		// when out is longer than message in data, use some bogus index in msg
  220|  4.11k|		mask = good & constant_time_lt(i, mlen);
  221|  4.11k|		msg_index = constant_time_select(mask, i + SC_PKCS1_PADDING_MIN_SIZE, 0); // to now overflow msg buffer
  ------------------
  |  |   40|  4.11k|#define SC_PKCS1_PADDING_MIN_SIZE 11
  ------------------
  222|  4.11k|		out[i] = constant_time_select_8(mask, msg[msg_index], out[i]);
  223|  4.11k|	}
  224|       |
  225|     46|	*out_len = constant_time_select(good, mlen, *out_len);
  226|     46|	free(msg_orig);
  227|     46|	return constant_time_select(good, mlen, SC_ERROR_WRONG_PADDING);
  ------------------
  |  |   93|     46|#define SC_ERROR_WRONG_PADDING			-1412
  ------------------
  228|     46|}
sc_pkcs1_encode:
  612|    122|{
  613|    122|	int    rv, i;
  614|    122|	size_t tmp_len = *out_len;
  615|    122|	const u8    *tmp = in;
  616|    122|	unsigned int hash_algo, pad_algo;
  617|    122|	size_t mod_len = BYTES4BITS(mod_bits);
  ------------------
  |  |  145|    122|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  618|    122|#ifdef ENABLE_OPENSSL
  619|    122|	size_t sLen;
  620|    122|	EVP_MD* md = NULL;
  621|    122|	unsigned int mgf1_hash;
  622|    122|#endif
  623|       |
  624|    122|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    122|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    122|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    122|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    122|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 122]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|       |
  626|    122|	hash_algo = flags & SC_ALGORITHM_RSA_HASHES;
  ------------------
  |  |  142|    122|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
  627|    122|	pad_algo  = flags & SC_ALGORITHM_RSA_PADS;
  ------------------
  |  |  103|    122|#define SC_ALGORITHM_RSA_PADS		0x000000FF
  ------------------
  628|    122|	if (pad_algo == 0)
  ------------------
  |  Branch (628:6): [True: 51, False: 71]
  ------------------
  629|     51|		pad_algo = SC_ALGORITHM_RSA_PAD_NONE;
  ------------------
  |  |  104|     51|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
  630|    122|	sc_log(ctx, "hash algorithm 0x%X, pad algorithm 0x%X", hash_algo, pad_algo);
  ------------------
  |  |   71|    122|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  631|       |
  632|    122|	if ((pad_algo == SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 || pad_algo == SC_ALGORITHM_RSA_PAD_NONE) &&
  ------------------
  |  |  109|    244|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              	if ((pad_algo == SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 || pad_algo == SC_ALGORITHM_RSA_PAD_NONE) &&
  ------------------
  |  |  104|     51|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
  |  Branch (632:7): [True: 71, False: 51]
  |  Branch (632:57): [True: 51, False: 0]
  ------------------
  633|    122|	    hash_algo != SC_ALGORITHM_RSA_HASH_NONE) {
  ------------------
  |  |  133|    122|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  |  Branch (633:6): [True: 95, False: 27]
  ------------------
  634|     95|		i = sc_pkcs1_add_digest_info_prefix(hash_algo, in, in_len, out, &tmp_len);
  635|     95|		if (i != SC_SUCCESS) {
  ------------------
  |  |   28|     95|#define SC_SUCCESS				0
  ------------------
  |  Branch (635:7): [True: 0, False: 95]
  ------------------
  636|      0|			sc_log(ctx, "Unable to add digest info 0x%x", hash_algo);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  637|      0|			LOG_FUNC_RETURN(ctx, i);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|      0|		}
  639|     95|		tmp = out;
  640|     95|	} else   {
  641|     27|		tmp_len = in_len;
  642|     27|	}
  643|       |
  644|    122|	switch(pad_algo) {
  645|     51|	case SC_ALGORITHM_RSA_PAD_NONE:
  ------------------
  |  |  104|     51|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
  |  Branch (645:2): [True: 51, False: 71]
  ------------------
  646|       |		/* padding done by card => nothing to do */
  647|     51|		if (out != tmp)
  ------------------
  |  Branch (647:7): [True: 3, False: 48]
  ------------------
  648|      3|			memcpy(out, tmp, tmp_len);
  649|     51|		*out_len = tmp_len;
  650|     51|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     51|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     51|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     51|	int _ret = r; \
  |  |  |  |  155|     51|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 51, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     51|		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: 51]
  |  |  |  |  ------------------
  |  |  |  |  157|     51|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     51|	} 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|     51|	return _ret; \
  |  |  |  |  163|     51|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  651|     71|	case SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01:
  ------------------
  |  |  109|     71|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (651:2): [True: 71, False: 51]
  ------------------
  652|       |		/* add pkcs1 bt01 padding */
  653|     71|		rv = sc_pkcs1_add_01_padding(tmp, tmp_len, out, out_len, mod_len);
  654|     71|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     71|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     71|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     71|	int _ret = r; \
  |  |  |  |  155|     71|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 71, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     71|		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: 71]
  |  |  |  |  ------------------
  |  |  |  |  157|     71|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     71|	} 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|     71|	return _ret; \
  |  |  |  |  163|     71|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  655|      0|	case SC_ALGORITHM_RSA_PAD_PSS:
  ------------------
  |  |  107|      0|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  |  Branch (655:2): [True: 0, False: 122]
  ------------------
  656|       |		/* add PSS padding */
  657|      0|#ifdef ENABLE_OPENSSL
  658|      0|		mgf1_hash = flags & SC_ALGORITHM_MGF1_HASHES;
  ------------------
  |  |  150|      0|#define SC_ALGORITHM_MGF1_HASHES	0x01F00000
  ------------------
  659|      0|		if (hash_algo == SC_ALGORITHM_RSA_HASH_NONE) {
  ------------------
  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  |  Branch (659:7): [True: 0, False: 0]
  ------------------
  660|       |			/* this is generic RSA_PKCS1_PSS mechanism with hash
  661|       |			 * already done outside of the module. The parameters
  662|       |			 * were already checked so we need to adjust the hash
  663|       |			 * algorithm to do the padding with the correct hash
  664|       |			 * function.
  665|       |			 */
  666|      0|			hash_algo = hash_len2algo(tmp_len);
  667|      0|		}
  668|       |		/* sLen is by default same as hash length */
  669|      0|		if (!(md = hash_flag2md(ctx, hash_algo))) {
  ------------------
  |  Branch (669:7): [True: 0, False: 0]
  ------------------
  670|      0|			sc_log_openssl(ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  671|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  672|      0|		}
  673|      0|		sLen = EVP_MD_size(md);
  674|      0|		sc_evp_md_free(md);
  675|       |		/* if application provide sLen, use it */
  676|      0|		if (pMechanism != NULL) {
  ------------------
  |  Branch (676:7): [True: 0, False: 0]
  ------------------
  677|      0|			CK_MECHANISM *mech = (CK_MECHANISM *)pMechanism;
  678|      0|			CK_RSA_PKCS_PSS_PARAMS *pss_params;
  679|      0|			if (mech->pParameter && sizeof(CK_RSA_PKCS_PSS_PARAMS) == mech->ulParameterLen) {
  ------------------
  |  Branch (679:8): [True: 0, False: 0]
  |  Branch (679:28): [True: 0, False: 0]
  ------------------
  680|      0|				pss_params = mech->pParameter;
  681|      0|				sLen = pss_params->sLen;
  682|      0|			}
  683|      0|		}
  684|      0|		rv = sc_pkcs1_add_pss_padding(ctx, hash_algo, mgf1_hash,
  685|      0|		    tmp, tmp_len, out, out_len, mod_bits, sLen);
  686|       |#else
  687|       |		rv = SC_ERROR_NOT_SUPPORTED;
  688|       |#endif
  689|      0|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  690|      0|	default:
  ------------------
  |  Branch (690:2): [True: 0, False: 122]
  ------------------
  691|       |		/* We shouldn't be called with an unexpected padding type, we've already
  692|       |		 * returned SC_ERROR_NOT_SUPPORTED if the card can't be used. */
  693|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  694|    122|	}
  695|    122|}
sc_get_encoding_flags:
  700|    423|{
  701|    423|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    423|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    423|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    423|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    423|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 423]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  702|    423|	if (pflags == NULL || sflags == NULL)
  ------------------
  |  Branch (702:6): [True: 0, False: 423]
  |  Branch (702:24): [True: 0, False: 423]
  ------------------
  703|    423|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  704|       |
  705|    423|	sc_log(ctx, "iFlags 0x%lX, card capabilities 0x%lX", iflags, caps);
  ------------------
  |  |   71|    423|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  706|       |
  707|       |	/* For ECDSA and GOSTR, we don't do any padding or hashing ourselves, the
  708|       |	 * card has to support the requested operation.  Similarly, for RSA with
  709|       |	 * raw padding (raw RSA) and ISO9796, we require the card to do it for us.
  710|       |	 * Finally, for PKCS1 (v1.5 and PSS) and ASNI X9.31 we can apply the padding
  711|       |	 * ourselves if the card supports raw RSA. */
  712|       |
  713|       |	/* TODO: Could convert GOSTR3410_HASH_GOSTR3411 -> GOSTR3410_RAW and
  714|       |	 *       ECDSA_HASH_ -> ECDSA_RAW using OpenSSL (not much benefit though). */
  715|       |
  716|    423|	if ((caps & iflags) == iflags) {
  ------------------
  |  Branch (716:6): [True: 169, False: 254]
  ------------------
  717|       |		/* Card supports the signature operation we want to do, great, let's
  718|       |		 * go with it then. */
  719|    169|		*sflags = iflags;
  720|    169|		*pflags = 0;
  721|       |
  722|    254|	} else if ((caps & SC_ALGORITHM_RSA_PAD_PSS) &&
  ------------------
  |  |  107|    254|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  |  Branch (722:13): [True: 65, False: 189]
  ------------------
  723|     65|			(iflags & SC_ALGORITHM_RSA_PAD_PSS)) {
  ------------------
  |  |  107|     65|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  |  Branch (723:4): [True: 0, False: 65]
  ------------------
  724|      0|		*sflags |= SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  107|      0|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  725|      0|		*sflags |= iflags & SC_ALGORITHM_MGF1_HASHES;
  ------------------
  |  |  150|      0|#define SC_ALGORITHM_MGF1_HASHES	0x01F00000
  ------------------
  726|      0|		*pflags = iflags & ~(iflags & (SC_ALGORITHM_MGF1_HASHES | SC_ALGORITHM_RSA_PAD_PSS));
  ------------------
  |  |  150|      0|#define SC_ALGORITHM_MGF1_HASHES	0x01F00000
  ------------------
              		*pflags = iflags & ~(iflags & (SC_ALGORITHM_MGF1_HASHES | SC_ALGORITHM_RSA_PAD_PSS));
  ------------------
  |  |  107|      0|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  727|       |
  728|    254|	} else if ((caps & SC_ALGORITHM_RSA_RAW) &&
  ------------------
  |  |  102|    254|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  |  Branch (728:13): [True: 212, False: 42]
  ------------------
  729|    212|				(iflags & SC_ALGORITHM_RSA_PAD_PKCS1
  ------------------
  |  |  111|    424|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|    212|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|    212|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  |  Branch (729:6): [True: 212, False: 0]
  ------------------
  730|      0|				|| iflags & SC_ALGORITHM_RSA_PAD_PSS
  ------------------
  |  |  107|    212|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  |  Branch (730:8): [True: 0, False: 0]
  ------------------
  731|      0|#ifdef ENABLE_OPENSSL
  732|      0|				|| iflags & SC_ALGORITHM_RSA_PAD_OAEP
  ------------------
  |  |  108|    212|#define SC_ALGORITHM_RSA_PAD_OAEP	0x00000020 /* PKCS#1 v2.0 OAEP */
  ------------------
  |  Branch (732:8): [True: 0, False: 0]
  ------------------
  733|      0|#endif
  734|    212|				|| iflags & SC_ALGORITHM_RSA_PAD_NONE)) {
  ------------------
  |  |  104|      0|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
  |  Branch (734:8): [True: 0, False: 0]
  ------------------
  735|       |		/* Use the card's raw RSA capability on the padded input */
  736|    212|		*sflags = SC_ALGORITHM_RSA_PAD_NONE;
  ------------------
  |  |  104|    212|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
  737|    212|		*pflags = iflags;
  738|       |
  739|    212|	} else if ((caps & (SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_NONE)) &&
  ------------------
  |  |  109|     42|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              	} else if ((caps & (SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_NONE)) &&
  ------------------
  |  |  133|     42|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  |  Branch (739:13): [True: 42, False: 0]
  ------------------
  740|     42|			(iflags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01)) {
  ------------------
  |  |  109|     42|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (740:4): [True: 42, False: 0]
  ------------------
  741|       |		/* A corner case - the card can partially do PKCS1, if we prepend the
  742|       |		 * DigestInfo bit it will do the rest. */
  743|     42|		*sflags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  109|     42|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		*sflags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|     42|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  744|     42|		*pflags = iflags & SC_ALGORITHM_RSA_HASHES;
  ------------------
  |  |  142|     42|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
  745|       |
  746|     42|	} else if ((caps & (SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02 | SC_ALGORITHM_RSA_HASH_NONE)) &&
  ------------------
  |  |  110|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
              	} else if ((caps & (SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02 | SC_ALGORITHM_RSA_HASH_NONE)) &&
  ------------------
  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  |  Branch (746:13): [True: 0, False: 0]
  ------------------
  747|      0|			(iflags & 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 */
  ------------------
  |  Branch (747:4): [True: 0, False: 0]
  ------------------
  748|      0|		*sflags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  110|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
              		*sflags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  749|      0|		*pflags = iflags & SC_ALGORITHM_RSA_HASHES;
  ------------------
  |  |  142|      0|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
  750|       |
  751|      0|	} else if ((iflags & SC_ALGORITHM_AES) == SC_ALGORITHM_AES) { /* TODO: seems like this constant does not belong to the same set of flags used form asymmetric algos. Fix this! */
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_AES		67
  ------------------
              	} else if ((iflags & SC_ALGORITHM_AES) == SC_ALGORITHM_AES) { /* TODO: seems like this constant does not belong to the same set of flags used form asymmetric algos. Fix this! */
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_AES		67
  ------------------
  |  Branch (751:13): [True: 0, False: 0]
  ------------------
  752|      0|		*sflags = 0;
  753|      0|		*pflags = 0;
  754|       |
  755|      0|	} else if ((iflags & SC_ALGORITHM_AES_FLAGS) > 0) {
  ------------------
  |  |  209|      0|#define SC_ALGORITHM_AES_FLAGS		 0x0F000000
  ------------------
  |  Branch (755:13): [True: 0, False: 0]
  ------------------
  756|      0|		*sflags = iflags & SC_ALGORITHM_AES_FLAGS;
  ------------------
  |  |  209|      0|#define SC_ALGORITHM_AES_FLAGS		 0x0F000000
  ------------------
  757|      0|		if (iflags & SC_ALGORITHM_AES_CBC_PAD)
  ------------------
  |  |  208|      0|#define SC_ALGORITHM_AES_CBC_PAD	 0x04000000
  ------------------
  |  Branch (757:7): [True: 0, False: 0]
  ------------------
  758|      0|			*pflags = SC_ALGORITHM_AES_CBC_PAD;
  ------------------
  |  |  208|      0|#define SC_ALGORITHM_AES_CBC_PAD	 0x04000000
  ------------------
  759|      0|		else
  760|      0|			*pflags = 0;
  761|       |
  762|      0|	} else {
  763|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "unsupported algorithm");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  764|      0|	}
  765|       |
  766|    423|	sc_log(ctx, "pad flags 0x%lX, secure algorithm flags 0x%lX", *pflags, *sflags);
  ------------------
  |  |   71|    423|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  767|    423|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    423|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    423|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    423|	int _ret = r; \
  |  |  |  |  155|    423|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 423, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    423|		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: 423]
  |  |  |  |  ------------------
  |  |  |  |  157|    423|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    423|	} 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|    423|	return _ret; \
  |  |  |  |  163|    423|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  768|    423|}
padding.c:sc_pkcs1_add_digest_info_prefix:
  381|     95|{
  382|     95|	int i;
  383|       |
  384|    452|	for (i = 0; digest_info_prefix[i].algorithm != 0; i++) {
  ------------------
  |  Branch (384:14): [True: 452, False: 0]
  ------------------
  385|    452|		if (algorithm == digest_info_prefix[i].algorithm) {
  ------------------
  |  Branch (385:7): [True: 95, False: 357]
  ------------------
  386|     95|			const u8 *hdr      = digest_info_prefix[i].hdr;
  387|     95|			size_t    hdr_len  = digest_info_prefix[i].hdr_len,
  388|     95|			          hash_len = digest_info_prefix[i].hash_len;
  389|       |
  390|     95|			if (in_len != hash_len || *out_len < (hdr_len + hash_len))
  ------------------
  |  Branch (390:8): [True: 0, False: 95]
  |  Branch (390:30): [True: 0, False: 95]
  ------------------
  391|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  392|       |
  393|     95|			memmove(out + hdr_len, in, hash_len);
  394|     95|			memmove(out, hdr, hdr_len);
  395|     95|			*out_len = hdr_len + hash_len;
  396|       |
  397|     95|			return SC_SUCCESS;
  ------------------
  |  |   28|     95|#define SC_SUCCESS				0
  ------------------
  398|     95|		}
  399|    452|	}
  400|       |
  401|      0|	return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  402|     95|}
padding.c:sc_pkcs1_add_01_padding:
   97|     71|{
   98|     71|	size_t i;
   99|       |
  100|     71|	if (*out_len < mod_length)
  ------------------
  |  Branch (100:6): [True: 0, False: 71]
  ------------------
  101|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  102|     71|	if (in_len + 11 > mod_length)
  ------------------
  |  Branch (102:6): [True: 0, False: 71]
  ------------------
  103|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  104|     71|	i = mod_length - in_len;
  105|     71|	memmove(out + i, in, in_len);
  106|     71|	*out++ = 0x00;
  107|     71|	*out++ = 0x01;
  108|       |
  109|     71|	memset(out, 0xFF, i - 3);
  110|     71|	out += i - 3;
  111|     71|	*out = 0x00;
  112|       |
  113|     71|	*out_len = mod_length;
  114|     71|	return SC_SUCCESS;
  ------------------
  |  |   28|     71|#define SC_SUCCESS				0
  ------------------
  115|     71|}

sc_asn1_decode_algorithm_id:
  509|  7.31k|{
  510|  7.31k|	struct sc_asn1_pkcs15_algorithm_info *alg_info = NULL;
  511|  7.31k|	struct sc_asn1_entry asn1_alg_id[3];
  512|  7.31k|	int r;
  513|       |
  514|  7.31k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  7.31k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  7.31k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  7.31k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  7.31k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 7.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  515|  7.31k|	sc_copy_asn1_entry(c_asn1_alg_id, asn1_alg_id);
  516|  7.31k|	sc_format_asn1_entry(asn1_alg_id + 0, &id->oid, NULL, 0);
  517|       |
  518|  7.31k|	memset(id, 0, sizeof(*id));
  519|  7.31k|	r = _sc_asn1_decode(ctx, asn1_alg_id, in, len, &in, &len, 0, depth + 1);
  520|  7.31k|	LOG_TEST_RET(ctx, r, "ASN.1 parsing of algo ID failed");
  ------------------
  |  |  174|  7.31k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.31k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.31k|	int _ret = (r); \
  |  |  |  |  168|  7.31k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 55, False: 7.25k]
  |  |  |  |  ------------------
  |  |  |  |  169|     55|		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|     55|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     55|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     55|		return _ret; \
  |  |  |  |  172|     55|	} \
  |  |  |  |  173|  7.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  521|       |
  522|  7.25k|        sc_log(ctx, "decoded OID '%s'", sc_dump_oid(&(id->oid)));
  ------------------
  |  |   71|  7.25k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  523|       |
  524|       |	/* See if we understand the algorithm, and if we do, check
  525|       |	 * whether we know how to decode any additional parameters */
  526|  7.25k|	id->algorithm = (unsigned int ) -1;
  527|  7.25k|	alg_info = sc_asn1_get_algorithm_info(id);
  528|  7.25k|	if (alg_info != NULL) {
  ------------------
  |  Branch (528:6): [True: 4.85k, False: 2.40k]
  ------------------
  529|  4.85k|		id->algorithm = alg_info->id;
  530|  4.85k|		if (alg_info->decode) {
  ------------------
  |  Branch (530:7): [True: 4.43k, False: 417]
  ------------------
  531|  4.43k|			if (asn1_alg_id[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|  4.43k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (531:8): [True: 9, False: 4.42k]
  ------------------
  532|      9|				sc_log(ctx, "SC_ASN1_PRESENT was set, so invalid");
  ------------------
  |  |   71|      9|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  533|      9|				LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ASN1_OBJECT);
  ------------------
  |  |  164|      9|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      9|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      9|	int _ret = r; \
  |  |  |  |  155|      9|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      9|		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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      9|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      9|	} 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|      9|	return _ret; \
  |  |  |  |  163|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  534|      9|			}
  535|  4.42k|			r = alg_info->decode(ctx, &id->params, in, len, depth);
  536|  4.42k|		}
  537|  4.85k|	}
  538|       |
  539|  7.25k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  7.25k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  7.25k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  7.25k|	int _ret = r; \
  |  |  |  |  155|  7.25k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7.25k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  7.25k|		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|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 29, False: 7.22k]
  |  |  |  |  ------------------
  |  |  |  |  157|  7.25k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  7.25k|	} 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|  7.25k|	return _ret; \
  |  |  |  |  163|  7.25k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  540|  7.25k|}
sc_asn1_encode_algorithm_id:
  546|  3.34k|{
  547|  3.34k|	struct sc_asn1_pkcs15_algorithm_info *alg_info;
  548|  3.34k|	struct sc_algorithm_id temp_id;
  549|  3.34k|	struct sc_asn1_entry asn1_alg_id[3];
  550|  3.34k|	u8 *obj = NULL;
  551|  3.34k|	size_t obj_len = 0;
  552|  3.34k|	int r;
  553|  3.34k|	u8 *tmp;
  554|       |
  555|  3.34k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.34k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.34k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.34k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.34k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.34k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|  3.34k|        sc_log(ctx, "type of algorithm to encode: %lu", id->algorithm);
  ------------------
  |  |   71|  3.34k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  557|  3.34k|	alg_info = sc_asn1_get_algorithm_info(id);
  558|  3.34k|	if (alg_info == NULL) {
  ------------------
  |  Branch (558:6): [True: 0, False: 3.34k]
  ------------------
  559|      0|		sc_log(ctx, "Cannot encode unknown algorithm %lu", id->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  560|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  561|      0|	}
  562|       |
  563|       |	/* Set the oid if not yet given */
  564|  3.34k|	if (!sc_valid_oid(&id->oid)) {
  ------------------
  |  Branch (564:6): [True: 2, False: 3.33k]
  ------------------
  565|      2|		temp_id = *id;
  566|      2|		temp_id.oid = alg_info->oid;
  567|      2|		id = &temp_id;
  568|      2|	}
  569|       |
  570|  3.34k|        sc_log(ctx, "encode algo %s", sc_dump_oid(&(id->oid)));
  ------------------
  |  |   71|  3.34k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  571|  3.34k|	sc_copy_asn1_entry(c_asn1_alg_id, asn1_alg_id);
  572|  3.34k|	sc_format_asn1_entry(asn1_alg_id + 0, (void *) &id->oid, NULL, 1);
  573|       |
  574|       |	/* no parameters, write NULL tag */
  575|       |	/* If it's EDDSA/XEDDSA, according to RFC8410, params
  576|       |	 * MUST be absent */
  577|       |	/* PKCS11 3.0 list them under ec_params */
  578|  3.34k|	if (id->algorithm != SC_ALGORITHM_EDDSA &&
  ------------------
  |  |   72|  6.68k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (578:6): [True: 3.34k, False: 0]
  ------------------
  579|  3.34k|	    id->algorithm != SC_ALGORITHM_XEDDSA &&
  ------------------
  |  |   73|  6.68k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (579:6): [True: 3.34k, False: 0]
  ------------------
  580|  3.34k|	    (!id->params || !alg_info->encode))
  ------------------
  |  Branch (580:7): [True: 286, False: 3.05k]
  |  Branch (580:22): [True: 0, False: 3.05k]
  ------------------
  581|    286|		asn1_alg_id[1].flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|    286|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  582|       |
  583|  3.34k|	r = _sc_asn1_encode(ctx, asn1_alg_id, buf, len, depth + 1);
  584|  3.34k|	LOG_TEST_RET(ctx, r, "ASN.1 encode of algorithm failed");
  ------------------
  |  |  174|  3.34k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.34k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.34k|	int _ret = (r); \
  |  |  |  |  168|  3.34k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.34k]
  |  |  |  |  ------------------
  |  |  |  |  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|  3.34k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.34k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|       |
  586|       |	/* Encode any parameters */
  587|  3.34k|	if (id->params && alg_info->encode) {
  ------------------
  |  Branch (587:6): [True: 3.05k, False: 286]
  |  Branch (587:20): [True: 3.05k, False: 0]
  ------------------
  588|  3.05k|		r = alg_info->encode(ctx, id->params, &obj, &obj_len, depth+1);
  589|  3.05k|		if (r < 0) {
  ------------------
  |  Branch (589:7): [True: 0, False: 3.05k]
  ------------------
  590|      0|			if (obj)
  ------------------
  |  Branch (590:8): [True: 0, False: 0]
  ------------------
  591|      0|				free(obj);
  592|      0|			LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  593|      0|		}
  594|  3.05k|	}
  595|       |
  596|  3.34k|	if (obj_len) {
  ------------------
  |  Branch (596:6): [True: 3.05k, False: 286]
  ------------------
  597|  3.05k|		tmp = (u8 *) realloc(*buf, *len + obj_len);
  598|  3.05k|		if (!tmp) {
  ------------------
  |  Branch (598:7): [True: 0, False: 3.05k]
  ------------------
  599|      0|			free(*buf);
  600|      0|			*buf = NULL;
  601|      0|			free(obj);
  602|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|      0|		}
  604|  3.05k|		*buf = tmp;
  605|  3.05k|		memcpy(*buf + *len, obj, obj_len);
  606|  3.05k|		*len += obj_len;
  607|  3.05k|		free(obj);
  608|  3.05k|	}
  609|       |
  610|  3.34k|	sc_log(ctx, "return encoded algorithm ID: %s", sc_dump_hex(*buf, *len));
  ------------------
  |  |   71|  3.34k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  611|  3.34k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.34k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.34k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.34k|	int _ret = r; \
  |  |  |  |  155|  3.34k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.34k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.34k|		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: 3.34k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.34k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.34k|	} 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|  3.34k|	return _ret; \
  |  |  |  |  163|  3.34k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|  3.34k|}
sc_asn1_clear_algorithm_id:
  616|  8.86k|{
  617|  8.86k|	struct sc_asn1_pkcs15_algorithm_info *aip;
  618|       |
  619|  8.86k|	if (id->params && (aip = sc_asn1_get_algorithm_info(id)) && aip->free) {
  ------------------
  |  Branch (619:6): [True: 5.40k, False: 3.46k]
  |  Branch (619:20): [True: 5.40k, False: 0]
  |  Branch (619:62): [True: 5.40k, False: 0]
  ------------------
  620|  5.40k|		aip->free(id->params);
  621|       |		id->params = NULL;
  622|  5.40k|	}
  623|  8.86k|}
pkcs15-algo.c:sc_asn1_get_algorithm_info:
  485|  16.0k|{
  486|  16.0k|	struct sc_asn1_pkcs15_algorithm_info *aip = NULL;
  487|       |
  488|   219k|	for (aip = algorithm_table; aip->id >= 0; aip++)   {
  ------------------
  |  Branch (488:30): [True: 216k, False: 2.40k]
  ------------------
  489|   216k|		if ((int) id->algorithm < 0 && sc_compare_oid(&id->oid, &aip->oid))
  ------------------
  |  Branch (489:7): [True: 105k, False: 111k]
  |  Branch (489:34): [True: 4.85k, False: 100k]
  ------------------
  490|  4.85k|			return aip;
  491|       |
  492|   212k|		if (aip->id == (int)id->algorithm)
  ------------------
  |  Branch (492:7): [True: 8.74k, False: 203k]
  ------------------
  493|  8.74k|			return aip;
  494|   212k|	}
  495|       |
  496|  2.40k|	return NULL;
  497|  16.0k|}
pkcs15-algo.c:asn1_decode_ec_params:
  264|  4.42k|{
  265|  4.42k|	int r;
  266|  4.42k|	struct sc_object_id curve;
  267|  4.42k|	struct sc_asn1_entry asn1_ec_params[4];
  268|  4.42k|	struct sc_ec_parameters *ecp;
  269|       |
  270|  4.42k|	memset(&curve, 0, sizeof(curve));
  271|       |
  272|       |	/* We only want to copy the parms if they are a namedCurve
  273|       |	 * or ecParameters  nullParam aka implicityCA is not to be
  274|       |	 * used with PKCS#11 2.20 */
  275|  4.42k|	sc_copy_asn1_entry(c_asn1_ec_params, asn1_ec_params);
  276|  4.42k|	sc_format_asn1_entry(asn1_ec_params + 1, &curve, 0, 0);
  277|       |
  278|       |	/* Some signature algorithms will not have any data */
  279|  4.42k|	if (buflen == 0 || buf == NULL)
  ------------------
  |  Branch (279:6): [True: 22, False: 4.40k]
  |  Branch (279:21): [True: 0, False: 4.40k]
  ------------------
  280|     22|		return 0;
  281|       |
  282|  4.40k|	r = sc_asn1_decode_choice(ctx, asn1_ec_params, buf, buflen, NULL, NULL);
  283|       |	/* r = index in asn1_ec_params */
  284|  4.40k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "asn1_decode_ec_params r=%d", r);
  ------------------
  |  |   70|  4.40k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  285|  4.40k|	if (r < 0)
  ------------------
  |  Branch (285:6): [True: 29, False: 4.37k]
  ------------------
  286|     29|		return r;
  287|       |
  288|  4.37k|	ecp = calloc(1, sizeof(struct sc_ec_parameters));
  289|  4.37k|	if (ecp == NULL)
  ------------------
  |  Branch (289:6): [True: 0, False: 4.37k]
  ------------------
  290|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  291|       |
  292|  4.37k|	if (r <= 1) {
  ------------------
  |  Branch (292:6): [True: 4.37k, False: 0]
  ------------------
  293|  4.37k|		ecp->der.value = malloc(buflen);
  294|  4.37k|		if (ecp->der.value == NULL) {
  ------------------
  |  Branch (294:7): [True: 0, False: 4.37k]
  ------------------
  295|      0|			free(ecp);
  296|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  297|      0|		}
  298|  4.37k|		ecp->der.len = buflen;
  299|  4.37k|		memcpy(ecp->der.value, buf, buflen);
  300|  4.37k|	}
  301|      0|	else    {
  302|      0|		r = 0;
  303|      0|	}
  304|       |
  305|  4.37k|	ecp->type = r; /* but 0 = ecparams if any, 1=named curve */
  306|  4.37k|	*paramp = ecp;
  307|  4.37k|	return SC_SUCCESS;
  ------------------
  |  |   28|  4.37k|#define SC_SUCCESS				0
  ------------------
  308|  4.37k|};
pkcs15-algo.c:asn1_encode_ec_params:
  313|  3.05k|{
  314|  3.05k|	 struct sc_ec_parameters *ecp = (struct sc_ec_parameters *) params;
  315|       |
  316|       |	/* Only handle named curves. They may be absent too */
  317|  3.05k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "asn1_encode_ec_params() called");
  ------------------
  |  |   70|  3.05k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  318|  3.05k|	*buf = NULL;
  319|  3.05k|	*buflen = 0;
  320|  3.05k|	if (ecp && ecp->type == 1 && ecp->der.value) { /* named curve */
  ------------------
  |  Branch (320:6): [True: 3.05k, False: 0]
  |  Branch (320:13): [True: 3.05k, False: 0]
  |  Branch (320:31): [True: 3.05k, False: 0]
  ------------------
  321|  3.05k|		*buf = malloc(ecp->der.len);
  322|  3.05k|		if (*buf == NULL)
  ------------------
  |  Branch (322:7): [True: 0, False: 3.05k]
  ------------------
  323|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  324|       |
  325|  3.05k|		memcpy(*buf, ecp->der.value, ecp->der.len);
  326|  3.05k|		*buflen = ecp->der.len;
  327|  3.05k|	}
  328|      0|	else   {
  329|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "Not named curve");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  330|      0|	}
  331|       |
  332|  3.05k|	return 0;
  333|  3.05k|}
pkcs15-algo.c:asn1_free_ec_params:
  337|  5.40k|{
  338|  5.40k|	struct sc_ec_parameters *ecp = (struct sc_ec_parameters *) params;
  339|       |
  340|  5.40k|	if (ecp) {
  ------------------
  |  Branch (340:6): [True: 5.40k, False: 0]
  ------------------
  341|  5.40k|		if (ecp->der.value)
  ------------------
  |  Branch (341:7): [True: 5.40k, False: 0]
  ------------------
  342|  5.40k|			free(ecp->der.value);
  343|  5.40k|		if (ecp->named_curve)
  ------------------
  |  Branch (343:7): [True: 0, False: 5.40k]
  ------------------
  344|      0|			free(ecp->named_curve);
  345|  5.40k|		free(ecp);
  346|  5.40k|	}
  347|  5.40k|}

sc_pkcs15emu_cac_init_ex:
  371|  14.3k|{
  372|  14.3k|	sc_card_t   *card = p15card->card;
  373|  14.3k|	sc_context_t    *ctx = card->ctx;
  374|       |
  375|  14.3k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  14.3k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  14.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  14.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  14.3k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 14.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  376|       |
  377|  14.3k|	if (cac_detect_card(p15card))
  ------------------
  |  Branch (377:6): [True: 13.3k, False: 1.03k]
  ------------------
  378|  13.3k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  13.3k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  379|  1.03k|	return sc_pkcs15emu_cac_init(p15card);
  380|  14.3k|}
pkcs15-cac.c:cac_detect_card:
   65|  14.3k|{
   66|  14.3k|	sc_card_t *card = p15card->card;
   67|       |
   68|  14.3k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  14.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  14.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  14.3k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 14.3k]
  |  |  ------------------
  ------------------
   69|  14.3k|	if (card->type < SC_CARD_TYPE_CAC_GENERIC
  ------------------
  |  Branch (69:6): [True: 12.1k, False: 2.27k]
  ------------------
   70|  2.27k|		|| card->type >= SC_CARD_TYPE_CAC_GENERIC+1000)
  ------------------
  |  Branch (70:6): [True: 1.23k, False: 1.03k]
  ------------------
   71|  13.3k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  13.3k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
   72|  1.03k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.03k|#define SC_SUCCESS				0
  ------------------
   73|  14.3k|}
pkcs15-cac.c:sc_pkcs15emu_cac_init:
   89|  1.03k|{
   90|  1.03k|	static const pindata pins[] = {
   91|  1.03k|		{ "1", "PIN", "", 0x00,
   92|  1.03k|		  SC_PKCS15_PIN_TYPE_ASCII_NUMERIC,
  ------------------
  |  |   89|  1.03k|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
   93|  1.03k|		  8, 4, 8,
   94|  1.03k|		  SC_PKCS15_PIN_FLAG_NEEDS_PADDING |
  ------------------
  |  |   59|  1.03k|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
   95|  1.03k|		  SC_PKCS15_PIN_FLAG_INITIALIZED ,
  ------------------
  |  |   58|  1.03k|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
   96|  1.03k|		  -1, 0xFF,
   97|  1.03k|		  SC_PKCS15_CO_FLAG_PRIVATE },
  ------------------
  |  |   50|  1.03k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
   98|  1.03k|		{ NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0}
   99|  1.03k|	};
  100|       |	/* oid for key usage */
  101|  1.03k|	static const struct sc_object_id usage_type = {{ 2, 5, 29, 15, -1 }};
  102|  1.03k|	unsigned int usage;
  103|       |
  104|       |
  105|       |	/*
  106|       |	 * The size of the key or the algid is not really known
  107|       |	 * but can be derived from the certificates.
  108|       |	 * the cert, pubkey and privkey are a set.
  109|       |	 * Key usages bits taken from certificate key usage extension.
  110|       |	 */
  111|       |
  112|  1.03k|	int    r, i;
  113|  1.03k|	sc_card_t *card = p15card->card;
  114|  1.03k|	sc_serial_number_t serial;
  115|  1.03k|	char buf[SC_MAX_SERIALNR * 2 + 1];
  116|  1.03k|	int count;
  117|  1.03k|	char *token_name = NULL;
  118|       |
  119|       |
  120|  1.03k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.03k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.03k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.03k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.03k]
  |  |  ------------------
  ------------------
  121|       |
  122|  1.03k|	memset(&serial, 0, sizeof(serial));
  123|       |
  124|       |	/* could read this off card if needed */
  125|       |
  126|  1.03k|	set_string(&p15card->tokeninfo->label, cac_get_name(card->type));
  127|  1.03k|	set_string(&p15card->tokeninfo->manufacturer_id, MANU_ID);
  ------------------
  |  |   46|  1.03k|#define MANU_ID		"Common Access Card"
  ------------------
  128|       |
  129|       |	/*
  130|       |	 * get serial number
  131|       |	 */
  132|  1.03k|	r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
  133|  1.03k|	if (r < 0) {
  ------------------
  |  Branch (133:6): [True: 839, False: 196]
  ------------------
  134|    839|		sc_log(card->ctx, "sc_card_ctl rc=%d",r);
  ------------------
  |  |   71|    839|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  135|    839|		set_string(&p15card->tokeninfo->serial_number, "00000000");
  136|    839|	} else {
  137|    196|		sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
  138|    196|		set_string(&p15card->tokeninfo->serial_number, buf);
  139|    196|	}
  140|       |
  141|       |	/* set pins */
  142|       |	/* TODO we should not create PIN objects if it is not initialized
  143|       |	 * (opensc-tool -s 0020000000 returns 0x6A 0x88)
  144|       |	 */
  145|  1.03k|	sc_log(card->ctx,  "CAC adding pins...");
  ------------------
  |  |   71|  1.03k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  146|  2.07k|	for (i = 0; pins[i].id; i++) {
  ------------------
  |  Branch (146:14): [True: 1.03k, False: 1.03k]
  ------------------
  147|  1.03k|		struct sc_pkcs15_auth_info pin_info;
  148|  1.03k|		struct sc_pkcs15_object   pin_obj;
  149|  1.03k|		const char * label;
  150|       |
  151|  1.03k|		memset(&pin_info, 0, sizeof(pin_info));
  152|  1.03k|		memset(&pin_obj,  0, sizeof(pin_obj));
  153|       |
  154|  1.03k|		pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|  1.03k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  155|  1.03k|		sc_pkcs15_format_id(pins[i].id, &pin_info.auth_id);
  156|  1.03k|		pin_info.attrs.pin.reference     = pins[i].ref;
  157|  1.03k|		pin_info.attrs.pin.flags         = pins[i].flags;
  158|  1.03k|		pin_info.attrs.pin.type          = pins[i].type;
  159|  1.03k|		pin_info.attrs.pin.min_length    = pins[i].minlen;
  160|  1.03k|		pin_info.attrs.pin.stored_length = pins[i].storedlen;
  161|  1.03k|		pin_info.attrs.pin.max_length    = pins[i].maxlen;
  162|  1.03k|		pin_info.attrs.pin.pad_char      = pins[i].pad_char;
  163|  1.03k|		sc_format_path(pins[i].path, &pin_info.path);
  164|  1.03k|		pin_info.tries_left    = -1;
  165|       |
  166|  1.03k|		label = pins[i].label;
  167|  1.03k|		sc_log(card->ctx,  "CAC Adding pin %d label=%s",i, label);
  ------------------
  |  |   71|  1.03k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  168|  1.03k|		strncpy(pin_obj.label, label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|  1.03k|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  169|  1.03k|		pin_obj.flags = pins[i].obj_flags;
  170|       |
  171|       |		/* get the ACA path in case it needs to be selected before PIN verify */
  172|  1.03k|		r = sc_card_ctl(card, SC_CARDCTL_CAC_GET_ACA_PATH, &pin_info.path);
  173|  1.03k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Can not get ACA path.");
  ------------------
  |  |  184|  1.03k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.03k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.03k|	int _ret = (r); \
  |  |  |  |  178|  1.03k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  1.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  174|       |
  175|  1.03k|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  176|  1.03k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Can not add pin object.");
  ------------------
  |  |  184|  1.03k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.03k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.03k|	int _ret = (r); \
  |  |  |  |  178|  1.03k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  1.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|  1.03k|	}
  178|       |
  179|       |	/* set other objects */
  180|  1.03k|	r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_INIT_GET_GENERIC_OBJECTS, &count);
  181|  1.03k|	LOG_TEST_GOTO_ERR(card->ctx, r, "Can not initiate generic objects.");
  ------------------
  |  |  184|  1.03k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.03k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.03k|	int _ret = (r); \
  |  |  |  |  178|  1.03k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  1.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|       |
  183|  1.43k|	for (i = 0; i < count; i++) {
  ------------------
  |  Branch (183:14): [True: 399, False: 1.03k]
  ------------------
  184|    399|		struct sc_pkcs15_data_info obj_info;
  185|    399|		struct sc_pkcs15_object    obj_obj;
  186|       |
  187|    399|		r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_GET_NEXT_GENERIC_OBJECT, &obj_info);
  188|    399|		LOG_TEST_GOTO_ERR(card->ctx, r, "Can not get next generic object.");
  ------------------
  |  |  184|    399|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    399|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    399|	int _ret = (r); \
  |  |  |  |  178|    399|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 399]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    399|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 399]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|    399|		memset(&obj_obj, 0, sizeof(obj_obj));
  190|    399|		memcpy(obj_obj.label, obj_info.app_label, sizeof(obj_obj.label));
  191|       |
  192|    399|		r = sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_DATA_OBJECT,
  ------------------
  |  |  442|    399|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  193|    399|			&obj_obj, &obj_info);
  194|    399|		LOG_TEST_GOTO_ERR(card->ctx, r, "Can not finalize generic object.");
  ------------------
  |  |  184|    399|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    399|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    399|	int _ret = (r); \
  |  |  |  |  178|    399|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 399]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    399|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 399]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|    399|	}
  196|  1.03k|	r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_FINAL_GET_GENERIC_OBJECTS, &count);
  197|  1.03k|	LOG_TEST_GOTO_ERR(card->ctx, r, "Can not finalize generic objects.");
  ------------------
  |  |  184|  1.03k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.03k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.03k|	int _ret = (r); \
  |  |  |  |  178|  1.03k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  1.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|       |
  199|       |	/*
  200|       |	 * certs, pubkeys and priv keys are related and we assume
  201|       |	 * they are in order
  202|       |	 * We need to read the cert, get modulus and keylen
  203|       |	 * We use those for the pubkey, and priv key objects.
  204|       |	 */
  205|  1.03k|	sc_log(card->ctx,  "CAC adding certs, pub and priv keys...");
  ------------------
  |  |   71|  1.03k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  206|  1.03k|	r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_INIT_GET_CERT_OBJECTS, &count);
  207|  1.03k|	LOG_TEST_GOTO_ERR(card->ctx, r, "Can not initiate cert objects.");
  ------------------
  |  |  184|  1.03k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.03k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.03k|	int _ret = (r); \
  |  |  |  |  178|  1.03k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  1.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  208|       |
  209|  3.55k|	for (i = 0; i < count; i++) {
  ------------------
  |  Branch (209:14): [True: 2.52k, False: 1.03k]
  ------------------
  210|  2.52k|		struct sc_pkcs15_data_info obj_info;
  211|  2.52k|		struct sc_pkcs15_cert_info cert_info;
  212|  2.52k|		struct sc_pkcs15_pubkey_info pubkey_info;
  213|  2.52k|		struct sc_pkcs15_prkey_info prkey_info;
  214|  2.52k|		struct sc_pkcs15_object cert_obj;
  215|  2.52k|		struct sc_pkcs15_object pubkey_obj;
  216|  2.52k|		struct sc_pkcs15_object prkey_obj;
  217|  2.52k|		sc_pkcs15_der_t   cert_der;
  218|  2.52k|		sc_pkcs15_cert_t *cert_out = NULL;
  219|       |
  220|  2.52k|		r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_GET_NEXT_CERT_OBJECT, &obj_info);
  221|  2.52k|		LOG_TEST_RET(card->ctx, r, "Can not get next object");
  ------------------
  |  |  174|  2.52k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.52k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.52k|	int _ret = (r); \
  |  |  |  |  168|  2.52k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.52k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.52k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.52k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|       |
  223|  2.52k|		memset(&cert_info, 0, sizeof(cert_info));
  224|  2.52k|		memset(&pubkey_info, 0, sizeof(pubkey_info));
  225|  2.52k|		memset(&prkey_info, 0, sizeof(prkey_info));
  226|  2.52k|		memset(&cert_obj,  0, sizeof(cert_obj));
  227|  2.52k|		memset(&pubkey_obj,  0, sizeof(pubkey_obj));
  228|  2.52k|		memset(&prkey_obj,  0, sizeof(prkey_obj));
  229|       |
  230|  2.52k|		cert_info.id = obj_info.id;
  231|  2.52k|		pubkey_info.id = obj_info.id;
  232|  2.52k|		prkey_info.id = obj_info.id;
  233|  2.52k|		cert_info.path = obj_info.path;
  234|  2.52k|		prkey_info.path = obj_info.path;
  235|       |		/* Add 0x3f00 to the front of prkey_info.path to make sc_key_file happy */
  236|       |		/* only do this if our path.len is 1 or 2 */
  237|  2.52k|		if (prkey_info.path.len && prkey_info.path.len <= 2) {
  ------------------
  |  Branch (237:7): [True: 772, False: 1.74k]
  |  Branch (237:30): [True: 772, False: 0]
  ------------------
  238|    772|			prkey_info.path.value[2] = prkey_info.path.value[0];
  239|    772|			prkey_info.path.value[3] = prkey_info.path.value[1];
  240|    772|			prkey_info.path.value[0] = 0x3f;
  241|    772|			prkey_info.path.value[1] = 0x00;
  242|    772|			prkey_info.path.len += 2;
  243|    772|		}
  244|  2.52k|		pubkey_info.native        = 1;
  245|  2.52k|		pubkey_info.key_reference = ((int)obj_info.id.value[0]) << 8 | obj_info.id.value[1];
  246|  2.52k|		prkey_info.key_reference = ((int)obj_info.id.value[0]) << 8 | obj_info.id.value[1];
  247|  2.52k|		prkey_info.native        = 1;
  248|       |
  249|  2.52k|		memcpy(cert_obj.label, obj_info.app_label, sizeof(obj_info.app_label));
  250|  2.52k|		memcpy(pubkey_obj.label, obj_info.app_label, sizeof(obj_info.app_label));
  251|  2.52k|		memcpy(prkey_obj.label, obj_info.app_label, sizeof(obj_info.app_label));
  252|  2.52k|		prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|  2.52k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  253|  2.52k|		sc_pkcs15_format_id(pins[0].id, &prkey_obj.auth_id);
  254|       |
  255|  2.52k|		r = sc_pkcs15_read_file(p15card, &cert_info.path, &cert_der.value, &cert_der.len, 0);
  256|       |
  257|  2.52k|		if (r) {
  ------------------
  |  Branch (257:7): [True: 2.19k, False: 326]
  ------------------
  258|  2.19k|			sc_log(card->ctx,  "No cert found,i=%d", i);
  ------------------
  |  |   71|  2.19k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  259|  2.19k|			continue;
  260|  2.19k|		}
  261|    326|		cert_info.path.count = (int)cert_der.len;
  262|       |
  263|    326|		sc_log(card->ctx, "cert len=%zu, cert_info.path.count=%d r=%d",
  ------------------
  |  |   71|    326|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  264|    326|				cert_der.len, cert_info.path.count, r);
  265|    326|		sc_log_hex(card->ctx, "cert", cert_der.value, cert_der.len);
  ------------------
  |  |  129|    326|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    326|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  266|       |
  267|       |		/* cache it using the PKCS15 emulation objects */
  268|       |		/* as it does not change */
  269|    326|		if (cert_der.value) {
  ------------------
  |  Branch (269:7): [True: 175, False: 151]
  ------------------
  270|    175|			cert_info.value.value = cert_der.value;
  271|    175|			cert_info.value.len = cert_der.len;
  272|    175|			cert_info.path.len = 0; /* use in mem cert from now on */
  273|    175|		}
  274|       |
  275|       |		/* following will find the cached cert in cert_info */
  276|    326|		r =  sc_pkcs15_read_certificate(p15card, &cert_info, 0, &cert_out);
  277|    326|		if (r < 0 || cert_out->key == NULL) {
  ------------------
  |  Branch (277:7): [True: 326, False: 0]
  |  Branch (277:16): [True: 0, False: 0]
  ------------------
  278|    326|			sc_log(card->ctx,  "Failed to read/parse the certificate r=%d",r);
  ------------------
  |  |   71|    326|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  279|    326|			if (cert_out != NULL)
  ------------------
  |  Branch (279:8): [True: 0, False: 326]
  ------------------
  280|      0|				sc_pkcs15_free_certificate(cert_out);
  281|    326|			free(cert_info.value.value);
  282|    326|			continue;
  283|    326|		}
  284|       |
  285|      0|		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  286|      0|		if (r < 0) {
  ------------------
  |  Branch (286:7): [True: 0, False: 0]
  ------------------
  287|      0|			sc_log(card->ctx,  " Failed to add cert obj r=%d",r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  288|      0|			sc_pkcs15_free_certificate(cert_out);
  289|      0|			free(cert_info.value.value);
  290|      0|			continue;
  291|      0|		}
  292|       |		/* set the token name to the name of the CN of the first certificate */
  293|      0|		if (!token_name) {
  ------------------
  |  Branch (293:7): [True: 0, False: 0]
  ------------------
  294|      0|			u8 * cn_name = NULL;
  295|      0|			size_t cn_len = 0;
  296|      0|			static const struct sc_object_id cn_oid = {{ 2, 5, 4, 3, -1 }};
  297|      0|			r = sc_pkcs15_get_name_from_dn(card->ctx, cert_out->subject,
  298|      0|				cert_out->subject_len, &cn_oid, &cn_name, &cn_len);
  299|      0|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (299:8): [True: 0, False: 0]
  ------------------
  300|      0|				token_name = malloc (cn_len+1);
  301|      0|				if (!token_name) {
  ------------------
  |  Branch (301:9): [True: 0, False: 0]
  ------------------
  302|      0|					free(cn_name);
  303|      0|					r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  304|      0|					goto fail;
  305|      0|				}
  306|      0|				memcpy(token_name, cn_name, cn_len);
  307|      0|				free(cn_name);
  308|      0|				token_name[cn_len] = 0;
  309|      0|				free(p15card->tokeninfo->label);
  310|      0|				p15card->tokeninfo->label = token_name;
  311|      0|			}
  312|      0|		}
  313|       |
  314|       |
  315|      0|		r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, cert_out->key, &pubkey_info.direct.spki.value, &pubkey_info.direct.spki.len);
  316|      0|		if (r < 0)
  ------------------
  |  Branch (316:7): [True: 0, False: 0]
  ------------------
  317|      0|			goto fail;
  318|      0|		pubkey_obj.emulated = cert_out->key;
  319|       |
  320|      0|		r = sc_pkcs15_get_bitstring_extension(card->ctx, cert_out, &usage_type, &usage, NULL);
  321|      0|		if (r < 0) {
  ------------------
  |  Branch (321:7): [True: 0, False: 0]
  ------------------
  322|      0|			usage = SC_X509_DATA_ENCIPHERMENT|SC_X509_DIGITAL_SIGNATURE; /* basic default usage */
  ------------------
  |  |  617|      0|#define SC_X509_DATA_ENCIPHERMENT     0x0008UL
  ------------------
              			usage = SC_X509_DATA_ENCIPHERMENT|SC_X509_DIGITAL_SIGNATURE; /* basic default usage */
  ------------------
  |  |  614|      0|#define SC_X509_DIGITAL_SIGNATURE     0x0001UL
  ------------------
  323|      0|		}
  324|      0|		sc_pkcs15_map_usage(usage, cert_out->key->algorithm, &pubkey_info.usage, &prkey_info.usage, 1);
  325|      0|		sc_log(card->ctx,   "cert %s: cert_usage=0x%x, pub_usage=0x%x priv_usage=0x%x\n",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  326|      0|				sc_dump_hex(cert_info.id.value, cert_info.id.len),
  327|      0|				 usage, pubkey_info.usage, prkey_info.usage);
  328|      0|		if (cert_out->key->algorithm != SC_ALGORITHM_RSA) {
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (328:7): [True: 0, False: 0]
  ------------------
  329|      0|			sc_log(card->ctx, "unsupported key.algorithm %lu", cert_out->key->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  330|      0|			sc_pkcs15_free_certificate(cert_out);
  331|      0|			free(pubkey_info.direct.spki.value);
  332|      0|			continue;
  333|      0|		} else {
  334|      0|			pubkey_info.modulus_length = cert_out->key->u.rsa.modulus.len * 8;
  335|      0|			prkey_info.modulus_length = cert_out->key->u.rsa.modulus.len * 8;
  336|      0|			r = sc_pkcs15emu_add_rsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
  337|      0|			sc_log(card->ctx,  "adding rsa public key r=%d usage=%x",r, pubkey_info.usage);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  338|      0|			if (r < 0) {
  ------------------
  |  Branch (338:8): [True: 0, False: 0]
  ------------------
  339|      0|				free(pubkey_info.direct.spki.value);
  340|      0|				goto fail;
  341|      0|			}
  342|      0|			pubkey_info.direct.spki.value = NULL; /* moved to the pubkey object on p15card  */
  343|      0|			pubkey_info.direct.spki.len = 0;
  344|      0|			r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  345|      0|			if (r < 0)
  ------------------
  |  Branch (345:8): [True: 0, False: 0]
  ------------------
  346|      0|				goto fail;
  347|      0|			sc_log(card->ctx,  "adding rsa private key r=%d usage=%x",r, prkey_info.usage);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  348|      0|		}
  349|       |
  350|      0|		cert_out->key = NULL;
  351|      0|fail:
  352|      0|		sc_pkcs15_free_certificate(cert_out);
  353|      0|		if (r < 0) {
  ------------------
  |  Branch (353:7): [True: 0, False: 0]
  ------------------
  354|      0|			(card->ops->card_ctl)(card, SC_CARDCTL_CAC_FINAL_GET_CERT_OBJECTS, &count);
  355|      0|			LOG_TEST_GOTO_ERR(card->ctx, r, "Failed to add object.");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  356|      0|		}
  357|       |
  358|      0|	}
  359|  1.03k|	r = (card->ops->card_ctl)(card, SC_CARDCTL_CAC_FINAL_GET_CERT_OBJECTS, &count);
  360|  1.03k|	LOG_TEST_GOTO_ERR(card->ctx, r, "Can not finalize cert objects.");
  ------------------
  |  |  184|  1.03k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.03k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.03k|	int _ret = (r); \
  |  |  |  |  178|  1.03k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  1.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  361|       |
  362|  1.03k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.03k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.03k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.03k|	int _ret = r; \
  |  |  |  |  155|  1.03k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.03k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.03k|		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: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.03k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.03k|	} 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|  1.03k|	return _ret; \
  |  |  |  |  163|  1.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|       |
  364|      0|err:
  365|      0|	sc_pkcs15_card_clear(p15card);
  366|      0|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  367|      0|}
pkcs15-cac.c:cac_get_name:
   78|  1.03k|{
   79|  1.03k|    switch (type) {
   80|    194|    case SC_CARD_TYPE_CAC_I: return ("CAC I");
  ------------------
  |  Branch (80:5): [True: 194, False: 841]
  ------------------
   81|    393|    case SC_CARD_TYPE_CAC_II: return ("CAC II");
  ------------------
  |  Branch (81:5): [True: 393, False: 642]
  ------------------
   82|    448|    case SC_CARD_TYPE_CAC_ALT_HID: return ("CAC ALT HID");
  ------------------
  |  Branch (82:5): [True: 448, False: 587]
  ------------------
   83|      0|    default: break;
  ------------------
  |  Branch (83:5): [True: 0, False: 1.03k]
  ------------------
   84|  1.03k|    }
   85|      0|    return ("CAC");
   86|  1.03k|}

sc_pkcs15_read_cached_file:
  134|  15.5k|{
  135|  15.5k|	char fname[PATH_MAX];
  136|  15.5k|	int rv;
  137|  15.5k|	FILE *f;
  138|  15.5k|	size_t count;
  139|  15.5k|	struct stat stbuf;
  140|  15.5k|	u8 *data = NULL;
  141|       |
  142|  15.5k|	if (path->len < 2)
  ------------------
  |  Branch (142:6): [True: 2.20k, False: 13.3k]
  ------------------
  143|  2.20k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  2.20k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  144|       |
  145|       |	/* Accept full path or FILE-ID path with AID */
  146|  13.3k|	if ((path->type != SC_PATH_TYPE_PATH) && (path->type != SC_PATH_TYPE_FILE_ID || path->aid.len == 0))
  ------------------
  |  |  119|  13.3k|#define SC_PATH_TYPE_PATH		2
  ------------------
              	if ((path->type != SC_PATH_TYPE_PATH) && (path->type != SC_PATH_TYPE_FILE_ID || path->aid.len == 0))
  ------------------
  |  |  117|  3.62k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (146:6): [True: 1.81k, False: 11.5k]
  |  Branch (146:44): [True: 2, False: 1.81k]
  |  Branch (146:82): [True: 817, False: 994]
  ------------------
  147|    819|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    819|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  148|       |
  149|  12.5k|	sc_log(p15card->card->ctx, "try to read cache for %s", sc_print_path(path));
  ------------------
  |  |   71|  12.5k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  150|  12.5k|	rv = generate_cache_filename(p15card, path, fname, sizeof(fname));
  151|  12.5k|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|  12.5k|#define SC_SUCCESS				0
  ------------------
  |  Branch (151:6): [True: 12.5k, False: 0]
  ------------------
  152|  12.5k|		return rv;
  153|      0|	sc_log(p15card->card->ctx, "read cached file %s", fname);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  154|       |
  155|      0|	f = fopen(fname, "rb");
  156|      0|	if (!f)
  ------------------
  |  Branch (156:6): [True: 0, False: 0]
  ------------------
  157|      0|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  158|      0|	if (fstat(fileno(f), &stbuf))   {
  ------------------
  |  Branch (158:6): [True: 0, False: 0]
  ------------------
  159|      0|		fclose(f);
  160|      0|		return  SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  161|      0|	}
  162|       |
  163|      0|	if (path->count < 0) {
  ------------------
  |  Branch (163:6): [True: 0, False: 0]
  ------------------
  164|      0|		count = stbuf.st_size;
  165|      0|	}
  166|      0|	else {
  167|      0|		count = path->count;
  168|      0|		if (path->index + count > (size_t)stbuf.st_size)   {
  ------------------
  |  Branch (168:7): [True: 0, False: 0]
  ------------------
  169|      0|			rv = SC_ERROR_FILE_NOT_FOUND; /* cache file bad? */
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  170|      0|			goto err;
  171|      0|		}
  172|       |
  173|      0|		if (0 != fseek(f, (long)path->index, SEEK_SET)) {
  ------------------
  |  Branch (173:7): [True: 0, False: 0]
  ------------------
  174|      0|			rv = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  175|      0|			goto err;
  176|      0|		}
  177|      0|	}
  178|       |
  179|      0|	if (*buf == NULL) {
  ------------------
  |  Branch (179:6): [True: 0, False: 0]
  ------------------
  180|      0|		if (count == 0) {
  ------------------
  |  Branch (180:7): [True: 0, False: 0]
  ------------------
  181|      0|			data = NULL;
  182|      0|		} else {
  183|      0|			data = malloc(count);
  184|      0|			if (data == NULL)   {
  ------------------
  |  Branch (184:8): [True: 0, False: 0]
  ------------------
  185|      0|				rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  186|      0|				goto err;
  187|      0|			}
  188|      0|		}
  189|      0|	}
  190|      0|	else {
  191|      0|		if (count > *bufsize) {
  ------------------
  |  Branch (191:7): [True: 0, False: 0]
  ------------------
  192|      0|			rv =  SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  193|      0|			goto err;
  194|      0|		}
  195|      0|		data = *buf;
  196|      0|	}
  197|       |
  198|      0|	if (count > 0 && count != fread(data, 1, count, f)) {
  ------------------
  |  Branch (198:6): [True: 0, False: 0]
  |  Branch (198:19): [True: 0, False: 0]
  ------------------
  199|      0|		rv = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  200|      0|		goto err;
  201|      0|	}
  202|      0|	*buf = data;
  203|      0|	*bufsize = count;
  204|       |
  205|      0|	rv = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  206|       |
  207|      0|err:
  208|      0|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (208:6): [True: 0, False: 0]
  ------------------
  209|      0|		if (data != *buf) {
  ------------------
  |  Branch (209:7): [True: 0, False: 0]
  ------------------
  210|      0|			free(data);
  211|      0|		}
  212|      0|	}
  213|       |
  214|      0|	fclose(f);
  215|      0|	return rv;
  216|      0|}
sc_pkcs15_cache_file:
  221|  1.12k|{
  222|  1.12k|	char fname[PATH_MAX];
  223|  1.12k|	int r;
  224|  1.12k|	long len;
  225|  1.12k|	FILE *f;
  226|  1.12k|	size_t c;
  227|       |
  228|  1.12k|	r = generate_cache_filename(p15card, path, fname, sizeof(fname));
  229|  1.12k|	if (r != 0)
  ------------------
  |  Branch (229:6): [True: 1.12k, False: 0]
  ------------------
  230|  1.12k|		return r;
  231|       |
  232|      0|	f = fopen(fname, "ab");
  233|       |	/* If the open failed because the cache directory does
  234|       |	 * not exist, create it and a re-try the fopen() call.
  235|       |	 */
  236|      0|	if (f == NULL && errno == ENOENT) {
  ------------------
  |  Branch (236:6): [True: 0, False: 0]
  |  Branch (236:19): [True: 0, False: 0]
  ------------------
  237|      0|		if ((r = sc_make_cache_dir(p15card->card->ctx)) < 0)
  ------------------
  |  Branch (237:7): [True: 0, False: 0]
  ------------------
  238|      0|			return r;
  239|      0|		f = fopen(fname, "ab");
  240|      0|	}
  241|      0|	if (f == NULL)
  ------------------
  |  Branch (241:6): [True: 0, False: 0]
  ------------------
  242|      0|		return 0;
  243|       |
  244|       |	/* we opened the file for appending so we should be at the end of file.
  245|       |	 * The ftell() will give use the length of the file */
  246|      0|	len = ftell(f);
  247|      0|	if (len > path->index) {
  ------------------
  |  Branch (247:6): [True: 0, False: 0]
  ------------------
  248|       |		/* override previous cache records on this location */
  249|      0|		r = fseek(f, path->index, SEEK_SET);
  250|      0|		if (r != 0) {
  ------------------
  |  Branch (250:7): [True: 0, False: 0]
  ------------------
  251|      0|			fclose(f);
  252|      0|			return 0;
  253|      0|		}
  254|      0|	} else if (path->index > len) {
  ------------------
  |  Branch (254:13): [True: 0, False: 0]
  ------------------
  255|       |		/* We miss some bytes so we will not cache this chunk */
  256|      0|		fclose(f);
  257|      0|		return 0;
  258|      0|	}
  259|       |
  260|      0|	c = fwrite(buf, 1, bufsize, f);
  261|      0|	fclose(f);
  262|      0|	if (c != bufsize) {
  ------------------
  |  Branch (262:6): [True: 0, False: 0]
  ------------------
  263|      0|		sc_log(p15card->card->ctx, "fwrite() wrote only %zu bytes", c);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  264|      0|		unlink(fname);
  265|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  266|      0|	}
  267|      0|	return 0;
  268|      0|}
pkcs15-cache.c:generate_cache_filename:
   63|  13.6k|{
   64|  13.6k|	char dir[PATH_MAX];
   65|  13.6k|	char *last_update = NULL;
   66|  13.6k|	char *serial_number = NULL;
   67|  13.6k|	int  r;
   68|  13.6k|	unsigned u;
   69|  13.6k|	size_t change_counter;
   70|       |
   71|  13.6k|	if (p15card == NULL || p15card->tokeninfo == NULL || p15card->card == NULL || p15card->card->ctx) {
  ------------------
  |  Branch (71:6): [True: 0, False: 13.6k]
  |  Branch (71:25): [True: 0, False: 13.6k]
  |  Branch (71:55): [True: 0, False: 13.6k]
  |  Branch (71:80): [True: 13.6k, False: 0]
  ------------------
   72|  13.6k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  13.6k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   73|  13.6k|	}
   74|       |
   75|      0|	serial_number = p15card->tokeninfo->serial_number;
   76|      0|	if (serial_number == NULL &&
  ------------------
  |  Branch (76:6): [True: 0, False: 0]
  ------------------
   77|      0|			(p15card->card->uid.len == 0 || p15card->card->uid.value[0] == RANDOM_UID_INDICATOR))
  ------------------
  |  |   40|      0|#define RANDOM_UID_INDICATOR 0x08
  ------------------
  |  Branch (77:5): [True: 0, False: 0]
  |  Branch (77:36): [True: 0, False: 0]
  ------------------
   78|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   79|       |
   80|      0|	if (path->len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|      0|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (80:6): [True: 0, False: 0]
  ------------------
   81|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   82|      0|	r = sc_get_cache_dir(p15card->card->ctx, dir, sizeof(dir));
   83|      0|	if (r)
  ------------------
  |  Branch (83:6): [True: 0, False: 0]
  ------------------
   84|      0|		return r;
   85|      0|	snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "/");
   86|       |
   87|      0|	last_update = sc_pkcs15_get_lastupdate(p15card);
   88|      0|	if (!last_update || !is_safe_cache_component(last_update))
  ------------------
  |  Branch (88:6): [True: 0, False: 0]
  |  Branch (88:22): [True: 0, False: 0]
  ------------------
   89|      0|		last_update = "NODATE";
   90|       |
   91|      0|	if (serial_number && is_safe_cache_component(serial_number)) {
  ------------------
  |  Branch (91:6): [True: 0, False: 0]
  |  Branch (91:23): [True: 0, False: 0]
  ------------------
   92|      0|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir),
   93|      0|				"%s_%s", serial_number, last_update);
   94|      0|	} else {
   95|      0|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "uid-%s_%s",
   96|      0|				sc_dump_hex(p15card->card->uid.value, p15card->card->uid.len), last_update);
   97|      0|	}
   98|       |
   99|      0|	if (SC_SUCCESS == sc_card_ctl(p15card->card, SC_CARDCTL_GET_CHANGE_COUNTER, &change_counter))
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (99:6): [True: 0, False: 0]
  ------------------
  100|      0|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "_%zu", change_counter);
  101|       |
  102|      0|	if (path->aid.len &&
  ------------------
  |  Branch (102:6): [True: 0, False: 0]
  ------------------
  103|      0|		(path->type == SC_PATH_TYPE_FILE_ID || path->type == SC_PATH_TYPE_PATH))   {
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
              		(path->type == SC_PATH_TYPE_FILE_ID || path->type == SC_PATH_TYPE_PATH))   {
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (103:4): [True: 0, False: 0]
  |  Branch (103:42): [True: 0, False: 0]
  ------------------
  104|      0|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "_");
  105|      0|		for (u = 0; u < path->aid.len; u++)
  ------------------
  |  Branch (105:15): [True: 0, False: 0]
  ------------------
  106|      0|			snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir),
  107|      0|					"%02X",  path->aid.value[u]);
  108|      0|	}
  109|      0|	else if (path->type != SC_PATH_TYPE_PATH)  {
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (109:11): [True: 0, False: 0]
  ------------------
  110|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  111|      0|	}
  112|       |
  113|      0|	if (path->len)   {
  ------------------
  |  Branch (113:6): [True: 0, False: 0]
  ------------------
  114|      0|		size_t offs = 0;
  115|       |
  116|      0|		if (path->len > 2 && memcmp(path->value, "\x3F\x00", 2) == 0)
  ------------------
  |  Branch (116:7): [True: 0, False: 0]
  |  Branch (116:24): [True: 0, False: 0]
  ------------------
  117|      0|			offs = 2;
  118|      0|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "_");
  119|      0|		for (u = 0; u < path->len - offs; u++)
  ------------------
  |  Branch (119:15): [True: 0, False: 0]
  ------------------
  120|      0|			snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir),
  121|      0|					"%02X",  path->value[u + offs]);
  122|      0|	}
  123|       |
  124|      0|	if (!buf)
  ------------------
  |  Branch (124:6): [True: 0, False: 0]
  ------------------
  125|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  126|      0|	strlcpy(buf, dir, bufsize);
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  127|       |
  128|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  129|      0|}

sc_pkcs15emu_cardos_init_ex:
  173|  10.2k|{
  174|  10.2k|	if (cardos_pkcs15emu_detect_card(p15card))
  ------------------
  |  Branch (174:6): [True: 9.49k, False: 796]
  ------------------
  175|  9.49k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  9.49k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  176|       |
  177|    796|	return sc_pkcs15emu_cardos_init(p15card, aid);
  178|  10.2k|}
pkcs15-cardos.c:cardos_pkcs15emu_detect_card:
  139|  10.2k|{
  140|  10.2k|	if (p15card->card->type <  SC_CARD_TYPE_CARDOS_BASE)
  ------------------
  |  Branch (140:6): [True: 393, False: 9.89k]
  ------------------
  141|    393|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|    393|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  142|       |
  143|  9.89k|	if (p15card->card->type >= SC_CARD_TYPE_CARDOS_BASE + 1000)
  ------------------
  |  Branch (143:6): [True: 9.09k, False: 796]
  ------------------
  144|  9.09k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  9.09k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  145|       |
  146|    796|	return SC_SUCCESS;
  ------------------
  |  |   28|    796|#define SC_SUCCESS				0
  ------------------
  147|  9.89k|}
pkcs15-cardos.c:sc_pkcs15emu_cardos_init:
  152|    796|{
  153|    796|	sc_card_t *card = p15card->card;
  154|    796|	int r;
  155|       |
  156|    796|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    796|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    796|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    796|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    796|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 796]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  157|       |
  158|    796|	r = sc_pkcs15_bind_internal(p15card, aid);
  159|    796|	LOG_TEST_RET(card->ctx, r, "sc_pkcs15_bind_internal failed");
  ------------------
  |  |  174|    796|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    796|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    796|	int _ret = (r); \
  |  |  |  |  168|    796|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 782, False: 14]
  |  |  |  |  ------------------
  |  |  |  |  169|    782|		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|    782|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    782|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    782|		return _ret; \
  |  |  |  |  172|    782|	} \
  |  |  |  |  173|    796|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 14]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|       |
  161|       |	/* If card has created algorithms, return  */
  162|     14|	sc_log(card->ctx, " card->algorithms:%p card->algorithm_count:%d", card->algorithms, card->algorithm_count);
  ------------------
  |  |   71|     14|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  163|     14|	if (!card->algorithms && card->algorithm_count == 0) {
  ------------------
  |  Branch (163:6): [True: 10, False: 4]
  |  Branch (163:27): [True: 10, False: 0]
  ------------------
  164|     10|		r = cardos_fix_token_info(p15card);
  165|     10|	}
  166|       |
  167|     14|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     14|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     14|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     14|	int _ret = r; \
  |  |  |  |  155|     14|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     14|		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: 14]
  |  |  |  |  ------------------
  |  |  |  |  157|     14|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     14|	} 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|     14|	return _ret; \
  |  |  |  |  163|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  168|     14|}
pkcs15-cardos.c:cardos_fix_token_info:
   43|     10|{
   44|     10|	sc_card_t *card;
   45|     10|	struct sc_supported_algo_info (*saa)[SC_MAX_SUPPORTED_ALGORITHMS];
   46|     10|	struct sc_supported_algo_info *sa;
   47|     10|	struct sc_cardctl_cardos_pass_algo_flags *passed = NULL;
   48|     10|	int r = 0;
   49|     10|	int i;
   50|       |
   51|     10|	card = p15card->card;
   52|       |
   53|     10|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     10|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     10|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     10|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 10]
  |  |  ------------------
  ------------------
   54|       |
   55|     10|	passed = calloc(1, sizeof(struct sc_cardctl_cardos_pass_algo_flags));
   56|     10|	if (!passed)
  ------------------
  |  Branch (56:6): [True: 0, False: 10]
  ------------------
   57|     10|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_ENOUGH_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   58|       |
   59|     10|	passed->pass = 1; /* get used_flags and card_flags from card */
   60|     10|	r = sc_card_ctl(p15card->card, SC_CARDCTL_CARDOS_PASS_ALGO_FLAGS, passed);
   61|     10|	if (r < 0) {
  ------------------
  |  Branch (61:6): [True: 0, False: 10]
  ------------------
   62|      0|		free(passed);
   63|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|      0|	}
   65|       |
   66|     10|	saa = &(p15card->tokeninfo->supported_algos);
   67|       |
   68|     10|	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "Original Flags: 0x%8.8lx card->flags:0x%8.8lx", passed->used_flags, passed->card_flags);
  ------------------
  |  |   70|     10|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   69|       |
   70|     10|	if (passed->card_flags) { /* user forced the flags, use them */
  ------------------
  |  Branch (70:6): [True: 0, False: 10]
  ------------------
   71|      0|		passed->new_flags = passed->card_flags; /* from card_atr flags */
   72|     10|	} else {
   73|       |
   74|     10|		for (i = 0, sa = saa[0]; i < SC_MAX_SUPPORTED_ALGORITHMS; i++, sa++) {
  ------------------
  |  |   61|     10|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (74:28): [True: 10, False: 0]
  ------------------
   75|       |
   76|     10|			if (sa->reference == 0 && sa->mechanism == 0
  ------------------
  |  Branch (76:8): [True: 10, False: 0]
  |  Branch (76:30): [True: 10, False: 0]
  ------------------
   77|     10|					&& sa->operations == 0 && sa->algo_ref == 0)
  ------------------
  |  Branch (77:9): [True: 10, False: 0]
  |  Branch (77:32): [True: 10, False: 0]
  ------------------
   78|     10|				break;
   79|       |
   80|      0|			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "supported_algos[%d] mechanism:0x%8.8x", i, sa->mechanism);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   81|      0|			switch(sa->mechanism) {
   82|      0|			case 0x01 :
  ------------------
  |  Branch (82:4): [True: 0, False: 0]
  ------------------
   83|       |				/*
   84|       |				 * Card appears to use lower 4 bits of reference as key, and upper
   85|       |				 * 4 bits as mech for card.
   86|       |				 * Also has a bug if mechanism = 1 (CKM_RSA_PKCS1) and reference 0x10 
   87|       |				 * bit is set mechanism should be 3 (CKM_RSA_X_509) 
   88|       |				 * correct the mechanism in tokenInfo
   89|       |				 */
   90|      0|				if (sa->reference & 0x10) {
  ------------------
  |  Branch (90:9): [True: 0, False: 0]
  ------------------
   91|      0|					sc_log(card->ctx, "Changing mechanism to CKM_RSA_X_509 based on reference");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   92|      0|					passed->new_flags |= SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  102|      0|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
   93|      0|						| SC_ALGORITHM_RSA_PAD_NONE;
  ------------------
  |  |  104|      0|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
   94|      0|					sa->mechanism = 0x03;
   95|      0|				} else
   96|      0|				passed->new_flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
   97|      0|				break;
   98|      0|			case 0x03 :
  ------------------
  |  Branch (98:4): [True: 0, False: 0]
  ------------------
   99|      0|				passed->new_flags |= SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  102|      0|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  100|      0|					| SC_ALGORITHM_RSA_PAD_NONE;
  ------------------
  |  |  104|      0|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
  101|      0|				break;
  102|      0|			case 0x06 :
  ------------------
  |  Branch (102:4): [True: 0, False: 0]
  ------------------
  103|      0|				passed->new_flags |= SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|      0|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  104|      0|				break;
  105|      0|			case 0x1041:
  ------------------
  |  Branch (105:4): [True: 0, False: 0]
  ------------------
  106|      0|				passed->ec_flags |= SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|      0|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  107|       |				/* no old_ec_flags */
  108|       |				/* TODO turn on sizes from  ec curves OIDS */
  109|      0|				break;
  110|      0|			default:
  ------------------
  |  Branch (110:4): [True: 0, False: 0]
  ------------------
  111|      0|				sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "UNKNOWN MECH: 0x%8.8x", sa->mechanism);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  112|      0|			}
  113|       |
  114|      0|			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "New_flags 0x%8.8lx New_ec_flags: 0x%8.8lx",
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  115|      0|				passed->new_flags, passed->ec_flags);
  116|      0|		}
  117|       |
  118|     10|		if (passed->new_flags == 0) {
  ------------------
  |  Branch (118:7): [True: 10, False: 0]
  ------------------
  119|     10|			if (p15card->tokeninfo && p15card->tokeninfo->flags & SC_PKCS15_TOKEN_EID_COMPLIANT) {
  ------------------
  |  |  598|     10|#define SC_PKCS15_TOKEN_EID_COMPLIANT			0x08
  ------------------
  |  Branch (119:8): [True: 10, False: 0]
  |  Branch (119:30): [True: 0, False: 10]
  ------------------
  120|      0|				sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "EID_COMPLIANT flag found");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  121|      0|				passed->new_flags = (passed->used_flags & ~SC_ALGORITHM_SPECIFIC_FLAGS) | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |   96|      0|#define SC_ALGORITHM_SPECIFIC_FLAGS	0x001FFFFF
  ------------------
              				passed->new_flags = (passed->used_flags & ~SC_ALGORITHM_SPECIFIC_FLAGS) | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  122|      0|				passed->new_flags |= (passed->used_flags & SC_ALGORITHM_RSA_PAD_PSS);
  ------------------
  |  |  107|      0|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  123|      0|			} else
  124|     10|				passed->new_flags = passed->used_flags; /* from default cardos_init */
  125|     10|		}
  126|     10|	}
  127|       |
  128|     10|	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL,"Final New_flags 0x%8.8lx New_ec_flags: 0x%8.8lx", passed->new_flags, passed->ec_flags);
  ------------------
  |  |   70|     10|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  129|       |
  130|     10|	passed->pass = 2; /* tell card driver to use the new flags */
  131|     10|	r = sc_card_ctl(p15card->card, SC_CARDCTL_CARDOS_PASS_ALGO_FLAGS, passed);
  132|       |
  133|     10|	free(passed);
  134|     10|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     10|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     10|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     10|	int _ret = r; \
  |  |  |  |  155|     10|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     10|		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: 10]
  |  |  |  |  ------------------
  |  |  |  |  157|     10|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     10|	} 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|     10|	return _ret; \
  |  |  |  |  163|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  135|     10|}

sc_pkcs15emu_cedulauy_init_ex:
  196|  12.9k|{
  197|  12.9k|	if (p15card->card->type != SC_CARD_TYPE_CEDULAUY)
  ------------------
  |  Branch (197:6): [True: 12.8k, False: 90]
  ------------------
  198|  12.8k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.8k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  199|       |
  200|     90|	return sc_pkcs15emu_cedulauy_init(p15card);
  201|  12.9k|}
pkcs15-cedulauy.c:sc_pkcs15emu_cedulauy_init:
   70|     90|{
   71|     90|	struct sc_context *ctx = p15card->card->ctx;
   72|     90|	struct sc_aid aid;
   73|     90|	int r;
   74|     90|	size_t i;
   75|       |
   76|     90|	struct sc_pkcs15_auth_info pin_info = {0};
   77|     90|	struct sc_pkcs15_object pin_obj = {0};
   78|     90|	struct sc_pkcs15_cert_info cert_info = {0};
   79|     90|	struct sc_pkcs15_object cert_obj = {0};
   80|     90|	struct sc_pkcs15_prkey_info prkey_info = {0};
   81|     90|	struct sc_pkcs15_object prkey_obj = {0};
   82|     90|	struct sc_pkcs15_cert *cert = NULL;
   83|     90|	struct sc_app_info *appinfo;
   84|       |
   85|     90|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     90|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     90|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     90|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     90|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   86|       |
   87|     90|	memcpy(aid.value, cedulauy_aid, sizeof cedulauy_aid);
   88|     90|	aid.len = sizeof cedulauy_aid;
   89|       |
   90|     90|	appinfo = calloc(1, sizeof(struct sc_app_info));
   91|     90|	if (appinfo == NULL) {
  ------------------
  |  Branch (91:6): [True: 0, False: 90]
  ------------------
   92|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|      0|	}
   94|     90|	appinfo->aid = aid;
   95|     90|	appinfo->ddo.aid = aid;
   96|     90|	p15card->app = appinfo;
   97|       |
   98|       |	/* Global PIN (reference 0x11, ASCII numeric, zero-padded to 12 bytes). */
   99|     90|	pin_info.auth_id.value[0] = CEDULAUY_OBJ_ID;
  ------------------
  |  |   52|     90|#define CEDULAUY_OBJ_ID	  0x01	 /* links cert <-> prkey */
  ------------------
  100|     90|	pin_info.auth_id.len = 1;
  101|     90|	pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|     90|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  102|     90|	pin_info.attrs.pin.reference = CEDULAUY_PIN_REF;
  ------------------
  |  |   51|     90|#define CEDULAUY_PIN_REF  0x11	 /* Global PIN reference */
  ------------------
  103|     90|	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_NEEDS_PADDING;
  ------------------
  |  |   58|     90|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
              	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_NEEDS_PADDING;
  ------------------
  |  |   59|     90|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  104|     90|	pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|     90|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  105|     90|	pin_info.attrs.pin.min_length = 4;
  106|     90|	pin_info.attrs.pin.stored_length = 12;
  107|     90|	pin_info.attrs.pin.max_length = 12;
  108|     90|	pin_info.attrs.pin.pad_char = 0x00;
  109|     90|	pin_info.tries_left = -1;
  110|     90|	pin_info.max_tries = -1;
  111|     90|	strlcpy(pin_obj.label, "PIN", sizeof pin_obj.label);
  ------------------
  |  |   43|     90|#define strlcpy _strlcpy
  ------------------
  112|     90|	r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  113|     90|	LOG_TEST_RET(ctx, r, "Cannot add Global PIN object");
  ------------------
  |  |  174|     90|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     90|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     90|	int _ret = (r); \
  |  |  |  |  168|     90|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 90]
  |  |  |  |  ------------------
  |  |  |  |  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|     90|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  114|       |
  115|       |	/* Signing certificate (EF B001 under the IAS application). */
  116|     90|	sc_format_path("i" CEDULAUY_CERT_FID, &cert_info.path); /* 'i' => select by file ID */
  ------------------
  |  |   49|     90|#define CEDULAUY_CERT_FID "B001" /* signing certificate EF */
  ------------------
  117|     90|	cert_info.path.aid = aid;
  118|     90|	cert_info.id.value[0] = CEDULAUY_OBJ_ID;
  ------------------
  |  |   52|     90|#define CEDULAUY_OBJ_ID	  0x01	 /* links cert <-> prkey */
  ------------------
  119|     90|	cert_info.id.len = 1;
  120|     90|	strlcpy(cert_obj.label, "Certificado de Firma", sizeof cert_obj.label);
  ------------------
  |  |   43|     90|#define strlcpy _strlcpy
  ------------------
  121|     90|	r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  122|     90|	LOG_TEST_RET(ctx, r, "Cannot add signing certificate object");
  ------------------
  |  |  174|     90|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     90|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     90|	int _ret = (r); \
  |  |  |  |  168|     90|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 90]
  |  |  |  |  ------------------
  |  |  |  |  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|     90|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  123|       |
  124|       |	/* Set the token label and serial number from the certificate, when
  125|       |	 * readable.  The serial number also keys the file cache. */
  126|     90|	if (sc_pkcs15_read_certificate(p15card, &cert_info, 0, &cert) == SC_SUCCESS) {
  ------------------
  |  |   28|     90|#define SC_SUCCESS				0
  ------------------
  |  Branch (126:6): [True: 0, False: 90]
  ------------------
  127|      0|		static const struct sc_object_id cn_oid = {
  128|      0|				{2, 5, 4, 3, -1}
  129|      0|		};
  130|      0|		u8 *cn = NULL;
  131|      0|		size_t cn_len = 0;
  132|      0|		const u8 *serial = cert->serial;
  133|      0|		size_t serial_len = cert->serial_len;
  134|       |
  135|      0|		sc_pkcs15_get_name_from_dn(ctx, cert->subject, cert->subject_len,
  136|      0|				&cn_oid, &cn, &cn_len);
  137|      0|		if (cn_len > 0) {
  ------------------
  |  Branch (137:7): [True: 0, False: 0]
  ------------------
  138|      0|			char *label = malloc(cn_len + 1);
  139|      0|			if (label) {
  ------------------
  |  Branch (139:8): [True: 0, False: 0]
  ------------------
  140|      0|				memcpy(label, cn, cn_len);
  141|      0|				label[cn_len] = '\0';
  142|      0|				free(p15card->tokeninfo->label);
  143|      0|				p15card->tokeninfo->label = label;
  144|      0|			}
  145|      0|		}
  146|      0|		free(cn);
  147|       |
  148|       |		/* strip the ASN.1 INTEGER header, if present */
  149|      0|		if (serial_len > 2 && serial[0] == 0x02 && serial[1] == serial_len - 2) {
  ------------------
  |  Branch (149:7): [True: 0, False: 0]
  |  Branch (149:25): [True: 0, False: 0]
  |  Branch (149:46): [True: 0, False: 0]
  ------------------
  150|      0|			serial += 2;
  151|      0|			serial_len -= 2;
  152|      0|		}
  153|      0|		if (serial_len > 0) {
  ------------------
  |  Branch (153:7): [True: 0, False: 0]
  ------------------
  154|      0|			char *sn = malloc(serial_len * 2 + 1);
  155|      0|			if (sn) {
  ------------------
  |  Branch (155:8): [True: 0, False: 0]
  ------------------
  156|      0|				sc_bin_to_hex(serial, serial_len, sn, serial_len * 2 + 1, 0);
  157|      0|				free(p15card->tokeninfo->serial_number);
  158|      0|				p15card->tokeninfo->serial_number = sn;
  159|      0|			}
  160|      0|		}
  161|       |
  162|      0|		sc_pkcs15_free_certificate(cert);
  163|      0|	}
  164|       |
  165|       |	/* Signing private key (reference 0x01, RSA 2048, PIN-protected). */
  166|     90|	prkey_info.id.value[0] = CEDULAUY_OBJ_ID;
  ------------------
  |  |   52|     90|#define CEDULAUY_OBJ_ID	  0x01	 /* links cert <-> prkey */
  ------------------
  167|     90|	prkey_info.id.len = 1;
  168|     90|	prkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
  ------------------
  |  |  307|     90|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
              	prkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
  ------------------
  |  |  314|     90|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  169|     90|	prkey_info.native = 1;
  170|     90|	prkey_info.key_reference = CEDULAUY_KEY_REF;
  ------------------
  |  |   50|     90|#define CEDULAUY_KEY_REF  0x01	 /* signing private key reference */
  ------------------
  171|     90|	prkey_info.modulus_length = 2048;
  172|     90|	prkey_obj.auth_id.value[0] = CEDULAUY_OBJ_ID;
  ------------------
  |  |   52|     90|#define CEDULAUY_OBJ_ID	  0x01	 /* links cert <-> prkey */
  ------------------
  173|     90|	prkey_obj.auth_id.len = 1;
  174|     90|	prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|     90|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  175|     90|	strlcpy(prkey_obj.label, "Clave de Firma", sizeof prkey_obj.label);
  ------------------
  |  |   43|     90|#define strlcpy _strlcpy
  ------------------
  176|     90|	r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  177|     90|	LOG_TEST_RET(ctx, r, "Cannot add signing private key object");
  ------------------
  |  |  174|     90|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     90|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     90|	int _ret = (r); \
  |  |  |  |  168|     90|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 90]
  |  |  |  |  ------------------
  |  |  |  |  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|     90|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 90]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  178|       |
  179|       |	/* Public identity data objects (DF 7000), readable without PIN. */
  180|    450|	for (i = 0; i < sizeof cedulauy_data_files / sizeof cedulauy_data_files[0]; i++) {
  ------------------
  |  Branch (180:14): [True: 360, False: 90]
  ------------------
  181|    360|		struct sc_pkcs15_data_info dinfo = {0};
  182|    360|		struct sc_pkcs15_object dobj = {0};
  183|       |
  184|    360|		sc_format_path(cedulauy_data_files[i].path, &dinfo.path);
  185|    360|		strlcpy(dinfo.app_label, cedulauy_data_files[i].label, sizeof dinfo.app_label);
  ------------------
  |  |   43|    360|#define strlcpy _strlcpy
  ------------------
  186|    360|		strlcpy(dobj.label, cedulauy_data_files[i].label, sizeof dobj.label);
  ------------------
  |  |   43|    360|#define strlcpy _strlcpy
  ------------------
  187|    360|		r = sc_pkcs15emu_add_data_object(p15card, &dobj, &dinfo);
  188|    360|		LOG_TEST_RET(ctx, r, "Cannot add identity data object");
  ------------------
  |  |  174|    360|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    360|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    360|	int _ret = (r); \
  |  |  |  |  168|    360|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 360]
  |  |  |  |  ------------------
  |  |  |  |  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|    360|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 360]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|    360|	}
  190|       |
  191|     90|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     90|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     90|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     90|	int _ret = r; \
  |  |  |  |  155|     90|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 90, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     90|		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: 90]
  |  |  |  |  ------------------
  |  |  |  |  157|     90|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     90|	} 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|     90|	return _ret; \
  |  |  |  |  163|     90|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|     90|}

sc_pkcs15_get_name_from_dn:
  157|  1.13k|{
  158|  1.13k|	const u8 *rdn = NULL;
  159|  1.13k|	const u8 *next_ava = NULL;
  160|  1.13k|	size_t rdn_len = 0;
  161|  1.13k|	size_t next_ava_len = 0;
  162|  1.13k|	int rv;
  163|       |
  164|  1.13k|	rdn = sc_asn1_skip_tag(ctx, &dn, &dn_len, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &rdn_len);
  ------------------
  |  |  206|  1.13k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              	rdn = sc_asn1_skip_tag(ctx, &dn, &dn_len, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &rdn_len);
  ------------------
  |  |  141|  1.13k|#define SC_ASN1_CONS			0x20000000
  ------------------
  165|  1.13k|	if (rdn == NULL)
  ------------------
  |  Branch (165:6): [True: 0, False: 1.13k]
  ------------------
  166|  1.13k|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "ASN.1 decoding of Distinguished Name");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|       |
  168|  1.18k|	for (next_ava = rdn, next_ava_len = rdn_len; next_ava_len; ) {
  ------------------
  |  Branch (168:47): [True: 1.13k, False: 49]
  ------------------
  169|  1.13k|		const u8 *ava, *dummy, *oidp;
  170|  1.13k|		struct sc_object_id oid;
  171|  1.13k|		size_t ava_len = 0, dummy_len, oid_len = 0;
  172|       |
  173|       |		/* unwrap the set and point to the next ava */
  174|  1.13k|		ava = sc_asn1_skip_tag(ctx, &next_ava, &next_ava_len, SC_ASN1_TAG_SET | SC_ASN1_CONS, &ava_len);
  ------------------
  |  |  207|  1.13k|#define SC_ASN1_TAG_SET			17
  ------------------
              		ava = sc_asn1_skip_tag(ctx, &next_ava, &next_ava_len, SC_ASN1_TAG_SET | SC_ASN1_CONS, &ava_len);
  ------------------
  |  |  141|  1.13k|#define SC_ASN1_CONS			0x20000000
  ------------------
  175|  1.13k|		if (ava == NULL)
  ------------------
  |  Branch (175:7): [True: 348, False: 787]
  ------------------
  176|  1.13k|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "ASN.1 decoding of AVA");
  ------------------
  |  |  174|    348|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    348|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    348|	int _ret = (r); \
  |  |  |  |  168|    348|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 348, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    348|		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|    348|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    348|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    348|		return _ret; \
  |  |  |  |  172|    348|	} \
  |  |  |  |  173|    348|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|       |
  178|       |		/* It would be nice to use sc_asn1_decode here to parse the entire AVA, but we are missing 1 critical
  179|       |		 *	function in the templates: the ability to accept any tag for value. This prevents us from just
  180|       |		 *	grabbing the value as is out of the template. AVA's can have tags of PRINTABLE_STRING,
  181|       |		 *	TELETEXSTRING, T61STRING or UTF8_STRING with PRINTABLE_STRING and UTF8_STRING being the most common.
  182|       |		 * The other feature that would be nice is returning a pointer to our requested data using the space
  183|       |		 *	of the parent (basically what this code is doing here), rather than allocating and copying.
  184|       |		 */
  185|       |
  186|       |		/* unwrap the sequence */
  187|    787|		dummy = ava; dummy_len = ava_len;
  188|    787|		ava = sc_asn1_skip_tag(ctx, &dummy, &dummy_len, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &ava_len);
  ------------------
  |  |  206|    787|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		ava = sc_asn1_skip_tag(ctx, &dummy, &dummy_len, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &ava_len);
  ------------------
  |  |  141|    787|#define SC_ASN1_CONS			0x20000000
  ------------------
  189|    787|		if (ava == NULL)
  ------------------
  |  Branch (189:7): [True: 260, False: 527]
  ------------------
  190|    787|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "ASN.1 decoding of AVA");
  ------------------
  |  |  174|    260|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    260|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    260|	int _ret = (r); \
  |  |  |  |  168|    260|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 260, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    260|		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|    260|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    260|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    260|		return _ret; \
  |  |  |  |  172|    260|	} \
  |  |  |  |  173|    260|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  191|       |
  192|       |		/* unwrap the oid */
  193|    527|		oidp = sc_asn1_skip_tag(ctx, &ava, &ava_len, SC_ASN1_TAG_OBJECT, &oid_len);
  ------------------
  |  |  200|    527|#define SC_ASN1_TAG_OBJECT		6
  ------------------
  194|    527|		if (ava == NULL || ava_len < 1)
  ------------------
  |  Branch (194:7): [True: 0, False: 527]
  |  Branch (194:22): [True: 10, False: 517]
  ------------------
  195|    527|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "ASN.1 decoding of AVA OID");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|       |
  197|       |		/* Convert to OID */
  198|    517|		rv = sc_asn1_decode_object_id(oidp, oid_len, &oid);
  199|    517|		if (rv != SC_SUCCESS)
  ------------------
  |  |   28|    517|#define SC_SUCCESS				0
  ------------------
  |  Branch (199:7): [True: 426, False: 91]
  ------------------
  200|    517|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "ASN.1 decoding of AVA OID");
  ------------------
  |  |  174|    426|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    426|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    426|	int _ret = (r); \
  |  |  |  |  168|    426|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 426, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    426|		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|    426|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    426|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    426|		return _ret; \
  |  |  |  |  172|    426|	} \
  |  |  |  |  173|    426|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|       |
  202|     91|		if (sc_compare_oid(&oid, type) == 0)
  ------------------
  |  Branch (202:7): [True: 49, False: 42]
  ------------------
  203|     49|			continue;
  204|       |
  205|       |		/* Yes, then return the name */
  206|     42|		dummy = sc_asn1_skip_tag(ctx, &ava, &ava_len, ava[0] & SC_ASN1_TAG_PRIMITIVE, &dummy_len);
  ------------------
  |  |  191|     42|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
  207|     42|		if (dummy == NULL)
  ------------------
  |  Branch (207:7): [True: 26, False: 16]
  ------------------
  208|     42|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "ASN.1 decoding of AVA name");
  ------------------
  |  |  174|     26|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     26|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     26|	int _ret = (r); \
  |  |  |  |  168|     26|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 26, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     26|		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|     26|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     26|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     26|		return _ret; \
  |  |  |  |  172|     26|	} \
  |  |  |  |  173|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  209|     16|		if (*name == NULL) {
  ------------------
  |  Branch (209:7): [True: 16, False: 0]
  ------------------
  210|     16|			*name = malloc(dummy_len);
  211|     16|			if (*name == NULL)
  ------------------
  |  Branch (211:8): [True: 0, False: 16]
  ------------------
  212|     16|				LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  213|     16|			*name_len = dummy_len;
  214|     16|		}
  215|       |
  216|     16|		*name_len = MIN(dummy_len, *name_len);
  ------------------
  |  |   69|     16|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 16]
  |  |  ------------------
  ------------------
  217|     16|		memcpy(*name, dummy, *name_len);
  218|     16|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     16|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     16|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     16|	int _ret = r; \
  |  |  |  |  155|     16|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     16|		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: 16]
  |  |  |  |  ------------------
  |  |  |  |  157|     16|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     16|	} 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|     16|	return _ret; \
  |  |  |  |  163|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|     16|	}
  220|       |
  221|     49|	LOG_FUNC_RETURN(ctx, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  164|     49|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     49|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     49|	int _ret = r; \
  |  |  |  |  155|     49|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     49|		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|     49|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     49|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     49|	} 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|     49|	return _ret; \
  |  |  |  |  163|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|     49|}
sc_pkcs15_get_extension:
  247|  1.15k|{
  248|  1.15k|	const u8 *ext = NULL;
  249|  1.15k|	const u8 *next_ext = NULL;
  250|  1.15k|	size_t ext_len = 0;
  251|  1.15k|	size_t next_ext_len = 0;
  252|  1.15k|	struct sc_object_id oid;
  253|  1.15k|	u8 *val = NULL;
  254|  1.15k|	size_t val_len = 0;
  255|  1.15k|	int critical;
  256|  1.15k|	int r;
  257|  1.15k|	struct sc_asn1_entry asn1_cert_ext[] = {
  258|  1.15k|		{ "x509v3 entry OID", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, 0, &oid, 0 },
  ------------------
  |  |  159|  1.15k|#define SC_ASN1_OBJECT                  6
  ------------------
              		{ "x509v3 entry OID", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, 0, &oid, 0 },
  ------------------
  |  |  200|  1.15k|#define SC_ASN1_TAG_OBJECT		6
  ------------------
  259|  1.15k|		{ "criticalFlag",  SC_ASN1_BOOLEAN, SC_ASN1_TAG_BOOLEAN, SC_ASN1_OPTIONAL, &critical, NULL },
  ------------------
  |  |  153|  1.15k|#define SC_ASN1_BOOLEAN                 1
  ------------------
              		{ "criticalFlag",  SC_ASN1_BOOLEAN, SC_ASN1_TAG_BOOLEAN, SC_ASN1_OPTIONAL, &critical, NULL },
  ------------------
  |  |  195|  1.15k|#define SC_ASN1_TAG_BOOLEAN		1
  ------------------
              		{ "criticalFlag",  SC_ASN1_BOOLEAN, SC_ASN1_TAG_BOOLEAN, SC_ASN1_OPTIONAL, &critical, NULL },
  ------------------
  |  |  148|  1.15k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  260|  1.15k|		{ "extensionValue",SC_ASN1_OCTET_STRING, SC_ASN1_TAG_OCTET_STRING, SC_ASN1_ALLOC, &val, &val_len },
  ------------------
  |  |  157|  1.15k|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "extensionValue",SC_ASN1_OCTET_STRING, SC_ASN1_TAG_OCTET_STRING, SC_ASN1_ALLOC, &val, &val_len },
  ------------------
  |  |  198|  1.15k|#define SC_ASN1_TAG_OCTET_STRING	4
  ------------------
              		{ "extensionValue",SC_ASN1_OCTET_STRING, SC_ASN1_TAG_OCTET_STRING, SC_ASN1_ALLOC, &val, &val_len },
  ------------------
  |  |  149|  1.15k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  261|  1.15k|		{ NULL, 0, 0, 0, NULL, NULL }
  262|  1.15k|	};
  263|       |
  264|  1.15k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.15k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.15k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.15k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.15k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  265|       |
  266|  1.15k|	for (next_ext = cert->extensions, next_ext_len = cert->extensions_len; next_ext_len; ) {
  ------------------
  |  Branch (266:73): [True: 0, False: 1.15k]
  ------------------
  267|       |		/* unwrap the set and point to the next ava */
  268|      0|		ext = sc_asn1_skip_tag(ctx, &next_ext, &next_ext_len,
  269|      0|			SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &ext_len);
  ------------------
  |  |  206|      0|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              			SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &ext_len);
  ------------------
  |  |  141|      0|#define SC_ASN1_CONS			0x20000000
  ------------------
  270|      0|		if (ext == NULL)
  ------------------
  |  Branch (270:7): [True: 0, False: 0]
  ------------------
  271|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "ASN.1 decoding of AVA");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  272|       |
  273|       |		/*
  274|       |		 * use the sc_asn1_decoder for clarity. NOTE it would be more efficient to do this by hand
  275|       |		 * so we avoid the many malloc/frees here, but one hopes that one day the asn1_decode will allow
  276|       |		 * a 'static pointer' flag that returns a const pointer to the actual asn1 space so we only need
  277|       |		 * to make a final copy of the extension value before we return */
  278|      0|		critical = 0;
  279|      0|		r = sc_asn1_decode(ctx, asn1_cert_ext, ext, ext_len, NULL, NULL);
  280|      0|		if (r < 0)
  ------------------
  |  Branch (280:7): [True: 0, False: 0]
  ------------------
  281|      0|			LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  282|       |
  283|       |		/* is it the RN we are looking for */
  284|      0|		if (sc_compare_oid(&oid, type) != 0) {
  ------------------
  |  Branch (284:7): [True: 0, False: 0]
  ------------------
  285|      0|			if (*ext_val == NULL) {
  ------------------
  |  Branch (285:8): [True: 0, False: 0]
  ------------------
  286|      0|				*ext_val = val;
  287|      0|				val = NULL;
  288|      0|				*ext_val_len = val_len;
  289|       |				/* do not free here -- return the allocated value to caller */
  290|      0|			}
  291|      0|			else {
  292|      0|				*ext_val_len = MIN(*ext_val_len, val_len);
  ------------------
  |  |   69|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  293|      0|				if (val) {
  ------------------
  |  Branch (293:9): [True: 0, False: 0]
  ------------------
  294|      0|					memcpy(*ext_val, val, *ext_val_len);
  295|      0|					free(val);
  296|      0|				}
  297|      0|			}
  298|       |
  299|      0|			if (is_critical)
  ------------------
  |  Branch (299:8): [True: 0, False: 0]
  ------------------
  300|      0|				*is_critical = critical;
  301|       |
  302|      0|			r = (int)val_len;
  303|      0|			LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  304|      0|		}
  305|      0|		if (val) {
  ------------------
  |  Branch (305:7): [True: 0, False: 0]
  ------------------
  306|      0|			free(val);
  307|      0|			val = NULL;
  308|      0|		}
  309|      0|	}
  310|  1.15k|	if (val)
  ------------------
  |  Branch (310:6): [True: 0, False: 1.15k]
  ------------------
  311|      0|	    free(val);
  312|       |
  313|  1.15k|	LOG_FUNC_RETURN(ctx, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  164|  1.15k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.15k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.15k|	int _ret = r; \
  |  |  |  |  155|  1.15k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.15k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.15k|		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|  1.15k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.15k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.15k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.15k|	} 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|  1.15k|	return _ret; \
  |  |  |  |  163|  1.15k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  314|  1.15k|}
sc_pkcs15_get_bitstring_extension:
  324|  1.15k|{
  325|  1.15k|	int r;
  326|  1.15k|	u8 *bit_string = NULL;
  327|  1.15k|	size_t bit_string_len=0, val_len = sizeof(*value);
  328|  1.15k|	struct sc_asn1_entry asn1_bit_string[] = {
  329|  1.15k|		{ "bitString", SC_ASN1_BIT_FIELD, SC_ASN1_TAG_BIT_STRING, 0, value, &val_len },
  ------------------
  |  |  171|  1.15k|#define SC_ASN1_BIT_FIELD		131	/* bit string as integer */
  ------------------
              		{ "bitString", SC_ASN1_BIT_FIELD, SC_ASN1_TAG_BIT_STRING, 0, value, &val_len },
  ------------------
  |  |  197|  1.15k|#define SC_ASN1_TAG_BIT_STRING		3
  ------------------
  330|  1.15k|		{ NULL, 0, 0, 0, NULL, NULL }
  331|  1.15k|	};
  332|       |
  333|  1.15k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.15k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.15k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.15k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.15k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  334|       |
  335|  1.15k|	r = sc_pkcs15_get_extension(ctx, cert, type, &bit_string, &bit_string_len, is_critical);
  336|  1.15k|	LOG_TEST_RET(ctx, r, "Get extension error");
  ------------------
  |  |  174|  1.15k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.15k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.15k|	int _ret = (r); \
  |  |  |  |  168|  1.15k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.15k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.15k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.15k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.15k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.15k|		return _ret; \
  |  |  |  |  172|  1.15k|	} \
  |  |  |  |  173|  1.15k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  337|       |
  338|      0|	r = sc_asn1_decode(ctx, asn1_bit_string, bit_string, bit_string_len, NULL, NULL);
  339|      0|	free(bit_string);
  340|      0|	LOG_TEST_RET(ctx, r, "Decoding extension bit string");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|       |
  342|      0|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  343|      0|}
sc_pkcs15_pubkey_from_cert:
  349|     35|{
  350|     35|	int rv;
  351|     35|	struct sc_pkcs15_cert * cert;
  352|       |
  353|     35|	cert =  calloc(1, sizeof(struct sc_pkcs15_cert));
  354|     35|	if (cert == NULL)
  ------------------
  |  Branch (354:6): [True: 0, False: 35]
  ------------------
  355|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  356|       |
  357|     35|	rv = parse_x509_cert(ctx, cert_blob, cert);
  358|       |
  359|     35|	*out = cert->key;
  360|     35|	cert->key = NULL;
  361|     35|	sc_pkcs15_free_certificate(cert);
  362|       |
  363|     35|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     35|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     35|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     35|	int _ret = r; \
  |  |  |  |  155|     35|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 35, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     35|		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: 35]
  |  |  |  |  ------------------
  |  |  |  |  157|     35|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     35|	} 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|     35|	return _ret; \
  |  |  |  |  163|     35|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  364|     35|}
sc_pkcs15_read_certificate:
  370|  5.05k|{
  371|  5.05k|	struct sc_context *ctx = NULL;
  372|  5.05k|	struct sc_pkcs15_cert *cert = NULL;
  373|  5.05k|	struct sc_pkcs15_der der;
  374|  5.05k|	int r;
  375|       |
  376|  5.05k|	if (p15card == NULL || info == NULL || cert_out == NULL) {
  ------------------
  |  Branch (376:6): [True: 0, False: 5.05k]
  |  Branch (376:25): [True: 0, False: 5.05k]
  |  Branch (376:41): [True: 0, False: 5.05k]
  ------------------
  377|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  378|      0|	}
  379|  5.05k|	ctx = p15card->card->ctx;
  380|  5.05k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  5.05k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.05k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.05k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.05k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.05k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|       |
  382|  5.05k|	if (info->value.len && info->value.value)   {
  ------------------
  |  Branch (382:6): [True: 3.41k, False: 1.63k]
  |  Branch (382:25): [True: 3.41k, False: 0]
  ------------------
  383|  3.41k|		sc_der_copy(&der, &info->value);
  384|  3.41k|	}
  385|  1.63k|	else if (info->path.len) {
  ------------------
  |  Branch (385:11): [True: 1.52k, False: 112]
  ------------------
  386|  1.52k|		r = sc_pkcs15_read_file(p15card, &info->path, &der.value, &der.len, private_obj);
  387|  1.52k|		LOG_TEST_RET(ctx, r, "Unable to read certificate file.");
  ------------------
  |  |  174|  1.52k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.52k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.52k|	int _ret = (r); \
  |  |  |  |  168|  1.52k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.24k, False: 279]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.24k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  1.24k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.24k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.24k|		return _ret; \
  |  |  |  |  172|  1.24k|	} \
  |  |  |  |  173|  1.52k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 279]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  388|  1.52k|	}
  389|    112|	else   {
  390|    112|		LOG_FUNC_RETURN(ctx, SC_ERROR_OBJECT_NOT_FOUND);
  ------------------
  |  |  164|    112|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    112|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    112|	int _ret = r; \
  |  |  |  |  155|    112|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 112, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    112|		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|    112|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 112, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    112|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    112|	} 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|    112|	return _ret; \
  |  |  |  |  163|    112|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  391|    112|	}
  392|       |
  393|  3.69k|	cert = malloc(sizeof(struct sc_pkcs15_cert));
  394|  3.69k|	if (cert == NULL) {
  ------------------
  |  Branch (394:6): [True: 0, False: 3.69k]
  ------------------
  395|      0|		free(der.value);
  396|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  397|      0|	}
  398|  3.69k|	memset(cert, 0, sizeof(struct sc_pkcs15_cert));
  399|  3.69k|	if (parse_x509_cert(ctx, &der, cert)) {
  ------------------
  |  Branch (399:6): [True: 1.37k, False: 2.32k]
  ------------------
  400|  1.37k|		free(der.value);
  401|  1.37k|		sc_pkcs15_free_certificate(cert);
  402|  1.37k|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ASN1_OBJECT);
  ------------------
  |  |  164|  1.37k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.37k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.37k|	int _ret = r; \
  |  |  |  |  155|  1.37k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.37k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.37k|		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|  1.37k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.37k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.37k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.37k|	} 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|  1.37k|	return _ret; \
  |  |  |  |  163|  1.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  403|  1.37k|	}
  404|  2.32k|	free(der.value);
  405|       |
  406|  2.32k|	*cert_out = cert;
  407|  2.32k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  2.32k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.32k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.32k|	int _ret = r; \
  |  |  |  |  155|  2.32k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.32k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.32k|		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: 2.32k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.32k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.32k|	} 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|  2.32k|	return _ret; \
  |  |  |  |  163|  2.32k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  408|  2.32k|}
sc_pkcs15_decode_cdf_entry:
  445|      4|{
  446|      4|	sc_context_t *ctx = p15card->card->ctx;
  447|      4|	struct sc_pkcs15_cert_info info;
  448|      4|	struct sc_asn1_entry	asn1_cred_ident[3], asn1_com_cert_attr[4],
  449|      4|				asn1_x509_cert_attr[2], asn1_type_cert_attr[2],
  450|      4|				asn1_cert[2], asn1_x509_cert_value_choice[3];
  451|      4|	struct sc_asn1_pkcs15_object cert_obj = {
  452|      4|		obj, asn1_com_cert_attr, NULL,
  453|      4|		asn1_type_cert_attr };
  454|      4|	sc_pkcs15_der_t *der = &info.value;
  455|      4|	u8 id_value[128];
  456|      4|	int id_type;
  457|      4|	size_t id_value_len = sizeof(id_value);
  458|      4|	int r;
  459|       |
  460|      4|	sc_copy_asn1_entry(c_asn1_cred_ident, asn1_cred_ident);
  461|      4|	sc_copy_asn1_entry(c_asn1_com_cert_attr, asn1_com_cert_attr);
  462|      4|	sc_copy_asn1_entry(c_asn1_x509_cert_attr, asn1_x509_cert_attr);
  463|      4|	sc_copy_asn1_entry(c_asn1_x509_cert_value_choice, asn1_x509_cert_value_choice);
  464|      4|	sc_copy_asn1_entry(c_asn1_type_cert_attr, asn1_type_cert_attr);
  465|      4|	sc_copy_asn1_entry(c_asn1_cert, asn1_cert);
  466|       |
  467|      4|	sc_format_asn1_entry(asn1_cred_ident + 0, &id_type, NULL, 0);
  468|      4|	sc_format_asn1_entry(asn1_cred_ident + 1, &id_value, &id_value_len, 0);
  469|      4|	sc_format_asn1_entry(asn1_com_cert_attr + 0, &info.id, NULL, 0);
  470|      4|	sc_format_asn1_entry(asn1_com_cert_attr + 1, &info.authority, NULL, 0);
  471|      4|	sc_format_asn1_entry(asn1_com_cert_attr + 2, asn1_cred_ident, NULL, 0);
  472|      4|	sc_format_asn1_entry(asn1_x509_cert_attr + 0, asn1_x509_cert_value_choice, NULL, 0);
  473|      4|	sc_format_asn1_entry(asn1_x509_cert_value_choice + 0, &info.path, NULL, 0);
  474|      4|	sc_format_asn1_entry(asn1_x509_cert_value_choice + 1, &der->value, &der->len, 0);
  475|      4|	sc_format_asn1_entry(asn1_type_cert_attr + 0, asn1_x509_cert_attr, NULL, 0);
  476|      4|	sc_format_asn1_entry(asn1_cert + 0, &cert_obj, NULL, 0);
  477|       |
  478|       |	/* Fill in defaults */
  479|      4|	memset(&info, 0, sizeof(info));
  480|      4|	info.authority = 0;
  481|       |
  482|      4|	r = sc_asn1_decode(ctx, asn1_cert, *buf, *buflen, buf, buflen);
  483|       |	/* In case of error, trash the cert value (direct coding) */
  484|      4|	if (r < 0 && der->value)
  ------------------
  |  Branch (484:6): [True: 4, False: 0]
  |  Branch (484:15): [True: 0, False: 4]
  ------------------
  485|      0|		free(der->value);
  486|      4|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|      4|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (486:6): [True: 1, False: 3]
  ------------------
  487|      1|		return r;
  488|      3|	LOG_TEST_RET(ctx, r, "ASN.1 decoding failed");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|      0|	if (!p15card->app || !p15card->app->ddo.aid.len) {
  ------------------
  |  Branch (490:6): [True: 0, False: 0]
  |  Branch (490:23): [True: 0, False: 0]
  ------------------
  491|      0|		if (!p15card->file_app) {
  ------------------
  |  Branch (491:7): [True: 0, False: 0]
  ------------------
  492|      0|			free(der->value);
  493|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  494|      0|		}
  495|      0|		r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path);
  496|      0|		LOG_TEST_RET(ctx, r, "Cannot make absolute path");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  497|      0|	}
  498|      0|	else   {
  499|      0|		info.path.aid = p15card->app->ddo.aid;
  500|      0|	}
  501|      0|	sc_log(ctx, "Certificate path '%s'", sc_print_path(&info.path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  502|       |
  503|      0|	switch (p15card->opts.pin_protected_certificate) {
  ------------------
  |  Branch (503:10): [True: 0, False: 0]
  ------------------
  504|      0|		case SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY:
  ------------------
  |  |  611|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY	2
  ------------------
  |  Branch (504:3): [True: 0, False: 0]
  ------------------
  505|      0|			sc_log(ctx, "Declassifying certificate");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  506|      0|			obj->flags &= ~SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  507|      0|			break;
  508|      0|		case SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE:
  ------------------
  |  |  610|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE		1
  ------------------
  |  Branch (508:3): [True: 0, False: 0]
  ------------------
  509|      0|			sc_log(ctx, "Ignoring certificate");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  510|      0|			free(der->value);
  511|      0|			return 0;
  512|      0|	}
  513|       |
  514|      0|	obj->type = SC_PKCS15_TYPE_CERT_X509;
  ------------------
  |  |  439|      0|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  515|      0|	obj->data = malloc(sizeof(info));
  516|      0|	if (obj->data == NULL)
  ------------------
  |  Branch (516:6): [True: 0, False: 0]
  ------------------
  517|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|      0|	memcpy(obj->data, &info, sizeof(info));
  519|       |
  520|      0|	return 0;
  521|      0|}
sc_pkcs15_free_certificate:
  644|  3.73k|{
  645|  3.73k|	if (cert == NULL) {
  ------------------
  |  Branch (645:6): [True: 0, False: 3.73k]
  ------------------
  646|      0|		return;
  647|      0|	}
  648|       |
  649|  3.73k|	sc_pkcs15_free_pubkey(cert->key);
  650|  3.73k|	free(cert->subject);
  651|  3.73k|	free(cert->issuer);
  652|  3.73k|	free(cert->serial);
  653|  3.73k|	free(cert->data.value);
  654|  3.73k|	free(cert->extensions);
  655|  3.73k|	free(cert);
  656|  3.73k|}
sc_pkcs15_free_cert_info:
  661|  2.64k|{
  662|  2.64k|	if (!cert)
  ------------------
  |  Branch (662:6): [True: 0, False: 2.64k]
  ------------------
  663|      0|		return;
  664|  2.64k|	free(cert->value.value);
  665|  2.64k|	free(cert);
  666|  2.64k|}
pkcs15-cert.c:parse_x509_cert:
   39|  3.73k|{
   40|  3.73k|	int r;
   41|  3.73k|	struct sc_algorithm_id sig_alg = {0};
   42|  3.73k|	struct sc_pkcs15_pubkey *pubkey = NULL;
   43|  3.73k|	unsigned char *serial = NULL, *issuer = NULL, *subject = NULL, *buf =  der->value;
   44|  3.73k|	size_t serial_len = 0, issuer_len = 0, subject_len = 0, data_len = 0, buflen = der->len;
   45|  3.73k|	struct sc_asn1_entry asn1_version[] = {
   46|  3.73k|		{ "version", SC_ASN1_INTEGER, SC_ASN1_TAG_INTEGER, 0, &cert->version, NULL },
  ------------------
  |  |  154|  3.73k|#define SC_ASN1_INTEGER                 2
  ------------------
              		{ "version", SC_ASN1_INTEGER, SC_ASN1_TAG_INTEGER, 0, &cert->version, NULL },
  ------------------
  |  |  196|  3.73k|#define SC_ASN1_TAG_INTEGER		2
  ------------------
   47|  3.73k|		{ NULL, 0, 0, 0, NULL, NULL }
   48|  3.73k|	};
   49|  3.73k|	struct sc_asn1_entry asn1_extensions[] = {
   50|  3.73k|		{ "x509v3",		SC_ASN1_OCTET_STRING,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_OPTIONAL| SC_ASN1_ALLOC, &cert->extensions, &cert->extensions_len },
  ------------------
  |  |  157|  3.73k|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "x509v3",		SC_ASN1_OCTET_STRING,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_OPTIONAL| SC_ASN1_ALLOC, &cert->extensions, &cert->extensions_len },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "x509v3",		SC_ASN1_OCTET_STRING,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_OPTIONAL| SC_ASN1_ALLOC, &cert->extensions, &cert->extensions_len },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "x509v3",		SC_ASN1_OCTET_STRING,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_OPTIONAL| SC_ASN1_ALLOC, &cert->extensions, &cert->extensions_len },
  ------------------
  |  |  148|  3.73k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
              		{ "x509v3",		SC_ASN1_OCTET_STRING,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_OPTIONAL| SC_ASN1_ALLOC, &cert->extensions, &cert->extensions_len },
  ------------------
  |  |  149|  3.73k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   51|  3.73k|		{ NULL, 0, 0, 0, NULL, NULL }
   52|  3.73k|	};
   53|  3.73k|	struct sc_asn1_entry asn1_tbscert[] = {
   54|  3.73k|		{ "version",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 0 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_version, NULL },
  ------------------
  |  |  169|  3.73k|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "version",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 0 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_version, NULL },
  ------------------
  |  |  139|  3.73k|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
              		{ "version",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 0 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_version, NULL },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "version",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 0 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_version, NULL },
  ------------------
  |  |  148|  3.73k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
   55|  3.73k|		{ "serialNumber",	SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, &serial, &serial_len },
  ------------------
  |  |  157|  3.73k|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "serialNumber",	SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, &serial, &serial_len },
  ------------------
  |  |  196|  3.73k|#define SC_ASN1_TAG_INTEGER		2
  ------------------
              		{ "serialNumber",	SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, &serial, &serial_len },
  ------------------
  |  |  149|  3.73k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   56|  3.73k|		{ "signature",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  169|  3.73k|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "signature",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "signature",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
   57|  3.73k|		{ "issuer",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &issuer, &issuer_len },
  ------------------
  |  |  157|  3.73k|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "issuer",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &issuer, &issuer_len },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "issuer",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &issuer, &issuer_len },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "issuer",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &issuer, &issuer_len },
  ------------------
  |  |  149|  3.73k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   58|  3.73k|		{ "validity",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  169|  3.73k|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "validity",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "validity",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
   59|  3.73k|		{ "subject",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &subject, &subject_len },
  ------------------
  |  |  157|  3.73k|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "subject",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &subject, &subject_len },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "subject",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &subject, &subject_len },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "subject",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &subject, &subject_len },
  ------------------
  |  |  149|  3.73k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   60|       |		/* Use a callback to get the algorithm, parameters and pubkey into sc_pkcs15_pubkey */
   61|  3.73k|		{ "subjectPublicKeyInfo",SC_ASN1_CALLBACK, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, sc_pkcs15_pubkey_from_spki_fields,  &pubkey },
  ------------------
  |  |  181|  3.73k|#define SC_ASN1_CALLBACK		384
  ------------------
              		{ "subjectPublicKeyInfo",SC_ASN1_CALLBACK, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, sc_pkcs15_pubkey_from_spki_fields,  &pubkey },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "subjectPublicKeyInfo",SC_ASN1_CALLBACK, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, sc_pkcs15_pubkey_from_spki_fields,  &pubkey },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
   62|  3.73k|		{ "extensions",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 3 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_extensions, NULL },
  ------------------
  |  |  169|  3.73k|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "extensions",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 3 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_extensions, NULL },
  ------------------
  |  |  139|  3.73k|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
              		{ "extensions",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 3 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_extensions, NULL },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "extensions",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 3 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_extensions, NULL },
  ------------------
  |  |  148|  3.73k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
   63|  3.73k|		{ NULL, 0, 0, 0, NULL, NULL }
   64|  3.73k|	};
   65|  3.73k|	struct sc_asn1_entry asn1_cert[] = {
   66|  3.73k|		{ "tbsCertificate",	SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, asn1_tbscert, NULL },
  ------------------
  |  |  169|  3.73k|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "tbsCertificate",	SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, asn1_tbscert, NULL },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "tbsCertificate",	SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, asn1_tbscert, NULL },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
   67|  3.73k|		{ "signatureAlgorithm",	SC_ASN1_ALGORITHM_ID, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, &sig_alg, NULL },
  ------------------
  |  |  177|  3.73k|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
              		{ "signatureAlgorithm",	SC_ASN1_ALGORITHM_ID, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, &sig_alg, NULL },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "signatureAlgorithm",	SC_ASN1_ALGORITHM_ID, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, &sig_alg, NULL },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
   68|  3.73k|		{ "signatureValue",	SC_ASN1_BIT_STRING, SC_ASN1_TAG_BIT_STRING, 0, NULL, NULL },
  ------------------
  |  |  155|  3.73k|#define SC_ASN1_BIT_STRING              3
  ------------------
              		{ "signatureValue",	SC_ASN1_BIT_STRING, SC_ASN1_TAG_BIT_STRING, 0, NULL, NULL },
  ------------------
  |  |  197|  3.73k|#define SC_ASN1_TAG_BIT_STRING		3
  ------------------
   69|  3.73k|		{ NULL, 0, 0, 0, NULL, NULL }
   70|  3.73k|	};
   71|  3.73k|	struct sc_asn1_entry asn1_serial_number[] = {
   72|  3.73k|		{ "serialNumber", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  157|  3.73k|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "serialNumber", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  196|  3.73k|#define SC_ASN1_TAG_INTEGER		2
  ------------------
              		{ "serialNumber", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  149|  3.73k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   73|  3.73k|		{ NULL, 0, 0, 0, NULL, NULL }
   74|  3.73k|	};
   75|  3.73k|	struct sc_asn1_entry asn1_subject[] = {
   76|  3.73k|		{ "subject", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  157|  3.73k|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "subject", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "subject", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "subject", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  149|  3.73k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   77|  3.73k|		{ NULL, 0, 0, 0, NULL, NULL }
   78|  3.73k|	};
   79|  3.73k|	struct sc_asn1_entry asn1_issuer[] = {
   80|  3.73k|		{ "issuer", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  157|  3.73k|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "issuer", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "issuer", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "issuer", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  149|  3.73k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   81|  3.73k|		{ NULL, 0, 0, 0, NULL, NULL }
   82|  3.73k|	};
   83|       |
   84|  3.73k|	const u8 *obj;
   85|  3.73k|	size_t objlen;
   86|       |
   87|  3.73k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.73k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.73k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.73k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.73k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.73k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   88|       |
   89|  3.73k|	memset(cert, 0, sizeof(*cert));
   90|  3.73k|	obj = sc_asn1_verify_tag(ctx, buf, buflen, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &objlen);
  ------------------
  |  |  206|  3.73k|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              	obj = sc_asn1_verify_tag(ctx, buf, buflen, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &objlen);
  ------------------
  |  |  141|  3.73k|#define SC_ASN1_CONS			0x20000000
  ------------------
   91|  3.73k|	if (obj == NULL)
  ------------------
  |  Branch (91:6): [True: 848, False: 2.88k]
  ------------------
   92|  3.73k|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "X.509 certificate not found");
  ------------------
  |  |  174|    848|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    848|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    848|	int _ret = (r); \
  |  |  |  |  168|    848|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 848, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    848|		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|    848|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    848|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    848|		return _ret; \
  |  |  |  |  172|    848|	} \
  |  |  |  |  173|    848|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|       |
   94|  2.88k|	data_len = objlen + (obj - buf);
   95|  2.88k|	cert->data.value = malloc(data_len);
   96|  2.88k|	if (!cert->data.value)
  ------------------
  |  Branch (96:6): [True: 0, False: 2.88k]
  ------------------
   97|  2.88k|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   98|  2.88k|	memcpy(cert->data.value, buf, data_len);
   99|  2.88k|	cert->data.len = data_len;
  100|       |
  101|  2.88k|	r = sc_asn1_decode(ctx, asn1_cert, obj, objlen, NULL, NULL);
  102|  2.88k|	cert->key = pubkey;
  103|  2.88k|	cert->version++;
  104|       |
  105|  2.88k|	LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 parsing of certificate failed");
  ------------------
  |  |  184|  2.88k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.88k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.88k|	int _ret = (r); \
  |  |  |  |  178|  2.88k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 526, False: 2.35k]
  |  |  |  |  ------------------
  |  |  |  |  179|    526|		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|    526|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    526|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    526|		goto err; \
  |  |  |  |  182|    526|	} \
  |  |  |  |  183|  2.88k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.35k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  106|       |
  107|  2.35k|	if (!pubkey)
  ------------------
  |  Branch (107:6): [True: 15, False: 2.34k]
  ------------------
  108|  2.35k|		LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "Unable to decode subjectPublicKeyInfo from cert");
  ------------------
  |  |  184|     15|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     15|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     15|	int _ret = (r); \
  |  |  |  |  178|     15|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     15|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     15|		goto err; \
  |  |  |  |  182|     15|	} \
  |  |  |  |  183|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|       |
  110|       |
  111|  2.34k|	if (serial && serial_len)   {
  ------------------
  |  Branch (111:6): [True: 2.33k, False: 5]
  |  Branch (111:16): [True: 2.33k, False: 0]
  ------------------
  112|  2.33k|		sc_format_asn1_entry(asn1_serial_number + 0, serial, &serial_len, 1);
  113|  2.33k|		r = sc_asn1_encode(ctx, asn1_serial_number, &cert->serial, &cert->serial_len);
  114|  2.33k|		LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 encoding of serial failed");
  ------------------
  |  |  184|  2.33k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.33k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.33k|	int _ret = (r); \
  |  |  |  |  178|  2.33k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2.33k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  2.33k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.33k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|  2.33k|	}
  116|       |
  117|  2.34k|	if (subject && subject_len)   {
  ------------------
  |  Branch (117:6): [True: 2.34k, False: 0]
  |  Branch (117:17): [True: 2.34k, False: 0]
  ------------------
  118|  2.34k|		sc_format_asn1_entry(asn1_subject + 0, subject, &subject_len, 1);
  119|  2.34k|		r = sc_asn1_encode(ctx, asn1_subject, &cert->subject, &cert->subject_len);
  120|  2.34k|		LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 encoding of subject");
  ------------------
  |  |  184|  2.34k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.34k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.34k|	int _ret = (r); \
  |  |  |  |  178|  2.34k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2.34k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  2.34k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.34k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  121|  2.34k|	}
  122|       |
  123|  2.34k|	if (issuer && issuer_len)   {
  ------------------
  |  Branch (123:6): [True: 2.26k, False: 83]
  |  Branch (123:16): [True: 2.26k, False: 0]
  ------------------
  124|  2.26k|		sc_format_asn1_entry(asn1_issuer + 0, issuer, &issuer_len, 1);
  125|  2.26k|		r = sc_asn1_encode(ctx, asn1_issuer, &cert->issuer, &cert->issuer_len);
  126|  2.26k|		LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 encoding of issuer");
  ------------------
  |  |  184|  2.26k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.26k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.26k|	int _ret = (r); \
  |  |  |  |  178|  2.26k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2.26k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  2.26k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.26k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  127|  2.26k|	}
  128|       |
  129|  2.88k|err:
  130|       |	/* not used for anything */
  131|  2.88k|	sc_asn1_clear_algorithm_id(&sig_alg);
  132|  2.88k|	free(serial);
  133|  2.88k|	free(subject);
  134|  2.88k|	free(issuer);
  135|       |
  136|  2.88k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  2.88k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.88k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.88k|	int _ret = r; \
  |  |  |  |  155|  2.88k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.88k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.88k|		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|    526|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 526, False: 2.35k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.88k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.88k|	} 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|  2.88k|	return _ret; \
  |  |  |  |  163|  2.88k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  137|  2.88k|}

sc_pkcs15emu_chipdocit_init_ex:
  219|  10.1k|{
  220|  10.1k|	sc_card_t *card = p15card->card;
  221|  10.1k|	sc_pkcs15_id_t id_auth, id_ds;
  222|  10.1k|	struct sc_apdu apdu;
  223|       |
  224|  10.1k|	memset(&id_auth, 0, sizeof id_auth);
  225|  10.1k|	id_auth.len = 1;
  226|  10.1k|	id_auth.value[0] = 0x01;
  227|  10.1k|	memset(&id_ds, 0, sizeof id_ds);
  228|  10.1k|	id_ds.len = 1;
  229|  10.1k|	id_ds.value[0] = 0x02;
  230|  10.1k|	u8 csn[32];
  231|  10.1k|	int r;
  232|       |
  233|  10.1k|	(void)aid;
  234|  10.1k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  10.1k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  10.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  10.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  10.1k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  235|  10.1k|	if (card->type != SC_CARD_TYPE_CHIPDOC_IT)
  ------------------
  |  Branch (235:6): [True: 10.1k, False: 0]
  ------------------
  236|  10.1k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  10.1k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  10.1k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  10.1k|	int _ret = r; \
  |  |  |  |  155|  10.1k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  10.1k|		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|  10.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  10.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  10.1k|	} 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|  10.1k|	return _ret; \
  |  |  |  |  163|  10.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  237|       |
  238|      0|	set_string(&p15card->tokeninfo->label, card->name);
  239|      0|	set_string(&p15card->tokeninfo->manufacturer_id, "Bit4id / NXP");
  240|       |
  241|       |	/* Serial = card serial number (GET DATA 00 CA 01 14), read in clear. */
  242|      0|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x01, 0x14);
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  243|      0|	apdu.resp = csn;
  244|      0|	apdu.resplen = sizeof csn;
  245|      0|	apdu.le = 256;
  246|      0|	if (sc_transmit_apdu(card, &apdu) == SC_SUCCESS && sc_check_sw(card, apdu.sw1, apdu.sw2) == SC_SUCCESS && apdu.resplen) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
              	if (sc_transmit_apdu(card, &apdu) == SC_SUCCESS && sc_check_sw(card, apdu.sw1, apdu.sw2) == SC_SUCCESS && apdu.resplen) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (246:6): [True: 0, False: 0]
  |  Branch (246:53): [True: 0, False: 0]
  |  Branch (246:108): [True: 0, False: 0]
  ------------------
  247|      0|		char hex[2 * sizeof(csn) + 1];
  248|      0|		sc_bin_to_hex(csn, apdu.resplen, hex, sizeof hex, 0);
  249|      0|		set_string(&p15card->tokeninfo->serial_number, hex);
  250|      0|	}
  251|       |
  252|      0|	r = add_pin(p15card);
  253|      0|	LOG_TEST_RET(card->ctx, r, "add PIN failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  254|       |
  255|       |	/* Auth key/cert: LCNS0, key ref 0x10, EF 0001. */
  256|      0|	r = read_ds_cert(p15card, 0x0001, &id_auth, "CNS", 0);
  257|      0|	LOG_TEST_RET(card->ctx, r, "read auth cert failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  258|      0|	r = add_prkey(p15card, &id_auth, "CNS",
  259|      0|			0x10, SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_DECRYPT, 0);
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
              			0x10, SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_DECRYPT, 0);
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  260|      0|	LOG_TEST_RET(card->ctx, r, "add auth key failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  261|       |
  262|       |	/* Qualified-signature key/cert: DS3, key ref 0x11, EF 0002, nonRepudiation. */
  263|      0|	r = read_ds_cert(p15card, 0x0002, &id_ds, "DS3", 1);
  264|      0|	LOG_TEST_RET(card->ctx, r, "read DS cert failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  265|      0|	r = add_prkey(p15card, &id_ds, "DS3",
  266|      0|			0x11, SC_PKCS15_PRKEY_USAGE_NONREPUDIATION, 1);
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  267|      0|	LOG_TEST_RET(card->ctx, r, "add DS key failed");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  268|       |
  269|      0|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  270|      0|}

coolkey_get_attribute_lv:
  244|  2.15k|{
  245|  2.15k|	struct sc_pkcs15_data *item = (struct sc_pkcs15_data *)ptr;
  246|  2.15k|	return coolkey_get_attribute_bytes_alloc(card, obj, type, &item->data, &item->data_len);
  247|  2.15k|}
sc_pkcs15emu_coolkey_init_ex:
  727|  12.7k|{
  728|  12.7k|	sc_card_t      *card = p15card->card;
  729|  12.7k|	sc_context_t    *ctx = card->ctx;
  730|  12.7k|	int rv;
  731|       |
  732|  12.7k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  12.7k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  12.7k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  12.7k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  12.7k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 12.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  733|       |
  734|  12.7k|	rv = coolkey_detect_card(p15card);
  735|  12.7k|	if (rv)
  ------------------
  |  Branch (735:6): [True: 12.0k, False: 706]
  ------------------
  736|  12.7k|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  12.0k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  12.0k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  12.0k|	int _ret = r; \
  |  |  |  |  155|  12.0k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12.0k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  12.0k|		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|  12.0k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 12.0k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  12.0k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  12.0k|	} 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|  12.0k|	return _ret; \
  |  |  |  |  163|  12.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  737|    706|	rv = sc_pkcs15emu_coolkey_init(p15card);
  738|       |
  739|    706|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    706|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    706|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    706|	int _ret = r; \
  |  |  |  |  155|    706|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 706, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    706|		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: 706]
  |  |  |  |  ------------------
  |  |  |  |  157|    706|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    706|	} 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|    706|	return _ret; \
  |  |  |  |  163|    706|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|    706|}
pkcs15-coolkey.c:coolkey_get_attribute_bytes_alloc:
  206|  2.15k|{
  207|  2.15k|	const u8 *val;
  208|  2.15k|	size_t val_len;
  209|  2.15k|	int r;
  210|       |
  211|  2.15k|	r = coolkey_get_attribute(card, obj, type, &val, &val_len, NULL);
  212|  2.15k|	if (r < 0 || val_len < 1) {
  ------------------
  |  Branch (212:6): [True: 2.14k, False: 13]
  |  Branch (212:15): [True: 6, False: 7]
  ------------------
  213|  2.15k|		return r;
  214|  2.15k|	}
  215|      7|	*data = malloc(val_len);
  216|      7|	if (*data == NULL) {
  ------------------
  |  Branch (216:6): [True: 0, False: 7]
  ------------------
  217|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  218|      0|	}
  219|      7|	memcpy(*data, val, val_len);
  220|      7|	*data_len = val_len;
  221|      7|	return SC_SUCCESS;
  ------------------
  |  |   28|      7|#define SC_SUCCESS				0
  ------------------
  222|      7|}
pkcs15-coolkey.c:coolkey_get_attribute:
   91|  45.7k|coolkey_get_attribute(sc_card_t *card, sc_cardctl_coolkey_object_t *obj, CK_ATTRIBUTE_TYPE type, const u8 **val, size_t *val_len, u8 *data_type) {
   92|  45.7k|	sc_cardctl_coolkey_attribute_t attribute;
   93|  45.7k|	int r;
   94|       |
   95|  45.7k|	attribute.object = obj;
   96|  45.7k|	attribute.attribute_type = type;
   97|       |
   98|  45.7k|	r = sc_card_ctl(card, SC_CARDCTL_COOLKEY_GET_ATTRIBUTE, &attribute);
   99|  45.7k|	if (r < 0) {
  ------------------
  |  Branch (99:6): [True: 24.3k, False: 21.3k]
  ------------------
  100|  24.3k|		return r;
  101|  24.3k|	}
  102|  21.3k|	*val = attribute.attribute_value;
  103|  21.3k|	*val_len = attribute.attribute_length;
  104|  21.3k|	if (data_type) {
  ------------------
  |  Branch (104:6): [True: 2.11k, False: 19.2k]
  ------------------
  105|  2.11k|		*data_type = attribute.attribute_data_type;
  106|  2.11k|	}
  107|  21.3k|	return SC_SUCCESS;
  ------------------
  |  |   28|  21.3k|#define SC_SUCCESS				0
  ------------------
  108|  45.7k|}
pkcs15-coolkey.c:coolkey_detect_card:
   60|  12.7k|{
   61|  12.7k|	sc_card_t *card = p15card->card;
   62|       |
   63|  12.7k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  12.7k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  12.7k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  12.7k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 12.7k]
  |  |  ------------------
  ------------------
   64|  12.7k|	if (card->type < SC_CARD_TYPE_COOLKEY_GENERIC
  ------------------
  |  Branch (64:6): [True: 11.2k, False: 1.54k]
  ------------------
   65|  1.54k|		|| card->type >= SC_CARD_TYPE_COOLKEY_GENERIC+1000)
  ------------------
  |  Branch (65:6): [True: 840, False: 706]
  ------------------
   66|  12.0k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  12.0k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
   67|    706|	return SC_SUCCESS;
  ------------------
  |  |   28|    706|#define SC_SUCCESS				0
  ------------------
   68|  12.7k|}
pkcs15-coolkey.c:sc_pkcs15emu_coolkey_init:
  467|    706|{
  468|    706|	int use_pin_cache_backup = p15card->opts.use_pin_cache;
  469|    706|	static const pindata pins[] = {
  470|    706|		{ "1", NULL, "", 0x00,
  471|    706|		  SC_PKCS15_PIN_TYPE_ASCII_NUMERIC,
  ------------------
  |  |   89|    706|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  472|    706|		  32, 4, 32,
  473|    706|		  SC_PKCS15_PIN_FLAG_INITIALIZED,
  ------------------
  |  |   58|    706|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  474|    706|		  -1, 0xFF,
  475|    706|		  SC_PKCS15_CO_FLAG_PRIVATE },
  ------------------
  |  |   50|    706|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  476|    706|		{ NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  477|    706|	};
  478|       |
  479|       |	/*
  480|       |	 * The size of the key or the algid is not really known
  481|       |	 * but can be derived from the certificates.
  482|       |	 * the cert, pubkey and privkey are a set.
  483|       |	 * Key usages bits taken from certificate key usage extension.
  484|       |	 */
  485|       |
  486|    706|	int    r, i;
  487|    706|	sc_card_t *card = p15card->card;
  488|    706|	sc_serial_number_t serial;
  489|    706|	int count;
  490|    706|	struct sc_pkcs15_object *obj;
  491|       |
  492|    706|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    706|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    706|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    706|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 706]
  |  |  ------------------
  ------------------
  493|       |
  494|    706|	memset(&serial, 0, sizeof(serial));
  495|       |
  496|       |	/* coolkey caches a nonce once it logs in, don't keep the pin around. The card will
  497|       |	 * stay logged in until it's been pulled from the reader, in which case you want to reauthenticate
  498|       |	 * anyway */
  499|    706|	p15card->opts.use_pin_cache = 0;
  500|       |
  501|       |	/* get the token info from the card */
  502|    706|	r = sc_card_ctl(card, SC_CARDCTL_COOLKEY_GET_TOKEN_INFO, p15card->tokeninfo);
  503|    706|	if (r < 0) {
  ------------------
  |  Branch (503:6): [True: 0, False: 706]
  ------------------
  504|       |		/* put some defaults in if we didn't succeed */
  505|      0|		set_string(&p15card->tokeninfo->label, "Coolkey");
  506|      0|		set_string(&p15card->tokeninfo->manufacturer_id, "Unknown");
  507|      0|		set_string(&p15card->tokeninfo->serial_number, "00000000");
  508|      0|	}
  509|       |
  510|       |	/* set pins */
  511|    706|	sc_log(card->ctx,  "Coolkey adding pins...");
  ------------------
  |  |   71|    706|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  512|  1.41k|	for (i = 0; pins[i].id; i++) {
  ------------------
  |  Branch (512:14): [True: 706, False: 706]
  ------------------
  513|    706|		struct sc_pkcs15_auth_info pin_info;
  514|    706|		struct sc_pkcs15_object   pin_obj;
  515|    706|		const char * label;
  516|       |
  517|    706|		memset(&pin_info, 0, sizeof(pin_info));
  518|    706|		memset(&pin_obj,  0, sizeof(pin_obj));
  519|       |
  520|    706|		pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    706|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  521|    706|		sc_pkcs15_format_id(pins[i].id, &pin_info.auth_id);
  522|    706|		pin_info.attrs.pin.reference     = pins[i].ref;
  523|    706|		pin_info.attrs.pin.flags         = pins[i].flags;
  524|    706|		pin_info.attrs.pin.type          = pins[i].type;
  525|    706|		pin_info.attrs.pin.min_length    = pins[i].minlen;
  526|    706|		pin_info.attrs.pin.stored_length = pins[i].storedlen;
  527|    706|		pin_info.attrs.pin.max_length    = pins[i].maxlen;
  528|    706|		pin_info.attrs.pin.pad_char      = pins[i].pad_char;
  529|    706|		sc_format_path(pins[i].path, &pin_info.path);
  530|    706|		pin_info.tries_left    = -1;
  531|       |
  532|    706|		label = pins[i].label? pins[i].label : p15card->tokeninfo->label;
  ------------------
  |  Branch (532:11): [True: 0, False: 706]
  ------------------
  533|    706|		sc_log(card->ctx,  "Coolkey Adding pin %d label=%s",i, label);
  ------------------
  |  |   71|    706|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  534|    706|		strncpy(pin_obj.label, label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|    706|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  535|    706|		pin_obj.flags = pins[i].obj_flags;
  536|       |
  537|    706|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  538|    706|		LOG_TEST_GOTO_ERR(card->ctx, r, "Can not add pin object.");
  ------------------
  |  |  184|    706|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    706|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    706|	int _ret = (r); \
  |  |  |  |  178|    706|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 706]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    706|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 706]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  539|    706|	}
  540|       |
  541|       |	/* set other objects */
  542|    706|	r = (card->ops->card_ctl)(card, SC_CARDCTL_COOLKEY_INIT_GET_OBJECTS, &count);
  543|    706|	LOG_TEST_GOTO_ERR(card->ctx, r, "Can not initiate objects.");
  ------------------
  |  |  184|    706|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    706|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    706|	int _ret = (r); \
  |  |  |  |  178|    706|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 706]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    706|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 706]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|       |
  545|    706|	sc_log(card->ctx,  "Iterating over %d objects", count);
  ------------------
  |  |   71|    706|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  546|  5.91k|	for (i = 0; i < count; i++) {
  ------------------
  |  Branch (546:14): [True: 5.20k, False: 706]
  ------------------
  547|  5.20k|		struct sc_cardctl_coolkey_object     coolkey_obj;
  548|  5.20k|		struct sc_pkcs15_object    obj_obj;
  549|  5.20k|		struct sc_pkcs15_cert_info cert_info = {0};
  550|  5.20k|		struct sc_pkcs15_pubkey_info pubkey_info = {0};
  551|  5.20k|		struct sc_pkcs15_prkey_info prkey_info = {0};
  552|  5.20k|		sc_pkcs15_pubkey_t *key = NULL;
  553|  5.20k|		void *obj_info = NULL;
  554|  5.20k|		int obj_type = 0;
  555|  5.20k|		CK_KEY_TYPE key_type;
  556|  5.20k|		CK_OBJECT_CLASS obj_class;
  557|  5.20k|		size_t len;
  558|       |
  559|  5.20k|		r = (card->ops->card_ctl)(card, SC_CARDCTL_COOLKEY_GET_NEXT_OBJECT, &coolkey_obj);
  560|  5.20k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Can not get next object from card.");
  ------------------
  |  |  184|  5.20k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  5.20k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  5.20k|	int _ret = (r); \
  |  |  |  |  178|  5.20k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 5.20k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  5.20k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 5.20k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  561|  5.20k|		sc_log(card->ctx, "Loading object %d", i);
  ------------------
  |  |   71|  5.20k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  562|  5.20k|		memset(&obj_obj, 0, sizeof(obj_obj));
  563|       |		/* coolkey applets have label only on the certificates,
  564|       |		 * but we should copy it also to the keys matching the same ID */
  565|  5.20k|		coolkey_get_attribute_bytes(card, &coolkey_obj, CKA_LABEL, (u8 *)obj_obj.label, &len, sizeof(obj_obj.label));
  ------------------
  |  |  140|  5.20k|#define CKA_LABEL 0x00000003UL
  ------------------
  566|  5.20k|		coolkey_get_flags(card, &coolkey_obj, &obj_obj.flags);
  567|  5.20k|		if (obj_obj.flags & SC_PKCS15_CO_FLAG_PRIVATE) {
  ------------------
  |  |   50|  5.20k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (567:7): [True: 1.11k, False: 4.09k]
  ------------------
  568|  1.11k|			sc_pkcs15_format_id(pins[0].id, &obj_obj.auth_id);
  569|  1.11k|		}
  570|       |
  571|  5.20k|		r = coolkey_get_attribute_ulong(card, &coolkey_obj, CKA_CLASS, &obj_class);
  ------------------
  |  |  137|  5.20k|#define CKA_CLASS 0x00000000UL
  ------------------
  572|  5.20k|		if (r < 0) {
  ------------------
  |  Branch (572:7): [True: 3.15k, False: 2.05k]
  ------------------
  573|  3.15k|			goto fail;
  574|  3.15k|		}
  575|  2.05k|		switch (obj_class) {
  576|  1.37k|		case CKO_PRIVATE_KEY:
  ------------------
  |  | 1030|  1.37k|#define CKO_PRIVATE_KEY 0x00000003UL
  ------------------
  |  Branch (576:3): [True: 1.37k, False: 673]
  ------------------
  577|  1.37k|			sc_log(card->ctx, "Processing private key object %d", i);
  ------------------
  |  |   71|  1.37k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  578|  1.37k|			r = coolkey_get_attribute_ulong(card, &coolkey_obj, CKA_KEY_TYPE, &key_type);
  ------------------
  |  |  159|  1.37k|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  579|       |			/* default to CKK_RSA */
  580|  1.37k|			if (r == SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|  1.37k|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (580:8): [True: 1.34k, False: 28]
  ------------------
  581|  1.34k|				key_type = CKK_RSA;
  ------------------
  |  |  464|  1.34k|#define CKK_RSA 0x00000000UL
  ------------------
  582|  1.34k|				r = SC_SUCCESS;
  ------------------
  |  |   28|  1.34k|#define SC_SUCCESS				0
  ------------------
  583|  1.34k|			}
  584|  1.37k|			if (r < 0) {
  ------------------
  |  Branch (584:8): [True: 13, False: 1.36k]
  ------------------
  585|     13|				goto fail;
  586|     13|			}
  587|       |			/* set the info values */
  588|  1.36k|			obj_info = &prkey_info;
  589|  1.36k|			coolkey_get_id(card, &coolkey_obj, &prkey_info.id);
  590|  1.36k|			prkey_info.path = coolkey_obj.path;
  591|  1.36k|			prkey_info.key_reference = (int)coolkey_obj.id;
  592|  1.36k|			prkey_info.native = 1;
  593|  1.36k|			coolkey_get_usage(card, &coolkey_obj, &prkey_info.usage);
  594|  1.36k|			coolkey_get_access(card, &coolkey_obj, &prkey_info.access_flags);
  595|  1.36k|			key = coolkey_get_public_key(p15card, &coolkey_obj, key_type);
  596|  1.36k|			if (key_type == CKK_RSA) {
  ------------------
  |  |  464|  1.36k|#define CKK_RSA 0x00000000UL
  ------------------
  |  Branch (596:8): [True: 1.34k, False: 15]
  ------------------
  597|  1.34k|				obj_type = SC_PKCS15_TYPE_PRKEY_RSA;
  ------------------
  |  |  419|  1.34k|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  598|  1.34k|				if (key) {
  ------------------
  |  Branch (598:9): [True: 0, False: 1.34k]
  ------------------
  599|      0|					prkey_info.modulus_length = key->u.rsa.modulus.len*8;
  600|      0|				}
  601|  1.34k|			} else if (key_type == CKK_EC) {
  ------------------
  |  |  467|     15|#define CKK_EC 0x00000003UL
  ------------------
  |  Branch (601:15): [True: 1, False: 14]
  ------------------
  602|      1|				obj_type = SC_PKCS15_TYPE_PRKEY_EC;
  ------------------
  |  |  421|      1|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  603|      1|				if (key) {
  ------------------
  |  Branch (603:9): [True: 0, False: 1]
  ------------------
  604|      0|					prkey_info.field_length = key->u.ec.params.field_length;
  605|      0|				}
  606|     14|			} else {
  607|     14|				goto fail;
  608|     14|			}
  609|  1.35k|			break;
  610|       |
  611|  1.35k|		case CKO_PUBLIC_KEY:
  ------------------
  |  | 1029|    129|#define CKO_PUBLIC_KEY 0x00000002UL
  ------------------
  |  Branch (611:3): [True: 129, False: 1.92k]
  ------------------
  612|    129|			sc_log(card->ctx, "Processing public key object %d", i);
  ------------------
  |  |   71|    129|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  613|    129|			r = coolkey_get_attribute_ulong(card, &coolkey_obj, CKA_KEY_TYPE, &key_type);
  ------------------
  |  |  159|    129|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  614|       |			/* default to CKK_RSA */
  615|    129|			if (r == SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|    129|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (615:8): [True: 126, False: 3]
  ------------------
  616|    126|				key_type = CKK_RSA;
  ------------------
  |  |  464|    126|#define CKK_RSA 0x00000000UL
  ------------------
  617|    126|				r = SC_SUCCESS;
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
  618|    126|			}
  619|    129|			if (r < 0) {
  ------------------
  |  Branch (619:8): [True: 2, False: 127]
  ------------------
  620|      2|				goto fail;
  621|      2|			}
  622|    127|			key = coolkey_get_public_key(p15card, &coolkey_obj, key_type);
  623|    127|			if (key == NULL) {
  ------------------
  |  Branch (623:8): [True: 126, False: 1]
  ------------------
  624|    126|				goto fail;
  625|    126|			}
  626|       |			/* set the info values */
  627|      1|			obj_info = &pubkey_info;
  628|      1|			r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, key, &pubkey_info.direct.spki.value,
  629|      1|				&pubkey_info.direct.spki.len);
  630|      1|			if (r < 0)
  ------------------
  |  Branch (630:8): [True: 1, False: 0]
  ------------------
  631|      1|				goto fail;
  632|      0|			coolkey_get_id(card, &coolkey_obj, &pubkey_info.id);
  633|      0|			pubkey_info.path = coolkey_obj.path;
  634|      0|			pubkey_info.native = 1;
  635|      0|			pubkey_info.key_reference = (int)coolkey_obj.id;
  636|      0|			coolkey_get_usage(card, &coolkey_obj, &pubkey_info.usage);
  637|      0|			coolkey_get_access(card, &coolkey_obj, &pubkey_info.access_flags);
  638|      0|			if (key_type == CKK_RSA) {
  ------------------
  |  |  464|      0|#define CKK_RSA 0x00000000UL
  ------------------
  |  Branch (638:8): [True: 0, False: 0]
  ------------------
  639|      0|				obj_type = SC_PKCS15_TYPE_PUBKEY_RSA;
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  640|      0|				pubkey_info.modulus_length = key->u.rsa.modulus.len*8;
  641|      0|			} else if (key_type == CKK_EC) {
  ------------------
  |  |  467|      0|#define CKK_EC 0x00000003UL
  ------------------
  |  Branch (641:15): [True: 0, False: 0]
  ------------------
  642|      0|				obj_type = SC_PKCS15_TYPE_PUBKEY_EC;
  ------------------
  |  |  428|      0|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  643|      0|				pubkey_info.field_length = key->u.ec.params.field_length;
  644|      0|			} else {
  645|      0|				goto fail;
  646|      0|			}
  647|       |			/* set the obj values */
  648|      0|			obj_obj.emulated = key;
  649|      0|			key = NULL;
  650|      0|			break;
  651|       |
  652|    461|		case CKO_CERTIFICATE:
  ------------------
  |  | 1028|    461|#define CKO_CERTIFICATE 0x00000001UL
  ------------------
  |  Branch (652:3): [True: 461, False: 1.58k]
  ------------------
  653|    461|			sc_log(card->ctx, "Processing certificate object %d", i);
  ------------------
  |  |   71|    461|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  654|    461|			obj_info = &cert_info;
  655|    461|			coolkey_get_id(card, &coolkey_obj, &cert_info.id);
  656|    461|			cert_info.path = coolkey_obj.path;
  657|    461|			obj_type = SC_PKCS15_TYPE_CERT_X509;
  ------------------
  |  |  439|    461|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  658|       |
  659|       |			/* following will find the cached cert in cert_info */
  660|    461|			r = coolkey_get_certificate(card, &coolkey_obj, &cert_info.value);
  661|    461|			if (r < 0) {
  ------------------
  |  Branch (661:8): [True: 116, False: 345]
  ------------------
  662|    116|				goto fail;
  663|    116|			}
  664|    345|			break;
  665|       |
  666|       |
  667|    345|		default:
  ------------------
  |  Branch (667:3): [True: 83, False: 1.96k]
  ------------------
  668|       |			/* no other recognized types which are stored 'on card' */
  669|     83|			sc_log(card->ctx, "Unknown object type %lu, skipping", obj_class);
  ------------------
  |  |   71|     83|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  670|     83|			continue;
  671|  2.05k|		}
  672|       |
  673|  1.69k|		r = sc_pkcs15emu_object_add(p15card, obj_type, &obj_obj, obj_info);
  674|  1.69k|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|  1.69k|#define SC_SUCCESS				0
  ------------------
  |  Branch (674:7): [True: 0, False: 1.69k]
  ------------------
  675|      0|			sc_log(card->ctx, "sc_pkcs15emu_object_add() returned %d", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  676|  5.12k|fail:
  677|  5.12k|		if (key) {
  ------------------
  |  Branch (677:7): [True: 15, False: 5.10k]
  ------------------
  678|     15|			sc_pkcs15_free_pubkey(key);
  679|     15|		}
  680|  5.12k|		free(cert_info.value.value);
  681|  5.12k|		free(pubkey_info.direct.spki.value);
  682|  5.12k|	}
  683|    706|	r = (card->ops->card_ctl)(card, SC_CARDCTL_COOLKEY_FINAL_GET_OBJECTS, &count);
  684|    706|	LOG_TEST_GOTO_ERR(card->ctx, r, "Can not finalize objects.");
  ------------------
  |  |  184|    706|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    706|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    706|	int _ret = (r); \
  |  |  |  |  178|    706|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 706]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    706|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 706]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  685|       |
  686|       |	/* Iterate over all the created objects and fill missing labels */
  687|  3.10k|	for (obj = p15card->obj_list; obj != NULL; obj = obj->next) {
  ------------------
  |  Branch (687:32): [True: 2.40k, False: 706]
  ------------------
  688|  2.40k|		struct sc_pkcs15_id *id = NULL;
  689|  2.40k|		struct sc_pkcs15_object *cert_object;
  690|       |
  691|       |		/* label non-empty -- do not overwrite */
  692|  2.40k|		if (obj->label[0] != '\0')
  ------------------
  |  Branch (692:7): [True: 707, False: 1.69k]
  ------------------
  693|    707|			continue;
  694|       |
  695|  1.69k|		switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  1.69k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  696|      0|		case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (696:3): [True: 0, False: 1.69k]
  ------------------
  697|      0|			id = &((struct sc_pkcs15_pubkey_info *)obj->data)->id;
  698|      0|			break;
  699|  1.34k|		case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  1.34k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (699:3): [True: 1.34k, False: 345]
  ------------------
  700|  1.34k|			id = &((struct sc_pkcs15_prkey_info *)obj->data)->id;
  701|  1.34k|			break;
  702|    345|		default:
  ------------------
  |  Branch (702:3): [True: 345, False: 1.34k]
  ------------------
  703|       |			/* We do not care about other objects */
  704|    345|			continue;
  705|  1.69k|		}
  706|  1.34k|		r = sc_pkcs15_find_cert_by_id(p15card, id, &cert_object);
  707|  1.34k|		if (r != 0)
  ------------------
  |  Branch (707:7): [True: 1.19k, False: 159]
  ------------------
  708|  1.19k|			continue;
  709|       |
  710|    159|		sc_log(card->ctx, "Copy label \"%s\" from cert to key object",
  ------------------
  |  |   71|    159|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  711|    159|			cert_object->label);
  712|    159|		memcpy(obj->label, cert_object->label, SC_PKCS15_MAX_LABEL_SIZE);
  ------------------
  |  |   35|    159|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  713|    159|	}
  714|       |
  715|    706|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    706|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    706|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    706|	int _ret = r; \
  |  |  |  |  155|    706|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 706, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    706|		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: 706]
  |  |  |  |  ------------------
  |  |  |  |  157|    706|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    706|	} 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|    706|	return _ret; \
  |  |  |  |  163|    706|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  716|       |
  717|      0|err:
  718|      0|	sc_pkcs15_card_clear(p15card);
  719|      0|	p15card->opts.use_pin_cache = use_pin_cache_backup;
  720|       |
  721|      0|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  722|      0|}
pkcs15-coolkey.c:coolkey_get_attribute_bytes:
  187|  7.03k|{
  188|  7.03k|	const u8 *val;
  189|  7.03k|	size_t val_len = 0;
  190|  7.03k|	int r;
  191|       |
  192|  7.03k|	r = coolkey_get_attribute(card, obj, type, &val, &val_len, NULL);
  193|  7.03k|	if (r < 0) {
  ------------------
  |  Branch (193:6): [True: 5.22k, False: 1.81k]
  ------------------
  194|  5.22k|		return r;
  195|  5.22k|	}
  196|  1.81k|	if (val_len > max_data_len) {
  ------------------
  |  Branch (196:6): [True: 2, False: 1.80k]
  ------------------
  197|      2|		val_len = max_data_len;
  198|      2|	}
  199|  1.81k|	memcpy(data, val, val_len);
  200|  1.81k|	*data_len = val_len;
  201|  1.81k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.81k|#define SC_SUCCESS				0
  ------------------
  202|  7.03k|}
pkcs15-coolkey.c:coolkey_get_flags:
  359|  5.37k|{
  360|  5.37k|	return coolkey_set_bool_flags(card, obj, flag_ptr, flag_table, flag_table_size);
  361|  5.37k|}
pkcs15-coolkey.c:coolkey_set_bool_flags:
  336|  8.10k|{
  337|  8.10k|	unsigned int flags = 0;
  338|  8.10k|	int i;
  339|       |
  340|  37.9k|	for (i=0; i< table_size; i++) {
  ------------------
  |  Branch (340:12): [True: 29.8k, False: 8.10k]
  ------------------
  341|  29.8k|		if (coolkey_get_attribute_boolean(card, obj, table[i].attribute_type)) {
  ------------------
  |  Branch (341:7): [True: 3.97k, False: 25.8k]
  ------------------
  342|  3.97k|			flags |= table[i].pkcs15_flags;
  343|  3.97k|		}
  344|  29.8k|	}
  345|  8.10k|	*flags_ptr = flags;
  346|  8.10k|	return SC_SUCCESS;
  ------------------
  |  |   28|  8.10k|#define SC_SUCCESS				0
  ------------------
  347|  8.10k|}
pkcs15-coolkey.c:coolkey_get_attribute_boolean:
  169|  29.8k|{
  170|  29.8k|	int r;
  171|  29.8k|	const u8 *val = NULL;
  172|  29.8k|	size_t val_len = 0;
  173|       |
  174|  29.8k|	r = coolkey_get_attribute(card, obj, attr_type, &val, &val_len, NULL);
  175|  29.8k|	if (r < 0) {
  ------------------
  |  Branch (175:6): [True: 12.4k, False: 17.4k]
  ------------------
  176|       |		/* attribute not valid for this object, set boolean to false */
  177|  12.4k|		return 0;
  178|  12.4k|	}
  179|  17.4k|	if ((val_len == 1) && (*val == 1)) {
  ------------------
  |  Branch (179:6): [True: 17.4k, False: 19]
  |  Branch (179:24): [True: 3.97k, False: 13.4k]
  ------------------
  180|  3.97k|		return 1;
  181|  3.97k|	}
  182|  13.4k|	return 0;
  183|  17.4k|}
pkcs15-coolkey.c:coolkey_get_attribute_ulong:
  149|  6.71k|{
  150|  6.71k|	const u8 *val = NULL;
  151|  6.71k|	size_t val_len = 0;
  152|  6.71k|	u8 data_type = 0;
  153|  6.71k|	int r;
  154|       |
  155|  6.71k|	r  = coolkey_get_attribute(card, obj, type, &val, &val_len, &data_type);
  156|  6.71k|	if (r < 0) {
  ------------------
  |  Branch (156:6): [True: 4.60k, False: 2.11k]
  ------------------
  157|  4.60k|		return r;
  158|  4.60k|	}
  159|  2.11k|	if ((data_type != SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG) &&
  ------------------
  |  | 1069|  2.11k|#define SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG 1
  ------------------
  |  Branch (159:6): [True: 93, False: 2.01k]
  ------------------
  160|     93|	    (val_len != sizeof(CK_ULONG))) {
  ------------------
  |  Branch (160:6): [True: 45, False: 48]
  ------------------
  161|     45|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|     45|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  162|     45|	}
  163|  2.06k|	*value = bebytes2ulong(val);
  164|  2.06k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.06k|#define SC_SUCCESS				0
  ------------------
  165|  2.11k|}
pkcs15-coolkey.c:coolkey_get_id:
  226|  1.82k|{
  227|  1.82k|	return coolkey_get_attribute_bytes(card, obj, CKA_ID, id->value , &id->len, sizeof(id->value));
  ------------------
  |  |  161|  1.82k|#define CKA_ID 0x00000102UL
  ------------------
  228|  1.82k|}
pkcs15-coolkey.c:coolkey_get_usage:
  352|  1.36k|{
  353|  1.36k|	return coolkey_set_bool_flags(card, obj, usage_ptr, usage_table, usage_table_size);
  354|  1.36k|}
pkcs15-coolkey.c:coolkey_get_access:
  365|  1.36k|{
  366|  1.36k|	return coolkey_set_bool_flags(card, obj, access_ptr, access_table, access_table_size);
  367|  1.36k|}
pkcs15-coolkey.c:coolkey_get_public_key:
  456|  1.49k|{
  457|  1.49k|	sc_pkcs15_pubkey_t *key;
  458|       |
  459|  1.49k|	key = coolkey_make_public_key(p15card->card, obj, key_type);
  460|  1.49k|	if (key) {
  ------------------
  |  Branch (460:6): [True: 15, False: 1.47k]
  ------------------
  461|     15|		return key;
  462|     15|	}
  463|  1.47k|	return coolkey_get_public_key_from_certificate(p15card, obj);
  464|  1.49k|}
pkcs15-coolkey.c:coolkey_make_public_key:
  375|  1.49k|{
  376|  1.49k|	sc_pkcs15_pubkey_t *key;
  377|  1.49k|	int r;
  378|       |
  379|  1.49k|	key = calloc(1, sizeof(struct sc_pkcs15_pubkey));
  380|  1.49k|	if (!key)
  ------------------
  |  Branch (380:6): [True: 0, False: 1.49k]
  ------------------
  381|      0|		return NULL;
  382|  1.49k|	switch (key_type) {
  ------------------
  |  Branch (382:10): [True: 1.47k, False: 15]
  ------------------
  383|  1.47k|	case CKK_RSA:
  ------------------
  |  |  464|  1.47k|#define CKK_RSA 0x00000000UL
  ------------------
  |  Branch (383:2): [True: 1.47k, False: 16]
  ------------------
  384|  1.47k|		key->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|  1.47k|#define SC_ALGORITHM_RSA		0
  ------------------
  385|  1.47k|		r = coolkey_get_attribute_lv(card, obj, CKA_MODULUS, &key->u.rsa.modulus);
  ------------------
  |  |  174|  1.47k|#define CKA_MODULUS 0x00000120UL
  ------------------
  386|  1.47k|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  1.47k|#define SC_SUCCESS				0
  ------------------
  |  Branch (386:7): [True: 1.47k, False: 2]
  ------------------
  387|  1.47k|			goto fail;
  388|  1.47k|		}
  389|      2|		r = coolkey_get_attribute_lv(card, obj, CKA_PUBLIC_EXPONENT, &key->u.rsa.exponent);
  ------------------
  |  |  176|      2|#define CKA_PUBLIC_EXPONENT 0x00000122UL
  ------------------
  390|      2|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
  |  Branch (390:7): [True: 2, False: 0]
  ------------------
  391|      2|			goto fail;
  392|      2|		}
  393|      0|		break;
  394|      1|	case CKK_EC:
  ------------------
  |  |  467|      1|#define CKK_EC 0x00000003UL
  ------------------
  |  Branch (394:2): [True: 1, False: 1.49k]
  ------------------
  395|      1|		key->algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   70|      1|#define SC_ALGORITHM_EC		2
  ------------------
  396|      1|		r = coolkey_get_attribute_bytes_alloc(card, obj, CKA_EC_POINT, &key->u.ec.ecpointQ.value, &key->u.ec.ecpointQ.len);
  ------------------
  |  |  201|      1|#define CKA_EC_POINT 0x00000181UL
  ------------------
  397|      1|	    if(r < 0) {
  ------------------
  |  Branch (397:9): [True: 1, False: 0]
  ------------------
  398|      1|			goto fail;
  399|      1|		}
  400|      0|		r = coolkey_get_attribute_bytes_alloc(card, obj, CKA_EC_PARAMS,
  ------------------
  |  |  200|      0|#define CKA_EC_PARAMS 0x00000180UL
  ------------------
  401|      0|				&key->u.ec.params.der.value, &key->u.ec.params.der.len);
  402|      0|		if (r < 0) {
  ------------------
  |  Branch (402:7): [True: 0, False: 0]
  ------------------
  403|      0|			goto fail;
  404|      0|		}
  405|      0|		r = sc_pkcs15_fix_ec_parameters(card->ctx, &key->u.ec.params);
  406|      0|		if (r < 0) {
  ------------------
  |  Branch (406:7): [True: 0, False: 0]
  ------------------
  407|      0|			goto fail;
  408|      0|		}
  409|      0|		break;
  410|  1.49k|	}
  411|     15|	return key;
  412|  1.47k|fail:
  413|  1.47k|	sc_pkcs15_free_pubkey(key);
  414|       |
  415|       |	/* now parse the DER cert */
  416|       |	return NULL;
  417|  1.49k|}
pkcs15-coolkey.c:coolkey_get_public_key_from_certificate:
  422|  1.47k|{
  423|  1.47k|	sc_pkcs15_cert_info_t cert_info;
  424|  1.47k|	sc_pkcs15_cert_t *cert_out = NULL;
  425|  1.47k|	sc_pkcs15_pubkey_t *key = NULL;
  426|  1.47k|	int r, private_obj;
  427|  1.47k|	unsigned int flags;
  428|       |
  429|  1.47k|	memset(&cert_info, 0, sizeof(cert_info));
  430|       |
  431|  1.47k|	r = coolkey_get_certificate(p15card->card, obj, &cert_info.value);
  432|  1.47k|	if (r < 0) {
  ------------------
  |  Branch (432:6): [True: 1.30k, False: 167]
  ------------------
  433|  1.30k|		goto fail;
  434|  1.30k|	}
  435|       |
  436|    167|	coolkey_get_flags(p15card->card, obj, &flags);
  437|    167|	private_obj = flags & SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    167|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  438|    167|	r = sc_pkcs15_read_certificate(p15card, &cert_info, private_obj, &cert_out);
  439|    167|	if (r < 0) {
  ------------------
  |  Branch (439:6): [True: 167, False: 0]
  ------------------
  440|    167|		goto fail;
  441|    167|	}
  442|      0|	key = cert_out->key;
  443|      0|	cert_out->key = NULL; /* adopt the key from the cert */
  444|  1.47k|fail:
  445|  1.47k|	if (cert_out) {
  ------------------
  |  Branch (445:6): [True: 0, False: 1.47k]
  ------------------
  446|      0|		sc_pkcs15_free_certificate(cert_out);
  447|      0|	}
  448|  1.47k|	if (cert_info.value.value) {
  ------------------
  |  Branch (448:6): [True: 164, False: 1.31k]
  ------------------
  449|    164|		free(cert_info.value.value);
  450|    164|	}
  451|  1.47k|	return key;
  452|      0|}
pkcs15-coolkey.c:coolkey_get_certificate:
  267|  1.93k|{
  268|  1.93k|	sc_cardctl_coolkey_object_t *cert_obj;
  269|  1.93k|	unsigned long object_id;
  270|  1.93k|	int r;
  271|       |
  272|  1.93k|	cert_obj = obj;
  273|  1.93k|	if (coolkey_get_object_type(obj->id) != COOLKEY_ID_CERT) {
  ------------------
  |  |  249|  1.93k|#define COOLKEY_ID_CERT ((unsigned long)'c')
  ------------------
  |  Branch (273:6): [True: 1.89k, False: 42]
  ------------------
  274|  1.89k|		r = coolkey_find_matching_cert(card, obj, &cert_obj);
  275|  1.89k|		if (r < 0) {
  ------------------
  |  Branch (275:7): [True: 1.25k, False: 638]
  ------------------
  276|  1.25k|			return r;
  277|  1.25k|		}
  278|  1.89k|	}
  279|    680|	r = coolkey_get_attribute_lv(card, cert_obj, CKA_VALUE, cert);
  ------------------
  |  |  143|    680|#define CKA_VALUE 0x00000011UL
  ------------------
  280|    680|	if (r == SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|    680|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (280:6): [True: 667, False: 13]
  ------------------
  281|    667|		object_id = coolkey_make_new_id(cert_obj->id, COOLKEY_ID_CERT_DATA);
  ------------------
  |  |  251|    667|#define COOLKEY_ID_CERT_DATA ((unsigned long)'C')
  ------------------
  282|    667|		r = coolkey_get_object(card, object_id, &cert_obj);
  283|    667|		if (r < 0) {
  ------------------
  |  Branch (283:7): [True: 166, False: 501]
  ------------------
  284|    166|			return r;
  285|    166|		}
  286|       |		/* fill in cert data */
  287|    501|		cert->value = malloc(cert_obj->length);
  288|    501|		if (cert->value == NULL) {
  ------------------
  |  Branch (288:7): [True: 0, False: 501]
  ------------------
  289|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  290|      0|		}
  291|    501|		memcpy(cert->value, cert_obj->data, cert_obj->length);
  292|    501|		cert->len = cert_obj->length;
  293|    501|		return SC_SUCCESS;
  ------------------
  |  |   28|    501|#define SC_SUCCESS				0
  ------------------
  294|    501|	}
  295|     13|	return r;
  296|    680|}
pkcs15-coolkey.c:coolkey_get_object_type:
  254|  1.93k|coolkey_get_object_type(unsigned long object_id) { return ((object_id >> 24 ) & 0xff); }
pkcs15-coolkey.c:coolkey_find_matching_cert:
  111|  1.89k|coolkey_find_matching_cert(sc_card_t *card, sc_cardctl_coolkey_object_t *in_obj, sc_cardctl_coolkey_object_t **cert_obj) {
  112|  1.89k|	sc_cardctl_coolkey_find_object_t fobj;
  113|  1.89k|	sc_cardctl_coolkey_attribute_t template[2];
  114|  1.89k|	u8 obj_class[4];
  115|  1.89k|	int r;
  116|       |
  117|       |	/* we are searching for certs .. */
  118|  1.89k|	template[0].attribute_type = CKA_CLASS;
  ------------------
  |  |  137|  1.89k|#define CKA_CLASS 0x00000000UL
  ------------------
  119|  1.89k|	template[0].attribute_data_type = SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG;
  ------------------
  |  | 1069|  1.89k|#define SC_CARDCTL_COOLKEY_ATTR_TYPE_ULONG 1
  ------------------
  120|  1.89k|	template[0].attribute_length = sizeof(obj_class);
  121|  1.89k|	template[0].attribute_value = obj_class;
  122|  1.89k|	ulong2bebytes(obj_class, CKO_CERTIFICATE);
  ------------------
  |  | 1028|  1.89k|#define CKO_CERTIFICATE 0x00000001UL
  ------------------
  123|       |
  124|       |	/* fetch the current object's CKA_ID */
  125|  1.89k|	template[1].attribute_type = CKA_ID;
  ------------------
  |  |  161|  1.89k|#define CKA_ID 0x00000102UL
  ------------------
  126|  1.89k|	template[1].object = in_obj;
  127|  1.89k|	r = sc_card_ctl(card, SC_CARDCTL_COOLKEY_GET_ATTRIBUTE, &template[1]);
  128|  1.89k|	if (r < 0) {
  ------------------
  |  Branch (128:6): [True: 17, False: 1.87k]
  ------------------
  129|     17|		return r;
  130|     17|	}
  131|  1.87k|	template[0].object = NULL; /*paranoia */
  132|  1.87k|	template[1].object = NULL; /*paranoia */
  133|       |
  134|       |	/* now find the cert that has the ID */
  135|  1.87k|	fobj.type = SC_CARDCTL_COOLKEY_FIND_BY_TEMPLATE;
  ------------------
  |  | 1080|  1.87k|#define SC_CARDCTL_COOLKEY_FIND_BY_TEMPLATE 1
  ------------------
  136|  1.87k|	fobj.obj = NULL;
  137|  1.87k|	fobj.coolkey_template = &template[0];
  138|  1.87k|	fobj.template_count=2;
  139|  1.87k|	r = sc_card_ctl(card, SC_CARDCTL_COOLKEY_FIND_OBJECT, &fobj);
  140|  1.87k|	if (r < 0) {
  ------------------
  |  Branch (140:6): [True: 1.24k, False: 638]
  ------------------
  141|  1.24k|		return r;
  142|  1.24k|	}
  143|    638|	*cert_obj = fobj.obj;
  144|    638|	return SC_SUCCESS;
  ------------------
  |  |   28|    638|#define SC_SUCCESS				0
  ------------------
  145|  1.87k|}
pkcs15-coolkey.c:coolkey_make_new_id:
  258|    667|{ return ((object_id  & 0x00ffffffUL)|(id_type << 24)); }
pkcs15-coolkey.c:coolkey_get_object:
   71|    667|coolkey_get_object(sc_card_t *card, unsigned long object_id, sc_cardctl_coolkey_object_t **obj) {
   72|    667|	sc_cardctl_coolkey_find_object_t fobj;
   73|    667|	int r;
   74|       |
   75|    667|	fobj.type = SC_CARDCTL_COOLKEY_FIND_BY_ID;
  ------------------
  |  | 1079|    667|#define SC_CARDCTL_COOLKEY_FIND_BY_ID       0
  ------------------
   76|    667|	fobj.find_id = object_id;
   77|    667|	fobj.obj = NULL;
   78|    667|	r = sc_card_ctl(card, SC_CARDCTL_COOLKEY_FIND_OBJECT, &fobj);
   79|    667|	if (r < 0) {
  ------------------
  |  Branch (79:6): [True: 166, False: 501]
  ------------------
   80|    166|		return r;
   81|    166|	}
   82|    501|	*obj = fobj.obj;
   83|    501|	return SC_SUCCESS;
  ------------------
  |  |   28|    501|#define SC_SUCCESS				0
  ------------------
   84|    667|}

sc_pkcs15_read_data_object:
   46|    255|{
   47|    255|	struct sc_context *ctx = p15card->card->ctx;
   48|    255|	struct sc_pkcs15_data *data_object;
   49|    255|	struct sc_pkcs15_der der;
   50|    255|	int r;
   51|       |
   52|    255|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    255|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    255|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    255|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    255|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 255]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|    255|	if (!info || !data_object_out)
  ------------------
  |  Branch (53:6): [True: 0, False: 255]
  |  Branch (53:15): [True: 0, False: 255]
  ------------------
   54|    255|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|       |
   56|    255|	if (!info->data.value)   {
  ------------------
  |  Branch (56:6): [True: 255, False: 0]
  ------------------
   57|    255|		r = sc_pkcs15_read_file(p15card, &info->path, (unsigned char **) &info->data.value, (size_t *) &info->data.len, private_obj);
   58|    255|		LOG_TEST_RET(ctx, r, "Cannot get DATA object data");
  ------------------
  |  |  174|    255|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    255|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    255|	int _ret = (r); \
  |  |  |  |  168|    255|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 151, False: 104]
  |  |  |  |  ------------------
  |  |  |  |  169|    151|		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|    151|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    151|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    151|		return _ret; \
  |  |  |  |  172|    151|	} \
  |  |  |  |  173|    255|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 104]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   59|    255|	}
   60|       |
   61|    104|	r = sc_der_copy(&der, &info->data);
   62|    104|	LOG_TEST_RET(ctx, r, "Cannot allocate memory for der value");
  ------------------
  |  |  174|    104|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    104|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    104|	int _ret = (r); \
  |  |  |  |  168|    104|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 104]
  |  |  |  |  ------------------
  |  |  |  |  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|    104|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 104]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   63|       |
   64|    104|	data_object = calloc(1, sizeof(struct sc_pkcs15_data));
   65|    104|	if (!data_object)   {
  ------------------
  |  Branch (65:6): [True: 0, False: 104]
  ------------------
   66|      0|		free(der.value);
   67|      0|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot allocate memory for data object");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   68|      0|	}
   69|       |
   70|    104|	data_object->data = der.value;
   71|    104|	data_object->data_len = der.len;
   72|    104|	*data_object_out = data_object;
   73|       |
   74|    104|	LOG_FUNC_RETURN(ctx,SC_SUCCESS);
  ------------------
  |  |  164|    104|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    104|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    104|	int _ret = r; \
  |  |  |  |  155|    104|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 104, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    104|		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: 104]
  |  |  |  |  ------------------
  |  |  |  |  157|    104|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    104|	} 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|    104|	return _ret; \
  |  |  |  |  163|    104|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   75|    104|}
sc_pkcs15_decode_dodf_entry:
   95|      2|{
   96|      2|        sc_context_t *ctx = p15card->card->ctx;
   97|      2|	struct sc_pkcs15_data_info info;
   98|      2|	struct sc_asn1_entry	asn1_com_data_attr[3],
   99|      2|				asn1_type_data_attr[2],
  100|      2|				asn1_data[2];
  101|      2|	struct sc_asn1_pkcs15_object data_obj = { obj, asn1_com_data_attr, NULL,
  102|      2|					     asn1_type_data_attr };
  103|      2|	size_t label_len = sizeof(info.app_label) - 1;
  104|      2|	int r;
  105|       |
  106|      2|	memset(info.app_label, 0, sizeof(info.app_label));
  107|       |
  108|      2|	sc_copy_asn1_entry(c_asn1_com_data_attr, asn1_com_data_attr);
  109|      2|	sc_copy_asn1_entry(c_asn1_type_data_attr, asn1_type_data_attr);
  110|      2|	sc_copy_asn1_entry(c_asn1_data, asn1_data);
  111|       |
  112|      2|	sc_format_asn1_entry(asn1_com_data_attr + 0, &info.app_label, &label_len, 0);
  113|      2|	sc_format_asn1_entry(asn1_com_data_attr + 1, &info.app_oid, NULL, 0);
  114|      2|	sc_format_asn1_entry(asn1_type_data_attr + 0, &info.path, NULL, 0);
  115|      2|	sc_format_asn1_entry(asn1_data + 0, &data_obj, NULL, 0);
  116|       |
  117|       |	/* Fill in defaults */
  118|      2|	memset(&info, 0, sizeof(info));
  119|      2|	sc_init_oid(&info.app_oid);
  120|       |
  121|      2|	r = sc_asn1_decode(ctx, asn1_data, *buf, *buflen, buf, buflen);
  122|      2|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|      2|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (122:6): [True: 1, False: 1]
  ------------------
  123|      1|		return r;
  124|      1|	LOG_TEST_RET(ctx, r, "ASN.1 decoding failed");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  125|       |
  126|      0|	if (!p15card->app || !p15card->app->ddo.aid.len) {
  ------------------
  |  Branch (126:6): [True: 0, False: 0]
  |  Branch (126:23): [True: 0, False: 0]
  ------------------
  127|      0|		if (!p15card->file_app) {
  ------------------
  |  Branch (127:7): [True: 0, False: 0]
  ------------------
  128|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  129|      0|		}
  130|      0|		r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path);
  131|      0|		if (r < 0)
  ------------------
  |  Branch (131:7): [True: 0, False: 0]
  ------------------
  132|      0|			return r;
  133|      0|	}
  134|      0|	else   {
  135|      0|		info.path.aid = p15card->app->ddo.aid;
  136|      0|	}
  137|       |
  138|      0|	obj->type = SC_PKCS15_TYPE_DATA_OBJECT;
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  139|      0|	obj->data = malloc(sizeof(info));
  140|      0|	if (obj->data == NULL)
  ------------------
  |  Branch (140:6): [True: 0, False: 0]
  ------------------
  141|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  142|      0|	memcpy(obj->data, &info, sizeof(info));
  143|       |
  144|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  145|      0|}
sc_pkcs15_free_data_object:
  180|    104|{
  181|    104|	if (data_object == NULL)
  ------------------
  |  Branch (181:6): [True: 0, False: 104]
  ------------------
  182|      0|		return;
  183|       |
  184|    104|	free(data_object->data);
  185|    104|	free(data_object);
  186|    104|}
sc_pkcs15_free_data_info:
  189|  25.5k|{
  190|  25.5k|	if (info && info->data.value)
  ------------------
  |  Branch (190:6): [True: 25.5k, False: 0]
  |  Branch (190:14): [True: 0, False: 25.5k]
  ------------------
  191|      0|		free(info->data.value);
  192|       |
  193|  25.5k|	free(info);
  194|  25.5k|}

sc_pkcs15emu_din_66291_init_ex:
  197|  12.0k|{
  198|  12.0k|    int r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.0k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  199|  12.0k|    sc_path_t path;
  200|  12.0k|    unsigned char *tokeninfo_content = NULL;
  201|  12.0k|    struct sc_file *file_tokeninfo = NULL;
  202|  12.0k|    struct sc_pkcs15_tokeninfo *tokeninfo = NULL;
  203|  12.0k|	sc_serial_number_t serial;
  204|       |
  205|  12.0k|    if (!p15card || ! p15card->card)
  ------------------
  |  Branch (205:9): [True: 0, False: 12.0k]
  |  Branch (205:21): [True: 0, False: 12.0k]
  ------------------
  206|      0|        return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  207|       |
  208|  12.0k|    SC_FUNC_CALLED(p15card->card->ctx, 1);
  ------------------
  |  |  148|  12.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  12.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  12.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 12.0k]
  |  |  ------------------
  ------------------
  209|       |
  210|  12.0k|    tokeninfo = sc_pkcs15_tokeninfo_new();
  211|  12.0k|    if (!p15card || !tokeninfo
  ------------------
  |  Branch (211:9): [True: 0, False: 12.0k]
  |  Branch (211:21): [True: 0, False: 12.0k]
  ------------------
  212|  12.0k|            || (aid && (aid->len != sizeof aid_CIA
  ------------------
  |  Branch (212:17): [True: 3.84k, False: 8.23k]
  |  Branch (212:25): [True: 2.43k, False: 1.41k]
  ------------------
  213|  1.41k|                    || 0 != memcmp(aid->value, aid_CIA, sizeof aid_CIA))))
  ------------------
  |  Branch (213:24): [True: 412, False: 998]
  ------------------
  214|  2.84k|        goto err;
  215|       |
  216|  9.23k|    if (!p15card->tokeninfo
  ------------------
  |  Branch (216:9): [True: 0, False: 9.23k]
  ------------------
  217|  9.23k|            || !p15card->tokeninfo->profile_indication.name
  ------------------
  |  Branch (217:16): [True: 9.23k, False: 0]
  ------------------
  218|      0|            || 0 != strcmp("DIN V 66291",
  ------------------
  |  Branch (218:16): [True: 0, False: 0]
  ------------------
  219|  9.23k|                p15card->tokeninfo->profile_indication.name)) {
  220|       |        /* it is possible that p15card->tokeninfo has not been touched yet */
  221|  9.23k|        if (SC_SUCCESS == sc_path_set(&path, SC_PATH_TYPE_DF_NAME,
  ------------------
  |  |   28|  9.23k|#define SC_SUCCESS				0
  ------------------
                      if (SC_SUCCESS == sc_path_set(&path, SC_PATH_TYPE_DF_NAME,
  ------------------
  |  |  118|  9.23k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (221:13): [True: 9.23k, False: 0]
  ------------------
  222|  9.23k|                    aid_CIA, sizeof aid_CIA, 0, 0)
  223|  9.23k|                && SC_SUCCESS == sc_select_file(p15card->card, &path, NULL)) {
  ------------------
  |  |   28|  9.23k|#define SC_SUCCESS				0
  ------------------
  |  Branch (223:20): [True: 865, False: 8.37k]
  ------------------
  224|    865|            sc_format_path("5032", &path);
  225|    865|            if (SC_SUCCESS != sc_select_file(p15card->card, &path, &file_tokeninfo))
  ------------------
  |  |   28|    865|#define SC_SUCCESS				0
  ------------------
  |  Branch (225:17): [True: 470, False: 395]
  ------------------
  226|    470|                goto err;
  227|       |
  228|    395|            tokeninfo_content = malloc(file_tokeninfo->size);
  229|    395|            if (!tokeninfo_content)
  ------------------
  |  Branch (229:17): [True: 0, False: 395]
  ------------------
  230|      0|                goto err;
  231|    395|            r = sc_read_binary(p15card->card, 0, tokeninfo_content, file_tokeninfo->size, 0);
  232|    395|            if (r < 0)
  ------------------
  |  Branch (232:17): [True: 111, False: 284]
  ------------------
  233|    111|                goto err;
  234|    284|            r = sc_pkcs15_parse_tokeninfo(p15card->card->ctx, tokeninfo, tokeninfo_content, r);
  235|    284|            if (r != SC_SUCCESS)
  ------------------
  |  |   28|    284|#define SC_SUCCESS				0
  ------------------
  |  Branch (235:17): [True: 265, False: 19]
  ------------------
  236|    265|                goto err;
  237|       |
  238|     19|            if (!tokeninfo->profile_indication.name
  ------------------
  |  Branch (238:17): [True: 19, False: 0]
  ------------------
  239|      0|                    || 0 != strcmp("DIN V 66291",
  ------------------
  |  Branch (239:24): [True: 0, False: 0]
  ------------------
  240|     19|                        tokeninfo->profile_indication.name)) {
  241|     19|                goto err;
  242|     19|            }
  243|  8.37k|        } else {
  244|       |            /* BARMER eGK doesn't include MF / DF.CIA_ESIGN / EF.CIA_Info
  245|       |             * just detect it via its specific AID */
  246|  8.37k|            if (SC_SUCCESS != sc_path_set(&path, SC_PATH_TYPE_DF_NAME,
  ------------------
  |  |   28|  8.37k|#define SC_SUCCESS				0
  ------------------
                          if (SC_SUCCESS != sc_path_set(&path, SC_PATH_TYPE_DF_NAME,
  ------------------
  |  |  118|  8.37k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (246:17): [True: 0, False: 8.37k]
  ------------------
  247|  8.37k|                        aid_gematik_egk, sizeof aid_gematik_egk, 0, 0)
  248|  8.37k|                    || SC_SUCCESS != sc_select_file(p15card->card, &path, NULL))
  ------------------
  |  |   28|  8.37k|#define SC_SUCCESS				0
  ------------------
  |  Branch (248:24): [True: 6.55k, False: 1.81k]
  ------------------
  249|  6.55k|                goto err;
  250|       |
  251|  1.81k|            tokeninfo->profile_indication.name = strdup("DIN V 66291");
  252|  1.81k|        }
  253|  9.23k|    }
  254|       |
  255|  1.81k|    if (SC_SUCCESS != sc_pkcs15emu_din_66291_init(p15card))
  ------------------
  |  |   28|  1.81k|#define SC_SUCCESS				0
  ------------------
  |  Branch (255:9): [True: 50, False: 1.76k]
  ------------------
  256|     50|        goto err;
  257|       |
  258|       |    /* save tokeninfo and file_tokeninfo */
  259|  1.76k|    sc_pkcs15_free_tokeninfo(p15card->tokeninfo);
  260|  1.76k|    sc_file_free(p15card->file_tokeninfo);
  261|  1.76k|    p15card->tokeninfo = tokeninfo;
  262|  1.76k|    p15card->file_tokeninfo = file_tokeninfo;
  263|  1.76k|    tokeninfo = NULL;
  264|  1.76k|    file_tokeninfo = NULL;
  265|       |
  266|       |    /* get the card serial number */
  267|  1.76k|    if (!p15card->tokeninfo->serial_number
  ------------------
  |  Branch (267:9): [True: 1.76k, False: 0]
  ------------------
  268|  1.76k|            && SC_SUCCESS == sc_card_ctl(p15card->card, SC_CARDCTL_GET_SERIALNR, &serial)) {
  ------------------
  |  |   28|  1.76k|#define SC_SUCCESS				0
  ------------------
  |  Branch (268:16): [True: 346, False: 1.42k]
  ------------------
  269|    346|        char serial_hex[SC_MAX_SERIALNR*2+2];
  270|    346|        sc_bin_to_hex(serial.value, serial.len , serial_hex, sizeof serial_hex, 0);
  271|    346|        set_string(&p15card->tokeninfo->serial_number, serial_hex);
  272|    346|    }
  273|       |
  274|  1.76k|    r = SC_SUCCESS;
  ------------------
  |  |   28|  1.76k|#define SC_SUCCESS				0
  ------------------
  275|       |
  276|  12.0k|err:
  277|  12.0k|    sc_pkcs15_free_tokeninfo(tokeninfo);
  278|  12.0k|    sc_file_free(file_tokeninfo);
  279|  12.0k|    free(tokeninfo_content);
  280|       |
  281|  12.0k|    return r;
  282|  1.76k|}
pkcs15-din-66291.c:sc_pkcs15emu_din_66291_init:
   42|  1.81k|{
   43|       |    /*  EF.C.CH.AUT
   44|       |     *  fileIdentifier ´C5 00´
   45|       |     *  shortFileIdentifier ´01´= 1 
   46|       |     *  PrK.CH.AUT 
   47|       |     *  keyIdentifier ´02´ = 2
   48|       |     *  privateKey …, Moduluslänge 2048 Bit 
   49|       |     *
   50|       |     *  EF.C.CH.ENC 
   51|       |     *  fileIdentifier ´C2 00´
   52|       |     *  shortFileIdentifier ´02´= 2
   53|       |     *  PrK.CH.ENC 
   54|       |     *  keyIdentifier ´03´ = 3
   55|       |     *  privateKey …, Moduluslänge 2048 Bit 
   56|       |     */
   57|  1.81k|    sc_path_t path;
   58|  1.81k|    size_t i;
   59|  1.81k|    struct sc_pin_cmd_data data;
   60|  1.81k|    const unsigned char user_pin_ref = 0x02;
   61|       |
   62|  1.81k|    sc_path_set(&path, SC_PATH_TYPE_DF_NAME, aid_ESIGN, sizeof aid_ESIGN, 0, 0);
  ------------------
  |  |  118|  1.81k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
   63|  1.81k|    if (SC_SUCCESS != sc_select_file(p15card->card, &path, NULL))
  ------------------
  |  |   28|  1.81k|#define SC_SUCCESS				0
  ------------------
  |  Branch (63:9): [True: 50, False: 1.76k]
  ------------------
   64|     50|        return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|     50|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   65|       |
   66|  1.76k|    memset(&data, 0, sizeof(data));
   67|  1.76k|    data.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|  1.76k|#define SC_PIN_CMD_GET_INFO	3
  ------------------
   68|  1.76k|    data.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|  1.76k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
   69|  1.76k|    data.pin_reference = user_pin_ref;
   70|       |
   71|  1.76k|    if (SC_SUCCESS == sc_pin_cmd(p15card->card, &data)) {
  ------------------
  |  |   28|  1.76k|#define SC_SUCCESS				0
  ------------------
  |  Branch (71:9): [True: 528, False: 1.23k]
  ------------------
   72|    528|        const unsigned char user_pin_id = 1;
   73|       |
   74|  1.58k|        for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (74:21): [True: 1.05k, False: 528]
  ------------------
   75|  1.05k|            const char *pin_names[3] = { "PIN", "PUK" };
   76|  1.05k|            const int pin_min[] = {6, 10};
   77|  1.05k|            const int pin_max[] = {8, 8};
   78|  1.05k|            const unsigned char user_puk_id = 2;
   79|  1.05k|            const int pin_id[] = {user_pin_id, user_puk_id};
   80|  1.05k|            const int pin_flags[] = {SC_PKCS15_PIN_FLAG_INITIALIZED,
  ------------------
  |  |   58|  1.05k|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
   81|  1.05k|                SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN|SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED};
  ------------------
  |  |   60|  1.05k|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
                              SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN|SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED};
  ------------------
  |  |   57|  1.05k|#define SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED		0x0008
  ------------------
   82|  1.05k|            const int max_tries[] = {3, 10};
   83|  1.05k|            struct sc_pkcs15_auth_info pin_info;
   84|  1.05k|            struct sc_pkcs15_object pin_obj;
   85|       |
   86|  1.05k|            memset(&pin_info, 0, sizeof(pin_info));
   87|  1.05k|            memset(&pin_obj, 0, sizeof(pin_obj));
   88|       |
   89|  1.05k|            pin_info.auth_id.value[0] = pin_id[i];
   90|  1.05k|            pin_info.auth_id.len = 1;
   91|  1.05k|            pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;	
  ------------------
  |  |   94|  1.05k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
   92|  1.05k|            pin_info.attrs.pin.flags = pin_flags[i];
   93|  1.05k|            pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|  1.05k|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
   94|  1.05k|            pin_info.attrs.pin.min_length = pin_min[i];
   95|  1.05k|            pin_info.attrs.pin.stored_length = pin_max[i];
   96|  1.05k|            pin_info.attrs.pin.max_length = pin_max[i];
   97|  1.05k|            pin_info.max_tries = max_tries[i];
   98|       |
   99|  1.05k|            strlcpy(pin_obj.label, pin_names[i], sizeof(pin_obj.label));
  ------------------
  |  |   43|  1.05k|#define strlcpy _strlcpy
  ------------------
  100|       |
  101|       |            /* catch the differences between PIN and PUK */
  102|  1.05k|            if (pin_flags[i] & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN) {
  ------------------
  |  |   60|  1.05k|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (102:17): [True: 528, False: 528]
  ------------------
  103|    528|                pin_info.tries_left = max_tries[i];
  104|    528|            } else {
  105|    528|                pin_info.attrs.pin.reference = user_pin_ref;
  106|    528|                pin_info.tries_left = data.pin1.tries_left;
  107|    528|                pin_info.logged_in = data.pin1.logged_in;
  108|    528|                pin_obj.auth_id.value[0] = user_puk_id;
  109|    528|                pin_obj.auth_id.len = 1;
  110|    528|            }
  111|       |
  112|  1.05k|            if (0 > sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info)) {
  ------------------
  |  Branch (112:17): [True: 0, False: 1.05k]
  ------------------
  113|      0|                sc_pkcs15_card_clear(p15card);
  114|      0|                return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  115|      0|            }
  116|  1.05k|        }
  117|       |
  118|  1.58k|        for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (118:21): [True: 1.05k, False: 528]
  ------------------
  119|  1.05k|            struct sc_aid aid;
  120|  1.05k|            const char *din_66291_cert_fids[] = { "C500", "C200"};
  121|  1.05k|            const char prk_id[] = { 0x10, 0x11,};
  122|  1.05k|            struct sc_pkcs15_cert_info cert_info;
  123|  1.05k|            struct sc_pkcs15_object cert_obj;
  124|  1.05k|            struct sc_pkcs15_prkey_info prkey_info;
  125|  1.05k|            struct sc_pkcs15_object prkey_obj;
  126|  1.05k|            const int prk_usage[2] = {
  127|  1.05k|                SC_PKCS15_PRKEY_USAGE_ENCRYPT
  ------------------
  |  |  305|  1.05k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
  128|  1.05k|                    | SC_PKCS15_PRKEY_USAGE_DECRYPT
  ------------------
  |  |  306|  1.05k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  129|  1.05k|                    | SC_PKCS15_PRKEY_USAGE_SIGN,
  ------------------
  |  |  307|  1.05k|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  130|  1.05k|                SC_PKCS15_PRKEY_USAGE_NONREPUDIATION};
  ------------------
  |  |  314|  1.05k|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  131|       |
  132|  1.05k|            memcpy(aid.value, aid_CIA, sizeof aid_CIA);
  133|  1.05k|            aid.len = sizeof aid_CIA;
  134|       |
  135|  1.05k|            memset(&prkey_info, 0, sizeof(prkey_info));
  136|  1.05k|            memset(&prkey_obj, 0, sizeof(prkey_obj));
  137|  1.05k|            memset(&cert_info, 0, sizeof(cert_info));
  138|  1.05k|            memset(&cert_obj, 0, sizeof(cert_obj));
  139|       |
  140|       |
  141|  1.05k|            sc_format_path(din_66291_cert_fids[i], &cert_info.path);
  142|  1.05k|            if (SC_SUCCESS != sc_select_file(p15card->card, &cert_info.path, NULL))
  ------------------
  |  |   28|  1.05k|#define SC_SUCCESS				0
  ------------------
  |  Branch (142:17): [True: 597, False: 459]
  ------------------
  143|    597|                continue;
  144|    459|            cert_info.path.aid = aid;
  145|       |
  146|    459|            cert_info.id.value[0] = prk_id[i];
  147|    459|            cert_info.id.len = 1;
  148|       |
  149|    459|            if (0 > sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info))
  ------------------
  |  Branch (149:17): [True: 0, False: 459]
  ------------------
  150|      0|                continue;
  151|       |
  152|    459|            if (i == 0) {
  ------------------
  |  Branch (152:17): [True: 368, False: 91]
  ------------------
  153|    368|                sc_pkcs15_cert_t *cert;
  154|    368|                if (SC_SUCCESS == sc_pkcs15_read_certificate(p15card, &cert_info, 0, &cert)) {
  ------------------
  |  |   28|    368|#define SC_SUCCESS				0
  ------------------
  |  Branch (154:21): [True: 0, False: 368]
  ------------------
  155|      0|                    static const struct sc_object_id cn_oid = {{ 2, 5, 4, 3, -1 }};
  156|      0|                    u8 *cn_name = NULL;
  157|      0|                    size_t cn_len = 0;
  158|      0|                    sc_pkcs15_get_name_from_dn(p15card->card->ctx, cert->subject,
  159|      0|                            cert->subject_len, &cn_oid, &cn_name, &cn_len);
  160|      0|                    if (cn_len > 0) {
  ------------------
  |  Branch (160:25): [True: 0, False: 0]
  ------------------
  161|      0|                        char *token_name = malloc(cn_len+1);
  162|      0|                        if (token_name) {
  ------------------
  |  Branch (162:29): [True: 0, False: 0]
  ------------------
  163|      0|                            memcpy(token_name, cn_name, cn_len);
  164|      0|                            token_name[cn_len] = '\0';
  165|      0|                            free(p15card->tokeninfo->label);
  166|      0|                            p15card->tokeninfo->label = token_name;
  167|      0|                        }
  168|      0|                    }
  169|      0|                    free(cn_name);
  170|      0|                    sc_pkcs15_free_certificate(cert);
  171|      0|                }
  172|    368|            }
  173|       |
  174|    459|            memset(&prkey_info, 0, sizeof(prkey_info));
  175|    459|            memset(&prkey_obj, 0, sizeof(prkey_obj));
  176|       |
  177|    459|            prkey_info.id.value[0] = prk_id[i];
  178|    459|            prkey_info.id.len = 1;
  179|    459|            prkey_info.usage  = prk_usage[i];
  180|    459|            prkey_info.native = 1;
  181|    459|            prkey_info.key_reference = prk_id[i];
  182|    459|            prkey_info.modulus_length = 2048;
  183|    459|            prkey_obj.auth_id.value[0] = user_pin_id;
  184|    459|            prkey_obj.auth_id.len = 1;
  185|    459|            prkey_obj.user_consent = 0;
  186|    459|            prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    459|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  187|       |
  188|    459|            if (0 > sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info))
  ------------------
  |  Branch (188:17): [True: 0, False: 459]
  ------------------
  189|      0|                continue;
  190|    459|        }
  191|    528|    }
  192|       |
  193|  1.76k|    return SC_SUCCESS;
  ------------------
  |  |   28|  1.76k|#define SC_SUCCESS				0
  ------------------
  194|  1.76k|}

sc_pkcs15emu_dnie_init_ex:
  281|  12.9k|{
  282|  12.9k|	int r=SC_SUCCESS;
  ------------------
  |  |   28|  12.9k|#define SC_SUCCESS				0
  ------------------
  283|  12.9k|	sc_context_t *ctx = p15card->card->ctx;
  284|  12.9k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  12.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  12.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  12.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  12.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 12.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  285|       |
  286|  12.9k|#if defined(ENABLE_OPENSSL) && defined(ENABLE_SM)
  287|       |	/* check for proper card */
  288|  12.9k|	r = dnie_match_card(p15card->card);
  289|  12.9k|	if (r == 0)
  ------------------
  |  Branch (289:6): [True: 12.1k, False: 748]
  ------------------
  290|  12.9k|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  12.1k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  12.1k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  12.1k|	int _ret = r; \
  |  |  |  |  155|  12.1k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  12.1k|		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|  12.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 12.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  12.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  12.1k|	} 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|  12.1k|	return _ret; \
  |  |  |  |  163|  12.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|       |	/* ok: initialize and return */
  292|    748|	LOG_FUNC_RETURN(ctx, sc_pkcs15emu_dnie_init(p15card));
  ------------------
  |  |  164|    748|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    748|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    748|	int _ret = r; \
  |  |  |  |  155|    748|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 748, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    748|		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|    748|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 748, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    748|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    748|	} 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|    748|	return _ret; \
  |  |  |  |  163|    748|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|       |#else
  294|       |	r = SC_ERROR_WRONG_CARD;
  295|       |	LOG_FUNC_RETURN(ctx, r);
  296|       |#endif
  297|    748|}
pkcs15-dnie.c:sc_pkcs15emu_dnie_init:
  139|    748|{
  140|    748|	u8 buf[1024];
  141|    748|	sc_pkcs15_df_t *df;
  142|    748|	sc_pkcs15_object_t *p15_obj;
  143|    748|	size_t len = sizeof(buf);
  144|    748|	int rv;
  145|    748|	struct sc_pkcs15_cert_info *p15_info = NULL;
  146|    748|	int use_pin_cache_backup = p15card->opts.use_pin_cache;
  147|       |
  148|    748|	sc_context_t *ctx = p15card->card->ctx;
  149|    748|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    748|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    748|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    748|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    748|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 748]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|       |
  151|       |	/* Check for correct card driver (i.e. iso7816) */
  152|    748|	if (strcmp(p15card->card->driver->short_name, "dnie") != 0)
  ------------------
  |  Branch (152:6): [True: 5, False: 743]
  ------------------
  153|      5|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      5|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  154|       |
  155|       |	/* Check for correct card atr */
  156|    743|	if (dnie_match_card(p15card->card) != 1)
  ------------------
  |  Branch (156:6): [True: 0, False: 743]
  ------------------
  157|      0|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  158|       |
  159|       |	/* The two keys inside DNIe 3.0 needs login before performing any signature.
  160|       |	 * They are CKA_ALWAYS_AUTHENTICATE although they are not tagged like that.
  161|       |	 * For the moment caching is forced if 3.0 is detected to make it work properly. */
  162|    743|	if (p15card->card->atr.value[15] >= DNIE_30_VERSION) {
  ------------------
  |  |  100|    743|#define DNIE_30_VERSION 0x04
  ------------------
  |  Branch (162:6): [True: 556, False: 187]
  ------------------
  163|    556|		p15card->opts.use_pin_cache = 1;
  164|    556|		p15card->opts.pin_cache_counter = DNIE_30_CACHE_COUNTER;
  ------------------
  |  |  101|    556|#define DNIE_30_CACHE_COUNTER 30000
  ------------------
  165|    556|		sc_log(ctx, "DNIe 3.0 detected - PKCS#15 options reset: use_file_cache=%d use_pin_cache=%d pin_cache_counter=%d pin_cache_ignore_user_consent=%d",
  ------------------
  |  |   71|    556|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  166|    556|			p15card->opts.use_file_cache,
  167|    556|			p15card->opts.use_pin_cache,
  168|    556|			p15card->opts.pin_cache_counter,
  169|    556|			p15card->opts.pin_cache_ignore_user_consent);
  170|    556|        }
  171|       |
  172|       |	/* Set root path of this application */
  173|    743|	sc_file_free(p15card->file_app);
  174|    743|	p15card->file_app = sc_file_new();
  175|    743|	if (NULL == p15card->file_app) {
  ------------------
  |  Branch (175:6): [True: 0, False: 743]
  ------------------
  176|      0|		rv = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|      0|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  177|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Can not create file.");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  178|      0|	}
  179|    743|	sc_format_path("3F00", &p15card->file_app->path);
  180|       |
  181|       |	/* Load TokenInfo */
  182|    743|	rv = dump_ef(p15card->card, "3F0050155032", buf, &len);
  183|    743|	LOG_TEST_GOTO_ERR(ctx, rv, "Reading of EF.TOKENINFO failed.");
  ------------------
  |  |  184|    743|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    743|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    743|	int _ret = (r); \
  |  |  |  |  178|    743|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 697, False: 46]
  |  |  |  |  ------------------
  |  |  |  |  179|    697|		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|    697|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    697|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    697|		goto err; \
  |  |  |  |  182|    697|	} \
  |  |  |  |  183|    743|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 46]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  184|       |
  185|     46|	rv = sc_pkcs15_parse_tokeninfo(p15card->card->ctx, p15card->tokeninfo,
  186|     46|				       buf, len);
  187|     46|	LOG_TEST_GOTO_ERR(ctx, rv, "Decoding of EF.TOKENINFO failed.");
  ------------------
  |  |  184|     46|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     46|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     46|	int _ret = (r); \
  |  |  |  |  178|     46|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 45, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  179|     45|		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|     45|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     45|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     45|		goto err; \
  |  |  |  |  182|     45|	} \
  |  |  |  |  183|     46|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|       |
  189|       |	/* Only accept the original stuff */
  190|      1|	if (strcmp(p15card->tokeninfo->manufacturer_id, "DGP-FNMT") != 0) {
  ------------------
  |  Branch (190:6): [True: 1, False: 0]
  ------------------
  191|      1|		rv = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      1|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  192|      1|		LOG_TEST_GOTO_ERR(ctx, rv, "Wrong card.");
  ------------------
  |  |  184|      1|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      1|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      1|	int _ret = (r); \
  |  |  |  |  178|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      1|		goto err; \
  |  |  |  |  182|      1|	} \
  |  |  |  |  183|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  193|      1|	}
  194|       |
  195|       |	/* Load ODF */
  196|      0|	rv = dump_ef(p15card->card, "3F0050155031", buf, &len);
  197|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "Reading of ODF failed.");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|       |
  199|      0|	rv = parse_odf(buf, len, p15card);
  200|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "Decoding of ODF failed.");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|       |
  202|       |	/* Decode EF.PrKDF, EF.PuKDF and EF.CDF */
  203|      0|	for (df = p15card->df_list; df != NULL; df = df->next) {
  ------------------
  |  Branch (203:30): [True: 0, False: 0]
  ------------------
  204|      0|		if (df->type == SC_PKCS15_PRKDF) {
  ------------------
  |  |  488|      0|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (204:7): [True: 0, False: 0]
  ------------------
  205|      0|			rv = sc_pkcs15_parse_df(p15card, df);
  206|      0|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (206:8): [True: 0, False: 0]
  ------------------
  207|      0|				sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  208|      0|				       "Decoding of EF.PrKDF (%s) failed: %d",
  209|      0|				       sc_print_path(&df->path), rv);
  210|      0|			}
  211|      0|		}
  212|      0|		if (df->type == SC_PKCS15_PUKDF) {
  ------------------
  |  |  489|      0|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (212:7): [True: 0, False: 0]
  ------------------
  213|      0|			rv = sc_pkcs15_parse_df(p15card, df);
  214|      0|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (214:8): [True: 0, False: 0]
  ------------------
  215|      0|				sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  216|      0|				       "Decoding of EF.PuKDF (%s) failed: %d",
  217|      0|				       sc_print_path(&df->path), rv);
  218|      0|			}
  219|      0|		}
  220|      0|		if (df->type == SC_PKCS15_CDF) {
  ------------------
  |  |  492|      0|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (220:7): [True: 0, False: 0]
  ------------------
  221|      0|			rv = sc_pkcs15_parse_df(p15card, df);
  222|      0|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (222:8): [True: 0, False: 0]
  ------------------
  223|      0|				sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  224|      0|				       "Decoding of EF.CDF (%s) failed: %d",
  225|      0|				       sc_print_path(&df->path), rv);
  226|      0|			}
  227|      0|		}
  228|      0|		if (df->type == SC_PKCS15_DODF) {
  ------------------
  |  |  495|      0|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (228:7): [True: 0, False: 0]
  ------------------
  229|      0|			rv = sc_pkcs15_parse_df(p15card, df);
  230|      0|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (230:8): [True: 0, False: 0]
  ------------------
  231|      0|				sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  232|      0|				       "Decoding of EF.DODF (%s) failed: %d",
  233|      0|				       sc_print_path(&df->path), rv);
  234|      0|			}
  235|      0|		}
  236|      0|	}
  237|       |
  238|       |	/* Perform required fixes */
  239|      0|	p15_obj = p15card->obj_list;
  240|      0|	while (p15_obj != NULL) {
  ------------------
  |  Branch (240:9): [True: 0, False: 0]
  ------------------
  241|       |		/* Add missing 'auth_id' to private objects */
  242|      0|		if ((p15_obj->flags & SC_PKCS15_CO_FLAG_PRIVATE)
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (242:7): [True: 0, False: 0]
  ------------------
  243|      0|		    && (p15_obj->auth_id.len == 0)) {
  ------------------
  |  Branch (243:10): [True: 0, False: 0]
  ------------------
  244|      0|			p15_obj->auth_id.value[0] = 0x01;
  245|      0|			p15_obj->auth_id.len = 1;
  246|      0|		};
  247|       |		/* Set path count to -1 for public certificates, as they
  248|       |		   will need to be decompressed and read_binary()'d, so
  249|       |		   we make sure we end up reading the file->size and not the
  250|       |		   path->count which is the compressed size on newer
  251|       |                   DNIe versions  */
  252|      0|		if ( p15_obj->df && (p15_obj->df->type == SC_PKCS15_CDF) ) {
  ------------------
  |  |  492|      0|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (252:8): [True: 0, False: 0]
  |  Branch (252:23): [True: 0, False: 0]
  ------------------
  253|      0|                    p15_info = (struct sc_pkcs15_cert_info *) p15_obj ->data;
  254|      0|		    p15_info ->path.count = -1;
  255|      0|		}
  256|       |		/* Remove found public keys as cannot be read_binary()'d */
  257|      0|		if ( p15_obj->df && (p15_obj->df->type == SC_PKCS15_PUKDF) ) {
  ------------------
  |  |  489|      0|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (257:8): [True: 0, False: 0]
  |  Branch (257:23): [True: 0, False: 0]
  ------------------
  258|      0|			sc_pkcs15_object_t *puk = p15_obj;
  259|      0|			p15_obj = p15_obj->next;
  260|      0|			sc_pkcs15_remove_object(p15card, puk);
  261|      0|			sc_pkcs15_free_object(puk);
  262|      0|                } else {
  263|      0|			p15_obj = p15_obj->next;
  264|      0|		}
  265|      0|	}
  266|       |	
  267|      0|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  268|       |
  269|    743|err:
  270|    743|	sc_pkcs15_card_clear(p15card);
  271|    743|	p15card->opts.use_pin_cache = use_pin_cache_backup;
  272|    743|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    743|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    743|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    743|	int _ret = r; \
  |  |  |  |  155|    743|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 743, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    743|		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|    743|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 743, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    743|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    743|	} 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|    743|	return _ret; \
  |  |  |  |  163|    743|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  273|    743|}
pkcs15-dnie.c:dump_ef:
   42|    743|{
   43|    743|	int rv;
   44|    743|	sc_file_t *file = NULL;
   45|    743|	sc_path_t scpath;
   46|    743|	sc_format_path(path, &scpath);
   47|    743|	rv = sc_select_file(card, &scpath, &file);
   48|    743|	if (rv < 0) {
  ------------------
  |  Branch (48:6): [True: 664, False: 79]
  ------------------
   49|    664|		sc_file_free(file);
   50|    664|		return rv;
   51|    664|	}
   52|     79|	if (file->size > *buf_len) {
  ------------------
  |  Branch (52:6): [True: 30, False: 49]
  ------------------
   53|     30|		sc_file_free(file);
   54|     30|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|     30|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
   55|     30|	}
   56|     49|	rv = sc_read_binary(card, 0, buf, file->size, 0);
   57|     49|	sc_file_free(file);
   58|     49|	if (rv < 0)
  ------------------
  |  Branch (58:6): [True: 3, False: 46]
  ------------------
   59|      3|		return rv;
   60|     46|	*buf_len = rv;
   61|       |
   62|     46|	return SC_SUCCESS;
  ------------------
  |  |   28|     46|#define SC_SUCCESS				0
  ------------------
   63|     49|}

sc_pkcs15emu_dtrust_init_ex:
  125|  10.1k|{
  126|  10.1k|	if (dtrust_pkcs15emu_detect_card(p15card))
  ------------------
  |  Branch (126:6): [True: 10.1k, False: 0]
  ------------------
  127|  10.1k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  10.1k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  128|       |
  129|      0|	return sc_pkcs15emu_dtrust_init(p15card, aid);
  130|  10.1k|}
pkcs15-dtrust.c:dtrust_pkcs15emu_detect_card:
   82|  10.1k|{
   83|  10.1k|	if (p15card->card->type < SC_CARD_TYPE_DTRUST_V4_1_STD)
  ------------------
  |  Branch (83:6): [True: 9.85k, False: 296]
  ------------------
   84|  9.85k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  9.85k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   85|       |
   86|    296|	if (p15card->card->type > SC_CARD_TYPE_DTRUST_V5_4_MULTI)
  ------------------
  |  Branch (86:6): [True: 296, False: 0]
  ------------------
   87|    296|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|    296|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   88|       |
   89|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
   90|    296|}

sc_pkcs15emu_eoi_init_ex:
   35|  10.1k|{
   36|  10.1k|	struct sc_card *card = p15card->card;
   37|  10.1k|	struct eoi_privdata *privdata = (struct eoi_privdata *)card->drv_data;
   38|  10.1k|	struct sc_pkcs15_search_key sk;
   39|  10.1k|	struct sc_pkcs15_object *objs[MAX_OBJECTS];
   40|  10.1k|	int i, j, len;
   41|       |
   42|  10.1k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  10.1k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  10.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  10.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  10.1k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   43|       |
   44|  10.1k|	if (card->type != SC_CARD_TYPE_EOI && card->type != SC_CARD_TYPE_EOI_CONTACTLESS)
  ------------------
  |  Branch (44:6): [True: 10.1k, False: 22]
  |  Branch (44:40): [True: 10.1k, False: 0]
  ------------------
   45|  10.1k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  10.1k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  10.1k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  10.1k|	int _ret = r; \
  |  |  |  |  155|  10.1k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  10.1k|		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|  10.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  10.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  10.1k|	} 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|  10.1k|	return _ret; \
  |  |  |  |  163|  10.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   46|       |
   47|     22|	if (!privdata)
  ------------------
  |  Branch (47:6): [True: 0, False: 22]
  ------------------
   48|     22|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   49|       |
   50|       |	/*
   51|       |	 * Some of the data is not accessible over the unencrypted channel
   52|       |	 * when contactless reader is used. So start SM now (if not yet established).
   53|       |	 */
   54|     22|	if (card->type == SC_CARD_TYPE_EOI_CONTACTLESS && card->sm_ctx.sm_mode == SM_MODE_NONE) {
  ------------------
  |  |   43|      0|#define SM_MODE_NONE		0x0
  ------------------
  |  Branch (54:6): [True: 0, False: 22]
  |  Branch (54:52): [True: 0, False: 0]
  ------------------
   55|      0|		int r = card->sm_ctx.ops.open(card);
   56|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (56:7): [True: 0, False: 0]
  ------------------
   57|      0|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   58|      0|	}
   59|       |
   60|       |	/*
   61|       |	 * Get the card objects, so we can manipulate them. See below
   62|       |	 */
   63|     22|	LOG_TEST_RET(card->ctx, sc_pkcs15_bind_internal(p15card, aid),
  ------------------
  |  |  174|     22|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     22|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     22|	int _ret = (r); \
  |  |  |  |  168|     22|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 20, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  169|     20|		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|     20|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     20|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     20|		return _ret; \
  |  |  |  |  172|     20|	} \
  |  |  |  |  173|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|      2|		"sc_pkcs15_bind_internal failed");
   65|       |
   66|       |	/*
   67|       |	 * PIN objects:
   68|       |	 * 1) Find the "Card CAN" PIN and store it's path, so we'll be able to fetch the CAN and do the PACE auth
   69|       |	 * 2) Add PIN's auth_info->path to the list of paths that can fail on select. sc_pin_cmd would break otherwise
   70|       |	 */
   71|      2|	memset(&sk, 0, sizeof(sk));
   72|      2|	sk.class_mask = SC_PKCS15_SEARCH_CLASS_AUTH;
  ------------------
  |  |  455|      2|#define SC_PKCS15_SEARCH_CLASS_AUTH		0x0040U
  ------------------
   73|      2|	len = sc_pkcs15_search_objects(p15card, &sk, (struct sc_pkcs15_object **)&objs, MAX_OBJECTS);
  ------------------
  |  |   24|      2|#define MAX_OBJECTS 8
  ------------------
   74|      2|	for (i = 0, j = 0; i < len; i++) {
  ------------------
  |  Branch (74:21): [True: 0, False: 2]
  ------------------
   75|      0|		struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)objs[i]->data;
   76|      0|		if (auth_info && auth_info->auth_id.len == 8 && !strcmp((char*)auth_info->auth_id.value, "Card CAN")) {
  ------------------
  |  Branch (76:7): [True: 0, False: 0]
  |  Branch (76:20): [True: 0, False: 0]
  |  Branch (76:51): [True: 0, False: 0]
  ------------------
   77|      0|			auth_info->path.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
   78|       |			/* Read the file that contains serial and encrypted CAN */
   79|      0|			if (sc_pkcs15_read_file(p15card, &auth_info->path, &privdata->enc_can.value, &privdata->enc_can.len, 0) == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (79:8): [True: 0, False: 0]
  ------------------
   80|       |				/* File should be 24 bytes long */
   81|      0|				if (privdata->enc_can.len != 24)
  ------------------
  |  Branch (81:9): [True: 0, False: 0]
  ------------------
   82|      0|					LOG_FUNC_RETURN(card->ctx, SC_ERROR_CORRUPTED_DATA);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   83|      0|				if (strlen(p15card->tokeninfo->serial_number) != 20)
  ------------------
  |  Branch (83:9): [True: 0, False: 0]
  ------------------
   84|      0|					LOG_FUNC_RETURN(card->ctx, SC_ERROR_CORRUPTED_DATA);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   85|       |				/* First 8 bytes are used as serial number */
   86|      0|				sc_bin_to_hex(privdata->enc_can.value, 8, &p15card->tokeninfo->serial_number[4], 17, 0);
   87|      0|			}
   88|       |			/* Do not add "Card CAN" to the list of PIN paths to ignore, otherwise the 2nd PKCS#15 app can not access it */
   89|      0|			auth_info = NULL;
   90|       |			/* Mark "Card CAN" as NOT a PIN object, so that it doesn't get it's own PKCS#11 slot */
   91|      0|			objs[i]->type &= ~SC_PKCS15_TYPE_AUTH_PIN;
  ------------------
  |  |  445|      0|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
   92|      0|		}
   93|       |		/*
   94|       |		 * For some reason QES app has "Norm PUK" not flagged as unblocking PIN and thus "Norm PUK" appears as a slot in
   95|       |		 * PKCS#11. Flag it as unblockingPin, so it doesn't appear as a separate slot.
   96|       |		 */
   97|      0|		if (auth_info && auth_info->auth_id.len == 8 && !strcmp((char*)auth_info->auth_id.value, "Norm PUK")) {
  ------------------
  |  Branch (97:7): [True: 0, False: 0]
  |  Branch (97:20): [True: 0, False: 0]
  |  Branch (97:51): [True: 0, False: 0]
  ------------------
   98|      0|			auth_info->attrs.pin.flags |= SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN;
  ------------------
  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
   99|      0|		}
  100|      0|		if (auth_info) {
  ------------------
  |  Branch (100:7): [True: 0, False: 0]
  ------------------
  101|      0|			privdata->pin_paths[j++] = &auth_info->path;
  102|      0|		}
  103|      0|	}
  104|       |
  105|       |	/*
  106|       |	 * Private key objects:
  107|       |	 * 1) Rename "Card PIN" to "Norm PIN" as it's the later name that is used throughout the PKCS#15 objects
  108|       |	 * 2) Add the key references to the prkey_mappings array, as it seems that eOI expects them counted from 0xA0 up (starting from 1 within each app)
  109|       |	 *    Currently there are 3 private keys on the card
  110|       |	 *     key_ref
  111|       |	 *       2 - for pinless entry (Prijava brez PIN-a), maps to 0xA1
  112|       |	 *       1 - for authentication in QES app (Podpis in prijava), maps to 0xA1
  113|       |	 *       3 - for signing in QES app (Podpis in prijava), maps to 0xA2
  114|       |	 */
  115|      2|	memset(&sk, 0, sizeof(sk));
  116|      2|	sk.class_mask = SC_PKCS15_SEARCH_CLASS_PRKEY;
  ------------------
  |  |  450|      2|#define SC_PKCS15_SEARCH_CLASS_PRKEY		0x0002U
  ------------------
  117|      2|	len = sc_pkcs15_search_objects(p15card, &sk, (struct sc_pkcs15_object **)&objs, MAX_OBJECTS);
  ------------------
  |  |   24|      2|#define MAX_OBJECTS 8
  ------------------
  118|       |	/*
  119|       |	 * If both PKCS#15 apps are enabled, prkey_mappings can already be partially filled up from the first PKCS#15 app
  120|       |	 * as the privdata is shared between both apps which use the same driver
  121|       |	  */
  122|      2|	for (j = 0; j < MAX_OBJECTS && privdata->prkey_mappings[j][1] != 0; j++) {
  ------------------
  |  |   24|      4|#define MAX_OBJECTS 8
  ------------------
  |  Branch (122:14): [True: 2, False: 0]
  |  Branch (122:33): [True: 0, False: 2]
  ------------------
  123|       |		/* NOP */
  124|      0|	}
  125|      2|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (125:14): [True: 0, False: 2]
  ------------------
  126|      0|		struct sc_pkcs15_prkey_info *prkey_info = (struct sc_pkcs15_prkey_info *)objs[i]->data;
  127|      0|		if ((objs[i]->auth_id.len == 8) && !strncmp((char*)objs[i]->auth_id.value, "Card PIN", 8)) {
  ------------------
  |  Branch (127:7): [True: 0, False: 0]
  |  Branch (127:38): [True: 0, False: 0]
  ------------------
  128|      0|			memcpy(objs[i]->auth_id.value, "Norm PIN", 8);
  129|      0|		}
  130|      0|		if (prkey_info && j < MAX_OBJECTS) {
  ------------------
  |  |   24|      0|#define MAX_OBJECTS 8
  ------------------
  |  Branch (130:7): [True: 0, False: 0]
  |  Branch (130:21): [True: 0, False: 0]
  ------------------
  131|      0|			privdata->prkey_mappings[j][0] = prkey_info->key_reference;
  132|      0|			privdata->prkey_mappings[j++][1] = 0xA0 + (i + 1);
  133|      0|		}
  134|      0|	}
  135|       |
  136|      2|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  137|      2|}

sc_pkcs15emu_entersafe_init_ex:
   79|  13.0k|{
   80|  13.0k|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  13.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  13.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  13.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 13.0k]
  |  |  ------------------
  ------------------
   81|       |
   82|  13.0k|	if (entersafe_detect_card(p15card))
  ------------------
  |  Branch (82:6): [True: 12.7k, False: 310]
  ------------------
   83|  12.7k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.7k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   84|    310|	return sc_pkcs15emu_entersafe_init(p15card);
   85|  13.0k|}
pkcs15-esinit.c:entersafe_detect_card:
   33|  13.0k|{
   34|  13.0k|	sc_card_t *card = p15card->card;
   35|       |
   36|  13.0k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  13.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  13.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  13.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 13.0k]
  |  |  ------------------
  ------------------
   37|       |
   38|       |	/* check if we have the correct card OS */
   39|  13.0k|	if (strcmp(card->name, "entersafe"))
  ------------------
  |  Branch (39:6): [True: 12.7k, False: 310]
  ------------------
   40|  12.7k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.7k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   41|       |
   42|    310|    return SC_SUCCESS;
  ------------------
  |  |   28|    310|#define SC_SUCCESS				0
  ------------------
   43|  13.0k|}
pkcs15-esinit.c:sc_pkcs15emu_entersafe_init:
   46|    310|{
   47|    310|	int    r;
   48|    310|	char   buf[256];
   49|    310|	sc_card_t *card = p15card->card;
   50|    310|	sc_serial_number_t serial;
   51|       |
   52|    310|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    310|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    310|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    310|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 310]
  |  |  ------------------
  ------------------
   53|       |
   54|       |	/* get serial number */
   55|    310|	r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
   56|    310|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    310|#define SC_SUCCESS				0
  ------------------
  |  Branch (56:6): [True: 294, False: 16]
  ------------------
   57|    294|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    294|#define SC_ERROR_INTERNAL			-1400
  ------------------
   58|     16|	r = sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
   59|     16|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     16|#define SC_SUCCESS				0
  ------------------
  |  Branch (59:6): [True: 0, False: 16]
  ------------------
   60|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   61|       |
   62|     16|	set_string(&p15card->tokeninfo->serial_number, buf);
   63|     16|	if (!p15card->tokeninfo->serial_number)
  ------------------
  |  Branch (63:6): [True: 0, False: 16]
  ------------------
   64|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   65|       |
   66|       |	/* the manufacturer ID, in this case Giesecke & Devrient GmbH */
   67|     16|	set_string(&p15card->tokeninfo->manufacturer_id, MANU_ID);
  ------------------
  |  |   30|     16|#define MANU_ID		"entersafe"
  ------------------
   68|     16|	if (!p15card->tokeninfo->manufacturer_id) {
  ------------------
  |  Branch (68:6): [True: 0, False: 16]
  ------------------
   69|      0|		free(p15card->tokeninfo->serial_number);
   70|      0|		p15card->tokeninfo->serial_number = NULL;
   71|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   72|      0|	}
   73|       |
   74|     16|	return SC_SUCCESS;
  ------------------
  |  |   28|     16|#define SC_SUCCESS				0
  ------------------
   75|     16|}

sc_pkcs15emu_esteid2018_init_ex:
  256|  10.2k|int sc_pkcs15emu_esteid2018_init_ex(sc_pkcs15_card_t *p15card, struct sc_aid *aid) {
  257|  10.2k|	if (p15card->card->type == SC_CARD_TYPE_ESTEID_2018 ||
  ------------------
  |  Branch (257:6): [True: 0, False: 10.2k]
  ------------------
  258|  10.2k|			p15card->card->type == SC_CARD_TYPE_ESTEID_2018_V2_2025 ||
  ------------------
  |  Branch (258:4): [True: 0, False: 10.2k]
  ------------------
  259|  10.2k|			is_latvian_eid(p15card))
  ------------------
  |  Branch (259:4): [True: 0, False: 10.2k]
  ------------------
  260|      0|		return sc_pkcs15emu_esteid2018_init(p15card);
  261|  10.2k|	return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  10.2k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  262|  10.2k|}
pkcs15-esteid2018.c:is_latvian_eid:
   38|  10.2k|{
   39|  10.2k|	return p15card->card->type == SC_CARD_TYPE_LATEID_2018 ||
  ------------------
  |  Branch (39:9): [True: 0, False: 10.2k]
  ------------------
   40|  10.2k|	       p15card->card->type == SC_CARD_TYPE_LATEID_2018_V2_2025;
  ------------------
  |  Branch (40:9): [True: 0, False: 10.2k]
  ------------------
   41|  10.2k|}

sc_pkcs15emu_esteid2025_init_ex:
  260|  10.2k|{
  261|  10.2k|	if (p15card->card->type == SC_CARD_TYPE_ESTEID_2025 || is_fin_eid(p15card))
  ------------------
  |  Branch (261:6): [True: 0, False: 10.2k]
  |  Branch (261:57): [True: 0, False: 10.2k]
  ------------------
  262|      0|		return sc_pkcs15emu_esteid2025_init(p15card);
  263|  10.2k|	return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  10.2k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  264|  10.2k|}
pkcs15-esteid2025.c:is_fin_eid:
   37|  10.2k|{
   38|  10.2k|	return p15card->card->type == SC_CARD_TYPE_FINEID_2022 ||
  ------------------
  |  Branch (38:9): [True: 0, False: 10.2k]
  ------------------
   39|  10.2k|	       p15card->card->type == SC_CARD_TYPE_FINEID_2025;
  ------------------
  |  Branch (39:9): [True: 0, False: 10.2k]
  ------------------
   40|  10.2k|}

sc_pkcs15emu_gemsafeV1_init_ex:
  451|  13.0k|{
  452|  13.0k|	if (gemsafe_detect_card(p15card))
  ------------------
  |  Branch (452:6): [True: 12.2k, False: 764]
  ------------------
  453|  12.2k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.2k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  454|    764|	return sc_pkcs15emu_gemsafeV1_init(p15card);
  455|  13.0k|}
pkcs15-gemsafeV1.c:gemsafe_detect_card:
  298|  13.0k|{
  299|  13.0k|	if (strcmp(p15card->card->name, "GemSAFE V1"))
  ------------------
  |  Branch (299:6): [True: 12.2k, False: 764]
  ------------------
  300|  12.2k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.2k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  301|       |
  302|    764|	return SC_SUCCESS;
  ------------------
  |  |   28|    764|#define SC_SUCCESS				0
  ------------------
  303|  13.0k|}
pkcs15-gemsafeV1.c:sc_pkcs15emu_gemsafeV1_init:
  306|    764|{
  307|    764|	int		    r;
  308|    764|	unsigned int    i;
  309|    764|	struct sc_path  path;
  310|    764|	struct sc_file *file = NULL;
  311|    764|	struct sc_card *card = p15card->card;
  312|    764|	struct sc_apdu  apdu;
  313|    764|	u8		    rbuf[SC_MAX_APDU_BUFFER_SIZE];
  314|       |
  315|    764|	sc_log(p15card->card->ctx, "Setting pkcs15 parameters");
  ------------------
  |  |   71|    764|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  316|       |
  317|    764|	set_string(&p15card->tokeninfo->label, APPLET_NAME);
  ------------------
  |  |   32|    764|#define APPLET_NAME		"GemSAFE V1"
  ------------------
  318|    764|	if (!p15card->tokeninfo->label)
  ------------------
  |  Branch (318:6): [True: 0, False: 764]
  ------------------
  319|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  320|       |
  321|    764|	set_string(&p15card->tokeninfo->serial_number, DRIVER_SERIAL_NUMBER);
  ------------------
  |  |   33|    764|#define DRIVER_SERIAL_NUMBER	"v0.9"
  ------------------
  322|    764|	if (!p15card->tokeninfo->serial_number) {
  ------------------
  |  Branch (322:6): [True: 0, False: 764]
  ------------------
  323|      0|		free(p15card->tokeninfo->label);
  324|      0|		p15card->tokeninfo->label = NULL;
  325|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  326|      0|	}
  327|       |
  328|       |	/* the GemSAFE applet version number */
  329|    764|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0xdf, 0x03);
  ------------------
  |  |  292|    764|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  330|    764|	apdu.cla = 0x80;
  331|    764|	apdu.resp = rbuf;
  332|    764|	apdu.resplen = sizeof(rbuf);
  333|       |	/* Manual says Le=0x05, but should be 0x08 to return full version number */
  334|    764|	apdu.le = 0x08;
  335|    764|	apdu.lc = 0;
  336|    764|	apdu.datalen = 0;
  337|    764|	r = sc_transmit_apdu(card, &apdu);
  338|    764|	if (r < 0)
  ------------------
  |  Branch (338:6): [True: 28, False: 736]
  ------------------
  339|     28|		sc_pkcs15_card_clear(p15card);
  340|    764|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    764|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    764|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    764|	int _ret = (r); \
  |  |  |  |  168|    764|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 28, False: 736]
  |  |  |  |  ------------------
  |  |  |  |  169|     28|		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|     28|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     28|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     28|		return _ret; \
  |  |  |  |  172|     28|	} \
  |  |  |  |  173|    764|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 736]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|       |
  342|    736|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00 || r != SC_SUCCESS) {
  ------------------
  |  |   28|    252|#define SC_SUCCESS				0
  ------------------
  |  Branch (342:6): [True: 447, False: 289]
  |  Branch (342:26): [True: 37, False: 252]
  |  Branch (342:46): [True: 0, False: 252]
  ------------------
  343|    484|		sc_pkcs15_card_clear(p15card);
  344|    484|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    484|#define SC_ERROR_INTERNAL			-1400
  ------------------
  345|    484|	}
  346|       |
  347|       |	/* the manufacturer ID, in this case GemPlus */
  348|    252|	set_string(&p15card->tokeninfo->manufacturer_id, MANU_ID);
  ------------------
  |  |   31|    252|#define MANU_ID			"Gemplus"
  ------------------
  349|    252|	if (!p15card->tokeninfo->manufacturer_id) {
  ------------------
  |  Branch (349:6): [True: 0, False: 252]
  ------------------
  350|      0|		sc_pkcs15_card_clear(p15card);
  351|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  352|      0|	}
  353|       |
  354|       |	/* determine allocated key containers and length of certificates */
  355|    252|	r = gemsafe_get_cert_len(card);
  356|    252|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    252|#define SC_SUCCESS				0
  ------------------
  |  Branch (356:6): [True: 187, False: 65]
  ------------------
  357|    187|		sc_pkcs15_card_clear(p15card);
  358|    187|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    187|#define SC_ERROR_INTERNAL			-1400
  ------------------
  359|    187|	}
  360|       |
  361|       |	/* set certs */
  362|     65|	sc_log(p15card->card->ctx, "Setting certificates");
  ------------------
  |  |   71|     65|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  363|    845|	for (i = 0; i < gemsafe_cert_max; i++) {
  ------------------
  |  Branch (363:14): [True: 780, False: 65]
  ------------------
  364|    780|		struct sc_pkcs15_id p15Id;
  365|    780|		struct sc_path path;
  366|       |
  367|    780|		if (gemsafe_cert[i].label == NULL)
  ------------------
  |  Branch (367:7): [True: 780, False: 0]
  ------------------
  368|    780|			continue;
  369|      0|		sc_format_path(gemsafe_cert[i].path, &path);
  370|      0|		sc_pkcs15_format_id(gemsafe_cert[i].id, &p15Id);
  371|      0|		path.index = gemsafe_cert[i].index;
  372|      0|		path.count = gemsafe_cert[i].count;
  373|      0|		sc_pkcs15emu_add_cert(p15card, SC_PKCS15_TYPE_CERT_X509,
  ------------------
  |  |  439|      0|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  374|      0|				      gemsafe_cert[i].authority, &path, &p15Id,
  375|      0|				      gemsafe_cert[i].label, gemsafe_cert[i].obj_flags);
  376|      0|	}
  377|       |
  378|       |	/* set gemsafe_pin */
  379|     65|	sc_log(p15card->card->ctx, "Setting PIN");
  ------------------
  |  |   71|     65|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  380|    130|	for (i=0; i < gemsafe_pin_max; i++) {
  ------------------
  |  Branch (380:12): [True: 130, False: 0]
  ------------------
  381|    130|		struct sc_pkcs15_id	p15Id;
  382|    130|		struct sc_path path;
  383|       |
  384|    130|		sc_pkcs15_format_id(gemsafe_pin[i].id, &p15Id);
  385|    130|		sc_format_path(gemsafe_pin[i].path, &path);
  386|    130|		if (gemsafe_pin[i].atr_len == 0 ||
  ------------------
  |  Branch (386:7): [True: 65, False: 65]
  ------------------
  387|     65|		   (gemsafe_pin[i].atr_len == p15card->card->atr.len &&
  ------------------
  |  Branch (387:7): [True: 0, False: 65]
  ------------------
  388|      0|		    memcmp(p15card->card->atr.value, gemsafe_pin[i].atr,
  ------------------
  |  Branch (388:7): [True: 0, False: 0]
  ------------------
  389|     65|			   p15card->card->atr.len) == 0)) {
  390|     65|			sc_pkcs15emu_add_pin(p15card, &p15Id, gemsafe_pin[i].label,
  391|     65|					     &path, gemsafe_pin[i].ref, gemsafe_pin[i].type,
  392|     65|					     gemsafe_pin[i].minlen, gemsafe_pin[i].maxlen,
  393|     65|					     gemsafe_pin[i].flags, gemsafe_pin[i].tries_left,
  394|     65|					     gemsafe_pin[i].pad_char, gemsafe_pin[i].obj_flags);
  395|     65|			break;
  396|     65|		}
  397|    130|	};
  398|       |
  399|       |	/* set private keys */
  400|     65|	sc_log(p15card->card->ctx, "Setting private keys");
  ------------------
  |  |   71|     65|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  401|    845|	for (i = 0; i < gemsafe_cert_max; i++) {
  ------------------
  |  Branch (401:14): [True: 780, False: 65]
  ------------------
  402|    780|		struct sc_pkcs15_id p15Id, authId, *pauthId;
  403|    780|		struct sc_path path;
  404|    780|		int key_ref = 0x03;
  405|       |
  406|    780|		if (gemsafe_prkeys[i].label == NULL)
  ------------------
  |  Branch (406:7): [True: 780, False: 0]
  ------------------
  407|    780|			continue;
  408|      0|		sc_pkcs15_format_id(gemsafe_prkeys[i].id, &p15Id);
  409|      0|		if (gemsafe_prkeys[i].auth_id) {
  ------------------
  |  Branch (409:7): [True: 0, False: 0]
  ------------------
  410|      0|			sc_pkcs15_format_id(gemsafe_prkeys[i].auth_id, &authId);
  411|      0|			pauthId = &authId;
  412|      0|		} else
  413|      0|			pauthId = NULL;
  414|      0|		sc_format_path(gemsafe_prkeys[i].path, &path);
  415|       |		/*
  416|       |		 * The key ref may be different for different sites;
  417|       |		 * by adding flags=n where the low order 4 bits can be
  418|       |		 * the key ref we can force it.
  419|       |		 */
  420|      0|		if ( p15card->card->flags & 0x0F) {
  ------------------
  |  Branch (420:8): [True: 0, False: 0]
  ------------------
  421|      0|			key_ref = p15card->card->flags & 0x0F;
  422|      0|			sc_log(p15card->card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  423|      0|				 "Overriding key_ref %d with %d\n",
  424|      0|				 gemsafe_prkeys[i].ref, key_ref);
  425|      0|		} else
  426|      0|			key_ref = gemsafe_prkeys[i].ref;
  427|      0|		sc_pkcs15emu_add_prkey(p15card, &p15Id, gemsafe_prkeys[i].label,
  428|      0|				       SC_PKCS15_TYPE_PRKEY_RSA,
  ------------------
  |  |  419|      0|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  429|      0|				       gemsafe_prkeys[i].modulus_len, gemsafe_prkeys[i].usage,
  430|      0|				       &path, key_ref, pauthId,
  431|      0|				       gemsafe_prkeys[i].obj_flags);
  432|      0|	}
  433|       |
  434|       |	/* select the application DF */
  435|     65|	sc_log(p15card->card->ctx, "Selecting application DF");
  ------------------
  |  |   71|     65|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  436|     65|	sc_format_path(GEMSAFE_APP_PATH, &path);
  ------------------
  |  |   34|     65|#define GEMSAFE_APP_PATH	"3F001600"
  ------------------
  437|     65|	r = sc_select_file(card, &path, &file);
  438|     65|	if (r != SC_SUCCESS || !file) {
  ------------------
  |  |   28|    130|#define SC_SUCCESS				0
  ------------------
  |  Branch (438:6): [True: 39, False: 26]
  |  Branch (438:25): [True: 0, False: 26]
  ------------------
  439|     39|		sc_pkcs15_card_clear(p15card);
  440|     39|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     39|#define SC_ERROR_INTERNAL			-1400
  ------------------
  441|     39|	}
  442|       |	/* set the application DF */
  443|     26|	sc_file_free(p15card->file_app);
  444|     26|	p15card->file_app = file;
  445|       |
  446|     26|	return SC_SUCCESS;
  ------------------
  |  |   28|     26|#define SC_SUCCESS				0
  ------------------
  447|     65|}
pkcs15-gemsafeV1.c:gemsafe_get_cert_len:
  163|    252|{
  164|    252|	int r;
  165|    252|	u8  ibuf[GEMSAFE_MAX_OBJLEN];
  166|    252|	u8 *iptr;
  167|    252|	struct sc_path path;
  168|    252|	struct sc_file *file;
  169|    252|	size_t objlen;
  170|    252|	int certlen;
  171|    252|	unsigned int ind, i=0;
  172|    252|	int read_len;
  173|       |
  174|    252|	sc_format_path(GEMSAFE_PATH, &path);
  ------------------
  |  |   35|    252|#define GEMSAFE_PATH		"3F0016000004"
  ------------------
  175|    252|	r = sc_select_file(card, &path, &file);
  176|    252|	if (r != SC_SUCCESS || !file)
  ------------------
  |  |   28|    504|#define SC_SUCCESS				0
  ------------------
  |  Branch (176:6): [True: 39, False: 213]
  |  Branch (176:25): [True: 0, False: 213]
  ------------------
  177|     39|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     39|#define SC_ERROR_INTERNAL			-1400
  ------------------
  178|    213|	sc_file_free(file);
  179|       |
  180|       |	/* Initial read */
  181|    213|	read_len = sc_read_binary(card, 0, ibuf, GEMSAFE_READ_QUANTUM, 0);
  ------------------
  |  |   40|    213|#define GEMSAFE_READ_QUANTUM    248
  ------------------
  182|    213|	if (read_len <= 2) {
  ------------------
  |  Branch (182:6): [True: 23, False: 190]
  ------------------
  183|     23|		sc_log(card->ctx, "Invalid size of object data: %d", read_len);
  ------------------
  |  |   71|     23|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  184|     23|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     23|#define SC_ERROR_INTERNAL			-1400
  ------------------
  185|     23|	}
  186|       |
  187|       |	/* Actual stored object size is encoded in first 2 bytes
  188|       |	 * (allocated EF space is much greater!)
  189|       |	 */
  190|    190|	objlen = (((size_t) ibuf[0]) << 8) | ibuf[1];
  191|    190|	sc_log(card->ctx, "Stored object is of size: %zu", objlen);
  ------------------
  |  |   71|    190|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  192|    190|	if (objlen < 1 || objlen > GEMSAFE_MAX_OBJLEN) {
  ------------------
  |  |   41|    186|#define GEMSAFE_MAX_OBJLEN      28672
  ------------------
  |  Branch (192:6): [True: 4, False: 186]
  |  Branch (192:20): [True: 16, False: 170]
  ------------------
  193|     20|		sc_log(card->ctx, "Invalid object size: %zu", objlen);
  ------------------
  |  |   71|     20|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  194|     20|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     20|#define SC_ERROR_INTERNAL			-1400
  ------------------
  195|     20|	}
  196|       |
  197|       |	/* It looks like the first thing in the block is a table of
  198|       |	 * which keys are allocated. The table is small and is in the
  199|       |	 * first 248 bytes. Example for a card with 10 key containers:
  200|       |	 * 01 f0 00 03 03 b0 00 03     <=  1st key unallocated
  201|       |	 * 01 f0 00 04 03 b0 00 04     <=  2nd key unallocated
  202|       |	 * 01 fe 14 00 05 03 b0 00 05  <=  3rd key allocated
  203|       |	 * 01 fe 14 01 06 03 b0 00 06  <=  4th key allocated
  204|       |	 * 01 f0 00 07 03 b0 00 07     <=  5th key unallocated
  205|       |	 * ...
  206|       |	 * 01 f0 00 0c 03 b0 00 0c     <= 10th key unallocated
  207|       |	 * For allocated keys, the fourth byte seems to indicate the
  208|       |	 * default key and the fifth byte indicates the key_ref of
  209|       |	 * the private key.
  210|       |	 */
  211|    170|	ind = 2; /* skip length */
  212|    254|	while (ind + 1 < (size_t)read_len && ibuf[ind] == 0x01 && i < gemsafe_cert_max) {
  ------------------
  |  Branch (212:9): [True: 222, False: 32]
  |  Branch (212:39): [True: 84, False: 138]
  |  Branch (212:60): [True: 84, False: 0]
  ------------------
  213|     84|		if (ibuf[ind+1] == 0xFE) {
  ------------------
  |  Branch (213:7): [True: 18, False: 66]
  ------------------
  214|     18|			gemsafe_prkeys[i].ref = ibuf[ind+4];
  215|     18|			sc_log(card->ctx, "Key container %d is allocated and uses key_ref %d",
  ------------------
  |  |   71|     18|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  216|     18|					i+1, gemsafe_prkeys[i].ref);
  217|     18|			ind += 9;
  218|     18|		}
  219|     66|		else {
  220|     66|			gemsafe_prkeys[i].label = NULL;
  221|     66|			gemsafe_cert[i].label = NULL;
  222|     66|			sc_log(card->ctx, "Key container %d is unallocated", i+1);
  ------------------
  |  |   71|     66|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  223|     66|			ind += 8;
  224|     66|		}
  225|     84|		i++;
  226|     84|	}
  227|       |
  228|       |	/* Delete additional key containers from the data structures if
  229|       |	 * this card can't accommodate them.
  230|       |	 */
  231|  2.12k|	for (; i < gemsafe_cert_max; i++) {
  ------------------
  |  Branch (231:9): [True: 1.95k, False: 170]
  ------------------
  232|  1.95k|		gemsafe_prkeys[i].label = NULL;
  233|  1.95k|		gemsafe_cert[i].label = NULL;
  234|  1.95k|	}
  235|       |
  236|       |	/* Read entire file, then dissect in memory.
  237|       |	 * Gemalto ClassicClient seems to do it the same way.
  238|       |	 */
  239|    170|	iptr = ibuf + read_len;
  240|  2.94k|	while ((size_t)(iptr - ibuf) < objlen) {
  ------------------
  |  Branch (240:9): [True: 2.87k, False: 65]
  ------------------
  241|  2.87k|		r = sc_read_binary(card, (unsigned)(iptr - ibuf), iptr,
  242|  2.87k|				   MIN(GEMSAFE_READ_QUANTUM, objlen - (iptr - ibuf)), 0);
  ------------------
  |  |   69|  2.87k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 2.61k, False: 259]
  |  |  ------------------
  ------------------
  243|  2.87k|		if (r < 0) {
  ------------------
  |  Branch (243:7): [True: 89, False: 2.78k]
  ------------------
  244|     89|			sc_log(card->ctx, "Could not read cert object");
  ------------------
  |  |   71|     89|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  245|     89|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     89|#define SC_ERROR_INTERNAL			-1400
  ------------------
  246|     89|		}
  247|  2.78k|		if (r == 0)
  ------------------
  |  Branch (247:7): [True: 16, False: 2.77k]
  ------------------
  248|     16|			break;
  249|  2.77k|		read_len += r;
  250|  2.77k|		iptr += r;
  251|  2.77k|	}
  252|     81|	if ((size_t)read_len < objlen) {
  ------------------
  |  Branch (252:6): [True: 16, False: 65]
  ------------------
  253|     16|		sc_log(card->ctx, "Could not read cert object");
  ------------------
  |  |   71|     16|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  254|     16|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     16|#define SC_ERROR_INTERNAL			-1400
  ------------------
  255|     16|	}
  256|       |
  257|       |	/* Search buffer for certificates, they start with 0x3082. */
  258|     65|	i = 0;
  259|  58.5k|	while (ind < objlen - 1) {
  ------------------
  |  Branch (259:9): [True: 58.4k, False: 64]
  ------------------
  260|  58.4k|		if (ibuf[ind] == 0x30 && ibuf[ind+1] == 0x82) {
  ------------------
  |  Branch (260:7): [True: 209, False: 58.2k]
  |  Branch (260:28): [True: 1, False: 208]
  ------------------
  261|       |			/* Find next allocated key container */
  262|     13|			while (i < gemsafe_cert_max && gemsafe_cert[i].label == NULL)
  ------------------
  |  Branch (262:11): [True: 12, False: 1]
  |  Branch (262:35): [True: 12, False: 0]
  ------------------
  263|     12|				i++;
  264|      1|			if (i == gemsafe_cert_max) {
  ------------------
  |  Branch (264:8): [True: 1, False: 0]
  ------------------
  265|      1|				sc_log(card->ctx, "Warning: Found orphaned certificate at offset %d", ind);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  266|      1|				return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  267|      1|			}
  268|       |			/* DER cert len is encoded this way */
  269|      0|			if (ind+3 >= sizeof ibuf)
  ------------------
  |  Branch (269:8): [True: 0, False: 0]
  ------------------
  270|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  271|      0|			certlen = ((((int)ibuf[ind + 2]) << 8) | ibuf[ind + 3]) + 4;
  272|      0|			sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  273|      0|			       "Found certificate of key container %d at offset %d, len %d",
  274|      0|			       i+1, ind, certlen);
  275|      0|			gemsafe_cert[i].index = ind;
  276|      0|			gemsafe_cert[i].count = certlen;
  277|      0|			ind += certlen;
  278|      0|			i++;
  279|      0|		} else
  280|  58.4k|			ind++;
  281|  58.4k|	}
  282|       |
  283|       |	/* Delete additional key containers from the data structures if
  284|       |	 * they're missing on the card.
  285|       |	 */
  286|    832|	for (; i < gemsafe_cert_max; i++) {
  ------------------
  |  Branch (286:9): [True: 768, False: 64]
  ------------------
  287|    768|		if (gemsafe_cert[i].label) {
  ------------------
  |  Branch (287:7): [True: 0, False: 768]
  ------------------
  288|      0|			sc_log(card->ctx, "Warning: Certificate of key container %d is missing", i+1);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  289|      0|			gemsafe_prkeys[i].label = NULL;
  290|      0|			gemsafe_cert[i].label = NULL;
  291|      0|		}
  292|    768|	}
  293|       |
  294|     64|	return SC_SUCCESS;
  ------------------
  |  |   28|     64|#define SC_SUCCESS				0
  ------------------
  295|     65|}
pkcs15-gemsafeV1.c:sc_pkcs15emu_add_object:
  490|     65|{
  491|     65|	sc_pkcs15_object_t *obj;
  492|     65|	int		df_type;
  493|       |
  494|     65|	obj = calloc(1, sizeof(*obj));
  495|     65|	if (!obj) {
  ------------------
  |  Branch (495:6): [True: 0, False: 65]
  ------------------
  496|      0|		LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  497|      0|	}
  498|       |
  499|     65|	obj->type  = type;
  500|     65|	obj->data  = data;
  501|       |
  502|     65|	if (label)
  ------------------
  |  Branch (502:6): [True: 65, False: 0]
  ------------------
  503|     65|		strncpy(obj->label, label, sizeof(obj->label)-1);
  504|       |
  505|     65|	obj->flags = obj_flags;
  506|     65|	if (auth_id)
  ------------------
  |  Branch (506:6): [True: 0, False: 65]
  ------------------
  507|      0|		obj->auth_id = *auth_id;
  508|       |
  509|     65|	switch (type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|     65|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  510|     65|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|     65|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (510:2): [True: 65, False: 0]
  ------------------
  511|     65|		df_type = SC_PKCS15_AODF;
  ------------------
  |  |  496|     65|#define SC_PKCS15_AODF			8
  ------------------
  512|     65|		break;
  513|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (513:2): [True: 0, False: 65]
  ------------------
  514|      0|		df_type = SC_PKCS15_PRKDF;
  ------------------
  |  |  488|      0|#define SC_PKCS15_PRKDF			0
  ------------------
  515|      0|		break;
  516|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (516:2): [True: 0, False: 65]
  ------------------
  517|      0|		df_type = SC_PKCS15_PUKDF;
  ------------------
  |  |  489|      0|#define SC_PKCS15_PUKDF			1
  ------------------
  518|      0|		break;
  519|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (519:2): [True: 0, False: 65]
  ------------------
  520|      0|		df_type = SC_PKCS15_CDF;
  ------------------
  |  |  492|      0|#define SC_PKCS15_CDF			4
  ------------------
  521|      0|		break;
  522|      0|	default:
  ------------------
  |  Branch (522:2): [True: 0, False: 65]
  ------------------
  523|      0|		sc_log(p15card->card->ctx, "Unknown PKCS15 object type %d", type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  524|      0|		free(obj);
  525|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  526|     65|	}
  527|       |
  528|     65|	obj->df = sc_pkcs15emu_get_df(p15card, df_type);
  529|     65|	sc_pkcs15_add_object(p15card, obj);
  530|       |
  531|     65|	return 0;
  532|     65|}
pkcs15-gemsafeV1.c:sc_pkcs15emu_get_df:
  459|     65|{
  460|     65|	sc_pkcs15_df_t	*df;
  461|     65|	sc_file_t	*file;
  462|     65|	int		created = 0;
  463|       |
  464|    130|	while (1) {
  ------------------
  |  Branch (464:9): [True: 130, Folded]
  ------------------
  465|    130|		for (df = p15card->df_list; df; df = df->next) {
  ------------------
  |  Branch (465:31): [True: 65, False: 65]
  ------------------
  466|     65|			if (df->type == type) {
  ------------------
  |  Branch (466:8): [True: 65, False: 0]
  ------------------
  467|     65|				if (created)
  ------------------
  |  Branch (467:9): [True: 65, False: 0]
  ------------------
  468|     65|					df->enumerated = 1;
  469|     65|				return df;
  470|     65|			}
  471|     65|		}
  472|       |
  473|     65|		if (created != 0)
  ------------------
  |  Branch (473:7): [True: 0, False: 65]
  ------------------
  474|      0|			return NULL;
  475|       |
  476|     65|		file = sc_file_new();
  477|     65|		if (!file)
  ------------------
  |  Branch (477:7): [True: 0, False: 65]
  ------------------
  478|      0|			return NULL;
  479|     65|		sc_format_path("11001101", &file->path);
  480|     65|		sc_pkcs15_add_df(p15card, type, &file->path);
  481|     65|		sc_file_free(file);
  482|     65|		created++;
  483|     65|	}
  484|     65|}
pkcs15-gemsafeV1.c:sc_pkcs15emu_add_pin:
  541|     65|{
  542|     65|	sc_pkcs15_auth_info_t *info;
  543|       |
  544|     65|	info = calloc(1, sizeof(*info));
  545|     65|	if (!info)
  ------------------
  |  Branch (545:6): [True: 0, False: 65]
  ------------------
  546|     65|		LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  547|       |
  548|     65|	info->auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|     65|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  549|     65|	info->auth_method = SC_AC_CHV;
  ------------------
  |  |  151|     65|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  550|     65|	info->auth_id           = *id;
  551|     65|	info->attrs.pin.min_length        = min_length;
  552|     65|	info->attrs.pin.max_length        = max_length;
  553|     65|	info->attrs.pin.stored_length     = max_length;
  554|     65|	info->attrs.pin.type              = type;
  555|     65|	info->attrs.pin.reference         = ref;
  556|     65|	info->attrs.pin.flags             = flags;
  557|     65|	info->attrs.pin.pad_char          = pad_char;
  558|     65|	info->tries_left        = tries_left;
  559|     65|	info->logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|     65|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
  560|       |
  561|     65|	if (path)
  ------------------
  |  Branch (561:6): [True: 65, False: 0]
  ------------------
  562|     65|		info->path = *path;
  563|       |
  564|     65|	return sc_pkcs15emu_add_object(p15card, SC_PKCS15_TYPE_AUTH_PIN, label, info, NULL, obj_flags);
  ------------------
  |  |  445|     65|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  565|     65|}

sc_pkcs15emu_gids_init_ex:
  241|  12.9k|{
  242|  12.9k|	if (p15card->card->type != SC_CARD_TYPE_GIDS_GENERIC && p15card->card->type != SC_CARD_TYPE_GIDS_V1 && p15card->card->type != SC_CARD_TYPE_GIDS_V2) {
  ------------------
  |  Branch (242:6): [True: 12.8k, False: 101]
  |  Branch (242:58): [True: 12.8k, False: 1]
  |  Branch (242:105): [True: 12.8k, False: 1]
  ------------------
  243|  12.8k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.8k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  244|  12.8k|	}
  245|    103|	return sc_pkcs15emu_gids_init(p15card);
  246|  12.9k|}
pkcs15-gids.c:sc_pkcs15emu_gids_init:
  112|    103|{
  113|    103|	sc_card_t *card = p15card->card;
  114|    103|	int r;
  115|    103|	size_t i;
  116|    103|	struct sc_pkcs15_auth_info pin_info;
  117|    103|	struct sc_pkcs15_object pin_obj;
  118|    103|	struct sc_pin_cmd_data pin_cmd_data;
  119|    103|	size_t recordsnum;
  120|    103|	int has_puk;
  121|       |
  122|    103|	r = sc_card_ctl(card, SC_CARDCTL_GIDS_GET_ALL_CONTAINERS, &recordsnum);
  123|    103|	LOG_TEST_RET(card->ctx, r, "unable to get the containers. Uninitialized card ?");
  ------------------
  |  |  174|    103|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    103|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    103|	int _ret = (r); \
  |  |  |  |  168|    103|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 103, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    103|		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|    103|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    103|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    103|		return _ret; \
  |  |  |  |  172|    103|	} \
  |  |  |  |  173|    103|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  124|       |
  125|      0|	r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, NULL);
  126|      0|	LOG_TEST_RET(card->ctx, r, "unable to get the serial number. Uninitialized card ?");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  127|       |
  128|      0|	free(p15card->tokeninfo->serial_number);
  129|      0|	p15card->tokeninfo->serial_number = (char*) malloc(card->serialnr.len *2 +1);
  130|      0|	if (!p15card->tokeninfo->serial_number) {
  ------------------
  |  Branch (130:6): [True: 0, False: 0]
  ------------------
  131|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  132|      0|	}
  133|      0|	sc_bin_to_hex(card->serialnr.value, card->serialnr.len, p15card->tokeninfo->serial_number, card->serialnr.len *2 +1, 0);
  134|       |
  135|      0|	if (p15card->tokeninfo->label == NULL) {
  ------------------
  |  Branch (135:6): [True: 0, False: 0]
  ------------------
  136|      0|		p15card->tokeninfo->label = strdup("GIDS card");
  137|      0|		if (p15card->tokeninfo->label == NULL) {
  ------------------
  |  Branch (137:7): [True: 0, False: 0]
  ------------------
  138|      0|			free(p15card->tokeninfo->serial_number);
  139|      0|			p15card->tokeninfo->serial_number = NULL;
  140|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|      0|		}
  142|      0|	}
  143|       |
  144|      0|	if ((p15card->tokeninfo->manufacturer_id != NULL) && !strcmp("(unknown)", p15card->tokeninfo->manufacturer_id)) {
  ------------------
  |  Branch (144:6): [True: 0, False: 0]
  |  Branch (144:55): [True: 0, False: 0]
  ------------------
  145|      0|		free(p15card->tokeninfo->manufacturer_id);
  146|      0|		p15card->tokeninfo->manufacturer_id = NULL;
  147|      0|	}
  148|       |
  149|      0|	if (p15card->tokeninfo->manufacturer_id == NULL) {
  ------------------
  |  Branch (149:6): [True: 0, False: 0]
  ------------------
  150|      0|		p15card->tokeninfo->manufacturer_id = strdup("www.mysmartlogon.com");
  151|      0|		if (p15card->tokeninfo->manufacturer_id == NULL) {
  ------------------
  |  Branch (151:7): [True: 0, False: 0]
  ------------------
  152|      0|			sc_pkcs15_card_clear(p15card);
  153|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|      0|		}
  155|      0|	}
  156|      0|	if (p15card->card->type == SC_CARD_TYPE_GIDS_V2) {
  ------------------
  |  Branch (156:6): [True: 0, False: 0]
  ------------------
  157|      0|		p15card->tokeninfo->version = 2;
  158|      0|	} else if (p15card->card->type == SC_CARD_TYPE_GIDS_V1) {
  ------------------
  |  Branch (158:13): [True: 0, False: 0]
  ------------------
  159|      0|		p15card->tokeninfo->version = 1;
  160|      0|	}
  161|       |
  162|      0|	memset(&pin_info, 0, sizeof(pin_info));
  163|      0|	memset(&pin_obj, 0, sizeof(pin_obj));
  164|       |
  165|      0|	pin_info.auth_id.len = 1;
  166|      0|	pin_info.auth_id.value[0] = 0x80;
  167|      0|	pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|      0|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  168|      0|	pin_info.attrs.pin.reference = 0x80;
  169|      0|	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_INITIALIZED;
  ------------------
  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
              	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_INITIALIZED;
  ------------------
  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  170|      0|	pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|      0|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  171|      0|	pin_info.attrs.pin.min_length = 4;
  172|      0|	pin_info.attrs.pin.stored_length = 0;
  173|      0|	pin_info.attrs.pin.max_length = 15;
  174|      0|	pin_info.attrs.pin.pad_char = '\0';
  175|      0|	pin_info.tries_left = -1;
  176|      0|	pin_info.max_tries = -1;
  177|       |
  178|      0|	memset(&pin_cmd_data, 0, sizeof(pin_cmd_data));
  179|      0|	pin_cmd_data.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  180|      0|	pin_cmd_data.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  181|      0|	pin_cmd_data.pin_reference = pin_info.attrs.pin.reference;
  182|       |
  183|      0|	r = sc_pin_cmd(card, &pin_cmd_data);
  184|      0|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (184:6): [True: 0, False: 0]
  ------------------
  185|      0|		pin_info.max_tries = pin_cmd_data.pin1.max_tries;
  186|      0|		pin_info.tries_left = pin_cmd_data.pin1.tries_left;
  187|      0|	}
  188|       |
  189|      0|	strlcpy(pin_obj.label, "UserPIN", sizeof(pin_obj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  190|      0|	pin_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
              	pin_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  191|       |
  192|       |	/*
  193|       |	 * check whether PUK is available on this card and then optionally
  194|       |	 * link PIN with PUK.
  195|       |	 */
  196|      0|	pin_cmd_data.pin_reference = 0x81;
  197|      0|	has_puk = sc_pin_cmd(card, &pin_cmd_data) == SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  198|      0|	if (has_puk) {
  ------------------
  |  Branch (198:6): [True: 0, False: 0]
  ------------------
  199|      0|		pin_obj.auth_id.len = 1;
  200|      0|		pin_obj.auth_id.value[0] = 0x81;
  201|      0|	}
  202|       |
  203|      0|	r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  204|      0|	LOG_TEST_GOTO_ERR(card->ctx, r, "unable to sc_pkcs15emu_add_pin_obj");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  205|       |
  206|      0|	if (has_puk) {
  ------------------
  |  Branch (206:6): [True: 0, False: 0]
  ------------------
  207|      0|		pin_info.auth_id.value[0] = 0x81;
  208|      0|		pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN;
  ------------------
  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
              		pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN;
  ------------------
  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
              		pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN;
  ------------------
  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  209|      0|		pin_info.attrs.pin.reference = 0x81;
  210|      0|		pin_info.max_tries = pin_cmd_data.pin1.max_tries;
  211|      0|		pin_info.tries_left = pin_cmd_data.pin1.tries_left;
  212|      0|		strlcpy(pin_obj.label, "PUK", sizeof(pin_obj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  213|      0|		pin_obj.auth_id.len = 0;
  214|      0|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  215|      0|		LOG_TEST_GOTO_ERR(card->ctx, r, "unable to sc_pkcs15emu_add_pin_obj with PUK");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  216|      0|	}
  217|       |
  218|      0|	r = sc_card_ctl(card, SC_CARDCTL_GIDS_GET_ALL_CONTAINERS, &recordsnum);
  219|      0|	LOG_TEST_GOTO_ERR(card->ctx, r, "sc_card_ctl SC_CARDCTL_GIDS_GET_ALL_CONTAINERS");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  220|       |
  221|      0|	for (i = 0; i < recordsnum; i++) {
  ------------------
  |  Branch (221:14): [True: 0, False: 0]
  ------------------
  222|      0|		sc_cardctl_gids_get_container_t container;
  223|      0|		memset(&container, 0, sizeof(sc_cardctl_gids_get_container_t));
  224|      0|		container.containernum = i;
  225|      0|		r = sc_card_ctl(card, SC_CARDCTL_GIDS_GET_CONTAINER_DETAIL, &container);
  226|      0|		if (r < 0) {
  ------------------
  |  Branch (226:7): [True: 0, False: 0]
  ------------------
  227|       |			// one of the container information couldn't be retrieved
  228|       |			// ignore it
  229|      0|			continue;
  230|      0|		}
  231|      0|		sc_pkcs15emu_gids_add_prkey(p15card, &container);
  232|      0|	}
  233|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  234|      0|err:
  235|      0|	sc_pkcs15_card_clear(p15card);
  236|      0|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  237|      0|}

sc_pkcs15emu_iasecc_init_ex:
  268|  12.8k|{
  269|  12.8k|	if (iasecc_pkcs15emu_detect_card(p15card))
  ------------------
  |  Branch (269:6): [True: 11.9k, False: 876]
  ------------------
  270|  11.9k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  11.9k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  271|       |
  272|    876|	return sc_pkcs15emu_iasecc_init(p15card, aid);
  273|  12.8k|}
pkcs15-iasecc.c:iasecc_pkcs15emu_detect_card:
  239|  12.8k|{
  240|  12.8k|	if (p15card->card->type < SC_CARD_TYPE_IASECC_BASE)
  ------------------
  |  Branch (240:6): [True: 9.11k, False: 3.70k]
  ------------------
  241|  9.11k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  9.11k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  242|       |
  243|  3.70k|	if (p15card->card->type > SC_CARD_TYPE_IASECC_BASE + 10)
  ------------------
  |  Branch (243:6): [True: 2.83k, False: 876]
  ------------------
  244|  2.83k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  2.83k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  245|       |
  246|    876|	return SC_SUCCESS;
  ------------------
  |  |   28|    876|#define SC_SUCCESS				0
  ------------------
  247|  3.70k|}
pkcs15-iasecc.c:sc_pkcs15emu_iasecc_init:
  252|    876|{
  253|    876|	struct sc_context *ctx = p15card->card->ctx;
  254|    876|	int rv;
  255|       |
  256|    876|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    876|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    876|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    876|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    876|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 876]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|       |
  258|    876|	rv = sc_pkcs15_bind_internal(p15card, aid);
  259|       |
  260|    876|	p15card->ops.parse_df = _iasecc_parse_df;
  261|       |
  262|    876|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    876|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    876|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    876|	int _ret = r; \
  |  |  |  |  155|    876|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 876, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    876|		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|    872|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 872, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|    876|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    876|	} 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|    876|	return _ret; \
  |  |  |  |  163|    876|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  263|    876|}

sc_pkcs15emu_idprime_init_ex:
  357|  13.3k|{
  358|  13.3k|	sc_card_t   *card = p15card->card;
  359|  13.3k|	sc_context_t    *ctx = card->ctx;
  360|       |
  361|  13.3k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  13.3k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  13.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  13.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  13.3k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 13.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  362|       |
  363|  13.3k|	if (idprime_detect_card(p15card))
  ------------------
  |  Branch (363:6): [True: 13.0k, False: 309]
  ------------------
  364|  13.0k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  13.0k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  365|    309|	return sc_pkcs15emu_idprime_init(p15card);
  366|  13.3k|}
pkcs15-idprime.c:idprime_detect_card:
   40|  13.3k|{
   41|  13.3k|	sc_card_t *card = p15card->card;
   42|       |
   43|  13.3k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  13.3k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  13.3k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  13.3k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 13.3k]
  |  |  ------------------
  ------------------
   44|       |
   45|  13.3k|	if (card->type < SC_CARD_TYPE_IDPRIME_BASE
  ------------------
  |  Branch (45:6): [True: 12.3k, False: 955]
  ------------------
   46|    955|		|| card->type >= SC_CARD_TYPE_IDPRIME_BASE+1000)
  ------------------
  |  Branch (46:6): [True: 646, False: 309]
  ------------------
   47|  13.0k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  13.0k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
   48|    309|	return SC_SUCCESS;
  ------------------
  |  |   28|    309|#define SC_SUCCESS				0
  ------------------
   49|  13.3k|}
pkcs15-idprime.c:sc_pkcs15emu_idprime_init:
   52|    309|{
   53|    309|	int r, i;
   54|    309|	sc_card_t *card = p15card->card;
   55|    309|	sc_serial_number_t serial;
   56|    309|	char buf[SC_MAX_SERIALNR * 2 + 1];
   57|    309|	int count;
   58|    309|	char *token_name = NULL;
   59|    309|	struct sc_pkcs15_auth_info pin_info;
   60|    309|	struct sc_pkcs15_object   pin_obj;
   61|    309|	const char pin_label[] = "PIN";
   62|    309|	const char *pin_id = "11";
   63|    309|	const char sig_pin_label[] = "Digital Signature PIN";
   64|    309|	const char *sig_pin_id = "83";
   65|       |
   66|       |	/* oid for key usage */
   67|    309|	static const struct sc_object_id usage_type = {{ 2, 5, 29, 15, -1 }};
   68|    309|	unsigned int usage;
   69|       |
   70|    309|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    309|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    309|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    309|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 309]
  |  |  ------------------
  ------------------
   71|       |
   72|       |	/* could read this off card if needed */
   73|    309|	set_string(&p15card->tokeninfo->label, "IDPrime");
   74|    309|	set_string(&p15card->tokeninfo->manufacturer_id, "Gemalto");
   75|       |
   76|       |	/*
   77|       |	 * get serial number
   78|       |	 */
   79|    309|	memset(&serial, 0, sizeof(serial));
   80|    309|	r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
   81|    309|	if (r < 0) {
  ------------------
  |  Branch (81:6): [True: 307, False: 2]
  ------------------
   82|    307|		sc_log(card->ctx, "sc_card_ctl rc=%d", r);
  ------------------
  |  |   71|    307|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   83|    307|		set_string(&p15card->tokeninfo->serial_number, "00000000");
   84|    307|	} else {
   85|      2|		sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
   86|      2|		set_string(&p15card->tokeninfo->serial_number, buf);
   87|      2|	}
   88|       |	/* set pin */
   89|    309|	sc_log(card->ctx,  "IDPrime adding pin...");
  ------------------
  |  |   71|    309|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   90|    309|	memset(&pin_info, 0, sizeof(pin_info));
   91|    309|	memset(&pin_obj,  0, sizeof(pin_obj));
   92|       |
   93|    309|	pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    309|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
   94|    309|	sc_pkcs15_format_id(pin_id, &pin_info.auth_id);
   95|    309|	pin_info.attrs.pin.reference     = 0x11;
   96|    309|	pin_info.attrs.pin.flags         = SC_PKCS15_PIN_FLAG_INITIALIZED;
  ------------------
  |  |   58|    309|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
   97|    309|	pin_info.attrs.pin.type          = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|    309|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
   98|    309|	pin_info.attrs.pin.min_length    = 4;
   99|    309|	pin_info.attrs.pin.stored_length = 0;
  100|    309|	pin_info.attrs.pin.max_length    = 16;
  101|    309|	pin_info.tries_left    = -1;
  102|       |
  103|    309|	if (card->type == SC_CARD_TYPE_IDPRIME_840
  ------------------
  |  Branch (103:6): [True: 15, False: 294]
  ------------------
  104|    294|	    || card->type == SC_CARD_TYPE_IDPRIME_940
  ------------------
  |  Branch (104:9): [True: 17, False: 277]
  ------------------
  105|    277|	    || card->type == SC_CARD_TYPE_IDPRIME_GENERIC) {
  ------------------
  |  Branch (105:9): [True: 227, False: 50]
  ------------------
  106|    259|		pin_info.attrs.pin.flags |= SC_PKCS15_PIN_FLAG_NEEDS_PADDING;
  ------------------
  |  |   59|    259|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  107|    259|		pin_info.attrs.pin.stored_length = 16;
  108|    259|		pin_info.attrs.pin.pad_char = 0x00;
  109|    259|	}
  110|       |
  111|    309|	sc_log(card->ctx,  "IDPrime Adding pin with label=%s", pin_label);
  ------------------
  |  |   71|    309|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  112|    309|	strncpy(pin_obj.label, pin_label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|    309|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  113|    309|	pin_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    309|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  114|       |
  115|    309|	r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  116|    309|	LOG_TEST_GOTO_ERR(card->ctx, r, "Can not add pin object");
  ------------------
  |  |  184|    309|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    309|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    309|	int _ret = (r); \
  |  |  |  |  178|    309|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 309]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    309|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 309]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  117|       |
  118|       |	/* set signature pin for 940 cards */
  119|    309|	if (card->type == SC_CARD_TYPE_IDPRIME_940) {
  ------------------
  |  Branch (119:6): [True: 17, False: 292]
  ------------------
  120|     17|		sc_log(card->ctx,  "IDPrime adding Digital Signature pin...");
  ------------------
  |  |   71|     17|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  121|     17|		memset(&pin_info, 0, sizeof(pin_info));
  122|     17|		memset(&pin_obj,  0, sizeof(pin_obj));
  123|       |
  124|     17|		pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|     17|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  125|     17|		sc_pkcs15_format_id(sig_pin_id, &pin_info.auth_id);
  126|     17|		pin_info.attrs.pin.reference     = 0x83;
  127|     17|		pin_info.attrs.pin.flags         = SC_PKCS15_PIN_FLAG_INITIALIZED;
  ------------------
  |  |   58|     17|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  128|     17|		pin_info.attrs.pin.type          = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|     17|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  129|     17|		pin_info.attrs.pin.min_length    = 4;
  130|     17|		pin_info.attrs.pin.stored_length = 0;
  131|     17|		pin_info.attrs.pin.max_length    = 16;
  132|     17|		pin_info.tries_left    = -1;
  133|       |
  134|     17|		pin_info.attrs.pin.flags |= SC_PKCS15_PIN_FLAG_NEEDS_PADDING;
  ------------------
  |  |   59|     17|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  135|     17|		pin_info.attrs.pin.stored_length = 16;
  136|     17|		pin_info.attrs.pin.pad_char = 0x00;
  137|       |
  138|     17|		sc_log(card->ctx,  "IDPrime Adding Digital Signature pin with label=%s", sig_pin_label);
  ------------------
  |  |   71|     17|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  139|     17|		strncpy(pin_obj.label, sig_pin_label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|     17|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  140|     17|		pin_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|     17|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  141|       |
  142|     17|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  143|     17|		LOG_TEST_GOTO_ERR(card->ctx, r, "Can not add Digital Signature pin object");
  ------------------
  |  |  184|     17|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     17|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     17|	int _ret = (r); \
  |  |  |  |  178|     17|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|     17|	}
  145|       |
  146|       |	/*
  147|       |	 * get token name if provided
  148|       |	 */
  149|    309|	r = sc_card_ctl(card, SC_CARDCTL_IDPRIME_GET_TOKEN_NAME, &token_name);
  150|    309|	if (r < 0) {
  ------------------
  |  Branch (150:6): [True: 302, False: 7]
  ------------------
  151|       |		/* On failure we will get the token name from certificates later */
  152|    302|		sc_log(card->ctx, "sc_card_ctl rc=%d", r);
  ------------------
  |  |   71|    302|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  153|    302|	} else {
  154|      7|		free(p15card->tokeninfo->label);
  155|      7|		p15card->tokeninfo->label = token_name;
  156|      7|		sc_log(card->ctx,  "IDPrime setting token label = %s", token_name);
  ------------------
  |  |   71|      7|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  157|      7|	}
  158|       |	/*
  159|       |	 * certs, pubkeys and priv keys are related and we assume
  160|       |	 * they are in order
  161|       |	 * We need to read the cert, get modulus and keylen
  162|       |	 * We use those for the pubkey, and priv key objects.
  163|       |	 */
  164|    309|	sc_log(card->ctx,  "IDPrime adding certs, pub and priv keys...");
  ------------------
  |  |   71|    309|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  165|    309|	r = (card->ops->card_ctl)(card, SC_CARDCTL_IDPRIME_INIT_GET_OBJECTS, &count);
  166|    309|	LOG_TEST_GOTO_ERR(card->ctx, r, "Can not initiate cert objects.");
  ------------------
  |  |  184|    309|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    309|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    309|	int _ret = (r); \
  |  |  |  |  178|    309|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 309]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    309|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 309]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  167|       |
  168|    937|	for (i = 0; i < count; i++) {
  ------------------
  |  Branch (168:14): [True: 628, False: 309]
  ------------------
  169|    628|		struct sc_pkcs15_prkey_info prkey_info;
  170|    628|		struct sc_pkcs15_cert_info cert_info;
  171|    628|		struct sc_pkcs15_pubkey_info pubkey_info;
  172|    628|		struct sc_pkcs15_object cert_obj;
  173|    628|		struct sc_pkcs15_object pubkey_obj;
  174|    628|		struct sc_pkcs15_object prkey_obj;
  175|    628|		sc_pkcs15_der_t cert_der;
  176|    628|		sc_pkcs15_cert_t *cert_out = NULL;
  177|    628|		const char *pin_id = NULL;
  178|       |
  179|    628|		r = (card->ops->card_ctl)(card, SC_CARDCTL_IDPRIME_GET_PIN_ID, (void *) &pin_id);
  180|    628|		LOG_TEST_GOTO_ERR(card->ctx, r, "Can not get PIN id of next object ");
  ------------------
  |  |  184|    628|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    628|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    628|	int _ret = (r); \
  |  |  |  |  178|    628|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 628]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    628|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 628]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  181|    628|		r = (card->ops->card_ctl)(card, SC_CARDCTL_IDPRIME_GET_NEXT_OBJECT, &prkey_info);
  182|    628|		LOG_TEST_GOTO_ERR(card->ctx, r, "Can not get next object");
  ------------------
  |  |  184|    628|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    628|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    628|	int _ret = (r); \
  |  |  |  |  178|    628|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 628]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    628|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 628]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  183|       |
  184|    628|		memset(&cert_info, 0, sizeof(cert_info));
  185|    628|		memset(&pubkey_info, 0, sizeof(pubkey_info));
  186|       |		/* prkey_info cleaned by the card_ctl call */
  187|    628|		memset(&cert_obj,  0, sizeof(cert_obj));
  188|    628|		memset(&pubkey_obj,  0, sizeof(pubkey_obj));
  189|    628|		memset(&prkey_obj,  0, sizeof(prkey_obj));
  190|       |
  191|    628|		cert_info.id = prkey_info.id;
  192|    628|		pubkey_info.id = prkey_info.id;
  193|    628|		cert_info.path = prkey_info.path;
  194|       |		/* For private keys, we no longer care for the path, just
  195|       |		 * the key reference later used in the security environment */
  196|    628|		prkey_info.path.len = 0;
  197|    628|		prkey_info.path.aid.len = 0;
  198|    628|		pubkey_info.key_reference = prkey_info.key_reference;
  199|    628|		sc_log(card->ctx,  "Key ref r=%x", prkey_info.key_reference);
  ------------------
  |  |   71|    628|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  200|       |
  201|    628|		pubkey_info.native        = 1;
  202|    628|		prkey_info.native        = 1;
  203|       |
  204|    628|		snprintf(cert_obj.label, SC_PKCS15_MAX_LABEL_SIZE, CERT_LABEL_TEMPLATE, i+1);
  ------------------
  |  |   35|    628|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
              		snprintf(cert_obj.label, SC_PKCS15_MAX_LABEL_SIZE, CERT_LABEL_TEMPLATE, i+1);
  ------------------
  |  |   35|    628|#define CERT_LABEL_TEMPLATE "Certificate %d"
  ------------------
  205|    628|		snprintf(pubkey_obj.label, SC_PKCS15_MAX_LABEL_SIZE, PUBKEY_LABEL_TEMPLATE, i+1);
  ------------------
  |  |   35|    628|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
              		snprintf(pubkey_obj.label, SC_PKCS15_MAX_LABEL_SIZE, PUBKEY_LABEL_TEMPLATE, i+1);
  ------------------
  |  |   36|    628|#define PUBKEY_LABEL_TEMPLATE "Public key %d"
  ------------------
  206|    628|		snprintf(prkey_obj.label, SC_PKCS15_MAX_LABEL_SIZE, PRIVKEY_LABEL_TEMPLATE, i+1);
  ------------------
  |  |   35|    628|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
              		snprintf(prkey_obj.label, SC_PKCS15_MAX_LABEL_SIZE, PRIVKEY_LABEL_TEMPLATE, i+1);
  ------------------
  |  |   37|    628|#define PRIVKEY_LABEL_TEMPLATE "Private key %d"
  ------------------
  207|    628|		prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    628|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  208|       |
  209|       |		/* Differentiate between objects accessible with normal and with digital signature pin */
  210|    628|		sc_pkcs15_format_id(pin_id, &prkey_obj.auth_id);
  211|    628|		sc_log(card->ctx,  "Pin ID r=%s", pin_id);
  ------------------
  |  |   71|    628|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  212|       |
  213|    628|		if (memcmp(pin_id, sig_pin_id, 2) == 0)
  ------------------
  |  Branch (213:7): [True: 46, False: 582]
  ------------------
  214|     46|			prkey_obj.user_consent = 1;
  215|       |
  216|    628|		r = sc_pkcs15_read_file(p15card, &cert_info.path, &cert_der.value, &cert_der.len, 0);
  217|       |
  218|    628|		if (r) {
  ------------------
  |  Branch (218:7): [True: 602, False: 26]
  ------------------
  219|    602|			sc_log(card->ctx,  "No cert found,i=%d", i);
  ------------------
  |  |   71|    602|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  220|    602|			continue;
  221|    602|		}
  222|     26|		cert_info.path.count = (int)cert_der.len;
  223|       |
  224|     26|		sc_log(card->ctx, "cert len=%zu, cert_info.path.count=%d r=%d",
  ------------------
  |  |   71|     26|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  225|     26|				cert_der.len, cert_info.path.count, r);
  226|     26|		sc_log_hex(card->ctx, "cert", cert_der.value, cert_der.len);
  ------------------
  |  |  129|     26|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     26|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  227|       |
  228|       |		/* cache it using the PKCS15 emulation objects */
  229|       |		/* as it does not change */
  230|     26|		if (cert_der.value) {
  ------------------
  |  Branch (230:7): [True: 16, False: 10]
  ------------------
  231|     16|			cert_info.value.value = cert_der.value;
  232|     16|			cert_info.value.len = cert_der.len;
  233|     16|			cert_info.path.len = 0; /* use in mem cert from now on */
  234|     16|		}
  235|       |
  236|       |		/* following will find the cached cert in cert_info */
  237|     26|		r =  sc_pkcs15_read_certificate(p15card, &cert_info, 0, &cert_out);
  238|     26|		if (r < 0 || cert_out->key == NULL) {
  ------------------
  |  Branch (238:7): [True: 26, False: 0]
  |  Branch (238:16): [True: 0, False: 0]
  ------------------
  239|     26|			sc_log(card->ctx,  "Failed to read/parse the certificate r=%d",r);
  ------------------
  |  |   71|     26|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  240|     26|			if (cert_out != NULL)
  ------------------
  |  Branch (240:8): [True: 0, False: 26]
  ------------------
  241|      0|				sc_pkcs15_free_certificate(cert_out);
  242|     26|			free(cert_der.value);
  243|     26|			continue;
  244|     26|		}
  245|       |
  246|      0|		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  247|      0|		if (r < 0) {
  ------------------
  |  Branch (247:7): [True: 0, False: 0]
  ------------------
  248|      0|			sc_log(card->ctx,  " Failed to add cert obj r=%d",r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  249|      0|			sc_pkcs15_free_certificate(cert_out);
  250|      0|			free(cert_der.value);
  251|      0|			continue;
  252|      0|		}
  253|       |		/* set the token name to the name of the CN of the first certificate */
  254|      0|		if (!token_name) {
  ------------------
  |  Branch (254:7): [True: 0, False: 0]
  ------------------
  255|      0|			u8 * cn_name = NULL;
  256|      0|			size_t cn_len = 0;
  257|      0|			static const struct sc_object_id cn_oid = {{ 2, 5, 4, 3, -1 }};
  258|      0|			r = sc_pkcs15_get_name_from_dn(card->ctx, cert_out->subject,
  259|      0|				cert_out->subject_len, &cn_oid, &cn_name, &cn_len);
  260|      0|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (260:8): [True: 0, False: 0]
  ------------------
  261|      0|				token_name = malloc (cn_len+1);
  262|      0|				if (!token_name) {
  ------------------
  |  Branch (262:9): [True: 0, False: 0]
  ------------------
  263|      0|					free(cn_name);
  264|      0|					r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  265|      0|					goto fail;
  266|      0|				}
  267|      0|				memcpy(token_name, cn_name, cn_len);
  268|      0|				free(cn_name);
  269|      0|				token_name[cn_len] = '\0';
  270|      0|				free(p15card->tokeninfo->label);
  271|      0|				p15card->tokeninfo->label = token_name;
  272|      0|			}
  273|      0|		}
  274|       |
  275|       |
  276|      0|		r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, cert_out->key,
  277|      0|			&pubkey_info.direct.spki.value, &pubkey_info.direct.spki.len);
  278|      0|		if (r < 0)
  ------------------
  |  Branch (278:7): [True: 0, False: 0]
  ------------------
  279|      0|			goto fail;
  280|      0|		pubkey_obj.emulated = cert_out->key;
  281|       |
  282|      0|		r = sc_pkcs15_get_bitstring_extension(card->ctx, cert_out, &usage_type, &usage, NULL);
  283|      0|		if (r < 0) {
  ------------------
  |  Branch (283:7): [True: 0, False: 0]
  ------------------
  284|      0|			usage = SC_X509_DATA_ENCIPHERMENT|SC_X509_DIGITAL_SIGNATURE; /* basic default usage */
  ------------------
  |  |  617|      0|#define SC_X509_DATA_ENCIPHERMENT     0x0008UL
  ------------------
              			usage = SC_X509_DATA_ENCIPHERMENT|SC_X509_DIGITAL_SIGNATURE; /* basic default usage */
  ------------------
  |  |  614|      0|#define SC_X509_DIGITAL_SIGNATURE     0x0001UL
  ------------------
  285|      0|		}
  286|      0|		sc_pkcs15_map_usage(usage, cert_out->key->algorithm, &pubkey_info.usage, &prkey_info.usage, 1);
  287|      0|		sc_log(card->ctx, "cert %s: cert_usage=0x%x, pub_usage=0x%x priv_usage=0x%x\n",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  288|      0|			sc_dump_hex(cert_info.id.value, cert_info.id.len),
  289|      0|			usage, pubkey_info.usage, prkey_info.usage);
  290|       |
  291|      0|		if (cert_out->key->algorithm == SC_ALGORITHM_RSA) {
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (291:7): [True: 0, False: 0]
  ------------------
  292|      0|			pubkey_info.modulus_length = cert_out->key->u.rsa.modulus.len * 8;
  293|      0|			prkey_info.modulus_length = cert_out->key->u.rsa.modulus.len * 8;
  294|      0|			sc_log(card->ctx, "adding rsa public key r=%d usage=%x", r, pubkey_info.usage);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  295|      0|			r = sc_pkcs15emu_add_rsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
  296|      0|			if (r < 0) {
  ------------------
  |  Branch (296:8): [True: 0, False: 0]
  ------------------
  297|      0|				free(pubkey_info.direct.spki.value);
  298|      0|				goto fail;
  299|      0|			}
  300|      0|			pubkey_info.direct.spki.value = NULL; /* moved to the pubkey object on p15card  */
  301|      0|			pubkey_info.direct.spki.len = 0;
  302|      0|			if (prkey_info.key_reference >= 0) {
  ------------------
  |  Branch (302:8): [True: 0, False: 0]
  ------------------
  303|      0|				sc_log(card->ctx, "adding rsa private key r=%d usage=%x", r, prkey_info.usage);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  304|      0|				r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  305|      0|			} else {
  306|      0|				sc_log(card->ctx, "missing rsa private key r=%d usage=%x", r, prkey_info.usage);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  307|      0|			}
  308|      0|			if (r < 0)
  ------------------
  |  Branch (308:8): [True: 0, False: 0]
  ------------------
  309|      0|				goto fail;
  310|      0|		} else if (cert_out->key->algorithm == SC_ALGORITHM_EC) {
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (310:14): [True: 0, False: 0]
  ------------------
  311|      0|			pubkey_info.field_length = cert_out->key->u.ec.params.field_length;
  312|      0|			prkey_info.field_length = cert_out->key->u.ec.params.field_length;
  313|      0|			sc_log(card->ctx, "adding ec public key r=%d usage=%x", r, pubkey_info.usage);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  314|      0|			r = sc_pkcs15emu_add_ec_pubkey(p15card, &pubkey_obj, &pubkey_info);
  315|      0|			if (r < 0) {
  ------------------
  |  Branch (315:8): [True: 0, False: 0]
  ------------------
  316|      0|				free(pubkey_info.direct.spki.value);
  317|      0|				goto fail;
  318|      0|			}
  319|      0|			pubkey_info.direct.spki.value = NULL;
  320|      0|			pubkey_info.direct.spki.len = 0;
  321|      0|			if (prkey_info.key_reference >= 0) {
  ------------------
  |  Branch (321:8): [True: 0, False: 0]
  ------------------
  322|      0|				sc_log(card->ctx, "adding ec private key r=%d usage=%x", r, prkey_info.usage);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  323|      0|				r = sc_pkcs15emu_add_ec_prkey(p15card, &prkey_obj, &prkey_info);
  324|      0|			} else {
  325|      0|				sc_log(card->ctx, "missing ec private key r=%d usage=%x", r, prkey_info.usage);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  326|      0|			}
  327|      0|			if (r < 0)
  ------------------
  |  Branch (327:8): [True: 0, False: 0]
  ------------------
  328|      0|				goto fail;
  329|      0|		} else {
  330|      0|			sc_log(card->ctx, "unsupported key.algorithm %lu", cert_out->key->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  331|      0|			sc_pkcs15_free_certificate(cert_out);
  332|      0|			free(pubkey_info.direct.spki.value);
  333|      0|			continue;
  334|      0|		}
  335|       |
  336|      0|		cert_out->key = NULL;
  337|      0|fail:
  338|      0|		sc_pkcs15_free_certificate(cert_out);
  339|      0|		if (r < 0) {
  ------------------
  |  Branch (339:7): [True: 0, False: 0]
  ------------------
  340|      0|			(card->ops->card_ctl)(card, SC_CARDCTL_IDPRIME_FINAL_GET_OBJECTS, &count);
  341|      0|			LOG_TEST_GOTO_ERR(card->ctx, r, "Failed to add object.");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  342|      0|		}
  343|       |
  344|      0|	}
  345|    309|	r = (card->ops->card_ctl)(card, SC_CARDCTL_IDPRIME_FINAL_GET_OBJECTS, &count);
  346|    309|	LOG_TEST_GOTO_ERR(card->ctx, r, "Can not finalize cert objects.");
  ------------------
  |  |  184|    309|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    309|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    309|	int _ret = (r); \
  |  |  |  |  178|    309|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 309]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    309|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 309]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|       |
  348|    309|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    309|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    309|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    309|	int _ret = r; \
  |  |  |  |  155|    309|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 309, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    309|		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: 309]
  |  |  |  |  ------------------
  |  |  |  |  157|    309|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    309|	} 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|    309|	return _ret; \
  |  |  |  |  163|    309|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  349|       |
  350|      0|err:
  351|      0|	sc_pkcs15_card_clear(p15card);
  352|      0|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|      0|}

sc_pkcs15emu_itacns_init_ex:
  881|  15.6k|{
  882|  15.6k|	sc_card_t *card = p15card->card;
  883|  15.6k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
  ------------------
  |  |  148|  15.6k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  15.6k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  15.6k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 15.6k]
  |  |  ------------------
  ------------------
  884|       |
  885|       |	/* Check card */
  886|  15.6k|	if (! (
  887|  15.6k|			(card->type > SC_CARD_TYPE_ITACNS_BASE &&
  ------------------
  |  Branch (887:5): [True: 5.63k, False: 9.96k]
  ------------------
  888|  5.63k|			card->type < SC_CARD_TYPE_ITACNS_BASE + 1000)
  ------------------
  |  Branch (888:4): [True: 499, False: 5.13k]
  ------------------
  889|  15.1k|		|| card->type == SC_CARD_TYPE_CARDOS_CIE_V1)
  ------------------
  |  Branch (889:6): [True: 0, False: 15.1k]
  ------------------
  890|  15.6k|		)
  891|  15.1k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  15.1k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  892|       |
  893|       |	/* Init card */
  894|    499|	return itacns_init(p15card);
  895|  15.6k|}
pkcs15-itacns.c:itacns_init:
  761|    499|{
  762|    499|	int r;
  763|    499|	sc_path_t path;
  764|    499|	int certificate_count = 0;
  765|    499|	int found_certs;
  766|    499|	int card_is_cie_v1, cns0_secenv;
  767|       |
  768|    499|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_NORMAL);
  ------------------
  |  |  148|    499|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    499|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    499|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 499]
  |  |  ------------------
  ------------------
  769|       |
  770|    499|	set_string(&p15card->tokeninfo->label, p15card->card->name);
  771|    499|	if(p15card->card->drv_data) {
  ------------------
  |  Branch (771:5): [True: 499, False: 0]
  ------------------
  772|    499|		unsigned int mask_code, ic_code;
  773|    499|		char buffer[256];
  774|    499|		itacns_drv_data_t *data =
  775|    499|			(itacns_drv_data_t*) p15card->card->drv_data;
  776|    499|		mask_code = data->mask_manufacturer_code;
  777|    499|		if (mask_code >= sizeof(itacns_mask_manufacturers)
  ------------------
  |  Branch (777:7): [True: 438, False: 61]
  ------------------
  778|    499|			/sizeof(itacns_mask_manufacturers[0]))
  779|    438|			mask_code = 0;
  780|    499|		ic_code = data->ic_manufacturer_code;
  781|    499|		if (ic_code >= sizeof(iso7816_ic_manufacturers)
  ------------------
  |  Branch (781:7): [True: 377, False: 122]
  ------------------
  782|    499|			/sizeof(iso7816_ic_manufacturers[0]))
  783|    377|			ic_code = 0;
  784|    499|		snprintf(buffer, sizeof(buffer), "IC: %s; mask: %s",
  785|    499|			iso7816_ic_manufacturers[ic_code],
  786|    499|			itacns_mask_manufacturers[mask_code]);
  787|    499|		set_string(&p15card->tokeninfo->manufacturer_id, buffer);
  788|    499|	}
  789|       |
  790|       |	/* Read and set serial */
  791|    499|	{
  792|    499|		u8 serial[17];
  793|    499|		int bytes;
  794|    499|		sc_format_path(path_serial, &path);
  795|    499|		bytes = loadFile(p15card, &path, serial, 16);
  796|    499|		if (bytes < 0) return bytes;
  ------------------
  |  Branch (796:7): [True: 244, False: 255]
  ------------------
  797|    255|		if (bytes > 16) return -1;
  ------------------
  |  Branch (797:7): [True: 0, False: 255]
  ------------------
  798|    255|		serial[bytes] = '\0';
  799|    255|		set_string(&p15card->tokeninfo->serial_number, (char*)serial);
  800|    255|	}
  801|       |
  802|       |	/* Is the card a CIE v1? */
  803|      0|	card_is_cie_v1 =
  804|    255|		   (p15card->card->type == SC_CARD_TYPE_ITACNS_CIE_V1)
  ------------------
  |  Branch (804:6): [True: 0, False: 255]
  ------------------
  805|    255|		|| (p15card->card->type == SC_CARD_TYPE_CARDOS_CIE_V1);
  ------------------
  |  Branch (805:6): [True: 0, False: 255]
  ------------------
  806|    255|	cns0_secenv = (card_is_cie_v1 ? 0x31 : 0x01);
  ------------------
  |  Branch (806:17): [True: 0, False: 255]
  ------------------
  807|       |
  808|       |	/* If it's a Siemens CIE v1 card, set algo flags accordingly. */
  809|    255|	if (card_is_cie_v1) {
  ------------------
  |  Branch (809:6): [True: 0, False: 255]
  ------------------
  810|      0|		int i;
  811|      0|		for (i = 0; i < p15card->card->algorithm_count; i++) {
  ------------------
  |  Branch (811:15): [True: 0, False: 0]
  ------------------
  812|      0|			sc_algorithm_info_t *info =
  813|      0|				&p15card->card->algorithms[i];
  814|       |
  815|      0|			if (info->algorithm != SC_ALGORITHM_RSA)
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (815:8): [True: 0, False: 0]
  ------------------
  816|      0|				continue;
  817|      0|			info->flags &= ~(SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  102|      0|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  818|      0|				| SC_ALGORITHM_RSA_HASH_NONE);
  ------------------
  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  819|      0|			info->flags |= (SC_ALGORITHM_RSA_PAD_PKCS1
  ------------------
  |  |  111|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  820|      0|				| SC_ALGORITHM_RSA_HASHES);
  ------------------
  |  |  142|      0|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
  821|      0|		}
  822|      0|	}
  823|       |
  824|       |	/* Data files */
  825|    255|	r = itacns_add_data_files(p15card);
  826|    255|	LOG_TEST_GOTO_ERR(p15card->card->ctx, r,
  ------------------
  |  |  184|    255|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    255|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    255|	int _ret = (r); \
  |  |  |  |  178|    255|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 255]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    255|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 255]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  827|    255|		"Could not add data files");
  828|       |
  829|       |	/*** Certificate and keys. ***/
  830|       |	/* Standard CNS */
  831|    255|	r = itacns_check_and_add_keyset(p15card, "CNS0", cns0_secenv,
  832|    255|		0, "3F0011001101", "3F003F01", NULL,
  833|    255|		0x10, &found_certs);
  834|    255|	LOG_TEST_GOTO_ERR(p15card->card->ctx, r,
  ------------------
  |  |  184|    255|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    255|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    255|	int _ret = (r); \
  |  |  |  |  178|    255|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 132, False: 123]
  |  |  |  |  ------------------
  |  |  |  |  179|    132|		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|    132|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    132|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    132|		goto err; \
  |  |  |  |  182|    132|	} \
  |  |  |  |  183|    255|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 123]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  835|    123|		"Could not add CNS0");
  836|    123|	certificate_count += found_certs;
  837|       |
  838|       |	/* Infocamere 1204 */
  839|    123|	r = itacns_check_and_add_keyset(p15card, "CNS01", 0x21,
  840|    123|		5, "3F002FFF8228", NULL, "3F002FFF0000",
  841|    123|		0x10, &found_certs);
  842|    123|	LOG_TEST_GOTO_ERR(p15card->card->ctx, r,
  ------------------
  |  |  184|    123|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    123|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    123|	int _ret = (r); \
  |  |  |  |  178|    123|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 45, False: 78]
  |  |  |  |  ------------------
  |  |  |  |  179|     45|		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|     45|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     45|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     45|		goto err; \
  |  |  |  |  182|     45|	} \
  |  |  |  |  183|    123|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 78]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  843|     78|		"Could not add CNS01");
  844|     78|	certificate_count += found_certs;
  845|       |
  846|       |	/* Digital signature */
  847|     78|	r = itacns_check_and_add_keyset(p15card, "CNS1", 0x10,
  848|     78|		0, "3F0014009010", "3F00140081108010", "3F0014008110",
  849|     78|		0x1a, &found_certs);
  850|     78|	LOG_TEST_GOTO_ERR(p15card->card->ctx, r,
  ------------------
  |  |  184|     78|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     78|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     78|	int _ret = (r); \
  |  |  |  |  178|     78|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 30, False: 48]
  |  |  |  |  ------------------
  |  |  |  |  179|     30|		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|     30|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     30|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     30|		goto err; \
  |  |  |  |  182|     30|	} \
  |  |  |  |  183|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  851|     48|		"Could not add CNS1");
  852|     48|	certificate_count += found_certs;
  853|       |
  854|       |	/* Idemia card */
  855|     48|	r = itacns_check_and_add_keyset(p15card, "CNS1", 0x02,
  856|     48|		0, "3F00140090012002", "3F0011001102", "3F0014009002",
  857|     48|		0x10, &found_certs);
  858|     48|	LOG_TEST_RET(p15card->card->ctx, r,
  ------------------
  |  |  174|     48|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     48|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     48|	int _ret = (r); \
  |  |  |  |  168|     48|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 23, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  169|     23|		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|     23|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     23|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     23|		return _ret; \
  |  |  |  |  172|     23|	} \
  |  |  |  |  173|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  859|     25|		"Could not add CNS1");
  860|     25|	certificate_count += found_certs;
  861|       |
  862|       |	/* Did we find anything? */
  863|     25|	if (certificate_count == 0)
  ------------------
  |  Branch (863:6): [True: 25, False: 0]
  ------------------
  864|     25|		sc_debug(p15card->card->ctx, SC_LOG_DEBUG_NORMAL,
  ------------------
  |  |   70|     25|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  865|     25|			"Warning: no certificates found!");
  866|       |
  867|       |	/* Back to Master File */
  868|     25|	sc_format_path("3F00", &path);
  869|     25|	r = sc_select_file(p15card->card, &path, NULL);
  870|     25|	LOG_TEST_GOTO_ERR(p15card->card->ctx, r,
  ------------------
  |  |  184|     25|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     25|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     25|	int _ret = (r); \
  |  |  |  |  178|     25|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 12, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  179|     12|		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|     12|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     12|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     12|		goto err; \
  |  |  |  |  182|     12|	} \
  |  |  |  |  183|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  871|     13|		"Could not select master file again");
  872|       |
  873|     13|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  164|     13|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     13|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     13|	int _ret = r; \
  |  |  |  |  155|     13|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     13|		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: 13]
  |  |  |  |  ------------------
  |  |  |  |  157|     13|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     13|	} 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|     13|	return _ret; \
  |  |  |  |  163|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  874|       |
  875|    219|err:
  876|    219|	sc_pkcs15_card_clear(p15card);
  877|    219|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  164|    219|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    219|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    219|	int _ret = r; \
  |  |  |  |  155|    219|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 219, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    219|		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|    219|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 219, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    219|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    219|	} 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|    219|	return _ret; \
  |  |  |  |  163|    219|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  878|    219|}
pkcs15-itacns.c:loadFile:
  169|    615|{
  170|    615|	int sc_res;
  171|    615|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_NORMAL);
  ------------------
  |  |  148|    615|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    615|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    615|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 615]
  |  |  ------------------
  ------------------
  172|       |
  173|    615|	sc_res = sc_select_file(p15card->card, path, NULL);
  174|    615|	if(sc_res != SC_SUCCESS)
  ------------------
  |  |   28|    615|#define SC_SUCCESS				0
  ------------------
  |  Branch (174:5): [True: 224, False: 391]
  ------------------
  175|    224|		return sc_res;
  176|       |
  177|    391|	sc_res = sc_read_binary(p15card->card, 0, buf, buflen, 0);
  178|    391|	return sc_res;
  179|    615|}
pkcs15-itacns.c:itacns_add_data_files:
  482|    255|{
  483|    255|	const size_t array_size =
  484|    255|		sizeof(itacns_data_files)/sizeof(itacns_data_files[0]);
  485|    255|	unsigned int i;
  486|    255|	int rv;
  487|    255|	sc_pkcs15_data_t *p15_personaldata = NULL;
  488|    255|	sc_pkcs15_data_info_t dinfo;
  489|    255|	struct sc_pkcs15_object *objs[32];
  490|    255|	struct sc_pkcs15_data_info *cinfo;
  491|    255|	int private_obj;
  492|       |
  493|  3.82k|	for(i=0; i < array_size; i++) {
  ------------------
  |  Branch (493:11): [True: 3.57k, False: 255]
  ------------------
  494|  3.57k|		sc_path_t path;
  495|  3.57k|		sc_pkcs15_data_info_t data;
  496|  3.57k|		sc_pkcs15_object_t    obj;
  497|       |
  498|  3.57k|		if (itacns_data_files[i].cie_only &&
  ------------------
  |  Branch (498:7): [True: 1.02k, False: 2.55k]
  ------------------
  499|  1.02k|			p15card->card->type != SC_CARD_TYPE_ITACNS_CIE_V2)
  ------------------
  |  Branch (499:4): [True: 344, False: 676]
  ------------------
  500|    344|			continue;
  501|       |
  502|  3.22k|		sc_format_path(itacns_data_files[i].path, &path);
  503|       |
  504|  3.22k|		memset(&data, 0, sizeof(data));
  505|  3.22k|		memset(&obj, 0, sizeof(obj));
  506|  3.22k|		strlcpy(data.app_label, itacns_data_files[i].label,
  ------------------
  |  |   43|  3.22k|#define strlcpy _strlcpy
  ------------------
  507|  3.22k|			sizeof(data.app_label));
  508|  3.22k|		strlcpy(obj.label, itacns_data_files[i].label,
  ------------------
  |  |   43|  3.22k|#define strlcpy _strlcpy
  ------------------
  509|  3.22k|			sizeof(obj.label));
  510|  3.22k|		data.path = path;
  511|  3.22k|		rv = sc_pkcs15emu_add_data_object(p15card, &obj, &data);
  512|  3.22k|		LOG_TEST_RET(p15card->card->ctx, rv,
  ------------------
  |  |  174|  3.22k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.22k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.22k|	int _ret = (r); \
  |  |  |  |  168|  3.22k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.22k]
  |  |  |  |  ------------------
  |  |  |  |  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|  3.22k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.22k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  513|  3.22k|			"Could not add data file");
  514|  3.22k|	}
  515|       |
  516|       |	/*
  517|       |	 * If we got this far, we can read the Personal Data file and glean
  518|       |	 * the user's full name. Thus we can use it to put together a
  519|       |	 * user-friendlier card name.
  520|       |	 */
  521|    255|	memset(&dinfo, 0, sizeof(dinfo));
  522|    255|	strlcpy(dinfo.app_label, "EF_DatiPersonali", sizeof(dinfo.app_label));
  ------------------
  |  |   43|    255|#define strlcpy _strlcpy
  ------------------
  523|       |
  524|       |	/* Find EF_DatiPersonali */
  525|       |
  526|    255|	rv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_DATA_OBJECT,
  ------------------
  |  |  442|    255|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  527|    255|		objs, 32);
  528|    255|	if(rv < 0) {
  ------------------
  |  Branch (528:5): [True: 0, False: 255]
  ------------------
  529|      0|		sc_log(p15card->card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  530|      0|			"Data enumeration failed");
  531|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  532|      0|	}
  533|       |
  534|    934|	for(i=0; i<32; i++) {
  ------------------
  |  Branch (534:11): [True: 934, False: 0]
  ------------------
  535|    934|		cinfo = (struct sc_pkcs15_data_info *) objs[i]->data;
  536|    934|		if(!strcmp("EF_DatiPersonali", objs[i]->label))
  ------------------
  |  Branch (536:6): [True: 255, False: 679]
  ------------------
  537|    255|			break;
  538|    934|	}
  539|       |
  540|    255|	if(i>=32) {
  ------------------
  |  Branch (540:5): [True: 0, False: 255]
  ------------------
  541|      0|		sc_log(p15card->card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  542|      0|			"Could not find EF_DatiPersonali: "
  543|      0|			"keeping generic card name");
  544|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  545|      0|	}
  546|       |
  547|    255|	private_obj = objs[i]->flags & SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    255|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  548|    255|	rv = sc_pkcs15_read_data_object(p15card, cinfo, private_obj, &p15_personaldata);
  549|    255|	if (rv) {
  ------------------
  |  Branch (549:6): [True: 151, False: 104]
  ------------------
  550|    151|		sc_log(p15card->card->ctx,
  ------------------
  |  |   71|    151|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  551|    151|			"Could not read EF_DatiPersonali: "
  552|    151|			"keeping generic card name");
  553|    151|		return SC_SUCCESS;
  ------------------
  |  |   28|    151|#define SC_SUCCESS				0
  ------------------
  554|    151|	}
  555|       |
  556|    104|	if (p15_personaldata->data) {
  ------------------
  |  Branch (556:6): [True: 90, False: 14]
  ------------------
  557|     90|		char fullname[160];
  558|     90|		if (get_name_from_EF_DatiPersonali(p15_personaldata->data,
  ------------------
  |  Branch (558:7): [True: 89, False: 1]
  ------------------
  559|     90|			p15_personaldata->data_len, fullname, sizeof(fullname))) {
  560|     89|			sc_log(p15card->card->ctx,
  ------------------
  |  |   71|     89|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  561|     89|				"Could not parse EF_DatiPersonali: "
  562|     89|				"keeping generic card name");
  563|     89|			sc_pkcs15_free_data_object(p15_personaldata);
  564|     89|			free(cinfo->data.value);
  565|     89|			cinfo->data.value = NULL;
  566|     89|			return SC_SUCCESS;
  ------------------
  |  |   28|     89|#define SC_SUCCESS				0
  ------------------
  567|     89|		}
  568|      1|		set_string(&p15card->tokeninfo->label, fullname);
  569|      1|	}
  570|     15|	free(cinfo->data.value);
  571|     15|	cinfo->data.value = NULL;
  572|     15|	sc_pkcs15_free_data_object(p15_personaldata);
  573|     15|	return SC_SUCCESS;
  ------------------
  |  |   28|     15|#define SC_SUCCESS				0
  ------------------
  574|    104|}
pkcs15-itacns.c:get_name_from_EF_DatiPersonali:
  387|     90|{
  388|     90|	const unsigned int EF_personaldata_maxlen = 400;
  389|     90|	const unsigned int tlv_length_size = 6;
  390|     90|	char *file = NULL;
  391|     90|	int file_size;
  392|       |
  393|       |	/*
  394|       |	 * Bytes 0-5 contain the ASCII encoding of the following TLV
  395|       |	 * structure's total size, in base 16.
  396|       |	 */
  397|     90|	if (EFdata_len < tlv_length_size) {
  ------------------
  |  Branch (397:6): [True: 3, False: 87]
  ------------------
  398|       |		/* We need at least 6 bytes for file length here */
  399|      3|		return -1;
  400|      3|	}
  401|     87|	file_size = hextoint((char*)EFdata, tlv_length_size);
  402|     87|	if (EFdata_len < (file_size + tlv_length_size)) {
  ------------------
  |  Branch (402:6): [True: 18, False: 69]
  ------------------
  403|       |		/* Inconsistent external file length and internal file length
  404|       |		 * suggests we are trying to process junk data.
  405|       |		 * If the internal data length is shorter, the data can be padded,
  406|       |		 * but we should be fine as we will not go behind the buffer limits */
  407|     18|		return -1;
  408|     18|	}
  409|     69|	file = (char*)&EFdata[tlv_length_size];
  410|       |
  411|     69|	enum {
  412|     69|		f_issuer_code = 0,
  413|     69|		f_issuing_date,
  414|     69|		f_expiry_date,
  415|     69|		f_last_name,
  416|     69|		f_first_name,
  417|     69|		f_birth_date,
  418|     69|		f_sex,
  419|     69|		f_height,
  420|     69|		f_codice_fiscale,
  421|     69|		f_citizenship_code,
  422|     69|		f_birth_township_code,
  423|     69|		f_birth_country,
  424|     69|		f_birth_certificate,
  425|     69|		f_residence_township_code,
  426|     69|		f_residence_address,
  427|     69|		f_expat_notes
  428|     69|	};
  429|       |
  430|       |	/* Read the fields up to f_first_name */
  431|     69|	struct {
  432|     69|		int len;
  433|     69|		char value[256];
  434|     69|	} fields[f_first_name+1];
  435|     69|	int i=0; /* offset inside the file */
  436|     69|	int f; /* field number */
  437|       |
  438|     69|	if (file_size < 0)
  ------------------
  |  Branch (438:6): [True: 57, False: 12]
  ------------------
  439|     57|		return -1;
  440|       |
  441|       |	/*
  442|       |	 * This shouldn't happen, but let us be protected against wrong
  443|       |	 * or malicious cards
  444|       |	 */
  445|     12|	if(file_size > (int)EF_personaldata_maxlen - (int)tlv_length_size)
  ------------------
  |  Branch (445:5): [True: 0, False: 12]
  ------------------
  446|      0|		file_size = EF_personaldata_maxlen - tlv_length_size;
  447|       |
  448|       |
  449|     12|	memset(fields, 0, sizeof(fields));
  450|       |
  451|     35|	for(f=0; f<f_first_name+1; f++) {
  ------------------
  |  Branch (451:11): [True: 34, False: 1]
  ------------------
  452|     34|		int field_size;
  453|       |
  454|       |		/* Don't read beyond the allocated buffer */
  455|     34|		if(i+2 > file_size)
  ------------------
  |  Branch (455:6): [True: 2, False: 32]
  ------------------
  456|      2|			return -1;
  457|     32|		field_size = hextoint((char*) &file[i], 2);
  458|     32|		i += 2;
  459|       |
  460|     32|		if (field_size < 0
  ------------------
  |  Branch (460:7): [True: 5, False: 27]
  ------------------
  461|     27|				|| i + field_size > file_size
  ------------------
  |  Branch (461:8): [True: 4, False: 23]
  ------------------
  462|     23|				|| field_size >= (int)sizeof(fields[f].value))
  ------------------
  |  Branch (462:8): [True: 0, False: 23]
  ------------------
  463|      9|			return -1;
  464|       |
  465|     23|		fields[f].len = field_size;
  466|     23|		strncpy(fields[f].value, &file[i], field_size);
  467|     23|		fields[f].value[field_size] = '\0';
  468|     23|		i += field_size;
  469|     23|	}
  470|       |
  471|      1|	if (fields[f_first_name].len + fields[f_last_name].len + 1 >= name_len)
  ------------------
  |  Branch (471:6): [True: 0, False: 1]
  ------------------
  472|      0|		return -1;
  473|       |
  474|       |	/* the lengths are already checked that they will fit in buffer */
  475|      1|	snprintf(name, name_len, "%.*s %.*s",
  476|      1|		fields[f_first_name].len, fields[f_first_name].value,
  477|      1|		fields[f_last_name].len, fields[f_last_name].value);
  478|      1|	return 0;
  479|      1|}
pkcs15-itacns.c:hextoint:
  370|    119|{
  371|    119|	char hex[16];
  372|    119|	char *end;
  373|    119|	int res;
  374|       |
  375|    119|	if(len >= sizeof(hex))
  ------------------
  |  Branch (375:5): [True: 0, False: 119]
  ------------------
  376|      0|		return -1;
  377|    119|	strncpy(hex, src, len);
  378|    119|	hex[len] = '\0';
  379|    119|	res = (int)strtol(hex, &end, 0x10);
  380|    119|	if(end != (char*)&hex[len])
  ------------------
  |  Branch (380:5): [True: 59, False: 60]
  ------------------
  381|     59|		return -1;
  382|     60|	return res;
  383|    119|}
pkcs15-itacns.c:itacns_check_and_add_keyset:
  654|    504|{
  655|    504|	int r;
  656|    504|	sc_path_t path;
  657|    504|	sc_pkcs15_id_t cert_id;
  658|    504|	int ext_info_ok;
  659|    504|	int ku = 0, xku = 0;
  660|    504|	size_t modulus_len = 0;
  661|    504|	int pubkey_usage_flags = 0, prkey_usage_flags = 0;
  662|       |
  663|    504|	cert_id.len = 1;
  664|    504|	cert_id.value[0] = sec_env;
  665|    504|	*found_certificates = 0;
  666|       |
  667|       |	/* Certificate */
  668|    504|	if (!cert_path) {
  ------------------
  |  Branch (668:6): [True: 0, False: 504]
  ------------------
  669|      0|		sc_log(p15card->card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  670|      0|			"We cannot use keys without a matching certificate");
  671|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  672|      0|	}
  673|       |
  674|    504|	sc_format_path(cert_path, &path);
  675|    504|	r = sc_select_file(p15card->card, &path, NULL);
  676|    504|	if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    504|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (676:6): [True: 19, False: 485]
  ------------------
  677|     19|		return 0;
  678|    485|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    485|#define SC_SUCCESS				0
  ------------------
  |  Branch (678:6): [True: 120, False: 365]
  ------------------
  679|    120|		sc_log(p15card->card->ctx,
  ------------------
  |  |   71|    120|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  680|    120|			"Could not find certificate for %s", label);
  681|    120|		return r;
  682|    120|	}
  683|       |
  684|       |	/*
  685|       |	 * Infocamere 1204 (and others?) store a more complex structure. We
  686|       |	 * are going to read the first bytes to guess its length, and invoke
  687|       |	 * itacns_add_cert so that it only reads the certificate.
  688|       |	 */
  689|    365|	if (cert_offset) {
  ------------------
  |  Branch (689:6): [True: 116, False: 249]
  ------------------
  690|    116|		u8 certlen[3];
  691|    116|		memset(certlen, 0, sizeof certlen);
  692|    116|		r = loadFile(p15card, &path, certlen, sizeof(certlen));
  693|    116|		LOG_TEST_RET(p15card->card->ctx, r,
  ------------------
  |  |  174|    116|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    116|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    116|	int _ret = (r); \
  |  |  |  |  168|    116|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 102]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|    116|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 102]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  694|    102|			"Could not read certificate file");
  695|    102|		if (r < 3)
  ------------------
  |  Branch (695:7): [True: 12, False: 90]
  ------------------
  696|     12|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     12|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  697|     90|		path.index = (int)cert_offset;
  698|     90|		path.count = (certlen[1] << 8) + certlen[2];
  699|       |		/* If those bytes are 00, then we are probably dealing with an
  700|       |		 * empty file. */
  701|     90|		if (path.count == 0)
  ------------------
  |  Branch (701:7): [True: 3, False: 87]
  ------------------
  702|      3|			return 0;
  703|     90|	}
  704|       |
  705|    336|	r = itacns_add_cert(p15card, SC_PKCS15_TYPE_CERT_X509, 0,
  ------------------
  |  |  439|    336|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  706|    336|		&path, &cert_id, label, 0, &ext_info_ok, &ku, &xku, &modulus_len);
  707|    336|	if (r == SC_ERROR_INVALID_ASN1_OBJECT)
  ------------------
  |  |   82|    336|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  |  Branch (707:6): [True: 252, False: 84]
  ------------------
  708|    252|		return 0;
  709|     84|	LOG_TEST_RET(p15card->card->ctx, r,
  ------------------
  |  |  174|     84|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     84|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     84|	int _ret = (r); \
  |  |  |  |  168|     84|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 84, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     84|		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|     84|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     84|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     84|		return _ret; \
  |  |  |  |  172|     84|	} \
  |  |  |  |  173|     84|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  710|      0|		"Could not add certificate");
  711|      0|	(*found_certificates)++;
  712|       |
  713|       |	/* Set usage flags */
  714|      0|	if(ext_info_ok) {
  ------------------
  |  Branch (714:5): [True: 0, False: 0]
  ------------------
  715|      0|#ifdef ENABLE_OPENSSL
  716|      0|		if (ku & KU_DIGITAL_SIGNATURE) {
  ------------------
  |  Branch (716:7): [True: 0, False: 0]
  ------------------
  717|      0|			pubkey_usage_flags |= SC_PKCS15_PRKEY_USAGE_VERIFY;
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  718|      0|			prkey_usage_flags |= SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  719|      0|		}
  720|      0|		if (ku & KU_NON_REPUDIATION) {
  ------------------
  |  Branch (720:7): [True: 0, False: 0]
  ------------------
  721|      0|			pubkey_usage_flags |= SC_PKCS15_PRKEY_USAGE_VERIFY;
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  722|      0|			prkey_usage_flags |= SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  723|      0|		}
  724|      0|		if (ku & KU_KEY_ENCIPHERMENT || ku & KU_KEY_AGREEMENT
  ------------------
  |  Branch (724:7): [True: 0, False: 0]
  |  Branch (724:35): [True: 0, False: 0]
  ------------------
  725|      0|			|| xku & XKU_SSL_CLIENT) {
  ------------------
  |  Branch (725:7): [True: 0, False: 0]
  ------------------
  726|      0|			pubkey_usage_flags |= SC_PKCS15_PRKEY_USAGE_WRAP;
  ------------------
  |  |  309|      0|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  727|      0|			prkey_usage_flags |= SC_PKCS15_PRKEY_USAGE_UNWRAP;
  ------------------
  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  728|      0|		}
  729|      0|		if (ku & KU_DATA_ENCIPHERMENT || xku & XKU_SMIME) {
  ------------------
  |  Branch (729:7): [True: 0, False: 0]
  |  Branch (729:36): [True: 0, False: 0]
  ------------------
  730|      0|			pubkey_usage_flags |= SC_PKCS15_PRKEY_USAGE_ENCRYPT;
  ------------------
  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
  731|      0|			prkey_usage_flags |= SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  732|      0|		}
  733|       |#else /* ENABLE_OPENSSL */
  734|       |		sc_log(p15card->card->ctx,
  735|       |			"Extended certificate info retrieved without OpenSSL. "
  736|       |			"How is this possible?");
  737|       |		return SC_ERROR_INTERNAL;
  738|       |#endif /* ENABLE_OPENSSL */
  739|      0|	} else {
  740|       |		/* Certificate info not retrieved; fall back onto defaults */
  741|      0|		pubkey_usage_flags =
  742|      0|			  SC_PKCS15_PRKEY_USAGE_VERIFY
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  743|      0|			| SC_PKCS15_PRKEY_USAGE_WRAP;
  ------------------
  |  |  309|      0|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  744|      0|		prkey_usage_flags =
  745|      0|			  SC_PKCS15_PRKEY_USAGE_SIGN
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  746|      0|			| SC_PKCS15_PRKEY_USAGE_UNWRAP;
  ------------------
  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  747|      0|	}
  748|       |
  749|      0|	r = itacns_add_keyset(p15card, label, sec_env, &cert_id,
  750|      0|		pubkey_path, prkey_path, pubkey_usage_flags, prkey_usage_flags,
  751|      0|		pin_ref, modulus_len);
  752|      0|	LOG_TEST_RET(p15card->card->ctx, r,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  753|      0|		"Could not add keys for this certificate");
  754|       |
  755|      0|	return r;
  756|      0|}
pkcs15-itacns.c:itacns_add_cert:
  189|    336|{
  190|    336|	int r;
  191|       |	/* const char *label = "Certificate"; */
  192|    336|	sc_pkcs15_cert_info_t info;
  193|    336|	sc_pkcs15_object_t    obj;
  194|    336|#ifdef ENABLE_OPENSSL
  195|    336|	X509 *x509;
  196|    336|	sc_pkcs15_cert_t *cert;
  197|    336|	int private_obj;
  198|    336|#endif
  199|       |
  200|    336|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_NORMAL);
  ------------------
  |  |  148|    336|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    336|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    336|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 336]
  |  |  ------------------
  ------------------
  201|       |
  202|    336|	if(type != SC_PKCS15_TYPE_CERT_X509) {
  ------------------
  |  |  439|    336|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  |  Branch (202:5): [True: 0, False: 336]
  ------------------
  203|      0|		sc_log(p15card->card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  204|      0|			"Cannot add a certificate of a type other than X.509");
  205|      0|		return 1;
  206|      0|	}
  207|       |
  208|    336|	*ext_info_ok = 0;
  209|       |
  210|       |
  211|    336|	memset(&info, 0, sizeof(info));
  212|    336|	memset(&obj,  0, sizeof(obj));
  213|       |
  214|    336|	info.id                = *id;
  215|    336|	info.authority         = authority;
  216|    336|	if (path)
  ------------------
  |  Branch (216:6): [True: 336, False: 0]
  ------------------
  217|    336|		info.path = *path;
  218|       |
  219|    336|	strlcpy(obj.label, label, sizeof(obj.label));
  ------------------
  |  |   43|    336|#define strlcpy _strlcpy
  ------------------
  220|       |
  221|       |	/* If we have OpenSSL, read keyUsage */
  222|    336|#ifdef ENABLE_OPENSSL
  223|    336|	private_obj = obj_flags & SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    336|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  224|    336|	r = sc_pkcs15_read_certificate(p15card, &info, private_obj, &cert);
  225|    336|	LOG_TEST_RET(p15card->card->ctx, r,
  ------------------
  |  |  174|    336|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    336|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    336|	int _ret = (r); \
  |  |  |  |  168|    336|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 336, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    336|		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|    336|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    336|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    336|		return _ret; \
  |  |  |  |  172|    336|	} \
  |  |  |  |  173|    336|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  226|      0|		"Could not read X.509 certificate");
  227|       |
  228|      0|	{
  229|      0|		const u8 *throwaway = cert->data.value;
  230|      0|		x509 = d2i_X509(NULL, &throwaway, cert->data.len);
  231|      0|	}
  232|       |
  233|      0|	if (cert->key && cert->key->algorithm == SC_ALGORITHM_RSA) {
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (233:6): [True: 0, False: 0]
  |  Branch (233:19): [True: 0, False: 0]
  ------------------
  234|      0|		*modulus_len = cert->key->u.rsa.modulus.len * 8;
  235|      0|	}
  236|       |
  237|      0|	sc_pkcs15_free_certificate(cert);
  238|      0|	if (!x509) {
  ------------------
  |  Branch (238:6): [True: 0, False: 0]
  ------------------
  239|      0|		sc_log_openssl(p15card->card->ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  240|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  241|      0|	}
  242|      0|	X509_check_purpose(x509, -1, 0);
  243|       |
  244|      0|	if(X509_get_extension_flags(x509) & EXFLAG_KUSAGE) {
  ------------------
  |  Branch (244:5): [True: 0, False: 0]
  ------------------
  245|      0|		*ext_info_ok = 1;
  246|      0|		*key_usage = X509_get_key_usage(x509);
  247|      0|		*x_key_usage = X509_get_extended_key_usage(x509);
  248|      0|	}
  249|      0|	OPENSSL_free(x509);
  250|       |
  251|      0|#endif /* ENABLE_OPENSSL */
  252|       |
  253|      0|	obj.flags = obj_flags;
  254|      0|	r = sc_pkcs15emu_add_x509_cert(p15card, &obj, &info);
  255|      0|	LOG_TEST_RET(p15card->card->ctx, r,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|      0|		"Could not add X.509 certificate");
  257|       |
  258|      0|	return r;
  259|      0|}

sc_pkcs15emu_jpki_init_ex:
  248|  12.8k|{
  249|  12.8k|	if (p15card->card->type != SC_CARD_TYPE_JPKI_BASE)
  ------------------
  |  Branch (249:6): [True: 12.7k, False: 72]
  ------------------
  250|  12.7k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.7k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  251|     72|	return sc_pkcs15emu_jpki_init(p15card);
  252|  12.8k|}
pkcs15-jpki.c:sc_pkcs15emu_jpki_init:
   38|     72|{
   39|     72|	sc_card_t *card = p15card->card;
   40|     72|	struct jpki_private_data *drvdata = JPKI_DRVDATA(card);
  ------------------
  |  |   36|     72|#define JPKI_DRVDATA(card) ((struct jpki_private_data *) ((card)->drv_data))
  ------------------
   41|     72|	int i, rc;
   42|       |
   43|     72|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|     72|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     72|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     72|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     72|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 72]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   44|       |
   45|     72|	set_string(&p15card->tokeninfo->label, "JPKI");
   46|     72|	set_string(&p15card->tokeninfo->manufacturer_id, "JPKI");
   47|       |	/* set dummy until we found serial number */
   48|     72|	set_string(&p15card->tokeninfo->serial_number, "00000000");
   49|       |
   50|       |	/* Select application directory */
   51|     72|	if (drvdata->selected != SELECT_JPKI_AP) {
  ------------------
  |  |   25|     72|#define SELECT_JPKI_AP 1
  ------------------
  |  Branch (51:6): [True: 72, False: 0]
  ------------------
   52|     72|		rc = jpki_select_ap(card);
   53|     72|		LOG_TEST_RET(card->ctx, rc, "select AP failed");
  ------------------
  |  |  174|     72|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     72|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     72|	int _ret = (r); \
  |  |  |  |  168|     72|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 61]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|     72|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 61]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   54|     61|		drvdata->selected = SELECT_JPKI_AP;
  ------------------
  |  |   25|     61|#define SELECT_JPKI_AP 1
  ------------------
   55|     61|	}
   56|       |
   57|       |	/* add certificates */
   58|    305|	for (i = 0; i < 4; i++) {
  ------------------
  |  Branch (58:14): [True: 244, False: 61]
  ------------------
   59|    244|		static const char *jpki_cert_names[4] = {
   60|    244|			"User Authentication Certificate",
   61|    244|			"Digital Signature Certificate",
   62|    244|			"User Authentication Certificate CA",
   63|    244|			"Digital Signature Certificate CA"
   64|    244|		};
   65|    244|		static char const *jpki_cert_paths[4] = {
   66|    244|			"000A",
   67|    244|			"0001",
   68|    244|			"000B",
   69|    244|			"0002"
   70|    244|		};
   71|    244|		static int jpki_cert_ids[4] = { 1, 2, 3, 4 };
   72|    244|		static int jpki_cert_flags[4] = {
   73|    244|			0,
   74|    244|			SC_PKCS15_CO_FLAG_PRIVATE,
  ------------------
  |  |   50|    244|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
   75|    244|			0,
   76|    244|			0,
   77|    244|		};
   78|    244|		static int jpki_cert_auth_id[4] = { 0, 2, 0, 0 };
   79|    244|		static int jpki_cert_authority[4] = {0, 0, 1, 1};
   80|    244|		struct sc_pkcs15_cert_info cert_info;
   81|    244|		struct sc_pkcs15_object cert_obj;
   82|    244|		memset(&cert_info, 0, sizeof(cert_info));
   83|    244|		memset(&cert_obj, 0, sizeof(cert_obj));
   84|       |
   85|    244|		cert_info.id.value[0] = jpki_cert_ids[i];
   86|    244|		cert_info.id.len = 1;
   87|    244|		sc_format_path(jpki_cert_paths[i], &cert_info.path);
   88|    244|		cert_info.path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    244|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
   89|       |
   90|    244|		strlcpy(cert_obj.label, jpki_cert_names[i], sizeof(cert_obj.label));
  ------------------
  |  |   43|    244|#define strlcpy _strlcpy
  ------------------
   91|    244|		cert_info.authority = jpki_cert_authority[i];
   92|    244|		cert_obj.flags = jpki_cert_flags[i];
   93|    244|		if (jpki_cert_auth_id[i]) {
  ------------------
  |  Branch (93:7): [True: 61, False: 183]
  ------------------
   94|     61|			cert_obj.auth_id.len = 1;
   95|     61|			cert_obj.auth_id.value[0] = jpki_cert_auth_id[i];
   96|     61|		}
   97|    244|		rc = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
   98|    244|		if (rc < 0) {
  ------------------
  |  Branch (98:7): [True: 0, False: 244]
  ------------------
   99|      0|			sc_pkcs15_card_clear(p15card);
  100|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|      0|		}
  102|       |
  103|    244|	}
  104|       |
  105|       |	/* add pins */
  106|    141|	for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (106:14): [True: 106, False: 35]
  ------------------
  107|    106|		static const char *jpki_pin_names[2] = {
  108|    106|			"User Authentication PIN",
  109|    106|			"Digital Signature PIN"
  110|    106|		};
  111|    106|		static const int jpki_pin_min[2] = { 4, 6 };
  112|    106|		static const int jpki_pin_max[2] = { 4, 16 };
  113|    106|		static const int jpki_pin_ref[2] = { 1, 2 };
  114|    106|		static const int jpki_pin_authid[2] = { 1, 2 };
  115|    106|		static const int jpki_pin_flags[2] = {
  116|    106|			SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   58|    106|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  117|    106|			SC_PKCS15_PIN_FLAG_LOCAL,
  ------------------
  |  |   55|    106|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  118|    106|			SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   58|    106|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  119|    106|			SC_PKCS15_PIN_FLAG_LOCAL
  ------------------
  |  |   55|    106|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  120|    106|		};
  121|    106|		static const int jpki_pin_max_tries[2] = {
  122|    106|			JPKI_AUTH_PIN_MAX_TRIES,
  ------------------
  |  |   30|    106|#define JPKI_AUTH_PIN_MAX_TRIES 3
  ------------------
  123|    106|			JPKI_SIGN_PIN_MAX_TRIES
  ------------------
  |  |   34|    106|#define JPKI_SIGN_PIN_MAX_TRIES 5
  ------------------
  124|    106|		};
  125|       |
  126|    106|		struct sc_pkcs15_auth_info pin_info;
  127|    106|		struct sc_pkcs15_object pin_obj;
  128|    106|		struct sc_pin_cmd_data pin_cmd_data;
  129|    106|		memset(&pin_info, 0, sizeof (pin_info));
  130|    106|		memset(&pin_obj, 0, sizeof (pin_obj));
  131|    106|		memset(&pin_cmd_data, 0, sizeof(pin_cmd_data));
  132|       |
  133|    106|		pin_info.auth_id.len = 1;
  134|    106|		pin_info.auth_id.value[0] = jpki_pin_authid[i];
  135|    106|		pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    106|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  136|    106|		pin_info.attrs.pin.reference = jpki_pin_ref[i];
  137|    106|		pin_info.attrs.pin.flags = jpki_pin_flags[i];
  138|    106|		pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|    106|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  139|    106|		pin_info.attrs.pin.min_length = jpki_pin_min[i];
  140|    106|		pin_info.attrs.pin.stored_length = 0;
  141|    106|		pin_info.attrs.pin.max_length = jpki_pin_max[i];
  142|    106|		pin_info.attrs.pin.pad_char = '\0';
  143|    106|		pin_info.max_tries = jpki_pin_max_tries[i];
  144|    106|		pin_info.tries_left = -1;
  145|    106|		pin_info.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|    106|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
  146|       |
  147|    106|		pin_cmd_data.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|    106|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  148|    106|		pin_cmd_data.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|    106|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  149|    106|		pin_cmd_data.pin_reference = jpki_pin_ref[i];
  150|    106|		rc = sc_pin_cmd(card, &pin_cmd_data);
  151|    106|		pin_info.tries_left = pin_cmd_data.pin1.tries_left;
  152|    106|		LOG_TEST_RET(card->ctx, rc, "sc_pin_cmd failed");
  ------------------
  |  |  174|    106|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    106|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    106|	int _ret = (r); \
  |  |  |  |  168|    106|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 26, False: 80]
  |  |  |  |  ------------------
  |  |  |  |  169|     26|		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|     26|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     26|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     26|		return _ret; \
  |  |  |  |  172|     26|	} \
  |  |  |  |  173|    106|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 80]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  153|     80|		strlcpy(pin_obj.label, jpki_pin_names[i], sizeof(pin_obj.label));
  ------------------
  |  |   43|     80|#define strlcpy _strlcpy
  ------------------
  154|     80|		pin_obj.flags = jpki_pin_flags[i];
  155|       |
  156|     80|		rc = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  157|     80|		if (rc < 0) {
  ------------------
  |  Branch (157:7): [True: 0, False: 80]
  ------------------
  158|      0|			sc_pkcs15_card_clear(p15card);
  159|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|      0|		}
  161|     80|	}
  162|       |
  163|       |	/* add private keys */
  164|    105|	for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (164:14): [True: 70, False: 35]
  ------------------
  165|     70|		static int prkey_pin[2] = { 1, 2 };
  166|     70|		static int prkey_usage[2] = {
  167|     70|			SC_PKCS15_PRKEY_USAGE_SIGN,
  ------------------
  |  |  307|     70|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  168|     70|			SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_NONREPUDIATION
  ------------------
  |  |  307|     70|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
              			SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_NONREPUDIATION
  ------------------
  |  |  314|     70|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  169|     70|		};
  170|     70|		static const char *prkey_name[2] = {
  171|     70|			"User Authentication Key",
  172|     70|			"Digital Signature Key"
  173|     70|		};
  174|     70|		static int prkey_user_consent[2] = { 0, 1 };
  175|     70|		struct sc_pkcs15_prkey_info prkey_info;
  176|     70|		struct sc_pkcs15_object prkey_obj;
  177|       |
  178|     70|		memset(&prkey_info, 0, sizeof (prkey_info));
  179|     70|		memset(&prkey_obj, 0, sizeof (prkey_obj));
  180|       |
  181|     70|		prkey_info.id.len = 1;
  182|     70|		prkey_info.id.value[0] = prkey_pin[i];
  183|     70|		prkey_info.usage = prkey_usage[i];
  184|     70|		prkey_info.native = 1;
  185|     70|		prkey_info.key_reference = i + 1;
  186|     70|		prkey_info.modulus_length = 2048;
  187|       |
  188|     70|		strlcpy(prkey_obj.label, prkey_name[i], sizeof (prkey_obj.label));
  ------------------
  |  |   43|     70|#define strlcpy _strlcpy
  ------------------
  189|     70|		prkey_obj.auth_id.len = 1;
  190|     70|		prkey_obj.auth_id.value[0] = prkey_pin[i];
  191|     70|		prkey_obj.user_consent = prkey_user_consent[i];
  192|     70|		prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|     70|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  193|       |
  194|     70|		rc = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  195|     70|		if (rc < 0) {
  ------------------
  |  Branch (195:7): [True: 0, False: 70]
  ------------------
  196|      0|			sc_pkcs15_card_clear(p15card);
  197|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|      0|		}
  199|     70|	}
  200|       |
  201|       |	/* add public keys */
  202|    105|	for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (202:14): [True: 70, False: 35]
  ------------------
  203|     70|		static int pubkey_id[2] = { 1, 2 };
  204|     70|		static const char *jpki_pubkey_names[2] = {
  205|     70|			"User Authentication Public Key",
  206|     70|			"Digital Signature Public Key"
  207|     70|		};
  208|     70|		static int jpki_pubkey_flags[2] = {
  209|     70|				0,
  210|     70|				SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   50|     70|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  211|     70|		static int jpki_pubkey_auth_id[2] = {0, 2};
  212|     70|		struct sc_pkcs15_pubkey_info pubkey_info;
  213|     70|		struct sc_pkcs15_object pubkey_obj;
  214|     70|		static char const *jpki_pubkey_paths[2] = {
  215|     70|			"000A",
  216|     70|			"0001"
  217|     70|		};
  218|       |
  219|     70|		memset(&pubkey_info, 0, sizeof (pubkey_info));
  220|     70|		memset(&pubkey_obj, 0, sizeof (pubkey_obj));
  221|       |
  222|     70|		strlcpy(pubkey_obj.label, jpki_pubkey_names[i], sizeof (pubkey_obj.label));
  ------------------
  |  |   43|     70|#define strlcpy _strlcpy
  ------------------
  223|     70|		pubkey_info.id.len = 1;
  224|     70|		pubkey_info.id.value[0] = pubkey_id[i];
  225|     70|		pubkey_info.native = 1;
  226|     70|		pubkey_info.key_reference = i + 1;
  227|       |
  228|     70|		sc_format_path(jpki_pubkey_paths[i], &pubkey_info.path);
  229|     70|		pubkey_info.path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     70|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  230|     70|		pubkey_obj.flags = jpki_pubkey_flags[i];
  231|     70|		if (jpki_pubkey_auth_id[i]) {
  ------------------
  |  Branch (231:7): [True: 35, False: 35]
  ------------------
  232|     35|			pubkey_obj.auth_id.len = 1;
  233|     35|			pubkey_obj.auth_id.value[0] = jpki_pubkey_auth_id[i];
  234|     35|		}
  235|       |
  236|     70|		rc = sc_pkcs15emu_add_rsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
  237|     70|		if (rc < 0) {
  ------------------
  |  Branch (237:7): [True: 0, False: 70]
  ------------------
  238|      0|			sc_pkcs15_card_clear(p15card);
  239|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  240|      0|		}
  241|     70|	}
  242|     35|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     35|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     35|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     35|	int _ret = r; \
  |  |  |  |  155|     35|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 35, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     35|		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: 35]
  |  |  |  |  ------------------
  |  |  |  |  157|     35|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     35|	} 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|     35|	return _ret; \
  |  |  |  |  163|     35|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|     35|}

sc_pkcs15emu_lteid_init_ex:
   70|  10.1k|{
   71|  10.1k|	if (p15card->card->type == SC_CARD_TYPE_LTEID) {
  ------------------
  |  Branch (71:6): [True: 0, False: 10.1k]
  ------------------
   72|      0|		return sc_pkcs15emu_lteid_init(p15card, aid);
   73|      0|	}
   74|       |
   75|  10.1k|	return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  10.1k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   76|  10.1k|}

sc_pkcs15emu_nqapplet_init_ex:
  179|  10.2k|{
  180|  10.2k|	int rv = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  10.2k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  181|  10.2k|	sc_context_t *ctx;
  182|  10.2k|	sc_card_t *card;
  183|       |
  184|  10.2k|	if (!p15card || !p15card->card || !p15card->card->ctx) {
  ------------------
  |  Branch (184:6): [True: 0, False: 10.2k]
  |  Branch (184:18): [True: 0, False: 10.2k]
  |  Branch (184:36): [True: 0, False: 10.2k]
  ------------------
  185|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  186|      0|	}
  187|       |
  188|  10.2k|	card = p15card->card;
  189|  10.2k|	ctx = card->ctx;
  190|       |
  191|  10.2k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
  ------------------
  |  |  148|  10.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  10.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  10.2k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 10.2k]
  |  |  ------------------
  ------------------
  192|       |
  193|  10.2k|	if (card->type < SC_CARD_TYPE_NQ_APPLET || card->type > SC_CARD_TYPE_NQ_APPLET_RFID) {
  ------------------
  |  Branch (193:6): [True: 9.81k, False: 461]
  |  Branch (193:45): [True: 318, False: 143]
  ------------------
  194|  10.1k|		sc_log(p15card->card->ctx, "Unsupported card type: %d", card->type);
  ------------------
  |  |   71|  10.1k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  195|  10.1k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  10.1k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  196|  10.1k|	}
  197|       |
  198|    143|	rv = add_nqapplet_objects(p15card);
  199|    143|	LOG_TEST_GOTO_ERR(ctx, rv, "Failed to add PKCS15");
  ------------------
  |  |  184|    143|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    143|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    143|	int _ret = (r); \
  |  |  |  |  178|    143|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 29, False: 114]
  |  |  |  |  ------------------
  |  |  |  |  179|     29|		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|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     29|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     29|		goto err; \
  |  |  |  |  182|     29|	} \
  |  |  |  |  183|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 114]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  200|       |
  201|    114|	if (aid != NULL) {
  ------------------
  |  Branch (201:6): [True: 0, False: 114]
  ------------------
  202|      0|		struct sc_file *file = sc_file_new();
  203|      0|		if (file != NULL) {
  ------------------
  |  Branch (203:7): [True: 0, False: 0]
  ------------------
  204|       |			/* PKCS11 depends on the file_app object, provide MF */
  205|      0|			sc_format_path("3f00", &file->path);
  206|      0|			sc_file_free(p15card->file_app);
  207|      0|			p15card->file_app = file;
  208|      0|		}
  209|      0|	}
  210|       |
  211|    114|	sc_pkcs15_free_tokeninfo(p15card->tokeninfo);
  212|       |
  213|    114|	p15card->tokeninfo = sc_pkcs15_tokeninfo_new();
  214|    114|	if (p15card->tokeninfo == NULL) {
  ------------------
  |  Branch (214:6): [True: 0, False: 114]
  ------------------
  215|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  216|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "unable to create tokeninfo struct");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|    114|	} else {
  218|    114|		char serial_hex[SC_MAX_SERIALNR * 2 + 2];
  219|       |
  220|    114|		sc_bin_to_hex(card->serialnr.value, card->serialnr.len, serial_hex, sizeof(serial_hex), 0);
  221|    114|		set_string(&p15card->tokeninfo->serial_number, serial_hex);
  222|    114|		set_string(&p15card->tokeninfo->label, name_Card);
  223|    114|		set_string(&p15card->tokeninfo->manufacturer_id, name_Vendor);
  224|    114|		p15card->tokeninfo->flags = SC_PKCS15_TOKEN_READONLY;
  ------------------
  |  |  595|    114|#define SC_PKCS15_TOKEN_READONLY			0x01
  ------------------
  225|    114|	}
  226|       |
  227|    114|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    114|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    114|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    114|	int _ret = r; \
  |  |  |  |  155|    114|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 114, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    114|		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: 114]
  |  |  |  |  ------------------
  |  |  |  |  157|    114|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    114|	} 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|    114|	return _ret; \
  |  |  |  |  163|    114|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  228|     29|err:
  229|     29|	sc_pkcs15_card_clear(p15card);
  230|     29|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     29|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     29|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     29|	int _ret = r; \
  |  |  |  |  155|     29|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     29|		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|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     29|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     29|	} 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|     29|	return _ret; \
  |  |  |  |  163|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  231|     29|}
pkcs15-nqApplet.c:add_nqapplet_objects:
  146|    143|{
  147|    143|	int rv;
  148|    143|	sc_card_t *card = p15card->card;
  149|       |
  150|    143|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    143|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    143|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    143|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    143|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 143]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  151|       |
  152|       |	// 1) User PIN
  153|    143|	rv = add_nqapplet_pin(p15card, "1", 0x01);
  154|    143|	LOG_TEST_RET(card->ctx, rv, "Failed to add PIN 1");
  ------------------
  |  |  174|    143|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    143|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    143|	int _ret = (r); \
  |  |  |  |  168|    143|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 143]
  |  |  |  |  ------------------
  |  |  |  |  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|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 143]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  155|       |
  156|       |	// 2.1) C.CH.Auth
  157|    143|	rv = add_nqapplet_certificate(p15card, "1", "C.CH.Auth", 0x00);
  158|    143|	LOG_TEST_RET(card->ctx, rv, "Failed to add Auth. certificate");
  ------------------
  |  |  174|    143|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    143|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    143|	int _ret = (r); \
  |  |  |  |  168|    143|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 29, False: 114]
  |  |  |  |  ------------------
  |  |  |  |  169|     29|		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|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     29|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     29|		return _ret; \
  |  |  |  |  172|     29|	} \
  |  |  |  |  173|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 114]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|       |
  160|       |	// 2.2) PrK.CH.Auth
  161|    114|	rv = add_nqapplet_private_key(p15card, "1", 0x01, "PrK.CH.Auth", "1",
  162|    114|	                              SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_DECRYPT);
  ------------------
  |  |  307|    114|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
              	                              SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_DECRYPT);
  ------------------
  |  |  306|    114|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  163|    114|	LOG_TEST_RET(card->ctx, rv, "Failed to add Auth. private key");
  ------------------
  |  |  174|    114|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    114|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    114|	int _ret = (r); \
  |  |  |  |  168|    114|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 114]
  |  |  |  |  ------------------
  |  |  |  |  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|    114|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 114]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|       |
  165|       |	// 3.1) C.CH.Encr
  166|    114|	rv = add_nqapplet_certificate(p15card, "2", "C.CH.Encr", 0x01);
  167|    114|	if (rv == SC_SUCCESS) {
  ------------------
  |  |   28|    114|#define SC_SUCCESS				0
  ------------------
  |  Branch (167:6): [True: 39, False: 75]
  ------------------
  168|       |		// 3.2) PrK.CH.Encr
  169|     39|		rv = add_nqapplet_private_key(p15card, "2", 0x02, "PrK.CH.Encr", "1", SC_PKCS15_PRKEY_USAGE_DECRYPT);
  ------------------
  |  |  306|     39|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  170|     39|		LOG_TEST_RET(card->ctx, rv, "Failed to add Encr. private key");
  ------------------
  |  |  174|     39|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     39|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     39|	int _ret = (r); \
  |  |  |  |  168|     39|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 39]
  |  |  |  |  ------------------
  |  |  |  |  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|     39|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|     75|	} else {
  172|     75|		sc_log(p15card->card->ctx, "The card has no C.CH.Encr, ignoring CH.Encr container");
  ------------------
  |  |   71|     75|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  173|     75|	}
  174|       |
  175|    114|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    114|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    114|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    114|	int _ret = r; \
  |  |  |  |  155|    114|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 114, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    114|		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: 114]
  |  |  |  |  ------------------
  |  |  |  |  157|    114|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    114|	} 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|    114|	return _ret; \
  |  |  |  |  163|    114|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  176|    114|}
pkcs15-nqApplet.c:add_nqapplet_pin:
   59|    143|{
   60|    143|	int rv;
   61|    143|	struct sc_pkcs15_auth_info pin_info;
   62|    143|	struct sc_pkcs15_object pin_obj;
   63|    143|	sc_card_t *card = p15card->card;
   64|       |
   65|    143|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    143|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    143|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    143|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    143|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 143]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   66|       |
   67|    143|	memset(&pin_info, 0, sizeof(pin_info));
   68|    143|	memset(&pin_obj, 0, sizeof(pin_obj));
   69|       |
   70|    143|	sc_pkcs15_format_id(id, &pin_info.auth_id);
   71|    143|	pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    143|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
   72|    143|	pin_info.attrs.pin.reference = reference;
   73|    143|	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_CASE_SENSITIVE |
  ------------------
  |  |   58|    143|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
              	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_CASE_SENSITIVE |
  ------------------
  |  |   54|    143|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
   74|    143|	                           SC_PKCS15_PIN_TYPE_FLAGS_PIN_GLOBAL | SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   75|    143|	( SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  ------------------
  |  |  |  |   58|    143|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  ------------------
              	                           SC_PKCS15_PIN_TYPE_FLAGS_PIN_GLOBAL | SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    143|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
   75|    143|	pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_UTF8;
  ------------------
  |  |   90|    143|#define SC_PKCS15_PIN_TYPE_UTF8				2
  ------------------
   76|    143|	pin_info.attrs.pin.min_length = 6;
   77|    143|	pin_info.attrs.pin.stored_length = 6;
   78|    143|	pin_info.attrs.pin.max_length = 6;
   79|    143|	pin_info.attrs.pin.pad_char = '\0';
   80|    143|	pin_info.tries_left = -1; // TODO
   81|    143|	pin_info.max_tries = 3;
   82|       |
   83|    143|	strlcpy(pin_obj.label, "UserPIN", sizeof(pin_obj.label));
  ------------------
  |  |   43|    143|#define strlcpy _strlcpy
  ------------------
   84|    143|	pin_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   51|    143|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              	pin_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    143|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
   85|       |
   86|    143|	rv = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
   87|    143|	LOG_TEST_RET(card->ctx, rv, "sc_pkcs15emu_add_pin_obj failed");
  ------------------
  |  |  174|    143|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    143|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    143|	int _ret = (r); \
  |  |  |  |  168|    143|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 143]
  |  |  |  |  ------------------
  |  |  |  |  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|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 143]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   88|       |
   89|    143|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    143|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    143|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    143|	int _ret = r; \
  |  |  |  |  155|    143|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 143, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    143|		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: 143]
  |  |  |  |  ------------------
  |  |  |  |  157|    143|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    143|	} 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|    143|	return _ret; \
  |  |  |  |  163|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   90|    143|}
pkcs15-nqApplet.c:add_nqapplet_certificate:
   93|    257|{
   94|    257|	int rv;
   95|    257|	struct sc_pkcs15_cert_info cert_info;
   96|    257|	struct sc_pkcs15_object cert_obj;
   97|    257|	sc_card_t *card = p15card->card;
   98|       |
   99|    257|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    257|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    257|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    257|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    257|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 257]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|       |
  101|    257|	memset(&cert_info, 0, sizeof(cert_info));
  102|    257|	memset(&cert_obj, 0, sizeof(cert_obj));
  103|       |
  104|    257|	sc_pkcs15_format_id(id, &cert_info.id);
  105|    257|	rv = get_nqapplet_certificate(card, data_id, &cert_info.value);
  106|    257|	LOG_TEST_RET(card->ctx, rv, "Failed to get certificate");
  ------------------
  |  |  174|    257|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    257|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    257|	int _ret = (r); \
  |  |  |  |  168|    257|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 104, False: 153]
  |  |  |  |  ------------------
  |  |  |  |  169|    104|		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|    104|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    104|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    104|		return _ret; \
  |  |  |  |  172|    104|	} \
  |  |  |  |  173|    257|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|       |
  108|    153|	strlcpy(cert_obj.label, name, sizeof(cert_obj.label));
  ------------------
  |  |   43|    153|#define strlcpy _strlcpy
  ------------------
  109|       |
  110|    153|	rv = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  111|    153|	LOG_TEST_RET(card->ctx, rv, "sc_pkcs15emu_add_x509_cert failed");
  ------------------
  |  |  174|    153|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    153|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    153|	int _ret = (r); \
  |  |  |  |  168|    153|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 153]
  |  |  |  |  ------------------
  |  |  |  |  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|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  112|       |
  113|    153|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    153|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    153|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    153|	int _ret = r; \
  |  |  |  |  155|    153|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 153, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    153|		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: 153]
  |  |  |  |  ------------------
  |  |  |  |  157|    153|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    153|	} 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|    153|	return _ret; \
  |  |  |  |  163|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  114|    153|}
pkcs15-nqApplet.c:get_nqapplet_certificate:
   35|    257|{
   36|    257|	int rv;
   37|    257|	u8 buffer[3072];
   38|    257|	size_t cb_buffer = sizeof(buffer);
   39|    257|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    257|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    257|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    257|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    257|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 257]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   40|       |
   41|    257|	rv = sc_get_data(card, data_id, buffer, cb_buffer);
   42|    257|	LOG_TEST_RET(card->ctx, rv, "GET DATA failed");
  ------------------
  |  |  174|    257|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    257|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    257|	int _ret = (r); \
  |  |  |  |  168|    257|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 26, False: 231]
  |  |  |  |  ------------------
  |  |  |  |  169|     26|		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|     26|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     26|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     26|		return _ret; \
  |  |  |  |  172|     26|	} \
  |  |  |  |  173|    257|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 231]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   43|    231|	if (rv == 0) {
  ------------------
  |  Branch (43:6): [True: 78, False: 153]
  ------------------
   44|     78|		LOG_TEST_RET(card->ctx, SC_ERROR_FILE_NOT_FOUND, "No certificate data returned");
  ------------------
  |  |  174|     78|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     78|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     78|	int _ret = (r); \
  |  |  |  |  168|     78|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 78, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     78|		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|     78|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     78|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     78|		return _ret; \
  |  |  |  |  172|     78|	} \
  |  |  |  |  173|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   45|     78|	}
   46|       |
   47|    153|	if (cert_info != NULL) {
  ------------------
  |  Branch (47:6): [True: 153, False: 0]
  ------------------
   48|    153|		free(cert_info->value);
   49|    153|		cert_info->value = malloc(rv);
   50|    153|		if (cert_info->value != NULL) {
  ------------------
  |  Branch (50:7): [True: 153, False: 0]
  ------------------
   51|    153|			cert_info->len = rv;
   52|    153|			memcpy(cert_info->value, buffer, rv);
   53|    153|		}
   54|    153|	}
   55|    153|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    153|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    153|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    153|	int _ret = r; \
  |  |  |  |  155|    153|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 153, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    153|		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: 153]
  |  |  |  |  ------------------
  |  |  |  |  157|    153|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    153|	} 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|    153|	return _ret; \
  |  |  |  |  163|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|    153|}
pkcs15-nqApplet.c:add_nqapplet_private_key:
  118|    153|{
  119|    153|	int rv;
  120|    153|	struct sc_pkcs15_prkey_info prkey_info;
  121|    153|	struct sc_pkcs15_object prkey_obj;
  122|    153|	sc_card_t *card = p15card->card;
  123|       |
  124|    153|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    153|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    153|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    153|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    153|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  125|       |
  126|    153|	memset(&prkey_info, 0, sizeof(prkey_info));
  127|    153|	memset(&prkey_obj, 0, sizeof(prkey_obj));
  128|       |
  129|    153|	sc_pkcs15_format_id(id, &prkey_info.id);
  130|    153|	prkey_info.usage = usage;
  131|    153|	prkey_info.native = 1;
  132|    153|	prkey_info.key_reference = reference;
  133|    153|	prkey_info.modulus_length = 3072;
  134|       |
  135|    153|	strlcpy(prkey_obj.label, name, sizeof(prkey_obj.label));
  ------------------
  |  |   43|    153|#define strlcpy _strlcpy
  ------------------
  136|    153|	prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    153|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  137|    153|	sc_pkcs15_format_id(pin_id, &prkey_obj.auth_id);
  138|       |
  139|    153|	rv = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  140|    153|	LOG_TEST_RET(card->ctx, rv, "sc_pkcs15emu_add_rsa_prkey failed");
  ------------------
  |  |  174|    153|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    153|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    153|	int _ret = (r); \
  |  |  |  |  168|    153|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 153]
  |  |  |  |  ------------------
  |  |  |  |  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|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|       |
  142|    153|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    153|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    153|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    153|	int _ret = r; \
  |  |  |  |  155|    153|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 153, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    153|		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: 153]
  |  |  |  |  ------------------
  |  |  |  |  157|    153|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    153|	} 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|    153|	return _ret; \
  |  |  |  |  163|    153|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  143|    153|}

sc_pkcs15emu_oberthur_init_ex:
 1160|  12.9k|{
 1161|  12.9k|	int rv;
 1162|       |
 1163|  12.9k|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|  12.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  12.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  12.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  12.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 12.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1164|  12.9k|	rv = oberthur_detect_card(p15card);
 1165|  12.9k|	if (!rv)
  ------------------
  |  Branch (1165:6): [True: 852, False: 12.1k]
  ------------------
 1166|    852|		rv = sc_pkcs15emu_oberthur_init(p15card);
 1167|       |
 1168|  12.9k|	LOG_FUNC_RETURN(p15card->card->ctx, rv);
  ------------------
  |  |  164|  12.9k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  12.9k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  12.9k|	int _ret = r; \
  |  |  |  |  155|  12.9k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  12.9k|		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|  12.9k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 12.9k, False: 49]
  |  |  |  |  ------------------
  |  |  |  |  157|  12.9k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  12.9k|	} 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|  12.9k|	return _ret; \
  |  |  |  |  163|  12.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1169|  12.9k|}
pkcs15-oberthur.c:oberthur_detect_card:
 1148|  12.9k|{
 1149|  12.9k|	struct sc_card *card = p15card->card;
 1150|       |
 1151|  12.9k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  12.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  12.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  12.9k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 12.9k]
  |  |  ------------------
  ------------------
 1152|  12.9k|	if (p15card->card->type != SC_CARD_TYPE_OBERTHUR_64K)
  ------------------
  |  Branch (1152:6): [True: 12.1k, False: 852]
  ------------------
 1153|  12.9k|		LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  12.1k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  12.1k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  12.1k|	int _ret = r; \
  |  |  |  |  155|  12.1k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  12.1k|		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|  12.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 12.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  12.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  12.1k|	} 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|  12.1k|	return _ret; \
  |  |  |  |  163|  12.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1154|    852|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    852|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    852|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    852|	int _ret = r; \
  |  |  |  |  155|    852|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 852, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    852|		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: 852]
  |  |  |  |  ------------------
  |  |  |  |  157|    852|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    852|	} 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|    852|	return _ret; \
  |  |  |  |  163|    852|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1155|    852|}
pkcs15-oberthur.c:sc_pkcs15emu_oberthur_init:
 1015|    852|{
 1016|    852|	struct sc_context *ctx = p15card->card->ctx;
 1017|    852|	struct sc_pkcs15_auth_info auth_info;
 1018|    852|	struct sc_pkcs15_object   obj;
 1019|    852|	struct sc_card *card = p15card->card;
 1020|    852|	struct sc_path path;
 1021|    852|	int rv, ii, tries_left;
 1022|    852|	char serial[0x10];
 1023|    852|	unsigned char sopin_reference = 0x04;
 1024|       |
 1025|    852|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    852|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    852|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    852|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 852]
  |  |  ------------------
  ------------------
 1026|    852|	sc_bin_to_hex(card->serialnr.value, card->serialnr.len, serial, sizeof(serial), 0);
 1027|    852|	set_string(&p15card->tokeninfo->serial_number, serial);
 1028|       |
 1029|    852|	p15card->ops.parse_df = sc_awp_parse_df;
 1030|    852|	p15card->ops.clear = sc_awp_clear;
 1031|       |
 1032|    852|	sc_log(ctx, "Oberthur init: serial %s", p15card->tokeninfo->serial_number);
  ------------------
  |  |   71|    852|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1033|       |
 1034|    852|	sc_format_path(AWP_PIN_DF, &path);
  ------------------
  |  |   69|    852|#define AWP_PIN_DF		"3F005011"
  ------------------
 1035|    852|	rv = sc_select_file(card, &path, NULL);
 1036|    852|	LOG_TEST_GOTO_ERR(ctx, rv, "Oberthur init failed: cannot select PIN dir");
  ------------------
  |  |  184|    852|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    852|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    852|	int _ret = (r); \
  |  |  |  |  178|    852|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 370, False: 482]
  |  |  |  |  ------------------
  |  |  |  |  179|    370|		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|    370|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    370|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    370|		goto err; \
  |  |  |  |  182|    370|	} \
  |  |  |  |  183|    852|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 482]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1037|       |
 1038|    482|	tries_left = -1;
 1039|    482|	rv = sc_verify(card, SC_AC_CHV, sopin_reference, (unsigned char *)"", 0, &tries_left);
  ------------------
  |  |  151|    482|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1040|    482|	if (rv && rv != SC_ERROR_PIN_CODE_INCORRECT)   {
  ------------------
  |  |   64|     75|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (1040:6): [True: 75, False: 407]
  |  Branch (1040:12): [True: 59, False: 16]
  ------------------
 1041|     59|		sopin_reference = 0x84;
 1042|     59|		rv = sc_verify(card, SC_AC_CHV, sopin_reference, (unsigned char *)"", 0, &tries_left);
  ------------------
  |  |  151|     59|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1043|     59|	}
 1044|    482|	if (rv && rv != SC_ERROR_PIN_CODE_INCORRECT)
  ------------------
  |  |   64|     70|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (1044:6): [True: 70, False: 412]
  |  Branch (1044:12): [True: 49, False: 21]
  ------------------
 1045|    482|		LOG_TEST_GOTO_ERR(ctx, rv, "Invalid state of SO-PIN");
  ------------------
  |  |  184|     49|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     49|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     49|	int _ret = (r); \
  |  |  |  |  178|     49|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     49|		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|     49|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     49|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     49|		goto err; \
  |  |  |  |  182|     49|	} \
  |  |  |  |  183|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1046|       |
 1047|       |	/* add PIN */
 1048|    433|	memset(&auth_info, 0, sizeof(auth_info));
 1049|    433|	memset(&obj,  0, sizeof(obj));
 1050|       |
 1051|    433|	auth_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    433|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1052|    433|	auth_info.auth_method	= SC_AC_CHV;
  ------------------
  |  |  151|    433|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1053|    433|	auth_info.auth_id.len = 1;
 1054|    433|	auth_info.auth_id.value[0] = 0xFF;
 1055|    433|	auth_info.attrs.pin.min_length		= 4;
 1056|    433|	auth_info.attrs.pin.max_length		= 64;
 1057|    433|	auth_info.attrs.pin.stored_length	= 64;
 1058|    433|	auth_info.attrs.pin.type		= SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|    433|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
 1059|    433|	auth_info.attrs.pin.reference		= sopin_reference;
 1060|    433|	auth_info.attrs.pin.pad_char		= 0xFF;
 1061|    433|	auth_info.attrs.pin.flags		= SC_PKCS15_PIN_FLAG_CASE_SENSITIVE
  ------------------
  |  |   54|    433|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
 1062|    433|				| SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|    433|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
 1063|    433|				| SC_PKCS15_PIN_FLAG_NEEDS_PADDING
  ------------------
  |  |   59|    433|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
 1064|    433|				| SC_PKCS15_PIN_FLAG_SO_PIN;
  ------------------
  |  |   61|    433|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
 1065|    433|	auth_info.tries_left		= tries_left;
 1066|    433|	auth_info.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|    433|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 1067|       |
 1068|    433|	strncpy(obj.label, "SO PIN", SC_PKCS15_MAX_LABEL_SIZE-1);
  ------------------
  |  |   35|    433|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
 1069|    433|	obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   51|    433|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              	obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    433|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 1070|       |
 1071|    433|	sc_log(ctx, "Add PIN(%s,auth_id:%s,reference:%i)", obj.label,
  ------------------
  |  |   71|    433|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1072|    433|			sc_pkcs15_print_id(&auth_info.auth_id), auth_info.attrs.pin.reference);
 1073|    433|	rv = sc_pkcs15emu_add_pin_obj(p15card, &obj, &auth_info);
 1074|    433|	LOG_TEST_GOTO_ERR(ctx, rv, "Oberthur init failed: cannot add PIN object");
  ------------------
  |  |  184|    433|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    433|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    433|	int _ret = (r); \
  |  |  |  |  178|    433|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 433]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    433|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 433]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1075|       |
 1076|    433|	tries_left = -1;
 1077|    433|	rv = sc_verify(card, SC_AC_CHV, 0x81, (unsigned char *)"", 0, &tries_left);
  ------------------
  |  |  151|    433|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1078|    433|	if (rv == SC_ERROR_PIN_CODE_INCORRECT)   {
  ------------------
  |  |   64|    433|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (1078:6): [True: 15, False: 418]
  ------------------
 1079|       |		/* add PIN */
 1080|     15|		memset(&auth_info, 0, sizeof(auth_info));
 1081|     15|		memset(&obj,  0, sizeof(obj));
 1082|       |
 1083|     15|		auth_info.auth_id.len = sizeof(PinDomainID) > sizeof(auth_info.auth_id.value)
  ------------------
  |  Branch (1083:27): [Folded, False: 15]
  ------------------
 1084|     15|				? sizeof(auth_info.auth_id.value) : sizeof(PinDomainID);
 1085|     15|		memcpy(auth_info.auth_id.value, PinDomainID, auth_info.auth_id.len);
 1086|     15|		auth_info.auth_method	= SC_AC_CHV;
  ------------------
  |  |  151|     15|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1087|       |
 1088|     15|		auth_info.attrs.pin.min_length		= 4;
 1089|     15|		auth_info.attrs.pin.max_length		= 64;
 1090|     15|		auth_info.attrs.pin.stored_length	= 64;
 1091|     15|		auth_info.attrs.pin.type		= SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|     15|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
 1092|     15|		auth_info.attrs.pin.reference		= 0x81;
 1093|     15|		auth_info.attrs.pin.pad_char		= 0xFF;
 1094|     15|		auth_info.attrs.pin.flags		= SC_PKCS15_PIN_FLAG_CASE_SENSITIVE
  ------------------
  |  |   54|     15|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
 1095|     15|					| SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|     15|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
 1096|     15|					| SC_PKCS15_PIN_FLAG_NEEDS_PADDING
  ------------------
  |  |   59|     15|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
 1097|     15|					| SC_PKCS15_PIN_FLAG_LOCAL;
  ------------------
  |  |   55|     15|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
 1098|     15|		auth_info.tries_left		= tries_left;
 1099|       |
 1100|     15|		strncpy(obj.label, PIN_DOMAIN_LABEL, SC_PKCS15_MAX_LABEL_SIZE-1);
  ------------------
  |  |   66|     15|#define PIN_DOMAIN_LABEL	"SCM"
  ------------------
              		strncpy(obj.label, PIN_DOMAIN_LABEL, SC_PKCS15_MAX_LABEL_SIZE-1);
  ------------------
  |  |   35|     15|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
 1101|     15|		obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   51|     15|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              		obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|     15|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 1102|     15|		if (sopin_reference == 0x84) {
  ------------------
  |  Branch (1102:7): [True: 4, False: 11]
  ------------------
 1103|       |			/*
 1104|       |			 * auth_pin_reset_oberthur_style() in card-oberthur.c
 1105|       |			 * always uses PUK with reference 0x84 for
 1106|       |			 * unblocking of User PIN
 1107|       |			 */
 1108|      4|			obj.auth_id.len = 1;
 1109|      4|			obj.auth_id.value[0] = 0xFF;
 1110|      4|		}
 1111|       |
 1112|     15|		sc_format_path(AWP_PIN_DF, &auth_info.path);
  ------------------
  |  |   69|     15|#define AWP_PIN_DF		"3F005011"
  ------------------
 1113|     15|		auth_info.path.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|     15|#define SC_PATH_TYPE_PATH		2
  ------------------
 1114|       |
 1115|     15|		sc_log(ctx, "Add PIN(%s,auth_id:%s,reference:%i)", obj.label,
  ------------------
  |  |   71|     15|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1116|     15|				sc_pkcs15_print_id(&auth_info.auth_id), auth_info.attrs.pin.reference);
 1117|     15|		rv = sc_pkcs15emu_add_pin_obj(p15card, &obj, &auth_info);
 1118|     15|		LOG_TEST_GOTO_ERR(ctx, rv, "Oberthur init failed: cannot add PIN object");
  ------------------
  |  |  184|     15|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     15|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     15|	int _ret = (r); \
  |  |  |  |  178|     15|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1119|     15|	}
 1120|    418|	else if (rv != SC_ERROR_DATA_OBJECT_NOT_FOUND)    {
  ------------------
  |  |   66|    418|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (1120:11): [True: 417, False: 1]
  ------------------
 1121|    417|		LOG_TEST_GOTO_ERR(ctx, rv, "Oberthur init failed: cannot verify PIN");
  ------------------
  |  |  184|    417|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    417|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    417|	int _ret = (r); \
  |  |  |  |  178|    417|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 22, False: 395]
  |  |  |  |  ------------------
  |  |  |  |  179|     22|		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|     22|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     22|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     22|		goto err; \
  |  |  |  |  182|     22|	} \
  |  |  |  |  183|    417|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 395]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1122|    417|	}
 1123|       |
 1124|  1.21k|	for (ii=0; oberthur_infos[ii].name; ii++)   {
  ------------------
  |  Branch (1124:13): [True: 1.16k, False: 49]
  ------------------
 1125|  1.16k|		sc_log(ctx, "Oberthur init: read %s file", oberthur_infos[ii].name);
  ------------------
  |  |   71|  1.16k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1126|  1.16k|		free(oberthur_infos[ii].content);
 1127|  1.16k|		rv = sc_oberthur_read_file(p15card, oberthur_infos[ii].path,
 1128|  1.16k|				&oberthur_infos[ii].content, &oberthur_infos[ii].len, 1);
 1129|  1.16k|		LOG_TEST_GOTO_ERR(ctx, rv, "Oberthur init failed: read oberthur file error");
  ------------------
  |  |  184|  1.16k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.16k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.16k|	int _ret = (r); \
  |  |  |  |  178|  1.16k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 109, False: 1.06k]
  |  |  |  |  ------------------
  |  |  |  |  179|    109|		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|    109|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    109|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    109|		goto err; \
  |  |  |  |  182|    109|	} \
  |  |  |  |  183|  1.16k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1130|       |
 1131|  1.06k|		sc_log(ctx, "Oberthur init: parse %s file, content length %zu",
  ------------------
  |  |   71|  1.06k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1132|  1.06k|				oberthur_infos[ii].name, oberthur_infos[ii].len);
 1133|  1.06k|		rv = oberthur_infos[ii].parser(p15card, oberthur_infos[ii].content, oberthur_infos[ii].len,
 1134|  1.06k|				oberthur_infos[ii].postpone_allowed);
 1135|  1.06k|		LOG_TEST_GOTO_ERR(ctx, rv, "Oberthur init failed: parse error");
  ------------------
  |  |  184|  1.06k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.06k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.06k|	int _ret = (r); \
  |  |  |  |  178|  1.06k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 253, False: 807]
  |  |  |  |  ------------------
  |  |  |  |  179|    253|		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|    253|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    253|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    253|		goto err; \
  |  |  |  |  182|    253|	} \
  |  |  |  |  183|  1.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 807]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1136|  1.06k|	}
 1137|       |
 1138|     49|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     49|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     49|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     49|	int _ret = r; \
  |  |  |  |  155|     49|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     49|		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: 49]
  |  |  |  |  ------------------
  |  |  |  |  157|     49|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     49|	} 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|     49|	return _ret; \
  |  |  |  |  163|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1139|       |
 1140|    803|err:
 1141|    803|	sc_pkcs15_card_clear(p15card);
 1142|    803|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    803|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    803|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    803|	int _ret = r; \
  |  |  |  |  155|    803|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 803, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    803|		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|    803|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 803, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    803|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    803|	} 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|    803|	return _ret; \
  |  |  |  |  163|    803|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1143|    803|}
pkcs15-oberthur.c:sc_awp_parse_df:
 1174|      6|{
 1175|      6|	struct sc_context *ctx = p15card->card->ctx;
 1176|      6|	unsigned char *buf = NULL;
 1177|      6|	size_t buf_len;
 1178|      6|	int rv;
 1179|       |
 1180|      6|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|      6|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      6|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      6|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      6|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1181|      6|	if (df->type != SC_PKCS15_PRKDF && df->type != SC_PKCS15_DODF)
  ------------------
  |  |  488|     12|#define SC_PKCS15_PRKDF			0
  ------------------
              	if (df->type != SC_PKCS15_PRKDF && df->type != SC_PKCS15_DODF)
  ------------------
  |  |  495|      6|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (1181:6): [True: 6, False: 0]
  |  Branch (1181:37): [True: 0, False: 6]
  ------------------
 1182|      6|		LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1183|       |
 1184|      6|	if (df->enumerated)
  ------------------
  |  Branch (1184:6): [True: 0, False: 6]
  ------------------
 1185|      6|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1186|       |
 1187|      6|	rv = sc_oberthur_read_file(p15card, AWP_OBJECTS_LIST_PRV, &buf, &buf_len, 1);
  ------------------
  |  |   74|      6|#define AWP_OBJECTS_LIST_PRV	"3F0050115000"
  ------------------
 1188|      6|	LOG_TEST_RET(ctx, rv, "Parse DF: read private objects info failed");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1189|       |
 1190|      0|	rv = sc_oberthur_parse_privateinfo(p15card, buf, buf_len, 0);
 1191|       |
 1192|      0|	if (buf)
  ------------------
  |  Branch (1192:6): [True: 0, False: 0]
  ------------------
 1193|      0|		free(buf);
 1194|       |
 1195|      0|	if (rv == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (1195:6): [True: 0, False: 0]
  ------------------
 1196|      0|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1197|       |
 1198|      0|	LOG_TEST_RET(ctx, rv, "Parse DF: private info parse error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1199|      0|	df->enumerated = 1;
 1200|       |
 1201|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1202|      0|}
pkcs15-oberthur.c:sc_oberthur_parse_privateinfo:
  500|     82|{
  501|     82|	struct sc_context *ctx = p15card->card->ctx;
  502|     82|	size_t ii;
  503|     82|	int rv;
  504|     82|	int no_more_private_keys = 0, no_more_private_data = 0;
  505|       |
  506|     82|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     82|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     82|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     82|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     82|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 82]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  507|       |
  508|  44.8k|	for (ii=0; ii+5<=len; ii+=5)   {
  ------------------
  |  Branch (508:13): [True: 44.7k, False: 49]
  ------------------
  509|  44.7k|		unsigned int file_id, size;
  510|       |
  511|  44.7k|		if(*(buff+ii) != 0xFF)
  ------------------
  |  Branch (511:6): [True: 44.4k, False: 357]
  ------------------
  512|  44.4k|			continue;
  513|       |
  514|    357|		file_id = 0x100 * *(buff+ii + 1) + *(buff+ii + 2);
  515|    357|		size = 0x100 * *(buff+ii + 3) + *(buff+ii + 4);
  516|    357|		sc_log(ctx, "add private object (file-id:%04X, size:%X)", file_id, size);
  ------------------
  |  |   71|    357|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  517|       |
  518|    357|		switch (*(buff+ii + 1))   {
  519|      2|		case BASE_ID_PRV_RSA :
  ------------------
  |  |   83|      2|#define BASE_ID_PRV_RSA   0x30
  ------------------
  |  Branch (519:3): [True: 2, False: 355]
  ------------------
  520|      2|			if (no_more_private_keys)
  ------------------
  |  Branch (520:8): [True: 0, False: 2]
  ------------------
  521|      0|				break;
  522|       |
  523|      2|			rv = sc_pkcs15emu_oberthur_add_prvkey(p15card, file_id, size);
  524|      2|			if (rv == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED && postpone_allowed)   {
  ------------------
  |  |   61|      4|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (524:8): [True: 0, False: 2]
  |  Branch (524:56): [True: 0, False: 0]
  ------------------
  525|      0|				struct sc_path path;
  526|       |
  527|      0|				sc_log(ctx, "postpone adding of the private keys");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  528|      0|				sc_format_path("5011A5A5", &path);
  529|      0|				rv = sc_pkcs15_add_df(p15card, SC_PKCS15_PRKDF, &path);
  ------------------
  |  |  488|      0|#define SC_PKCS15_PRKDF			0
  ------------------
  530|      0|				LOG_TEST_RET(ctx, rv, "Add PrkDF error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  531|      0|				no_more_private_keys = 1;
  532|      0|			}
  533|      2|			LOG_TEST_RET(ctx, rv, "Cannot parse private key info");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  534|      0|			break;
  535|     11|		case BASE_ID_PRV_DES :
  ------------------
  |  |   84|     11|#define BASE_ID_PRV_DES   0x40
  ------------------
  |  Branch (535:3): [True: 11, False: 346]
  ------------------
  536|     11|			break;
  537|    341|		case BASE_ID_PRV_DATA :
  ------------------
  |  |   86|    341|#define BASE_ID_PRV_DATA  0x60
  ------------------
  |  Branch (537:3): [True: 341, False: 16]
  ------------------
  538|    341|			sc_log(ctx, "*(buff+ii + 1):%X", *(buff+ii + 1));
  ------------------
  |  |   71|    341|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  539|    341|			if (no_more_private_data)
  ------------------
  |  Branch (539:8): [True: 18, False: 323]
  ------------------
  540|     18|				break;
  541|       |
  542|    323|			rv = sc_pkcs15emu_oberthur_add_data(p15card, file_id, size, 1);
  543|    323|			if (rv == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED && postpone_allowed)   {
  ------------------
  |  |   61|    646|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (543:8): [True: 6, False: 317]
  |  Branch (543:56): [True: 6, False: 0]
  ------------------
  544|      6|				struct sc_path path;
  545|       |
  546|      6|				sc_log(ctx, "postpone adding of the private data");
  ------------------
  |  |   71|      6|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  547|      6|				sc_format_path("5011A6A6", &path);
  548|      6|				rv = sc_pkcs15_add_df(p15card, SC_PKCS15_DODF, &path);
  ------------------
  |  |  495|      6|#define SC_PKCS15_DODF			7
  ------------------
  549|      6|				LOG_TEST_RET(ctx, rv, "Add DODF error");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  550|      6|				no_more_private_data = 1;
  551|      6|			}
  552|    323|			LOG_TEST_RET(ctx, rv, "Cannot parse private data info");
  ------------------
  |  |  174|    323|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    323|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    323|	int _ret = (r); \
  |  |  |  |  168|    323|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 28, False: 295]
  |  |  |  |  ------------------
  |  |  |  |  169|     28|		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|     28|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     28|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     28|		return _ret; \
  |  |  |  |  172|     28|	} \
  |  |  |  |  173|    323|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 295]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  553|    295|			break;
  554|    295|		default:
  ------------------
  |  Branch (554:3): [True: 3, False: 354]
  ------------------
  555|      3|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Private object parse error");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  556|    357|		}
  557|    357|	}
  558|       |
  559|     49|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     49|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     49|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     49|	int _ret = r; \
  |  |  |  |  155|     49|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 49, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     49|		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: 49]
  |  |  |  |  ------------------
  |  |  |  |  157|     49|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     49|	} 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|     49|	return _ret; \
  |  |  |  |  163|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  560|     49|}
pkcs15-oberthur.c:sc_pkcs15emu_oberthur_add_prvkey:
  763|      2|{
  764|      2|	struct sc_context *ctx = p15card->card->ctx;
  765|      2|	struct sc_pkcs15_prkey_info kinfo;
  766|      2|	struct sc_pkcs15_object kobj;
  767|      2|	struct crypto_container ccont;
  768|      2|	unsigned char *info_blob = NULL;
  769|      2|	size_t info_len = 0;
  770|      2|	unsigned flags;
  771|      2|	size_t offs, len;
  772|      2|	char ch_tmp[0x100];
  773|      2|	int rv;
  774|       |
  775|      2|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|      2|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      2|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      2|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      2|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  776|      2|	sc_log(ctx, "add private key(file-id:%04X,size:%04X)", file_id, size);
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  777|       |
  778|      2|	memset(&kinfo, 0, sizeof(kinfo));
  779|      2|	memset(&kobj, 0, sizeof(kobj));
  780|      2|	memset(&ccont, 0, sizeof(ccont));
  781|       |
  782|      2|	rv = sc_oberthur_get_friends (file_id, &ccont);
  783|      2|	LOG_TEST_RET(ctx, rv, "Failed to add private key: get friends error");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  784|       |
  785|      0|	if (ccont.id_cert)   {
  ------------------
  |  Branch (785:6): [True: 0, False: 0]
  ------------------
  786|      0|		struct sc_pkcs15_object *objs[32];
  787|      0|		int ii;
  788|       |
  789|      0|		sc_log(ctx, "friend certificate %04X", ccont.id_cert);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  790|      0|		rv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_CERT_X509, objs, 32);
  ------------------
  |  |  439|      0|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  791|      0|		LOG_TEST_RET(ctx, rv, "Failed to add private key: get certificates error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  792|       |
  793|      0|		for (ii=0; ii<rv; ii++) {
  ------------------
  |  Branch (793:14): [True: 0, False: 0]
  ------------------
  794|      0|			struct sc_pkcs15_cert_info *cert = (struct sc_pkcs15_cert_info *)objs[ii]->data;
  795|      0|			struct sc_path path = cert->path;
  796|      0|			unsigned int id = path.value[path.len - 2] * 0x100 + path.value[path.len - 1];
  797|       |
  798|      0|			if (id == ccont.id_cert)   {
  ------------------
  |  Branch (798:8): [True: 0, False: 0]
  ------------------
  799|      0|				strlcpy(kobj.label, objs[ii]->label, sizeof(kobj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  800|      0|				break;
  801|      0|			}
  802|      0|		}
  803|       |
  804|      0|		if (ii == rv)
  ------------------
  |  Branch (804:7): [True: 0, False: 0]
  ------------------
  805|      0|			LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "Failed to add private key: friend not found");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  806|      0|	}
  807|       |
  808|      0|	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", AWP_OBJECTS_DF_PRV, file_id | 0x100);
  ------------------
  |  |   76|      0|#define AWP_OBJECTS_DF_PRV	"3F0050119002"
  ------------------
  809|      0|	rv = sc_oberthur_read_file(p15card, ch_tmp, &info_blob, &info_len, 1);
  810|      0|	LOG_TEST_RET(ctx, rv, "Failed to add private key: read oberthur file error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  811|       |
  812|      0|	if (info_len < 2) {
  ------------------
  |  Branch (812:6): [True: 0, False: 0]
  ------------------
  813|      0|		free(info_blob);
  814|      0|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add private key: no 'tag'");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  815|      0|	}
  816|      0|	flags = *(info_blob + 0) * 0x100 + *(info_blob + 1);
  817|      0|	offs = 2;
  818|       |
  819|       |	/* CN */
  820|      0|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (820:6): [True: 0, False: 0]
  ------------------
  821|      0|		free(info_blob);
  822|      0|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add private key: no 'CN'");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  823|      0|	}
  824|      0|	len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  825|      0|	if (len + offs + 2 > info_len) {
  ------------------
  |  Branch (825:6): [True: 0, False: 0]
  ------------------
  826|      0|		free(info_blob);
  827|      0|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid 'CN' length");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  828|      0|	}
  829|      0|	if (len && !strlen(kobj.label))   {
  ------------------
  |  Branch (829:6): [True: 0, False: 0]
  |  Branch (829:13): [True: 0, False: 0]
  ------------------
  830|      0|		if (len > sizeof(kobj.label) - 1)
  ------------------
  |  Branch (830:7): [True: 0, False: 0]
  ------------------
  831|      0|			len = sizeof(kobj.label) - 1;
  832|      0|		strncpy(kobj.label, (char *)(info_blob + offs + 2), len);
  833|      0|	}
  834|      0|	offs += 2 + len;
  835|       |
  836|       |	/* ID */
  837|      0|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (837:6): [True: 0, False: 0]
  ------------------
  838|      0|		free(info_blob);
  839|      0|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add private key: no 'ID'");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  840|      0|	}
  841|      0|	len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  842|      0|	if (!len) {
  ------------------
  |  Branch (842:6): [True: 0, False: 0]
  ------------------
  843|      0|		free(info_blob);
  844|      0|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add private key: zero length ID");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|      0|	} else if (len + offs + 2 > info_len) {
  ------------------
  |  Branch (845:13): [True: 0, False: 0]
  ------------------
  846|      0|		free(info_blob);
  847|      0|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid 'ID' length");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  848|      0|	} else if (len > sizeof(kinfo.id.value)) {
  ------------------
  |  Branch (848:13): [True: 0, False: 0]
  ------------------
  849|      0|		free(info_blob);
  850|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Failed to add private key: invalid ID length");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  851|      0|	}
  852|      0|	memcpy(kinfo.id.value, info_blob + offs + 2, len);
  853|      0|	kinfo.id.len = len;
  854|      0|	offs += 2 + len;
  855|       |
  856|       |	/* Ignore Start/End dates */
  857|      0|	offs += 16;
  858|       |
  859|       |	/* Subject encoded in ASN1 */
  860|      0|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (860:6): [True: 0, False: 0]
  ------------------
  861|      0|		free(info_blob);
  862|      0|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add private key: no 'subject'");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  863|      0|	}
  864|      0|	len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  865|      0|	if (len + offs + 2 > info_len) {
  ------------------
  |  Branch (865:6): [True: 0, False: 0]
  ------------------
  866|      0|		free(info_blob);
  867|      0|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid 'subject' length");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  868|      0|	} else if (len) {
  ------------------
  |  Branch (868:13): [True: 0, False: 0]
  ------------------
  869|      0|		kinfo.subject.value = malloc(len);
  870|      0|		if (!kinfo.subject.value) {
  ------------------
  |  Branch (870:7): [True: 0, False: 0]
  ------------------
  871|      0|			free(info_blob);
  872|      0|			LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Failed to add private key: memory allocation error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  873|      0|		}
  874|      0|		kinfo.subject.len = len;
  875|      0|		memcpy(kinfo.subject.value, info_blob + offs + 2, len);
  876|      0|	}
  877|       |
  878|       |	/* Modulus and exponent are ignored */
  879|       |
  880|      0|	free(info_blob);
  881|       |
  882|      0|	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", AWP_OBJECTS_DF_PRV, file_id);
  ------------------
  |  |   76|      0|#define AWP_OBJECTS_DF_PRV	"3F0050119002"
  ------------------
  883|      0|	sc_format_path(ch_tmp, &kinfo.path);
  884|      0|	sc_log(ctx, "Private key info path %s", ch_tmp);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  885|       |
  886|      0|	kinfo.modulus_length	= size;
  887|      0|	kinfo.native		= 1;
  888|      0|	kinfo.key_reference	 = file_id & 0xFF;
  889|       |
  890|      0|	kinfo.usage = sc_oberthur_decode_usage(flags);
  891|      0|	kobj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  892|      0|	if (flags & OBERTHUR_ATTR_MODIFIABLE)
  ------------------
  |  |   45|      0|#define OBERTHUR_ATTR_MODIFIABLE	0x0001
  ------------------
  |  Branch (892:6): [True: 0, False: 0]
  ------------------
  893|      0|		kobj.flags |= SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  894|       |
  895|      0|	kobj.auth_id.len = sizeof(PinDomainID) > sizeof(kobj.auth_id.value)
  ------------------
  |  Branch (895:21): [Folded, False: 0]
  ------------------
  896|      0|			? sizeof(kobj.auth_id.value) : sizeof(PinDomainID);
  897|      0|	memcpy(kobj.auth_id.value, PinDomainID, kobj.auth_id.len);
  898|       |
  899|      0|	sc_log(ctx, "Parsed private key(reference:%i,usage:%X,flags:%X)", kinfo.key_reference, kinfo.usage, kobj.flags);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  900|       |
  901|      0|	rv = sc_pkcs15emu_add_rsa_prkey(p15card, &kobj, &kinfo);
  902|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  903|      0|}
pkcs15-oberthur.c:sc_oberthur_get_friends:
  165|      2|{
  166|      2|	struct container *cont;
  167|       |
  168|      2|	for (cont = Containers; cont; cont = cont->next)   {
  ------------------
  |  Branch (168:26): [True: 0, False: 2]
  ------------------
  169|      0|		if (cont->exchange.id_pub == id || cont->exchange.id_prv == id || cont->exchange.id_cert == id)   {
  ------------------
  |  Branch (169:7): [True: 0, False: 0]
  |  Branch (169:38): [True: 0, False: 0]
  |  Branch (169:69): [True: 0, False: 0]
  ------------------
  170|      0|			if (ccont)
  ------------------
  |  Branch (170:8): [True: 0, False: 0]
  ------------------
  171|      0|				memcpy(ccont, &cont->exchange, sizeof(struct crypto_container));
  172|      0|			break;
  173|      0|		}
  174|       |
  175|      0|		if (cont->sign.id_pub == id || cont->sign.id_prv == id || cont->sign.id_cert == id)   {
  ------------------
  |  Branch (175:7): [True: 0, False: 0]
  |  Branch (175:34): [True: 0, False: 0]
  |  Branch (175:61): [True: 0, False: 0]
  ------------------
  176|      0|			if (ccont)
  ------------------
  |  Branch (176:8): [True: 0, False: 0]
  ------------------
  177|      0|				memcpy(ccont, &cont->sign, sizeof(struct crypto_container));
  178|      0|			break;
  179|      0|		}
  180|      0|	}
  181|       |
  182|      2|	return cont ? 0 : SC_ERROR_TEMPLATE_NOT_FOUND;
  ------------------
  |  |  110|      2|#define SC_ERROR_TEMPLATE_NOT_FOUND		-1508
  ------------------
  |  Branch (182:9): [True: 0, False: 2]
  ------------------
  183|      2|}
pkcs15-oberthur.c:sc_oberthur_decode_usage:
  138|    130|{
  139|    130|	unsigned ret = 0;
  140|       |
  141|    130|	if (flags & OBERTHUR_ATTR_ENCRYPT)
  ------------------
  |  |   48|    130|#define OBERTHUR_ATTR_ENCRYPT		0x0008
  ------------------
  |  Branch (141:6): [True: 58, False: 72]
  ------------------
  142|     58|		ret |= SC_PKCS15_PRKEY_USAGE_ENCRYPT;
  ------------------
  |  |  305|     58|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
  143|    130|	if (flags & OBERTHUR_ATTR_DECRYPT)
  ------------------
  |  |   49|    130|#define OBERTHUR_ATTR_DECRYPT		0x0010
  ------------------
  |  Branch (143:6): [True: 57, False: 73]
  ------------------
  144|     57|		ret |= SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  306|     57|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  145|    130|	if (flags & OBERTHUR_ATTR_SIGN)
  ------------------
  |  |   50|    130|#define OBERTHUR_ATTR_SIGN		0x0020
  ------------------
  |  Branch (145:6): [True: 67, False: 63]
  ------------------
  146|     67|		ret |= SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|     67|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  147|    130|	if (flags & OBERTHUR_ATTR_RSIGN)
  ------------------
  |  |   52|    130|#define OBERTHUR_ATTR_RSIGN		0x0080
  ------------------
  |  Branch (147:6): [True: 47, False: 83]
  ------------------
  148|     47|		ret |= SC_PKCS15_PRKEY_USAGE_SIGNRECOVER;
  ------------------
  |  |  308|     47|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
  149|    130|	if (flags & OBERTHUR_ATTR_WRAP)
  ------------------
  |  |   54|    130|#define OBERTHUR_ATTR_WRAP		0x0200
  ------------------
  |  Branch (149:6): [True: 73, False: 57]
  ------------------
  150|     73|		ret |= SC_PKCS15_PRKEY_USAGE_WRAP;
  ------------------
  |  |  309|     73|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  151|    130|	if (flags & OBERTHUR_ATTR_UNWRAP)
  ------------------
  |  |   55|    130|#define OBERTHUR_ATTR_UNWRAP		0x0400
  ------------------
  |  Branch (151:6): [True: 62, False: 68]
  ------------------
  152|     62|		ret |= SC_PKCS15_PRKEY_USAGE_UNWRAP;
  ------------------
  |  |  310|     62|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  153|    130|	if (flags & OBERTHUR_ATTR_VERIFY)
  ------------------
  |  |   51|    130|#define OBERTHUR_ATTR_VERIFY		0x0040
  ------------------
  |  Branch (153:6): [True: 67, False: 63]
  ------------------
  154|     67|		ret |= SC_PKCS15_PRKEY_USAGE_VERIFY;
  ------------------
  |  |  311|     67|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  155|    130|	if (flags & OBERTHUR_ATTR_RVERIFY)
  ------------------
  |  |   53|    130|#define OBERTHUR_ATTR_RVERIFY		0x0100
  ------------------
  |  Branch (155:6): [True: 54, False: 76]
  ------------------
  156|     54|		ret |= SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER;
  ------------------
  |  |  312|     54|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
  157|    130|	if (flags & OBERTHUR_ATTR_DERIVE)
  ------------------
  |  |   56|    130|#define OBERTHUR_ATTR_DERIVE		0x0800
  ------------------
  |  Branch (157:6): [True: 61, False: 69]
  ------------------
  158|     61|		ret |= SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|     61|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  159|    130|	return ret;
  160|    130|}
pkcs15-oberthur.c:sc_pkcs15emu_oberthur_add_data:
  909|    381|{
  910|    381|	struct sc_context *ctx = p15card->card->ctx;
  911|    381|	struct sc_pkcs15_data_info dinfo;
  912|    381|	struct sc_pkcs15_object dobj;
  913|    381|	unsigned flags;
  914|    381|	unsigned char *info_blob = NULL, *label = NULL, *app = NULL, *oid = NULL;
  915|    381|	size_t info_len, label_len, app_len, oid_len, offs;
  916|    381|	char ch_tmp[0x100];
  917|    381|	int rv;
  918|       |
  919|    381|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    381|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    381|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    381|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 381]
  |  |  ------------------
  ------------------
  920|    381|	sc_log(ctx, "Add data(file-id:%04X,size:%i,is-private:%i)", file_id, size, private);
  ------------------
  |  |   71|    381|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  921|    381|	memset(&dinfo, 0, sizeof(dinfo));
  922|    381|	memset(&dobj, 0, sizeof(dobj));
  923|       |
  924|    381|	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", private ? AWP_OBJECTS_DF_PRV : AWP_OBJECTS_DF_PUB, file_id | 0x100);
  ------------------
  |  |   76|    323|#define AWP_OBJECTS_DF_PRV	"3F0050119002"
  ------------------
              	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", private ? AWP_OBJECTS_DF_PRV : AWP_OBJECTS_DF_PUB, file_id | 0x100);
  ------------------
  |  |   75|     58|#define AWP_OBJECTS_DF_PUB	"3F0050119001"
  ------------------
  |  Branch (924:45): [True: 323, False: 58]
  ------------------
  925|       |
  926|    381|	rv = sc_oberthur_read_file(p15card, ch_tmp, &info_blob, &info_len, 1);
  927|    381|	LOG_TEST_RET(ctx, rv, "Failed to add data: read oberthur file error");
  ------------------
  |  |  174|    381|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    381|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    381|	int _ret = (r); \
  |  |  |  |  168|    381|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 34, False: 347]
  |  |  |  |  ------------------
  |  |  |  |  169|     34|		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|     34|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     34|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     34|		return _ret; \
  |  |  |  |  172|     34|	} \
  |  |  |  |  173|    381|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 347]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  928|       |
  929|    347|	if (info_len < 2) {
  ------------------
  |  Branch (929:6): [True: 3, False: 344]
  ------------------
  930|      3|		free(info_blob);
  931|      3|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add certificate: no 'tag'");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  932|      3|	}
  933|    344|	flags = *(info_blob + 0) * 0x100 + *(info_blob + 1);
  934|    344|	offs = 2;
  935|       |
  936|       |	/* Label */
  937|    344|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (937:6): [True: 1, False: 343]
  ------------------
  938|      1|		free(info_blob);
  939|      1|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add data: no 'label'");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  940|      1|	}
  941|    343|	label = info_blob + offs + 2;
  942|    343|	label_len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  943|    343|	if (offs + 2 + label_len > info_len) {
  ------------------
  |  Branch (943:6): [True: 10, False: 333]
  ------------------
  944|     10|		free(info_blob);
  945|     10|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid length of 'label' received");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  946|     10|	}
  947|    333|	if (label_len > sizeof(dobj.label) - 1)
  ------------------
  |  Branch (947:6): [True: 168, False: 165]
  ------------------
  948|    168|		label_len = sizeof(dobj.label) - 1;
  949|    333|	offs += 2 + *(info_blob + offs + 1);
  950|       |
  951|       |	/* Application */
  952|    333|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (952:6): [True: 1, False: 332]
  ------------------
  953|      1|		free(info_blob);
  954|      1|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add data: no 'application'");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  955|      1|	}
  956|    332|	app = info_blob + offs + 2;
  957|    332|	app_len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  958|    332|	if (offs + 2 + app_len > info_len) {
  ------------------
  |  Branch (958:6): [True: 3, False: 329]
  ------------------
  959|      3|		free(info_blob);
  960|      3|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid length of 'application' received");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  961|      3|	}
  962|    329|	if (app_len > sizeof(dinfo.app_label) - 1)
  ------------------
  |  Branch (962:6): [True: 109, False: 220]
  ------------------
  963|    109|		app_len = sizeof(dinfo.app_label) - 1;
  964|    329|	offs += 2 + app_len;
  965|       |
  966|       |	/* OID encode like DER(ASN.1(oid)) */
  967|    329|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (967:6): [True: 1, False: 328]
  ------------------
  968|      1|		free(info_blob);
  969|      1|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add data: no 'OID'");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  970|      1|	}
  971|    328|	oid_len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  972|    328|	if (offs + 2 + oid_len > info_len) {
  ------------------
  |  Branch (972:6): [True: 1, False: 327]
  ------------------
  973|      1|		free(info_blob);
  974|      1|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid length of 'oid' received");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  975|      1|	}
  976|    327|	if (oid_len > 2) {
  ------------------
  |  Branch (976:6): [True: 8, False: 319]
  ------------------
  977|      8|		oid = info_blob + offs + 2;
  978|      8|		if (*oid != 0x06 || (*(oid + 1) != oid_len - 2)) {
  ------------------
  |  Branch (978:7): [True: 3, False: 5]
  |  Branch (978:23): [True: 4, False: 1]
  ------------------
  979|      7|			free(info_blob);
  980|      7|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add data: invalid 'OID' format");
  ------------------
  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      7|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      7|		return _ret; \
  |  |  |  |  172|      7|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  981|      7|		}
  982|      1|		oid += 2;
  983|      1|		oid_len -= 2;
  984|      1|	}
  985|       |
  986|    320|	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", private ? AWP_OBJECTS_DF_PRV : AWP_OBJECTS_DF_PUB, file_id);
  ------------------
  |  |   76|    289|#define AWP_OBJECTS_DF_PRV	"3F0050119002"
  ------------------
              	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", private ? AWP_OBJECTS_DF_PRV : AWP_OBJECTS_DF_PUB, file_id);
  ------------------
  |  |   75|     31|#define AWP_OBJECTS_DF_PUB	"3F0050119001"
  ------------------
  |  Branch (986:45): [True: 289, False: 31]
  ------------------
  987|       |
  988|    320|	sc_format_path(ch_tmp, &dinfo.path);
  989|       |
  990|    320|	memcpy(dobj.label, label, label_len);
  991|    320|	memcpy(dinfo.app_label, app, app_len);
  992|    320|	if (oid_len)
  ------------------
  |  Branch (992:6): [True: 4, False: 316]
  ------------------
  993|      4|		sc_asn1_decode_object_id(oid, oid_len, &dinfo.app_oid);
  994|       |
  995|    320|	if (flags & OBERTHUR_ATTR_MODIFIABLE)
  ------------------
  |  |   45|    320|#define OBERTHUR_ATTR_MODIFIABLE	0x0001
  ------------------
  |  Branch (995:6): [True: 29, False: 291]
  ------------------
  996|     29|		dobj.flags |= SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   51|     29|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  997|       |
  998|    320|	if (private)   {
  ------------------
  |  Branch (998:6): [True: 289, False: 31]
  ------------------
  999|    289|		dobj.auth_id.len = sizeof(PinDomainID) > sizeof(dobj.auth_id.value)
  ------------------
  |  Branch (999:22): [Folded, False: 289]
  ------------------
 1000|    289|				? sizeof(dobj.auth_id.value) : sizeof(PinDomainID);
 1001|    289|		memcpy(dobj.auth_id.value, PinDomainID, dobj.auth_id.len);
 1002|       |
 1003|    289|		dobj.flags |= SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    289|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 1004|    289|	}
 1005|       |
 1006|    320|	rv = sc_pkcs15emu_add_data_object(p15card, &dobj, &dinfo);
 1007|       |
 1008|    320|	free(info_blob);
 1009|    320|	LOG_FUNC_RETURN(p15card->card->ctx, rv);
  ------------------
  |  |  164|    320|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    320|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    320|	int _ret = r; \
  |  |  |  |  155|    320|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 320, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    320|		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: 320]
  |  |  |  |  ------------------
  |  |  |  |  157|    320|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    320|	} 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|    320|	return _ret; \
  |  |  |  |  163|    320|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1010|    320|}
pkcs15-oberthur.c:sc_awp_clear:
 1207|  1.65k|{
 1208|  1.65k|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|  1.65k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.65k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.65k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.65k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.65k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1209|  1.65k|}
pkcs15-oberthur.c:sc_oberthur_parse_tokeninfo:
  365|    375|{
  366|    375|	struct sc_context *ctx = p15card->card->ctx;
  367|    375|	char label[0x21];
  368|    375|	unsigned flags;
  369|    375|	int ii;
  370|       |
  371|    375|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    375|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    375|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    375|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    375|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 375]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  372|    375|	if (!buff || len < 0x24)
  ------------------
  |  Branch (372:6): [True: 0, False: 375]
  |  Branch (372:15): [True: 16, False: 359]
  ------------------
  373|    375|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Cannot parse token info");
  ------------------
  |  |  174|     16|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     16|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     16|	int _ret = (r); \
  |  |  |  |  168|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     16|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     16|		return _ret; \
  |  |  |  |  172|     16|	} \
  |  |  |  |  173|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  374|       |
  375|    359|	memset(label, 0, sizeof(label));
  376|       |
  377|    359|	memcpy(label, buff, 0x20);
  378|    359|	ii = 0x20;
  379|    434|	while (*(label + --ii)==' ' && ii)
  ------------------
  |  Branch (379:9): [True: 76, False: 358]
  |  Branch (379:33): [True: 75, False: 1]
  ------------------
  380|     75|		;
  381|    359|	*(label + ii + 1) = '\0';
  382|       |
  383|    359|	flags = *(buff + 0x22) * 0x100 + *(buff + 0x23);
  384|       |
  385|    359|	set_string(&p15card->tokeninfo->label, label);
  386|    359|	set_string(&p15card->tokeninfo->manufacturer_id, "Oberthur/OpenSC");
  387|       |
  388|    359|	if (flags & 0x01)
  ------------------
  |  Branch (388:6): [True: 11, False: 348]
  ------------------
  389|     11|		p15card->tokeninfo->flags |= SC_PKCS15_TOKEN_PRN_GENERATION;
  ------------------
  |  |  597|     11|#define SC_PKCS15_TOKEN_PRN_GENERATION			0x04
  ------------------
  390|       |
  391|    359|	sc_log(ctx, "label %s", p15card->tokeninfo->label);
  ------------------
  |  |   71|    359|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  392|    359|	sc_log(ctx, "manufacturer_id %s", p15card->tokeninfo->manufacturer_id);
  ------------------
  |  |   71|    359|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  393|       |
  394|    359|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    359|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    359|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    359|	int _ret = r; \
  |  |  |  |  155|    359|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 359, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    359|		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: 359]
  |  |  |  |  ------------------
  |  |  |  |  157|    359|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    359|	} 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|    359|	return _ret; \
  |  |  |  |  163|    359|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  395|    359|}
pkcs15-oberthur.c:sc_oberthur_parse_containers:
  401|    325|{
  402|    325|	struct sc_context *ctx = p15card->card->ctx;
  403|    325|	size_t offs;
  404|       |
  405|    325|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    325|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    325|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    325|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    325|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 325]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  406|       |
  407|    391|	while (Containers)   {
  ------------------
  |  Branch (407:9): [True: 66, False: 325]
  ------------------
  408|     66|		struct container *next = Containers->next;
  409|       |
  410|     66|		free (Containers);
  411|     66|		Containers = next;
  412|     66|	}
  413|       |
  414|    391|	for (offs=0; offs + 2 + 2+2+2 + 2+2+2 + 2+36 <= len;)  {
  ------------------
  |  Branch (414:15): [True: 100, False: 291]
  ------------------
  415|    100|		struct container *cont;
  416|    100|		unsigned char *ptr =  buff + offs + 2;
  417|       |
  418|    100|		sc_log(ctx, "parse contaniers offs:%zu, len:%zu", offs, len);
  ------------------
  |  |   71|    100|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  419|    100|		if (*(buff + offs) != 'R')
  ------------------
  |  Branch (419:7): [True: 34, False: 66]
  ------------------
  420|     34|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     34|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  421|       |
  422|     66|		cont = (struct container *)calloc(1, sizeof(struct container));
  423|     66|		if (!cont)
  ------------------
  |  Branch (423:7): [True: 0, False: 66]
  ------------------
  424|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  425|       |
  426|     66|		cont->exchange.id_pub = *ptr * 0x100 + *(ptr + 1);  ptr += 2;
  427|     66|		cont->exchange.id_prv = *ptr * 0x100 + *(ptr + 1);  ptr += 2;
  428|     66|		cont->exchange.id_cert = *ptr * 0x100 + *(ptr + 1); ptr += 2;
  429|       |
  430|     66|		cont->sign.id_pub = *ptr * 0x100 + *(ptr + 1);  ptr += 2;
  431|     66|		cont->sign.id_prv = *ptr * 0x100 + *(ptr + 1);  ptr += 2;
  432|     66|		cont->sign.id_cert = *ptr * 0x100 + *(ptr + 1); ptr += 2;
  433|       |
  434|     66|		memcpy(cont->uuid, ptr + 2, 36);
  435|     66|		sc_log(ctx, "UUID: %s; 0x%X, 0x%X, 0x%X", cont->uuid,
  ------------------
  |  |   71|     66|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  436|     66|				cont->exchange.id_pub, cont->exchange.id_prv, cont->exchange.id_cert);
  437|       |
  438|     66|		if (!Containers)  {
  ------------------
  |  Branch (438:7): [True: 16, False: 50]
  ------------------
  439|     16|			Containers = cont;
  440|     16|		}
  441|     50|		else   {
  442|     50|			cont->next = Containers;
  443|     50|			Containers->prev = (void *)cont;
  444|     50|			Containers = cont;
  445|     50|		}
  446|       |
  447|     66|		offs += *(buff + offs + 1) + 2;
  448|     66|	}
  449|       |
  450|    291|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    291|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    291|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    291|	int _ret = r; \
  |  |  |  |  155|    291|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 291, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    291|		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: 291]
  |  |  |  |  ------------------
  |  |  |  |  157|    291|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    291|	} 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|    291|	return _ret; \
  |  |  |  |  163|    291|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  451|    291|}
pkcs15-oberthur.c:sc_oberthur_parse_publicinfo:
  457|    278|{
  458|    278|	struct sc_context *ctx = p15card->card->ctx;
  459|    278|	size_t ii;
  460|    278|	int rv;
  461|       |
  462|    278|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    278|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    278|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    278|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    278|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 278]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  463|   124k|	for (ii=0; ii+5<=len; ii+=5)   {
  ------------------
  |  Branch (463:13): [True: 124k, False: 108]
  ------------------
  464|   124k|		unsigned int file_id, size;
  465|       |
  466|   124k|		if(*(buff+ii) != 0xFF)
  ------------------
  |  Branch (466:6): [True: 123k, False: 311]
  ------------------
  467|   123k|			continue;
  468|       |
  469|    311|		file_id = 0x100 * *(buff+ii + 1) + *(buff+ii + 2);
  470|    311|		size = 0x100 * *(buff+ii + 3) + *(buff+ii + 4);
  471|    311|		sc_log(ctx, "add public object(file-id:%04X,size:%X)", file_id, size);
  ------------------
  |  |   71|    311|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  472|       |
  473|    311|		switch (*(buff+ii + 1))   {
  474|    140|		case BASE_ID_PUB_RSA :
  ------------------
  |  |   81|    140|#define BASE_ID_PUB_RSA   0x10
  ------------------
  |  Branch (474:3): [True: 140, False: 171]
  ------------------
  475|    140|			rv = sc_pkcs15emu_oberthur_add_pubkey(p15card, file_id, size);
  476|    140|			LOG_TEST_RET(ctx, rv, "Cannot parse public key info");
  ------------------
  |  |  174|    140|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    140|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    140|	int _ret = (r); \
  |  |  |  |  168|    140|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 64, False: 76]
  |  |  |  |  ------------------
  |  |  |  |  169|     64|		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|     64|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     64|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     64|		return _ret; \
  |  |  |  |  172|     64|	} \
  |  |  |  |  173|    140|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 76]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  477|     76|			break;
  478|     76|		case BASE_ID_CERT :
  ------------------
  |  |   82|     73|#define BASE_ID_CERT	  0x20
  ------------------
  |  Branch (478:3): [True: 73, False: 238]
  ------------------
  479|     73|			rv = sc_pkcs15emu_oberthur_add_cert(p15card, file_id);
  480|     73|			LOG_TEST_RET(ctx, rv, "Cannot parse certificate info");
  ------------------
  |  |  174|     73|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     73|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     73|	int _ret = (r); \
  |  |  |  |  168|     73|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 73, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     73|		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|     73|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     73|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     73|		return _ret; \
  |  |  |  |  172|     73|	} \
  |  |  |  |  173|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|      0|			break;
  482|     34|		case BASE_ID_PUB_DES :
  ------------------
  |  |   87|     34|#define BASE_ID_PUB_DES   0x70
  ------------------
  |  Branch (482:3): [True: 34, False: 277]
  ------------------
  483|     34|			break;
  484|     58|		case BASE_ID_PUB_DATA :
  ------------------
  |  |   85|     58|#define BASE_ID_PUB_DATA  0x50
  ------------------
  |  Branch (484:3): [True: 58, False: 253]
  ------------------
  485|     58|			rv = sc_pkcs15emu_oberthur_add_data(p15card, file_id, size, 0);
  486|     58|			LOG_TEST_RET(ctx, rv, "Cannot parse data info");
  ------------------
  |  |  174|     58|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     58|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     58|	int _ret = (r); \
  |  |  |  |  168|     58|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 27, False: 31]
  |  |  |  |  ------------------
  |  |  |  |  169|     27|		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|     27|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     27|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     27|		return _ret; \
  |  |  |  |  172|     27|	} \
  |  |  |  |  173|     58|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  487|     31|			break;
  488|     31|		default:
  ------------------
  |  Branch (488:3): [True: 6, False: 305]
  ------------------
  489|      6|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Public object parse error");
  ------------------
  |  |  174|      6|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      6|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      6|	int _ret = (r); \
  |  |  |  |  168|      6|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      6|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      6|		return _ret; \
  |  |  |  |  172|      6|	} \
  |  |  |  |  173|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  490|    311|		}
  491|    311|	}
  492|       |
  493|    108|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    108|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    108|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    108|	int _ret = r; \
  |  |  |  |  155|    108|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 108, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    108|		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: 108]
  |  |  |  |  ------------------
  |  |  |  |  157|    108|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    108|	} 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|    108|	return _ret; \
  |  |  |  |  163|    108|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|    108|}
pkcs15-oberthur.c:sc_pkcs15emu_oberthur_add_pubkey:
  574|    140|{
  575|    140|	struct sc_context *ctx = p15card->card->ctx;
  576|    140|	struct sc_pkcs15_pubkey_info key_info;
  577|    140|	struct sc_pkcs15_object key_obj;
  578|    140|	char ch_tmp[0x100];
  579|    140|	unsigned char *info_blob = NULL;
  580|    140|	size_t len, info_len, offs;
  581|    140|	unsigned flags;
  582|    140|	int rv;
  583|       |
  584|    140|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    140|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    140|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    140|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    140|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 140]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|    140|	sc_log(ctx, "public key(file-id:%04X,size:%X)", file_id, size);
  ------------------
  |  |   71|    140|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  586|       |
  587|    140|	memset(&key_info, 0, sizeof(key_info));
  588|    140|	memset(&key_obj, 0, sizeof(key_obj));
  589|       |
  590|    140|	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", AWP_OBJECTS_DF_PUB, file_id | 0x100);
  ------------------
  |  |   75|    140|#define AWP_OBJECTS_DF_PUB	"3F0050119001"
  ------------------
  591|    140|	rv = sc_oberthur_read_file(p15card, ch_tmp, &info_blob, &info_len, 1);
  592|    140|	LOG_TEST_RET(ctx, rv, "Failed to add public key: read oberthur file error");
  ------------------
  |  |  174|    140|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    140|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    140|	int _ret = (r); \
  |  |  |  |  168|    140|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 133]
  |  |  |  |  ------------------
  |  |  |  |  169|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      7|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      7|		return _ret; \
  |  |  |  |  172|      7|	} \
  |  |  |  |  173|    140|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 133]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  593|       |
  594|       |	/* Flags */
  595|    133|	offs = 2;
  596|    133|	if (offs > info_len) {
  ------------------
  |  Branch (596:6): [True: 3, False: 130]
  ------------------
  597|      3|		free(info_blob);
  598|      3|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add public key: no 'tag'");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  599|      3|	}
  600|    130|	flags = *(info_blob + 0) * 0x100 + *(info_blob + 1);
  601|    130|	key_info.usage = sc_oberthur_decode_usage(flags);
  602|    130|	if (flags & OBERTHUR_ATTR_MODIFIABLE)
  ------------------
  |  |   45|    130|#define OBERTHUR_ATTR_MODIFIABLE	0x0001
  ------------------
  |  Branch (602:6): [True: 45, False: 85]
  ------------------
  603|     45|		key_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   51|     45|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  604|    130|	sc_log(ctx, "Public key key-usage:%04X", key_info.usage);
  ------------------
  |  |   71|    130|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  605|       |
  606|       |	/* Label */
  607|    130|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (607:6): [True: 1, False: 129]
  ------------------
  608|      1|		free(info_blob);
  609|      1|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add public key: no 'Label'");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  610|      1|	}
  611|    129|	len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  612|    129|	if (offs + 2 + len > info_len) {
  ------------------
  |  Branch (612:6): [True: 10, False: 119]
  ------------------
  613|     10|		free(info_blob);
  614|     10|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Failed to add public key: invalid 'Label' length");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  615|    119|	} else if (len) {
  ------------------
  |  Branch (615:13): [True: 71, False: 48]
  ------------------
  616|     71|		if (len > sizeof(key_obj.label) - 1)
  ------------------
  |  Branch (616:7): [True: 42, False: 29]
  ------------------
  617|     42|			len = sizeof(key_obj.label) - 1;
  618|     71|		memcpy(key_obj.label, info_blob + offs + 2, len);
  619|     71|	}
  620|    119|	offs += 2 + len;
  621|       |
  622|       |	/* ID */
  623|    119|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (623:6): [True: 1, False: 118]
  ------------------
  624|      1|		free(info_blob);
  625|      1|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add public key: no 'ID'");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  626|      1|	}
  627|    118|	len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  628|    118|	if (len == 0
  ------------------
  |  Branch (628:6): [True: 34, False: 84]
  ------------------
  629|     84|			|| len > sizeof(key_info.id.value)
  ------------------
  |  Branch (629:7): [True: 7, False: 77]
  ------------------
  630|     77|			|| offs + 2 + len > info_len) {
  ------------------
  |  Branch (630:7): [True: 1, False: 76]
  ------------------
  631|     42|		free(info_blob);
  632|     42|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Failed to add public key: invalid 'ID' length");
  ------------------
  |  |  174|     42|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     42|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     42|	int _ret = (r); \
  |  |  |  |  168|     42|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 42, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     42|		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|     42|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     42|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     42|		return _ret; \
  |  |  |  |  172|     42|	} \
  |  |  |  |  173|     42|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|     42|	}
  634|     76|	memcpy(key_info.id.value, info_blob + offs + 2, len);
  635|     76|	key_info.id.len = len;
  636|       |
  637|     76|	free(info_blob);
  638|       |
  639|       |	/* Ignore Start/End dates */
  640|       |
  641|     76|	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", AWP_OBJECTS_DF_PUB, file_id);
  ------------------
  |  |   75|     76|#define AWP_OBJECTS_DF_PUB	"3F0050119001"
  ------------------
  642|     76|	sc_format_path(ch_tmp, &key_info.path);
  643|       |
  644|     76|	key_info.native = 1;
  645|     76|	key_info.key_reference = file_id & 0xFF;
  646|     76|	key_info.modulus_length = size;
  647|       |
  648|     76|	rv = sc_pkcs15emu_add_rsa_pubkey(p15card, &key_obj, &key_info);
  649|       |
  650|     76|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     76|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     76|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     76|	int _ret = r; \
  |  |  |  |  155|     76|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 76, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     76|		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: 76]
  |  |  |  |  ------------------
  |  |  |  |  157|     76|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     76|	} 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|     76|	return _ret; \
  |  |  |  |  163|     76|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  651|     76|}
pkcs15-oberthur.c:sc_pkcs15emu_oberthur_add_cert:
  664|     73|{
  665|     73|	struct sc_context *ctx = p15card->card->ctx;
  666|     73|	struct sc_pkcs15_cert_info cinfo;
  667|     73|	struct sc_pkcs15_object cobj;
  668|     73|	unsigned char *info_blob = NULL, *cert_blob = NULL;
  669|     73|	size_t info_len, cert_len, len, offs;
  670|     73|	unsigned flags;
  671|     73|	int rv;
  672|     73|	char ch_tmp[0x20];
  673|       |
  674|     73|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     73|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     73|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     73|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     73|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 73]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  675|     73|	sc_log(ctx, "add certificate(file-id:%04X)", file_id);
  ------------------
  |  |   71|     73|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  676|       |
  677|     73|	memset(&cinfo, 0, sizeof(cinfo));
  678|     73|	memset(&cobj, 0, sizeof(cobj));
  679|       |
  680|     73|	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", AWP_OBJECTS_DF_PUB, file_id | 0x100);
  ------------------
  |  |   75|     73|#define AWP_OBJECTS_DF_PUB	"3F0050119001"
  ------------------
  681|     73|	rv = sc_oberthur_read_file(p15card, ch_tmp, &info_blob, &info_len, 1);
  682|     73|	LOG_TEST_RET(ctx, rv, "Failed to add certificate: read oberthur file error");
  ------------------
  |  |  174|     73|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     73|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     73|	int _ret = (r); \
  |  |  |  |  168|     73|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 25, False: 48]
  |  |  |  |  ------------------
  |  |  |  |  169|     25|		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|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     25|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     25|		return _ret; \
  |  |  |  |  172|     25|	} \
  |  |  |  |  173|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  683|       |
  684|     48|	if (info_len < 2) {
  ------------------
  |  Branch (684:6): [True: 1, False: 47]
  ------------------
  685|      1|		free(info_blob);
  686|      1|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add certificate: no 'tag'");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  687|      1|	}
  688|     47|	flags = *(info_blob + 0) * 0x100 + *(info_blob + 1);
  689|     47|	offs = 2;
  690|       |
  691|       |	/* Label */
  692|     47|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (692:6): [True: 1, False: 46]
  ------------------
  693|      1|		free(info_blob);
  694|      1|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add certificate: no 'CN'");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  695|      1|	}
  696|     46|	len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  697|     46|	if (len + offs + 2 > info_len) {
  ------------------
  |  Branch (697:6): [True: 14, False: 32]
  ------------------
  698|     14|		free(info_blob);
  699|     14|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid 'CN' length");
  ------------------
  |  |  174|     14|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     14|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     14|	int _ret = (r); \
  |  |  |  |  168|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     14|		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|     14|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     14|		return _ret; \
  |  |  |  |  172|     14|	} \
  |  |  |  |  173|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  700|     32|	} else if (len) {
  ------------------
  |  Branch (700:13): [True: 21, False: 11]
  ------------------
  701|     21|		if (len > sizeof(cobj.label) - 1)
  ------------------
  |  Branch (701:7): [True: 15, False: 6]
  ------------------
  702|     15|			len = sizeof(cobj.label) - 1;
  703|     21|		memcpy(cobj.label, info_blob + offs + 2, len);
  704|     21|	}
  705|     32|	offs += 2 + len;
  706|       |
  707|       |	/* ID */
  708|     32|	if (offs + 2 > info_len) {
  ------------------
  |  Branch (708:6): [True: 1, False: 31]
  ------------------
  709|      1|		free(info_blob);
  710|      1|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Failed to add certificate: no 'ID'");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  711|      1|	}
  712|     31|	len = *(info_blob + offs + 1) + *(info_blob + offs) * 0x100;
  713|     31|	if (len + offs + 2 > info_len) {
  ------------------
  |  Branch (713:6): [True: 7, False: 24]
  ------------------
  714|      7|		free(info_blob);
  715|      7|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid 'ID' length");
  ------------------
  |  |  174|      7|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      7|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      7|	int _ret = (r); \
  |  |  |  |  168|      7|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      7|		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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      7|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      7|		return _ret; \
  |  |  |  |  172|      7|	} \
  |  |  |  |  173|      7|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  716|     24|	} else if (len > sizeof(cinfo.id.value)) {
  ------------------
  |  Branch (716:13): [True: 2, False: 22]
  ------------------
  717|      2|		free(info_blob);
  718|      2|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Failed to add certificate: invalid 'ID' length");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  719|      2|	}
  720|     22|	memcpy(cinfo.id.value, info_blob + offs + 2, len);
  721|     22|	cinfo.id.len = len;
  722|       |
  723|     22|	free(info_blob);
  724|       |
  725|       |	/* Ignore subject, issuer and serial */
  726|       |
  727|     22|	snprintf(ch_tmp, sizeof(ch_tmp), "%s%04X", AWP_OBJECTS_DF_PUB, file_id);
  ------------------
  |  |   75|     22|#define AWP_OBJECTS_DF_PUB	"3F0050119001"
  ------------------
  728|     22|	sc_format_path(ch_tmp, &cinfo.path);
  729|     22|	rv = sc_oberthur_read_file(p15card, ch_tmp, &cert_blob, &cert_len, 1);
  730|     22|	LOG_TEST_RET(ctx, rv, "Failed to add certificate: read certificate error");
  ------------------
  |  |  174|     22|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     22|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     22|	int _ret = (r); \
  |  |  |  |  168|     22|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 19, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  169|     19|		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|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     19|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     19|		return _ret; \
  |  |  |  |  172|     19|	} \
  |  |  |  |  173|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  731|       |
  732|      3|	cinfo.value.value = cert_blob;
  733|      3|	cinfo.value.len = cert_len;
  734|       |
  735|      3|	rv = sc_oberthur_get_certificate_authority(ctx, &cinfo.value, &cinfo.authority);
  736|      3|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  |  Branch (736:6): [True: 3, False: 0]
  ------------------
  737|      3|		free(cinfo.value.value);
  738|      3|		LOG_TEST_RET(ctx, rv, "Failed to add certificate: get certificate attributes error");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  739|      3|	}
  740|       |
  741|      0|	if (flags & OBERTHUR_ATTR_MODIFIABLE)
  ------------------
  |  |   45|      0|#define OBERTHUR_ATTR_MODIFIABLE	0x0001
  ------------------
  |  Branch (741:6): [True: 0, False: 0]
  ------------------
  742|      0|		cobj.flags |= SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  743|       |
  744|      0|	rv = sc_pkcs15emu_add_x509_cert(p15card, &cobj, &cinfo);
  745|       |
  746|      0|	LOG_FUNC_RETURN(p15card->card->ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|      0|}
pkcs15-oberthur.c:sc_oberthur_get_certificate_authority:
  188|      3|{
  189|      3|#ifdef ENABLE_OPENSSL
  190|      3|	X509	*x;
  191|      3|	BUF_MEM buf_mem;
  192|      3|	BIO *bio = NULL;
  193|      3|	BASIC_CONSTRAINTS *bs = NULL;
  194|       |
  195|      3|	if (!der)
  ------------------
  |  Branch (195:6): [True: 0, False: 3]
  ------------------
  196|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  197|       |
  198|      3|	buf_mem.data = malloc(der->len);
  199|      3|	if (!buf_mem.data)
  ------------------
  |  Branch (199:6): [True: 0, False: 3]
  ------------------
  200|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  201|       |
  202|      3|	memcpy(buf_mem.data, der->value, der->len);
  203|      3|	buf_mem.max = buf_mem.length = der->len;
  204|       |
  205|      3|	bio = BIO_new(BIO_s_mem());
  206|      3|	if (!bio) {
  ------------------
  |  Branch (206:6): [True: 0, False: 3]
  ------------------
  207|      0|		free(buf_mem.data);
  208|      0|		sc_log_openssl(ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  209|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  210|      0|	}
  211|       |
  212|      3|	BIO_set_mem_buf(bio, &buf_mem, BIO_NOCLOSE);
  213|      3|	x = d2i_X509_bio(bio, 0);
  214|      3|	free(buf_mem.data);
  215|      3|	BIO_free(bio);
  216|      3|	if (!x) {
  ------------------
  |  Branch (216:6): [True: 3, False: 0]
  ------------------
  217|      3|		sc_log_openssl(ctx);
  ------------------
  |  |   72|      3|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  218|      3|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      3|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  219|      3|	}
  220|       |
  221|      0|	bs = (BASIC_CONSTRAINTS *)X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL);
  222|      0|	if (out_authority)
  ------------------
  |  Branch (222:6): [True: 0, False: 0]
  ------------------
  223|      0|		*out_authority = (bs && bs->ca);
  ------------------
  |  Branch (223:21): [True: 0, False: 0]
  |  Branch (223:27): [True: 0, False: 0]
  ------------------
  224|       |
  225|      0|	X509_free(x);
  226|       |
  227|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  228|       |#else
  229|       |	return SC_ERROR_NOT_SUPPORTED;
  230|       |#endif
  231|      3|}
pkcs15-oberthur.c:sc_oberthur_read_file:
  238|  1.79k|{
  239|  1.79k|	struct sc_context *ctx = p15card->card->ctx;
  240|  1.79k|	struct sc_card *card = p15card->card;
  241|  1.79k|	struct sc_file *file = NULL;
  242|  1.79k|	struct sc_path path;
  243|  1.79k|	size_t sz;
  244|  1.79k|	int rv;
  245|       |
  246|  1.79k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.79k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.79k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.79k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.79k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.79k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  247|  1.79k|	if (!in_path || !out || !out_len)
  ------------------
  |  Branch (247:6): [True: 0, False: 1.79k]
  |  Branch (247:18): [True: 0, False: 1.79k]
  |  Branch (247:26): [True: 0, False: 1.79k]
  ------------------
  248|  1.79k|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Cannot read oberthur file");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  249|       |
  250|  1.79k|	sc_log(ctx, "read file '%s'; verify_pin:%i", in_path, verify_pin);
  ------------------
  |  |   71|  1.79k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  251|       |
  252|  1.79k|	*out = NULL;
  253|  1.79k|	*out_len = 0;
  254|       |
  255|  1.79k|	sc_format_path(in_path, &path);
  256|  1.79k|	rv = sc_select_file(card, &path, &file);
  257|  1.79k|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|  1.79k|#define SC_SUCCESS				0
  ------------------
  |  Branch (257:6): [True: 180, False: 1.61k]
  ------------------
  258|    180|		sc_file_free(file);
  259|    180|		LOG_TEST_RET(ctx, rv, "Cannot select oberthur file to read");
  ------------------
  |  |  174|    180|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    180|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    180|	int _ret = (r); \
  |  |  |  |  168|    180|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 180, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    180|		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|    180|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    180|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    180|		return _ret; \
  |  |  |  |  172|    180|	} \
  |  |  |  |  173|    180|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|    180|	}
  261|       |
  262|  1.61k|	if (file->ef_structure == SC_FILE_EF_TRANSPARENT)
  ------------------
  |  |  221|  1.61k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (262:6): [True: 1.20k, False: 411]
  ------------------
  263|  1.20k|		sz = file->size;
  264|    411|	else
  265|    411|		sz = (file->record_length + 2) * file->record_count;
  266|       |
  267|  1.61k|	*out = calloc(1, sz);
  268|  1.61k|	if (*out == NULL) {
  ------------------
  |  Branch (268:6): [True: 0, False: 1.61k]
  ------------------
  269|      0|		sc_file_free(file);
  270|      0|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot read oberthur file");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|      0|	}
  272|       |
  273|  1.61k|	if (file->ef_structure == SC_FILE_EF_TRANSPARENT)   {
  ------------------
  |  |  221|  1.61k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (273:6): [True: 1.20k, False: 411]
  ------------------
  274|  1.20k|		rv = sc_read_binary(card, 0, *out, sz, 0);
  275|  1.20k|	}
  276|    411|	else	{
  277|    411|		unsigned int rec;
  278|    411|		size_t offs = 0;
  279|    411|		size_t rec_len = file->record_length;
  280|       |
  281|    411|		for (rec = 1; ; rec++)   {
  282|    411|			if (rec > file->record_count) {
  ------------------
  |  Branch (282:8): [True: 411, False: 0]
  ------------------
  283|    411|				rv = 0;
  284|    411|				break;
  285|    411|			}
  286|      0|			rv = sc_read_record(card, rec, 0, *out + offs + 2, rec_len, SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1298|      0|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  287|      0|			if (rv == SC_ERROR_RECORD_NOT_FOUND)   {
  ------------------
  |  |   52|      0|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (287:8): [True: 0, False: 0]
  ------------------
  288|      0|				rv = 0;
  289|      0|				break;
  290|      0|			}
  291|      0|			else if (rv < 0)   {
  ------------------
  |  Branch (291:13): [True: 0, False: 0]
  ------------------
  292|      0|				break;
  293|      0|			}
  294|       |
  295|      0|			rec_len = rv;
  296|       |
  297|      0|			*(*out + offs) = 'R';
  298|      0|			*(*out + offs + 1) = rv;
  299|       |
  300|      0|			offs += rv + 2;
  301|      0|		}
  302|       |
  303|    411|		sz = offs;
  304|    411|	}
  305|       |
  306|  1.61k|	sc_log(ctx, "read oberthur file result %i", rv);
  ------------------
  |  |   71|  1.61k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  307|  1.61k|	if (verify_pin && rv == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)   {
  ------------------
  |  |   61|  1.61k|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (307:6): [True: 1.61k, False: 0]
  |  Branch (307:20): [True: 1, False: 1.61k]
  ------------------
  308|      1|		struct sc_pkcs15_object *objs[0x10], *pin_obj = NULL;
  309|      1|		const struct sc_acl_entry *acl = sc_file_get_acl_entry(file, SC_AC_OP_READ);
  ------------------
  |  |  188|      1|#define SC_AC_OP_READ			22
  ------------------
  310|      1|		int ii, nobjs;
  311|       |
  312|      1|		if (acl == NULL) {
  ------------------
  |  Branch (312:7): [True: 1, False: 0]
  ------------------
  313|      1|			sc_file_free(file);
  314|      1|			free(*out);
  315|      1|			*out = NULL;
  316|      1|			LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|      1|		}
  318|       |
  319|      0|		nobjs = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 0x10);
  ------------------
  |  |  445|      0|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  320|      0|		if (nobjs < 1) {
  ------------------
  |  Branch (320:7): [True: 0, False: 0]
  ------------------
  321|      0|			sc_file_free(file);
  322|      0|			free(*out);
  323|      0|			*out = NULL;
  324|      0|			LOG_TEST_RET(ctx, SC_ERROR_DATA_OBJECT_NOT_FOUND,
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  325|      0|				"Cannot read oberthur file: get AUTH objects error");
  326|      0|		}
  327|       |
  328|      0|		for (ii = 0; ii < nobjs; ii++) {
  ------------------
  |  Branch (328:16): [True: 0, False: 0]
  ------------------
  329|      0|			struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *) objs[ii]->data;
  330|      0|			sc_log(ctx, "compare PIN/ACL refs:%i/%i, method:%i/%i",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  331|      0|				auth_info->attrs.pin.reference, acl->key_ref, auth_info->auth_method, acl->method);
  332|      0|			if (auth_info->attrs.pin.reference == (int)acl->key_ref && auth_info->auth_method == (unsigned)acl->method)   {
  ------------------
  |  Branch (332:8): [True: 0, False: 0]
  |  Branch (332:63): [True: 0, False: 0]
  ------------------
  333|      0|				pin_obj = objs[ii];
  334|      0|				break;
  335|      0|			}
  336|      0|		}
  337|       |
  338|      0|		if (!pin_obj || !pin_obj->content.value)    {
  ------------------
  |  Branch (338:7): [True: 0, False: 0]
  |  Branch (338:19): [True: 0, False: 0]
  ------------------
  339|      0|			rv = SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  340|      0|		}
  341|      0|		else    {
  342|      0|			rv = sc_pkcs15_verify_pin(p15card, pin_obj, pin_obj->content.value, pin_obj->content.len);
  343|      0|			if (!rv)
  ------------------
  |  Branch (343:8): [True: 0, False: 0]
  ------------------
  344|      0|				rv = sc_oberthur_read_file(p15card, in_path, out, out_len, 0);
  345|      0|		}
  346|      0|	}
  347|       |
  348|  1.61k|	sc_file_free(file);
  349|       |
  350|  1.61k|	if (rv < 0)   {
  ------------------
  |  Branch (350:6): [True: 19, False: 1.59k]
  ------------------
  351|     19|		free(*out);
  352|     19|		*out = NULL;
  353|     19|		*out_len = 0;
  354|     19|	}
  355|       |
  356|  1.61k|	*out_len = sz;
  357|       |
  358|  1.61k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  1.61k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.61k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.61k|	int _ret = r; \
  |  |  |  |  155|  1.61k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 502, False: 1.10k]
  |  |  |  |  ------------------
  |  |  |  |  156|    502|		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|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 19, False: 483]
  |  |  |  |  ------------------
  |  |  |  |  157|    502|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.10k|	} else { \
  |  |  |  |  159|  1.10k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.10k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.10k|	} \
  |  |  |  |  162|  1.61k|	return _ret; \
  |  |  |  |  163|  1.61k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  359|  1.61k|}

sc_pkcs15emu_openpgp_init_ex:
  694|  15.9k|{
  695|  15.9k|	if (openpgp_detect_card(p15card))
  ------------------
  |  Branch (695:6): [True: 15.2k, False: 653]
  ------------------
  696|  15.2k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  15.2k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  697|    653|	return sc_pkcs15emu_openpgp_init(p15card);
  698|  15.9k|}
pkcs15-openpgp.c:openpgp_detect_card:
  682|  15.9k|{
  683|  15.9k|	if (p15card->card->type == SC_CARD_TYPE_OPENPGP_BASE
  ------------------
  |  Branch (683:6): [True: 628, False: 15.2k]
  ------------------
  684|  15.2k|			|| p15card->card->type == SC_CARD_TYPE_OPENPGP_V1
  ------------------
  |  Branch (684:7): [True: 2, False: 15.2k]
  ------------------
  685|  15.2k|			|| p15card->card->type == SC_CARD_TYPE_OPENPGP_V2
  ------------------
  |  Branch (685:7): [True: 5, False: 15.2k]
  ------------------
  686|  15.2k|			|| p15card->card->type == SC_CARD_TYPE_OPENPGP_GNUK
  ------------------
  |  Branch (686:7): [True: 7, False: 15.2k]
  ------------------
  687|  15.2k|			|| p15card->card->type == SC_CARD_TYPE_OPENPGP_V3)
  ------------------
  |  Branch (687:7): [True: 11, False: 15.2k]
  ------------------
  688|    653|		return SC_SUCCESS;
  ------------------
  |  |   28|    653|#define SC_SUCCESS				0
  ------------------
  689|  15.2k|	else
  690|  15.2k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  15.2k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  691|  15.9k|}
pkcs15-openpgp.c:sc_pkcs15emu_openpgp_init:
  181|    653|{
  182|    653|	sc_card_t	*card = p15card->card;
  183|    653|	sc_context_t	*ctx = card->ctx;
  184|    653|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    653|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  185|    653|	char		string[256];
  186|    653|	u8		c4data[10];
  187|    653|	u8		c5data[100];
  188|    653|	int		r, i;
  189|    653|	const pgp_pin_cfg_t *pin_cfg = (card->type == SC_CARD_TYPE_OPENPGP_V1)
  ------------------
  |  Branch (189:33): [True: 2, False: 651]
  ------------------
  190|    653|	                               ? pin_cfg_v1 : pin_cfg_v2;
  191|    653|	sc_path_t path;
  192|    653|	sc_file_t *file = NULL;
  193|       |
  194|    653|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    653|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    653|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    653|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    653|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 653]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|       |
  196|    653|	set_string(&p15card->tokeninfo->label, "OpenPGP card");
  197|    653|	set_string(&p15card->tokeninfo->manufacturer_id, "OpenPGP project");
  198|       |
  199|       |	/* card->serialnr = 2 byte manufacturer_id + 4 byte serial_number */
  200|    653|	if (card->serialnr.len > 0) {
  ------------------
  |  Branch (200:6): [True: 435, False: 218]
  ------------------
  201|    435|		unsigned short manuf_id = bebytes2ushort(card->serialnr.value);
  202|    435|		int j;
  203|       |
  204|    435|		sc_bin_to_hex(card->serialnr.value, card->serialnr.len, string, sizeof(string), 0);
  205|    435|		set_string(&p15card->tokeninfo->serial_number, string);
  206|       |
  207|  10.4k|		for (j = 0; manuf_map[j].name != NULL; j++) {
  ------------------
  |  Branch (207:15): [True: 10.1k, False: 361]
  ------------------
  208|  10.1k|			if (manuf_id == manuf_map[j].id) {
  ------------------
  |  Branch (208:8): [True: 74, False: 10.0k]
  ------------------
  209|     74|				set_string(&p15card->tokeninfo->manufacturer_id, manuf_map[j].name);
  210|     74|				break;
  211|     74|			}
  212|  10.1k|		}
  213|    435|	}
  214|       |
  215|    653|	p15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_EID_COMPLIANT;
  ------------------
  |  |  597|    653|#define SC_PKCS15_TOKEN_PRN_GENERATION			0x04
  ------------------
              	p15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_EID_COMPLIANT;
  ------------------
  |  |  598|    653|#define SC_PKCS15_TOKEN_EID_COMPLIANT			0x08
  ------------------
  216|       |
  217|       |	/* Extract preferred language */
  218|    653|	r = read_file(card, "0065:5f2d", string, sizeof(string)-1);
  219|    653|	if (r < 0)
  ------------------
  |  Branch (219:6): [True: 613, False: 40]
  ------------------
  220|    613|		goto failed;
  221|     40|	string[r] = '\0';
  222|     40|	set_string(&p15card->tokeninfo->preferred_language, string);
  223|       |
  224|       |	/* Get CHV status bytes from DO 006E/0073/00C4:
  225|       |	 *  00:		1 == user consent for signature PIN
  226|       |	 *		(i.e. PIN still valid for next PSO:CDS command)
  227|       |	 *  01-03:	max length of pins 1-3
  228|       |	 *  04-07:	tries left for pins 1-3
  229|       |	 */
  230|     40|	sc_log(ctx, "Reading PW status bytes");
  ------------------
  |  |   71|     40|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  231|     40|	if ((r = read_file(card, "006E:0073:00C4", c4data, sizeof(c4data))) < 0)
  ------------------
  |  Branch (231:6): [True: 21, False: 19]
  ------------------
  232|     21|		goto failed;
  233|     19|	if (r != 7) {
  ------------------
  |  Branch (233:6): [True: 17, False: 2]
  ------------------
  234|     17|		sc_log(ctx, "CHV status bytes have unexpected length (expected 7, got %d)\n", r);
  ------------------
  |  |   71|     17|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  235|     17|		r = SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|     17|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  236|     17|		goto failed;
  237|     17|	}
  238|       |
  239|       |	/* Add PIN codes */
  240|      8|	for (i = 0; i < 3; i++) {
  ------------------
  |  Branch (240:14): [True: 6, False: 2]
  ------------------
  241|      6|		sc_pkcs15_auth_info_t pin_info;
  242|      6|		sc_pkcs15_object_t   pin_obj;
  243|       |
  244|      6|		memset(&pin_info, 0, sizeof(pin_info));
  245|      6|		memset(&pin_obj,  0, sizeof(pin_obj));
  246|       |
  247|      6|		pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|      6|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  248|      6|		pin_info.auth_id.len      = 1;
  249|      6|		pin_info.auth_id.value[0] = pin_cfg[i].reference;
  250|      6|		pin_info.attrs.pin.reference     = pin_cfg[i].reference;
  251|      6|		pin_info.attrs.pin.flags         = pin_cfg[i].flags;
  252|      6|		pin_info.attrs.pin.type          = SC_PKCS15_PIN_TYPE_UTF8;
  ------------------
  |  |   90|      6|#define SC_PKCS15_PIN_TYPE_UTF8				2
  ------------------
  253|      6|		pin_info.attrs.pin.min_length    = pin_cfg[i].min_length;
  254|      6|		pin_info.attrs.pin.stored_length = c4data[1 + pin_cfg[i].do_index];
  255|      6|		pin_info.attrs.pin.max_length    = c4data[1 + pin_cfg[i].do_index];
  256|      6|		pin_info.attrs.pin.pad_char      = '\0';
  257|      6|		pin_info.tries_left = c4data[4 + pin_cfg[i].do_index];
  258|      6|		pin_info.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|      6|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
  259|       |
  260|      6|		sc_format_path("3F00", &pin_info.path);
  261|       |
  262|      6|		strlcpy(pin_obj.label, pin_cfg[i].label, sizeof(pin_obj.label));
  ------------------
  |  |   43|      6|#define strlcpy _strlcpy
  ------------------
  263|      6|		pin_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   51|      6|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              		pin_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      6|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  264|      6|		if (i < 2) {
  ------------------
  |  Branch (264:7): [True: 4, False: 2]
  ------------------
  265|      4|			pin_obj.auth_id.len = 1;
  266|      4|			pin_obj.auth_id.value[0] = 3;
  267|      4|		}
  268|       |
  269|      6|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  270|      6|		if (r < 0) {
  ------------------
  |  Branch (270:7): [True: 0, False: 6]
  ------------------
  271|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  272|      0|			goto failed;
  273|      0|		}
  274|      6|	}
  275|       |
  276|       |	/* Get private key finger prints from DO 006E/0073/00C5:
  277|       |	 *  00-19:	finger print for SIG key
  278|       |	 *  20-39:	finger print for ENC key
  279|       |	 *  40-59:	finger print for AUT key
  280|       |	 */
  281|      2|	sc_log(ctx, "Reading Fingerprints");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  282|      2|	if ((r = read_file(card, "006E:0073:00C5", c5data, sizeof(c5data))) < 0)
  ------------------
  |  Branch (282:6): [True: 1, False: 1]
  ------------------
  283|      1|		goto failed;
  284|      1|	if (r < 60) {
  ------------------
  |  Branch (284:6): [True: 1, False: 0]
  ------------------
  285|      1|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  286|      1|			"finger print bytes have unexpected length (expected 60, got %d)\n", r);
  287|      1|		r = SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      1|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  288|      1|		goto failed;
  289|      1|	}
  290|       |
  291|      0|	sc_log(ctx, "Adding private keys");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  292|       |	/* XXX: check if "halfkeys" can be stored with gpg2. If not, add key pairs in one loop */
  293|      0|	for (i = 0; i < 3; i++) {
  ------------------
  |  Branch (293:14): [True: 0, False: 0]
  ------------------
  294|      0|		sc_pkcs15_prkey_info_t prkey_info;
  295|      0|		sc_pkcs15_object_t     prkey_obj;
  296|      0|		u8 cxdata[12];
  297|      0|		int cxdata_len = sizeof(cxdata);
  298|      0|		char path_template[] = "006E:0073:00Cx";
  299|      0|		int j;
  300|       |
  301|      0|		memset(&prkey_info, 0, sizeof(prkey_info));
  302|      0|		memset(&prkey_obj,  0, sizeof(prkey_obj));
  303|      0|		memset(&cxdata, 0, sizeof(cxdata));
  304|       |
  305|      0|		path_template[13] = '1' + i; /* The needed tags are C1 C2 and C3 */
  306|      0|		if ((cxdata_len = read_file(card, path_template, cxdata, sizeof(cxdata))) < 1)
  ------------------
  |  Branch (306:7): [True: 0, False: 0]
  ------------------
  307|      0|			goto failed;
  308|       |
  309|       |		/* check validity using finger prints */
  310|      0|		for (j = 19; j >= 0; j--) {
  ------------------
  |  Branch (310:16): [True: 0, False: 0]
  ------------------
  311|      0|			if (c5data[20 * i + j] != '\0')
  ------------------
  |  Branch (311:8): [True: 0, False: 0]
  ------------------
  312|      0|				break;
  313|      0|		}
  314|       |
  315|       |		/* only add valid keys, i.e. those with a legal algorithm identifier & finger print */
  316|      0|		if (j >= 0 && cxdata[0] != 0) {
  ------------------
  |  Branch (316:7): [True: 0, False: 0]
  |  Branch (316:17): [True: 0, False: 0]
  ------------------
  317|      0|			struct sc_object_id oid = {0};
  318|      0|			struct sc_algorithm_info * algorithm_info; /* no need to free */
  319|       |
  320|      0|			algorithm_info = NULL;
  321|      0|			prkey_info.id.len         = 1;
  322|      0|			prkey_info.id.value[0]    = i + 1;
  323|      0|			prkey_info.usage          = key_cfg[i].prkey_usage;
  324|      0|			prkey_info.native         = 1;
  325|      0|			prkey_info.key_reference  = i;
  326|       |
  327|      0|			strlcpy(prkey_obj.label, key_cfg[i].label, sizeof(prkey_obj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  328|      0|			prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE | SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
              			prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE | SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  329|      0|			prkey_obj.auth_id.len      = 1;
  330|      0|			prkey_obj.auth_id.value[0] = key_cfg[i].prkey_pin;
  331|       |
  332|       |			/* need to get size from algorithms using oid */
  333|      0|			if (cxdata[0] == SC_OPENPGP_KEYALGO_ECDH ||
  ------------------
  |  |  878|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (333:8): [True: 0, False: 0]
  ------------------
  334|      0|				cxdata[0] == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  879|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (334:5): [True: 0, False: 0]
  ------------------
  335|      0|				cxdata[0] == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  880|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (335:5): [True: 0, False: 0]
  ------------------
  336|       |				/* Last byte could be Import-Format of private key, let's ignore it,
  337|       |				 * as it is not part of OID */
  338|      0|				if (cxdata[cxdata_len-1] == SC_OPENPGP_KEYFORMAT_EC_STD ||
  ------------------
  |  |  887|      0|#define SC_OPENPGP_KEYFORMAT_EC_STD	0
  ------------------
  |  Branch (338:9): [True: 0, False: 0]
  ------------------
  339|      0|				    cxdata[cxdata_len-1] == SC_OPENPGP_KEYFORMAT_EC_STDPUB)
  ------------------
  |  |  888|      0|#define SC_OPENPGP_KEYFORMAT_EC_STDPUB	0xFF
  ------------------
  |  Branch (339:9): [True: 0, False: 0]
  ------------------
  340|      0|					cxdata_len--;
  341|      0|				r = sc_asn1_decode_object_id(&cxdata[1], cxdata_len-1, &oid);
  342|      0|				if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (342:9): [True: 0, False: 0]
  ------------------
  343|      0|					sc_log(ctx, "Failed to parse OID for elliptic curve algorithm");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  344|      0|				}
  345|      0|			}
  346|       |
  347|      0|			switch (cxdata[0]) {
  ------------------
  |  Branch (347:12): [True: 0, False: 0]
  ------------------
  348|      0|			case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  878|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (348:4): [True: 0, False: 0]
  ------------------
  349|      0|				if (sc_compare_oid(&oid, &curve25519_oid)) {
  ------------------
  |  Branch (349:9): [True: 0, False: 0]
  ------------------
  350|      0|					if ((algorithm_info = sc_card_find_xeddsa_alg(card, 0, &oid)))
  ------------------
  |  Branch (350:10): [True: 0, False: 0]
  ------------------
  351|      0|						prkey_info.field_length = algorithm_info->key_length;
  352|      0|					else {
  353|      0|						sc_log(ctx, "algorithm not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  354|      0|						continue;
  355|      0|					}
  356|      0|					break;
  357|      0|				}
  358|       |				/* Fall through */
  359|      0|			case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  879|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (359:4): [True: 0, False: 0]
  ------------------
  360|      0|				if((algorithm_info = sc_card_find_ec_alg(card, 0, &oid)))
  ------------------
  |  Branch (360:8): [True: 0, False: 0]
  ------------------
  361|      0|					prkey_info.field_length = algorithm_info->key_length;
  362|      0|				else {
  363|      0|					sc_log(ctx, "algorithm not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  364|      0|					continue;
  365|      0|				}
  366|      0|				break;
  367|      0|			case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  880|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (367:4): [True: 0, False: 0]
  ------------------
  368|      0|				if ((algorithm_info = sc_card_find_eddsa_alg(card, 0, &oid)))
  ------------------
  |  Branch (368:9): [True: 0, False: 0]
  ------------------
  369|      0|					prkey_info.field_length = algorithm_info->key_length;
  370|      0|				else {
  371|      0|					sc_log(ctx, "algorithm not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  372|      0|					continue;
  373|      0|				}
  374|      0|				break;
  375|      0|			}
  376|       |
  377|      0|			switch (cxdata[0]) {
  378|      0|			case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  880|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (378:4): [True: 0, False: 0]
  ------------------
  379|       |				/* Filter out invalid usage: EdDSA does not support anything but sign */
  380|      0|				prkey_info.usage &= PGP_SIG_PRKEY_USAGE;
  ------------------
  |  |   78|      0|#define PGP_SIG_PRKEY_USAGE	(SC_PKCS15_PRKEY_USAGE_SIGN \
  |  |  ------------------
  |  |  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  |  |  ------------------
  |  |   79|      0|				| SC_PKCS15_PRKEY_USAGE_SIGNRECOVER \
  |  |  ------------------
  |  |  |  |  308|      0|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  |  |  ------------------
  |  |   80|      0|				| SC_PKCS15_PRKEY_USAGE_NONREPUDIATION)
  |  |  ------------------
  |  |  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  |  |  ------------------
  ------------------
  381|      0|				r = sc_pkcs15emu_add_eddsa_prkey(p15card, &prkey_obj, &prkey_info);
  382|      0|				break;
  383|       |
  384|      0|			case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  878|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (384:4): [True: 0, False: 0]
  ------------------
  385|       |				/* This can result in either ECDSA key or EC_MONTGOMERY
  386|       |				 * so we need to check OID */
  387|      0|				if (sc_compare_oid(&oid, &curve25519_oid)) {
  ------------------
  |  Branch (387:9): [True: 0, False: 0]
  ------------------
  388|       |					/* This can do only DERIVE */
  389|      0|					prkey_info.usage = SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  390|      0|					r = sc_pkcs15emu_add_xeddsa_prkey(p15card, &prkey_obj, &prkey_info);
  391|      0|					break;
  392|      0|				}
  393|      0|				prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  394|      0|				prkey_info.usage &= ~PGP_ENC_PRKEY_USAGE;
  ------------------
  |  |   81|      0|#define	PGP_ENC_PRKEY_USAGE	(SC_PKCS15_PRKEY_USAGE_DECRYPT \
  |  |  ------------------
  |  |  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |   82|      0|				| SC_PKCS15_PRKEY_USAGE_UNWRAP)
  |  |  ------------------
  |  |  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  ------------------
  395|      0|				r = sc_pkcs15emu_add_ec_prkey(p15card, &prkey_obj, &prkey_info);
  396|      0|				break;
  397|       |
  398|      0|			case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  879|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (398:4): [True: 0, False: 0]
  ------------------
  399|      0|				prkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  400|      0|				r = sc_pkcs15emu_add_ec_prkey(p15card, &prkey_obj, &prkey_info);
  401|      0|				break;
  402|       |
  403|      0|			case SC_OPENPGP_KEYALGO_RSA:
  ------------------
  |  |  877|      0|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (403:4): [True: 0, False: 0]
  ------------------
  404|      0|				if (cxdata_len >= 3) {
  ------------------
  |  Branch (404:9): [True: 0, False: 0]
  ------------------
  405|       |					/* with Authentication key, can only decrypt if can change MSE */
  406|      0|					if (i == 2 && !(priv->ext_caps & EXT_CAP_MSE)) {
  ------------------
  |  Branch (406:10): [True: 0, False: 0]
  |  Branch (406:20): [True: 0, False: 0]
  ------------------
  407|      0|						prkey_info.usage &= ~PGP_ENC_PRKEY_USAGE;
  ------------------
  |  |   81|      0|#define	PGP_ENC_PRKEY_USAGE	(SC_PKCS15_PRKEY_USAGE_DECRYPT \
  |  |  ------------------
  |  |  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |   82|      0|				| SC_PKCS15_PRKEY_USAGE_UNWRAP)
  |  |  ------------------
  |  |  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  ------------------
  408|      0|					}
  409|      0|					prkey_info.modulus_length = bebytes2ushort(cxdata + 1);
  410|      0|					r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  411|      0|					break;
  412|      0|				}
  413|       |				/* Fallthrough */
  414|      0|			default:
  ------------------
  |  Branch (414:4): [True: 0, False: 0]
  ------------------
  415|      0|				sc_log(ctx, "Invalid algorithm identifier %x (length = %d)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  416|      0|					cxdata[0], r);
  417|      0|			}
  418|       |
  419|      0|			if (r < 0) {
  ------------------
  |  Branch (419:8): [True: 0, False: 0]
  ------------------
  420|      0|				r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  421|      0|				goto failed;
  422|      0|			}
  423|      0|		}
  424|      0|	}
  425|       |
  426|      0|	sc_log(ctx, "Adding public keys");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  427|       |	/* Add public keys */
  428|      0|	for (i = 0; i < 3; i++) {
  ------------------
  |  Branch (428:14): [True: 0, False: 0]
  ------------------
  429|      0|		sc_pkcs15_pubkey_info_t pubkey_info;
  430|      0|		sc_pkcs15_object_t      pubkey_obj;
  431|      0|		u8 cxdata[12];
  432|      0|		int cxdata_len = sizeof(cxdata);
  433|      0|		char path_template[] = "006E:0073:00Cx";
  434|      0|		int j;
  435|       |
  436|      0|		memset(&pubkey_info, 0, sizeof(pubkey_info));
  437|      0|		memset(&pubkey_obj,  0, sizeof(pubkey_obj));
  438|      0|		memset(&cxdata, 0, sizeof(cxdata));
  439|       |
  440|      0|		path_template[13] = '1' + i; /* The needed tags are C1 C2 and C3 */
  441|      0|		if ((cxdata_len = read_file(card, path_template, cxdata, sizeof(cxdata))) < 1)
  ------------------
  |  Branch (441:7): [True: 0, False: 0]
  ------------------
  442|      0|			goto failed;
  443|       |
  444|       |		/* check validity using finger prints */
  445|      0|		for (j = 19; j >= 0; j--) {
  ------------------
  |  Branch (445:16): [True: 0, False: 0]
  ------------------
  446|      0|			if (c5data[20 * i + j] != '\0')
  ------------------
  |  Branch (446:8): [True: 0, False: 0]
  ------------------
  447|      0|				break;
  448|      0|		}
  449|       |
  450|       |		/* only add valid keys, i.e. those with a legal algorithm identifier & finger print */
  451|      0|		if (j >= 0 && cxdata[0] != 0) {
  ------------------
  |  Branch (451:7): [True: 0, False: 0]
  |  Branch (451:17): [True: 0, False: 0]
  ------------------
  452|      0|			struct sc_object_id oid;
  453|      0|			struct sc_algorithm_info * algorithm_info; /* no need to free */
  454|       |
  455|      0|			algorithm_info = NULL;
  456|      0|			pubkey_info.id.len         = 1;
  457|      0|			pubkey_info.id.value[0]    = i + 1;
  458|      0|			pubkey_info.usage          = key_cfg[i].pubkey_usage;
  459|      0|			sc_format_path(key_cfg[i].pubkey_path, &pubkey_info.path);
  460|       |
  461|      0|			strlcpy(pubkey_obj.label, key_cfg[i].label, sizeof(pubkey_obj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  462|      0|			pubkey_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  463|       |
  464|      0|			if (cxdata[0] == SC_OPENPGP_KEYALGO_ECDH ||
  ------------------
  |  |  878|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (464:8): [True: 0, False: 0]
  ------------------
  465|      0|				cxdata[0] == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  879|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (465:5): [True: 0, False: 0]
  ------------------
  466|      0|				cxdata[0] == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  880|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (466:5): [True: 0, False: 0]
  ------------------
  467|       |				/* Last byte could be Import-Format of private key, let's ignore it,
  468|       |				 * as it is not part of OID */
  469|      0|				if (cxdata[cxdata_len-1] == SC_OPENPGP_KEYFORMAT_EC_STD ||
  ------------------
  |  |  887|      0|#define SC_OPENPGP_KEYFORMAT_EC_STD	0
  ------------------
  |  Branch (469:9): [True: 0, False: 0]
  ------------------
  470|      0|				    cxdata[cxdata_len-1] == SC_OPENPGP_KEYFORMAT_EC_STDPUB)
  ------------------
  |  |  888|      0|#define SC_OPENPGP_KEYFORMAT_EC_STDPUB	0xFF
  ------------------
  |  Branch (470:9): [True: 0, False: 0]
  ------------------
  471|      0|					cxdata_len--;
  472|      0|				r = sc_asn1_decode_object_id(&cxdata[1], cxdata_len-1, &oid);
  473|      0|				if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (473:9): [True: 0, False: 0]
  ------------------
  474|      0|					sc_log(ctx, "Failed to parse OID for elliptic curve algorithm");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  475|      0|				}
  476|      0|			}
  477|       |
  478|      0|			switch (cxdata[0]) {
  ------------------
  |  Branch (478:12): [True: 0, False: 0]
  ------------------
  479|      0|			case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  878|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (479:4): [True: 0, False: 0]
  ------------------
  480|      0|				if (sc_compare_oid(&oid, &curve25519_oid)) {
  ------------------
  |  Branch (480:9): [True: 0, False: 0]
  ------------------
  481|      0|					if ((algorithm_info = sc_card_find_xeddsa_alg(card, 0, &oid)))
  ------------------
  |  Branch (481:10): [True: 0, False: 0]
  ------------------
  482|      0|						pubkey_info.field_length = algorithm_info->key_length;
  483|      0|					else {
  484|      0|						sc_log(ctx, "algorithm not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  485|      0|						continue;
  486|      0|					}
  487|      0|					break;
  488|      0|				}
  489|       |				/* Fall through */
  490|      0|			case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  879|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (490:4): [True: 0, False: 0]
  ------------------
  491|      0|				if((algorithm_info = sc_card_find_ec_alg(card, 0, &oid)))
  ------------------
  |  Branch (491:8): [True: 0, False: 0]
  ------------------
  492|      0|					pubkey_info.field_length = algorithm_info->key_length;
  493|      0|				else {
  494|      0|					sc_log(ctx, "algorithm not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  495|      0|					continue;
  496|      0|				}
  497|      0|				break;
  498|      0|			case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  880|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (498:4): [True: 0, False: 0]
  ------------------
  499|      0|				if ((algorithm_info = sc_card_find_eddsa_alg(card, 0, &oid)))
  ------------------
  |  Branch (499:9): [True: 0, False: 0]
  ------------------
  500|      0|					pubkey_info.field_length = algorithm_info->key_length;
  501|      0|				else {
  502|      0|					sc_log(ctx, "algorithm not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  503|      0|					continue;
  504|      0|				}
  505|      0|				break;
  506|      0|			}
  507|       |
  508|      0|			switch (cxdata[0]) {
  509|      0|			case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  880|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (509:4): [True: 0, False: 0]
  ------------------
  510|       |				/* assuming Ed25519 as it is the only supported now */
  511|       |				/* Filter out invalid usage: ED does not support anything but sign */
  512|      0|				pubkey_info.usage &= PGP_SIG_PUBKEY_USAGE;
  ------------------
  |  |   85|      0|#define	PGP_SIG_PUBKEY_USAGE	(SC_PKCS15_PRKEY_USAGE_VERIFY \
  |  |  ------------------
  |  |  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  |  |  ------------------
  |  |   86|      0|				| SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER)
  |  |  ------------------
  |  |  |  |  312|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  |  |  ------------------
  ------------------
  513|      0|				r = sc_pkcs15emu_add_eddsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
  514|      0|				break;
  515|      0|			case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  878|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (515:4): [True: 0, False: 0]
  ------------------
  516|       |				/* This can result in either ECDSA key or EC_MONTGOMERY
  517|       |				 * so we need to check OID */
  518|      0|				if (sc_compare_oid(&oid, &curve25519_oid)) {
  ------------------
  |  Branch (518:9): [True: 0, False: 0]
  ------------------
  519|       |					/* XXX What can this key do? */
  520|      0|					pubkey_info.usage = SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  521|      0|					r = sc_pkcs15emu_add_xeddsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
  522|      0|					break;
  523|      0|				}
  524|      0|				pubkey_info.usage = SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  525|      0|				r = sc_pkcs15emu_add_ec_pubkey(p15card, &pubkey_obj, &pubkey_info);
  526|      0|				break;
  527|      0|			case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  879|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (527:4): [True: 0, False: 0]
  ------------------
  528|      0|				pubkey_info.usage = PGP_SIG_PUBKEY_USAGE;
  ------------------
  |  |   85|      0|#define	PGP_SIG_PUBKEY_USAGE	(SC_PKCS15_PRKEY_USAGE_VERIFY \
  |  |  ------------------
  |  |  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  |  |  ------------------
  |  |   86|      0|				| SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER)
  |  |  ------------------
  |  |  |  |  312|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  |  |  ------------------
  ------------------
  529|      0|				r = sc_pkcs15emu_add_ec_pubkey(p15card, &pubkey_obj, &pubkey_info);
  530|      0|				break;
  531|      0|			case SC_OPENPGP_KEYALGO_RSA:
  ------------------
  |  |  877|      0|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (531:4): [True: 0, False: 0]
  ------------------
  532|      0|				if (cxdata_len >= 3) {
  ------------------
  |  Branch (532:9): [True: 0, False: 0]
  ------------------
  533|       |					/* with Authentication pubkey, can only encrypt if can change MSE */
  534|      0|					if (i == 2 && !(priv->ext_caps & EXT_CAP_MSE)) {
  ------------------
  |  Branch (534:10): [True: 0, False: 0]
  |  Branch (534:20): [True: 0, False: 0]
  ------------------
  535|      0|						pubkey_info.usage &= ~PGP_ENC_PUBKEY_USAGE;
  ------------------
  |  |   87|      0|#define	PGP_ENC_PUBKEY_USAGE	(SC_PKCS15_PRKEY_USAGE_ENCRYPT \
  |  |  ------------------
  |  |  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  |  |  ------------------
  |  |   88|      0|				| SC_PKCS15_PRKEY_USAGE_WRAP)
  |  |  ------------------
  |  |  |  |  309|      0|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  |  |  ------------------
  ------------------
  536|      0|					}
  537|      0|					pubkey_info.modulus_length = bebytes2ushort(cxdata + 1);
  538|      0|					r = sc_pkcs15emu_add_rsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
  539|      0|					break;
  540|      0|				}
  541|       |				/* Fall through */
  542|      0|			default:
  ------------------
  |  Branch (542:4): [True: 0, False: 0]
  ------------------
  543|      0|				sc_log(ctx, "Invalid algorithm identifier %x (length = %d)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  544|      0|					cxdata[0], r);
  545|      0|			}
  546|       |
  547|      0|			if (r < 0) {
  ------------------
  |  Branch (547:8): [True: 0, False: 0]
  ------------------
  548|      0|				r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  549|      0|				goto failed;
  550|      0|			}
  551|      0|		}
  552|      0|	}
  553|       |
  554|       |	/* Check if certificate DO 7F21 holds data */
  555|      0|	sc_format_path("7F21", &path);
  556|      0|	r = sc_select_file(card, &path, &file);
  557|      0|	if (r < 0)
  ------------------
  |  Branch (557:6): [True: 0, False: 0]
  ------------------
  558|      0|		goto failed;
  559|       |
  560|      0|	for(u8 i=0; i<PGP_MAX_NUM_CERTS; i++) {
  ------------------
  |  |   47|      0|#define PGP_MAX_NUM_CERTS    3
  ------------------
  |  Branch (560:14): [True: 0, False: 0]
  ------------------
  561|      0|		struct sc_pkcs15_cert_info cert_info;
  562|      0|		struct sc_pkcs15_object    cert_obj;
  563|      0|		u8* buffer = malloc(MAX_OPENPGP_DO_SIZE);
  ------------------
  |  |  172|      0|#define	MAX_OPENPGP_DO_SIZE	8192
  ------------------
  564|      0|		int resp_len = 0;
  565|       |
  566|      0|		if (buffer == NULL)
  ------------------
  |  Branch (566:7): [True: 0, False: 0]
  ------------------
  567|      0|			goto failed;
  568|       |
  569|      0|		memset(&cert_info, 0, sizeof(cert_info));
  570|      0|		memset(&cert_obj,  0, sizeof(cert_obj));
  571|       |
  572|       |		/* try to SELECT DATA. Will only work for OpenPGP >= v3, errors are non-critical */
  573|      0|		sc_card_ctl(card, SC_CARDCTL_OPENPGP_SELECT_DATA, &i);
  574|       |
  575|      0|		sc_format_path(certs[i].path, &cert_info.path);
  576|       |
  577|       |		/* Certificate ID. We use the same ID as the authentication key */
  578|      0|		sc_pkcs15_format_id(certs[i].id, &cert_info.id);
  579|       |
  580|      0|		resp_len = sc_get_data(card, 0x7F21, buffer, MAX_OPENPGP_DO_SIZE);
  ------------------
  |  |  172|      0|#define	MAX_OPENPGP_DO_SIZE	8192
  ------------------
  581|       |
  582|       |		/* Response length => free buffer and continue with next id */
  583|      0|		if (resp_len == 0) {
  ------------------
  |  Branch (583:7): [True: 0, False: 0]
  ------------------
  584|      0|			free(buffer);
  585|      0|			continue;
  586|      0|		}
  587|       |
  588|       |		/* Catch error during sc_get_data */
  589|      0|		if (resp_len < 0) {
  ------------------
  |  Branch (589:7): [True: 0, False: 0]
  ------------------
  590|      0|			free(buffer);
  591|      0|			goto failed;
  592|      0|		}
  593|       |
  594|       |		/* Assemble certificate info struct, based on `certs` array */
  595|      0|		cert_info.value.len = resp_len;
  596|      0|		cert_info.value.value = buffer;
  597|      0|		cert_info.authority = certs[i].authority;
  598|      0|		cert_obj.flags = certs[i].obj_flags;
  599|       |
  600|       |		/* Object label */
  601|      0|		strlcpy(cert_obj.label, certs[i].label, sizeof(cert_obj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  602|       |
  603|      0|		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  604|      0|		if (r < 0) {
  ------------------
  |  Branch (604:7): [True: 0, False: 0]
  ------------------
  605|      0|			free(buffer);
  606|      0|			goto failed;
  607|      0|		}
  608|       |
  609|       |		/* only iterate, for OpenPGP >= v3, thus break on < v3 */
  610|      0|		if (card->type < SC_CARD_TYPE_OPENPGP_V3)
  ------------------
  |  Branch (610:7): [True: 0, False: 0]
  ------------------
  611|      0|			break;
  612|      0|	}
  613|       |
  614|       |	/* Add PKCS#15 DATA objects from other OpenPGP card DOs. The return
  615|       |	 * value is ignored, so this will not cause initialization to fail.
  616|       |	 */
  617|      0|	sc_pkcs15emu_openpgp_add_data(p15card);
  618|       |
  619|    653|failed:
  620|    653|	if (r < 0) {
  ------------------
  |  Branch (620:6): [True: 653, False: 0]
  ------------------
  621|    653|		sc_log(card->ctx,
  ------------------
  |  |   71|    653|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  622|    653|				"Failed to initialize OpenPGP emulation: %s\n",
  623|    653|				sc_strerror(r));
  624|    653|		sc_pkcs15_card_clear(p15card);
  625|    653|	}
  626|    653|	sc_file_free(file);
  627|    653|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    653|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    653|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    653|	int _ret = r; \
  |  |  |  |  155|    653|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 653, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    653|		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|    653|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 653, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    653|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    653|	} 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|    653|	return _ret; \
  |  |  |  |  163|    653|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  628|    653|}
pkcs15-openpgp.c:read_file:
  162|    695|{
  163|    695|	sc_path_t	path;
  164|    695|	sc_file_t	*file;
  165|    695|	int		r;
  166|       |
  167|    695|	sc_format_path(path_name, &path);
  168|    695|	if ((r = sc_select_file(card, &path, &file)) < 0)
  ------------------
  |  Branch (168:6): [True: 635, False: 60]
  ------------------
  169|    635|		return r;
  170|       |
  171|     60|	if (file->size < len)
  ------------------
  |  Branch (171:6): [True: 45, False: 15]
  ------------------
  172|     45|		len = file->size;
  173|       |
  174|     60|	sc_file_free(file);
  175|       |
  176|     60|	return sc_read_binary(card, 0, (u8 *) buf, len, 0);
  177|    695|}

sc_pkcs15_decode_aodf_entry:
   85|     12|{
   86|     12|	sc_context_t *ctx = p15card->card->ctx;
   87|     12|	struct sc_pkcs15_auth_info info;
   88|     12|	int r;
   89|     12|	size_t flags_len = sizeof(info.attrs.pin.flags);
   90|     12|	size_t derived_len = sizeof(info.attrs.authkey.derived);
   91|     12|	size_t padchar_len = 1;
   92|     12|	struct sc_asn1_entry asn1_com_ao_attr[2];
   93|     12|	struct sc_asn1_entry asn1_pin_attr[10], asn1_type_pin_attr[2];
   94|     12|	struct sc_asn1_entry asn1_authkey_attr[3], asn1_type_authkey_attr[2];
   95|     12|	struct sc_asn1_entry asn1_auth_type[2];
   96|     12|	struct sc_asn1_entry asn1_auth_type_choice[4];
   97|     12|	struct sc_asn1_pkcs15_object pin_obj = { obj, asn1_com_ao_attr, NULL, asn1_type_pin_attr };
   98|     12|	struct sc_asn1_pkcs15_object authkey_obj = { obj, asn1_com_ao_attr, NULL, asn1_type_authkey_attr };
   99|       |
  100|     12|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_ASN1);
  ------------------
  |  |  148|     12|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     12|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     12|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 12]
  |  |  ------------------
  ------------------
  101|       |
  102|     12|	sc_copy_asn1_entry(c_asn1_auth_type, asn1_auth_type);
  103|     12|	sc_copy_asn1_entry(c_asn1_auth_type_choice, asn1_auth_type_choice);
  104|       |
  105|     12|	sc_copy_asn1_entry(c_asn1_com_ao_attr, asn1_com_ao_attr);
  106|       |
  107|     12|	sc_copy_asn1_entry(c_asn1_type_pin_attr, asn1_type_pin_attr);
  108|     12|	sc_copy_asn1_entry(c_asn1_pin_attr, asn1_pin_attr);
  109|       |
  110|     12|	sc_copy_asn1_entry(c_asn1_type_authkey_attr, asn1_type_authkey_attr);
  111|     12|	sc_copy_asn1_entry(c_asn1_authkey_attr, asn1_authkey_attr);
  112|       |
  113|     12|	sc_format_asn1_entry(asn1_auth_type + 0, asn1_auth_type_choice, NULL, 0);
  114|     12|	sc_format_asn1_entry(asn1_auth_type_choice + 0, &pin_obj, NULL, 0);	/* 'pin' */
  115|     12|	sc_format_asn1_entry(asn1_auth_type_choice + 2, &authkey_obj, NULL, 0);	/* 'authKey' */
  116|       |
  117|       |	/* pinAttributes */
  118|     12|	sc_format_asn1_entry(asn1_type_pin_attr + 0, asn1_pin_attr, NULL, 0);
  119|     12|	sc_format_asn1_entry(asn1_pin_attr + 0, &info.attrs.pin.flags, &flags_len, 0);
  120|     12|	sc_format_asn1_entry(asn1_pin_attr + 1, &info.attrs.pin.type, NULL, 0);
  121|     12|	sc_format_asn1_entry(asn1_pin_attr + 2, &info.attrs.pin.min_length, NULL, 0);
  122|     12|	sc_format_asn1_entry(asn1_pin_attr + 3, &info.attrs.pin.stored_length, NULL, 0);
  123|     12|	sc_format_asn1_entry(asn1_pin_attr + 4, &info.attrs.pin.max_length, NULL, 0);
  124|     12|	sc_format_asn1_entry(asn1_pin_attr + 5, &info.attrs.pin.reference, NULL, 0);
  125|     12|	sc_format_asn1_entry(asn1_pin_attr + 6, &info.attrs.pin.pad_char, &padchar_len, 0);
  126|       |
  127|       |	/* authKeyAttributes */
  128|     12|	sc_format_asn1_entry(asn1_type_authkey_attr + 0, asn1_authkey_attr, NULL, 0);
  129|     12|	sc_format_asn1_entry(asn1_authkey_attr + 0, &info.attrs.authkey.derived, &derived_len, 0);
  130|     12|	sc_format_asn1_entry(asn1_authkey_attr + 1, &info.attrs.authkey.skey_id, NULL, 0);
  131|       |
  132|       |	/* We don't support lastPinChange yet. */
  133|     12|	sc_format_asn1_entry(asn1_pin_attr + 8, &info.path, NULL, 0);
  134|       |
  135|     12|	sc_format_asn1_entry(asn1_com_ao_attr + 0, &info.auth_id, NULL, 0);
  136|       |
  137|       |	/* Fill in defaults */
  138|     12|	memset(&info, 0, sizeof(info));
  139|     12|	info.tries_left = -1;
  140|     12|	info.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|     12|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
  141|       |
  142|     12|	r = sc_asn1_decode(ctx, asn1_auth_type, *buf, *buflen, buf, buflen);
  143|     12|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|     12|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (143:6): [True: 1, False: 11]
  ------------------
  144|      1|		return r;
  145|     11|	LOG_TEST_RET(ctx, r, "ASN.1 decoding failed");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  146|       |
  147|      1|	if (asn1_auth_type_choice[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|      1|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (147:6): [True: 0, False: 1]
  ------------------
  148|      0|		sc_log(ctx, "AuthType: PIN");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  149|      0|		obj->type = SC_PKCS15_TYPE_AUTH_PIN;
  ------------------
  |  |  445|      0|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  150|      0|		info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|      0|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  151|      0|		info.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  152|       |
  153|      0|		if (info.attrs.pin.max_length == 0) {
  ------------------
  |  Branch (153:7): [True: 0, False: 0]
  ------------------
  154|      0|			if (p15card->card->max_pin_len != 0)
  ------------------
  |  Branch (154:8): [True: 0, False: 0]
  ------------------
  155|      0|				info.attrs.pin.max_length = p15card->card->max_pin_len;
  156|      0|			else if (info.attrs.pin.stored_length != 0)
  ------------------
  |  Branch (156:13): [True: 0, False: 0]
  ------------------
  157|      0|				info.attrs.pin.max_length = info.attrs.pin.type != SC_PKCS15_PIN_TYPE_BCD ?
  ------------------
  |  |   88|      0|#define SC_PKCS15_PIN_TYPE_BCD				0
  ------------------
  |  Branch (157:33): [True: 0, False: 0]
  ------------------
  158|      0|					info.attrs.pin.stored_length : 2 * info.attrs.pin.stored_length;
  159|      0|			else
  160|      0|				info.attrs.pin.max_length = 8; /* shouldn't happen */
  161|      0|		}
  162|       |
  163|       |		/* OpenSC 0.11.4 and older encoded "pinReference" as a negative
  164|       |		   value. Fixed in 0.11.5 we need to add a hack, so old cards
  165|       |		   continue to work.
  166|       |		   The same invalid encoding has some models of the proprietary PKCS#15 cards.
  167|       |		*/
  168|      0|		if (info.attrs.pin.reference < 0)
  ------------------
  |  Branch (168:7): [True: 0, False: 0]
  ------------------
  169|      0|			info.attrs.pin.reference += 256;
  170|       |
  171|      0|		if (info.attrs.pin.flags & SC_PKCS15_PIN_FLAG_LOCAL)   {
  ------------------
  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (171:7): [True: 0, False: 0]
  ------------------
  172|       |			/* In OpenSC pkcs#15 framework 'path' is mandatory for the 'Local' PINs.
  173|       |			 * If 'path' do not present in PinAttributes, derive it from the PKCS#15 context. */
  174|      0|			if (!info.path.len)   {
  ------------------
  |  Branch (174:8): [True: 0, False: 0]
  ------------------
  175|       |				/* Give priority to AID defined in the application DDO */
  176|      0|				if (p15card->app && p15card->app->ddo.aid.len)
  ------------------
  |  Branch (176:9): [True: 0, False: 0]
  |  Branch (176:25): [True: 0, False: 0]
  ------------------
  177|      0|					info.path.aid = p15card->app->ddo.aid;
  178|      0|				else if (p15card->file_app && p15card->file_app->path.len)
  ------------------
  |  Branch (178:14): [True: 0, False: 0]
  |  Branch (178:35): [True: 0, False: 0]
  ------------------
  179|      0|					info.path = p15card->file_app->path;
  180|      0|				else
  181|      0|					return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  182|      0|			}
  183|      0|		}
  184|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "decoded PIN(ref:%X,path:%s)", info.attrs.pin.reference, sc_print_path(&info.path));
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  185|      0|	}
  186|      1|	else if (asn1_auth_type_choice[1].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|      1|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (186:11): [True: 1, False: 0]
  ------------------
  187|      1|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "BIO authentication object not yet supported");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|      1|	}
  189|      0|	else if (asn1_auth_type_choice[2].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (189:11): [True: 0, False: 0]
  ------------------
  190|      0|		sc_log(ctx, "AuthType: AuthKey");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  191|      0|		obj->type = SC_PKCS15_TYPE_AUTH_AUTHKEY;
  ------------------
  |  |  447|      0|#define SC_PKCS15_TYPE_AUTH_AUTHKEY		0x603
  ------------------
  192|      0|		info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_AUTH_KEY;
  ------------------
  |  |   96|      0|#define SC_PKCS15_PIN_AUTH_TYPE_AUTH_KEY		2
  ------------------
  193|      0|		info.auth_method = SC_AC_AUT;
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  194|      0|		if (!(asn1_authkey_attr[0].flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (194:7): [True: 0, False: 0]
  ------------------
  195|      0|			info.attrs.authkey.derived = 1;
  196|      0|	}
  197|      0|	else   {
  198|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "unknown authentication type");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|      0|	}
  200|       |
  201|      0|	obj->data = malloc(sizeof(info));
  202|      0|	if (obj->data == NULL)
  ------------------
  |  Branch (202:6): [True: 0, False: 0]
  ------------------
  203|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  204|      0|	memcpy(obj->data, &info, sizeof(info));
  205|       |
  206|      0|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  207|      0|}
sc_pkcs15_verify_pin:
  298|    456|{
  299|    456|	struct sc_context *ctx = p15card->card->ctx;
  300|    456|	struct sc_pkcs15_auth_info *auth_info;
  301|    456|	int r;
  302|       |
  303|    456|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    456|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    456|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    456|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    456|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 456]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  304|       |
  305|    456|	if (!pin_obj || !pin_obj->data)
  ------------------
  |  Branch (305:6): [True: 0, False: 456]
  |  Branch (305:18): [True: 0, False: 456]
  ------------------
  306|    456|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_PIN_REFERENCE);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  307|    456|	auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
  308|       |
  309|       |	/* Check the provided pin matches pin requirements */
  310|    456|	r = _validate_pin(p15card, auth_info, pinlen);
  311|       |
  312|    456|	if (r)
  ------------------
  |  Branch (312:6): [True: 180, False: 276]
  ------------------
  313|    456|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    180|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    180|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    180|	int _ret = r; \
  |  |  |  |  155|    180|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 180, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    180|		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|    180|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 180, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    180|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    180|	} 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|    180|	return _ret; \
  |  |  |  |  163|    180|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  314|       |
  315|    276|	r = _sc_pkcs15_verify_pin(p15card, pin_obj, pincode, pinlen);
  316|       |
  317|    276|	if (r == SC_SUCCESS)
  ------------------
  |  |   28|    276|#define SC_SUCCESS				0
  ------------------
  |  Branch (317:6): [True: 87, False: 189]
  ------------------
  318|     87|		sc_pkcs15_pincache_add(p15card, pin_obj, pincode, pinlen);
  319|       |
  320|    276|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    276|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    276|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    276|	int _ret = r; \
  |  |  |  |  155|    276|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 276, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    276|		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|    189|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 189, False: 87]
  |  |  |  |  ------------------
  |  |  |  |  157|    276|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    276|	} 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|    276|	return _ret; \
  |  |  |  |  163|    276|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  321|    276|}
_sc_pkcs15_verify_pin:
  327|    290|{
  328|    290|	return sc_pkcs15_verify_pin_with_session_pin(p15card, pin_obj, pincode,
  329|    290|			pinlen, NULL, NULL);
  330|    290|}
sc_pkcs15_verify_pin_with_session_pin:
  343|    290|{
  344|    290|	struct sc_context *ctx = p15card->card->ctx;
  345|    290|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
  346|    290|	int r;
  347|    290|	sc_card_t *card;
  348|    290|	struct sc_pin_cmd_data data;
  349|       |
  350|    290|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    290|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    290|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    290|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    290|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 290]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|    290|	sc_log(ctx, "PIN(type:%X; method:%X; value(%p:%zu)",
  ------------------
  |  |   71|    290|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  352|    290|			auth_info->auth_type, auth_info->auth_method, pincode, pinlen);
  353|    290|	card = p15card->card;
  354|       |
  355|    290|	if (pinlen > SC_MAX_PIN_SIZE) {
  ------------------
  |  |   40|    290|#define SC_MAX_PIN_SIZE			256 /* OpenPGP card has 254 max */
  ------------------
  |  Branch (355:6): [True: 0, False: 290]
  ------------------
  356|      0|		sc_notify_id(card->ctx, &card->reader->atr, p15card,
  357|      0|				NOTIFY_PIN_BAD);
  358|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_LENGTH, "Invalid PIN size");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  359|      0|	}
  360|       |
  361|       |	/* Initialize arguments */
  362|    290|	memset(&data, 0, sizeof(data));
  363|    290|	data.pin_type = auth_info->auth_method;
  364|       |
  365|    290|	if (auth_info->auth_type == SC_PKCS15_PIN_AUTH_TYPE_PIN)   {
  ------------------
  |  |   94|    290|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (365:6): [True: 290, False: 0]
  ------------------
  366|    290|		data.pin_reference = auth_info->attrs.pin.reference;
  367|    290|		data.pin1.min_length = auth_info->attrs.pin.min_length;
  368|    290|		data.pin1.max_length = auth_info->attrs.pin.max_length;
  369|    290|		data.pin1.pad_length = auth_info->attrs.pin.stored_length;
  370|    290|		data.pin1.pad_char = auth_info->attrs.pin.pad_char;
  371|    290|		data.pin1.data = pincode;
  372|    290|		data.pin1.len = pinlen;
  373|       |
  374|    290|		if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_NEEDS_PADDING)
  ------------------
  |  |   59|    290|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  |  Branch (374:7): [True: 150, False: 140]
  ------------------
  375|    150|			data.flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|    150|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  376|       |
  377|    290|		switch (auth_info->attrs.pin.type) {
  378|      3|		case SC_PKCS15_PIN_TYPE_BCD:
  ------------------
  |  |   88|      3|#define SC_PKCS15_PIN_TYPE_BCD				0
  ------------------
  |  Branch (378:3): [True: 3, False: 287]
  ------------------
  379|      3|			data.pin1.encoding = SC_PIN_ENCODING_BCD;
  ------------------
  |  |  426|      3|#define SC_PIN_ENCODING_BCD	1
  ------------------
  380|      3|			break;
  381|    257|		case SC_PKCS15_PIN_TYPE_ASCII_NUMERIC:
  ------------------
  |  |   89|    257|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  |  Branch (381:3): [True: 257, False: 33]
  ------------------
  382|    257|			data.pin1.encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|    257|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  383|    257|			break;
  384|     30|		default:
  ------------------
  |  Branch (384:3): [True: 30, False: 260]
  ------------------
  385|       |			/* assume/hope the card driver knows how to encode the pin */
  386|     30|			data.pin1.encoding = 0;
  387|    290|		}
  388|    290|	}
  389|      0|	else if (auth_info->auth_type == SC_PKCS15_PIN_AUTH_TYPE_AUTH_KEY)   {
  ------------------
  |  |   96|      0|#define SC_PKCS15_PIN_AUTH_TYPE_AUTH_KEY		2
  ------------------
  |  Branch (389:11): [True: 0, False: 0]
  ------------------
  390|      0|		struct sc_pkcs15_object *skey_obj = NULL;
  391|      0|		struct sc_pkcs15_id *skey_id =  &auth_info->attrs.authkey.skey_id;
  392|      0|		struct sc_pkcs15_skey_info *skey_info = NULL;
  393|       |
  394|      0|		r = sc_pkcs15_find_skey_by_id(p15card, skey_id, &skey_obj);
  395|      0|		if (r)   {
  ------------------
  |  Branch (395:7): [True: 0, False: 0]
  ------------------
  396|      0|			sc_log(ctx, "cannot find secret key with id:%s", sc_pkcs15_print_id(skey_id));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  397|      0|			LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|      0|		}
  399|      0|		skey_info = (struct sc_pkcs15_skey_info *)skey_obj->data;
  400|       |
  401|      0|		sc_log(ctx, "found secret key '%s'", skey_obj->label);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  402|      0|		data.pin_reference = skey_info->key_reference;
  403|      0|	}
  404|       |
  405|    290|	if ((p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD
  ------------------
  |  |  376|    580|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (405:7): [True: 0, False: 290]
  ------------------
  406|    290|				|| p15card->card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)) {
  ------------------
  |  |  560|    290|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (406:8): [True: 0, False: 290]
  ------------------
  407|      0|		if (!pincode && !pinlen)
  ------------------
  |  Branch (407:7): [True: 0, False: 0]
  |  Branch (407:19): [True: 0, False: 0]
  ------------------
  408|      0|			data.flags |= SC_PIN_CMD_USE_PINPAD;
  ------------------
  |  |  421|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  409|       |
  410|      0|		if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (410:7): [True: 0, False: 0]
  ------------------
  411|      0|			data.pin1.prompt = "Please enter SO PIN";
  412|      0|		else
  413|      0|			data.pin1.prompt = "Please enter PIN";
  414|      0|	}
  415|       |
  416|    290|	if (card->caps & SC_CARD_CAP_SESSION_PIN && sessionpin && sessionpinlen) {
  ------------------
  |  |  563|    580|#define SC_CARD_CAP_SESSION_PIN	0x00000200
  ------------------
  |  Branch (416:6): [True: 0, False: 290]
  |  Branch (416:46): [True: 0, False: 0]
  |  Branch (416:60): [True: 0, False: 0]
  ------------------
  417|       |		/* session pin is requested and supported with standard verification*/
  418|      0|		data.cmd = SC_PIN_CMD_GET_SESSION_PIN;
  ------------------
  |  |  419|      0|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  419|      0|		memcpy(&data.pin2, &data.pin1, sizeof (data.pin1));
  420|      0|		data.pin2.data = sessionpin;
  421|      0|		data.pin2.len = *sessionpinlen;
  422|    290|	} else {
  423|       |		/* perform a standard verify */
  424|    290|		data.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|    290|#define SC_PIN_CMD_VERIFY	0
  ------------------
  425|    290|		if (sessionpinlen)
  ------------------
  |  Branch (425:7): [True: 0, False: 290]
  ------------------
  426|      0|			*sessionpinlen = 0;
  427|    290|	}
  428|       |
  429|    290|	r = sc_lock(card);
  430|    290|	LOG_TEST_RET(ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|    290|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    290|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    290|	int _ret = (r); \
  |  |  |  |  168|    290|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 290]
  |  |  |  |  ------------------
  |  |  |  |  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|    290|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 290]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  431|       |
  432|       |	/* the path in the pin object is optional */
  433|    290|	if ((auth_info->path.len > 0) || ((auth_info->path.aid.len > 0))) {
  ------------------
  |  Branch (433:6): [True: 9, False: 281]
  |  Branch (433:35): [True: 8, False: 273]
  ------------------
  434|     17|		r = sc_select_file(card, &auth_info->path, NULL);
  435|     17|		if (r)
  ------------------
  |  Branch (435:7): [True: 9, False: 8]
  ------------------
  436|      9|			goto out;
  437|     17|	}
  438|       |
  439|    281|	r = sc_pin_cmd(card, &data);
  440|    281|	auth_info->tries_left = data.pin1.tries_left;
  441|    281|	sc_log(ctx, "PIN cmd result %i", r);
  ------------------
  |  |   71|    281|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  442|    281|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    281|#define SC_SUCCESS				0
  ------------------
  |  Branch (442:6): [True: 96, False: 185]
  ------------------
  443|     96|		sc_pkcs15_pincache_add(p15card, pin_obj, pincode, pinlen);
  444|     96|		if (data.cmd == SC_PIN_CMD_GET_SESSION_PIN && sessionpinlen) {
  ------------------
  |  |  419|    192|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (444:7): [True: 0, False: 96]
  |  Branch (444:49): [True: 0, False: 0]
  ------------------
  445|      0|			*sessionpinlen = data.pin2.len;
  446|      0|		}
  447|    185|	} else {
  448|    185|		sc_notify_id(card->ctx, &card->reader->atr, p15card,
  449|    185|				NOTIFY_PIN_BAD);
  450|    185|		if (data.cmd == SC_PIN_CMD_GET_SESSION_PIN && sessionpinlen) {
  ------------------
  |  |  419|    370|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (450:7): [True: 0, False: 185]
  |  Branch (450:49): [True: 0, False: 0]
  ------------------
  451|      0|			*sessionpinlen = 0;
  452|      0|		}
  453|    185|	}
  454|       |
  455|    281|	if (auth_info->auth_type == SC_PKCS15_PIN_AUTH_TYPE_PIN
  ------------------
  |  |   94|    562|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (455:6): [True: 281, False: 0]
  ------------------
  456|    281|			&& auth_info->auth_method != SC_AC_SESSION) {
  ------------------
  |  |  159|    281|#define SC_AC_SESSION			0x00000100 /* Session PIN */
  ------------------
  |  Branch (456:7): [True: 281, False: 0]
  ------------------
  457|    281|		sc_notify_id(card->ctx, &card->reader->atr, p15card,
  458|    281|				r == SC_SUCCESS ? NOTIFY_PIN_GOOD : NOTIFY_PIN_BAD);
  ------------------
  |  |   28|    281|#define SC_SUCCESS				0
  ------------------
  |  Branch (458:5): [True: 96, False: 185]
  ------------------
  459|    281|	}
  460|       |
  461|    290|out:
  462|    290|	sc_unlock(card);
  463|    290|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    290|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    290|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    290|	int _ret = r; \
  |  |  |  |  155|    290|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 290, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    290|		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|    194|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 194, False: 96]
  |  |  |  |  ------------------
  |  |  |  |  157|    290|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    290|	} 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|    290|	return _ret; \
  |  |  |  |  163|    290|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|    290|}
sc_pkcs15_change_pin:
  475|    102|{
  476|    102|	struct sc_context *ctx = p15card->card->ctx;
  477|    102|	struct sc_pin_cmd_data data;
  478|    102|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
  479|    102|	struct sc_card *card;
  480|    102|	int r;
  481|       |
  482|    102|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    102|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    102|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    102|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    102|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 102]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  483|    102|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    102|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (483:6): [True: 0, False: 102]
  ------------------
  484|    102|		LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  485|       |
  486|       |	/* make sure the pins are in valid range */
  487|    102|	r = _validate_pin(p15card, auth_info, oldpinlen);
  488|    102|	LOG_TEST_RET(ctx, r, "Old PIN value do not conform PIN policy");
  ------------------
  |  |  174|    102|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    102|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    102|	int _ret = (r); \
  |  |  |  |  168|    102|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 15, False: 87]
  |  |  |  |  ------------------
  |  |  |  |  169|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     15|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     15|		return _ret; \
  |  |  |  |  172|     15|	} \
  |  |  |  |  173|    102|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 87]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|     87|	r = _validate_pin(p15card, auth_info, newpinlen);
  491|     87|	LOG_TEST_RET(ctx, r, "New PIN value do not conform PIN policy");
  ------------------
  |  |  174|     87|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     87|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     87|	int _ret = (r); \
  |  |  |  |  168|     87|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 87]
  |  |  |  |  ------------------
  |  |  |  |  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|     87|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 87]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  492|       |
  493|     87|	card = p15card->card;
  494|     87|	r = sc_lock(card);
  495|     87|	LOG_TEST_RET(ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|     87|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     87|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     87|	int _ret = (r); \
  |  |  |  |  168|     87|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 87]
  |  |  |  |  ------------------
  |  |  |  |  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|     87|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 87]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  496|       |	/* the path in the pin object is optional */
  497|     87|	if ((auth_info->path.len > 0) || ((auth_info->path.aid.len > 0))) {
  ------------------
  |  Branch (497:6): [True: 3, False: 84]
  |  Branch (497:35): [True: 3, False: 81]
  ------------------
  498|      6|		r = sc_select_file(card, &auth_info->path, NULL);
  499|      6|		if (r)
  ------------------
  |  Branch (499:7): [True: 2, False: 4]
  ------------------
  500|      2|			goto out;
  501|      6|	}
  502|       |
  503|       |	/* set pin_cmd data */
  504|     85|	memset(&data, 0, sizeof(data));
  505|     85|	data.cmd             = SC_PIN_CMD_CHANGE;
  ------------------
  |  |  416|     85|#define SC_PIN_CMD_CHANGE	1
  ------------------
  506|     85|	data.pin_type        = SC_AC_CHV;
  ------------------
  |  |  151|     85|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  507|     85|	data.pin_reference   = auth_info->attrs.pin.reference;
  508|     85|	data.pin1.data       = oldpin;
  509|     85|	data.pin1.len        = oldpinlen;
  510|     85|	data.pin1.pad_char   = auth_info->attrs.pin.pad_char;
  511|     85|	data.pin1.min_length = auth_info->attrs.pin.min_length;
  512|     85|	data.pin1.max_length = auth_info->attrs.pin.max_length;
  513|     85|	data.pin1.pad_length = auth_info->attrs.pin.stored_length;
  514|     85|	data.pin2.data       = newpin;
  515|     85|	data.pin2.len        = newpinlen;
  516|     85|	data.pin2.pad_char   = auth_info->attrs.pin.pad_char;
  517|     85|	data.pin2.min_length = auth_info->attrs.pin.min_length;
  518|     85|	data.pin2.max_length = auth_info->attrs.pin.max_length;
  519|     85|	data.pin2.pad_length = auth_info->attrs.pin.stored_length;
  520|       |
  521|     85|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_NEEDS_PADDING)
  ------------------
  |  |   59|     85|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  |  Branch (521:6): [True: 48, False: 37]
  ------------------
  522|     48|		data.flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  422|     48|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  523|       |
  524|     85|	switch (auth_info->attrs.pin.type) {
  ------------------
  |  Branch (524:10): [True: 83, False: 2]
  ------------------
  525|      0|	case SC_PKCS15_PIN_TYPE_BCD:
  ------------------
  |  |   88|      0|#define SC_PKCS15_PIN_TYPE_BCD				0
  ------------------
  |  Branch (525:2): [True: 0, False: 85]
  ------------------
  526|      0|		data.pin1.encoding = SC_PIN_ENCODING_BCD;
  ------------------
  |  |  426|      0|#define SC_PIN_ENCODING_BCD	1
  ------------------
  527|      0|		data.pin2.encoding = SC_PIN_ENCODING_BCD;
  ------------------
  |  |  426|      0|#define SC_PIN_ENCODING_BCD	1
  ------------------
  528|      0|		break;
  529|     83|	case SC_PKCS15_PIN_TYPE_ASCII_NUMERIC:
  ------------------
  |  |   89|     83|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  |  Branch (529:2): [True: 83, False: 2]
  ------------------
  530|     83|		data.pin1.encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|     83|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  531|     83|		data.pin2.encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  425|     83|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  532|     83|		break;
  533|     85|	}
  534|       |
  535|     85|	if((!oldpin || !newpin)
  ------------------
  |  Branch (535:6): [True: 0, False: 85]
  |  Branch (535:17): [True: 0, False: 85]
  ------------------
  536|      0|			&& (p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD
  ------------------
  |  |  376|      0|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (536:8): [True: 0, False: 0]
  ------------------
  537|      0|				|| p15card->card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)) {
  ------------------
  |  |  560|      0|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (537:8): [True: 0, False: 0]
  ------------------
  538|      0|		data.flags |= SC_PIN_CMD_USE_PINPAD;
  ------------------
  |  |  421|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  539|      0|		if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
  ------------------
  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (539:7): [True: 0, False: 0]
  ------------------
  540|      0|			data.pin1.prompt = "Please enter SO PIN";
  541|      0|			data.pin2.prompt = "Please enter new SO PIN";
  542|      0|		}
  543|      0|		else {
  544|      0|			data.pin1.prompt = "Please enter PIN";
  545|      0|			data.pin2.prompt = "Please enter new PIN";
  546|      0|		}
  547|      0|	}
  548|       |
  549|     85|	r = sc_pin_cmd(card, &data);
  550|     85|	auth_info->tries_left = data.pin1.tries_left;
  551|     85|	if (r == SC_SUCCESS)
  ------------------
  |  |   28|     85|#define SC_SUCCESS				0
  ------------------
  |  Branch (551:6): [True: 6, False: 79]
  ------------------
  552|      6|		sc_pkcs15_pincache_add(p15card, pin_obj, newpin, newpinlen);
  553|       |
  554|     87|out:
  555|     87|	sc_unlock(card);
  556|     87|	return r;
  557|     85|}
sc_pkcs15_get_pin_info:
  688|    977|{
  689|    977|	int r;
  690|    977|	struct sc_pin_cmd_data data;
  691|    977|	struct sc_card *card = p15card->card;
  692|    977|	struct sc_context *ctx = card->ctx;
  693|    977|	struct sc_pkcs15_auth_info *pin_info = (struct sc_pkcs15_auth_info *) pin_obj->data;
  694|       |
  695|    977|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    977|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    977|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    977|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    977|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 977]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  696|       |
  697|    977|	r = sc_lock(card);
  698|    977|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    977|#define SC_SUCCESS				0
  ------------------
  |  Branch (698:6): [True: 0, False: 977]
  ------------------
  699|      0|		return r;
  700|       |
  701|    977|	if (pin_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)   {
  ------------------
  |  |   94|    977|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (701:6): [True: 0, False: 977]
  ------------------
  702|      0|		r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  703|      0|		goto out;
  704|      0|	}
  705|       |
  706|       |	/* the path in the pin object is optional */
  707|    977|	if ((pin_info->path.len > 0) || ((pin_info->path.aid.len > 0))) {
  ------------------
  |  Branch (707:6): [True: 58, False: 919]
  |  Branch (707:34): [True: 80, False: 839]
  ------------------
  708|    138|		r = sc_select_file(card, &pin_info->path, NULL);
  709|    138|		if (r)
  ------------------
  |  Branch (709:7): [True: 120, False: 18]
  ------------------
  710|    120|			goto out;
  711|    138|	}
  712|       |
  713|       |	/* Try to update PIN info from card */
  714|    857|	memset(&data, 0, sizeof(data));
  715|    857|	data.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|    857|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  716|    857|	data.pin_type = pin_info->auth_method;
  717|    857|	data.pin_reference = pin_info->attrs.pin.reference;
  718|       |
  719|    857|	r = sc_pin_cmd(card, &data);
  720|    857|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    857|#define SC_SUCCESS				0
  ------------------
  |  Branch (720:6): [True: 239, False: 618]
  ------------------
  721|    239|		if (data.pin1.max_tries > 0)
  ------------------
  |  Branch (721:7): [True: 0, False: 239]
  ------------------
  722|      0|			pin_info->max_tries = data.pin1.max_tries;
  723|    239|		pin_info->tries_left = data.pin1.tries_left;
  724|    239|		pin_info->logged_in = data.pin1.logged_in;
  725|    239|	}
  726|       |
  727|    977|out:
  728|    977|	sc_unlock(card);
  729|    977|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    977|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    977|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    977|	int _ret = r; \
  |  |  |  |  155|    977|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 977, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    977|		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|    738|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 738, False: 239]
  |  |  |  |  ------------------
  |  |  |  |  157|    977|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    977|	} 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|    977|	return _ret; \
  |  |  |  |  163|    977|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  730|    977|}
sc_pkcs15_free_auth_info:
  734|  6.68k|{
  735|  6.68k|	free(auth_info);
  736|  6.68k|}
sc_pkcs15_pincache_add:
  742|    189|{
  743|    189|	struct sc_context *ctx = p15card->card->ctx;
  744|    189|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
  745|    189|	struct sc_pkcs15_object *obj = NULL;
  746|    189|	int r;
  747|       |
  748|    189|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    189|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    189|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    189|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    189|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 189]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  749|       |
  750|    189|	if (!pin || !pinlen)   {
  ------------------
  |  Branch (750:6): [True: 0, False: 189]
  |  Branch (750:14): [True: 0, False: 189]
  ------------------
  751|      0|		sc_log(ctx, "No cache for zero length PIN");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  752|      0|		return;
  753|      0|	}
  754|    189|	else if (!p15card->opts.use_pin_cache)   {
  ------------------
  |  Branch (754:11): [True: 2, False: 187]
  ------------------
  755|      2|		sc_log(ctx, "PIN caching not enabled");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  756|      2|		return;
  757|      2|	}
  758|    187|	else if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)   {
  ------------------
  |  |   94|    187|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (758:11): [True: 0, False: 187]
  ------------------
  759|      0|		sc_log(ctx, "only 'PIN' auth. object can be cached");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  760|      0|		return;
  761|      0|	}
  762|       |
  763|       |	/* If the PIN protects an object with user consent, don't cache it */
  764|       |
  765|    187|	obj = p15card->obj_list;
  766|  2.51k|	while (obj != NULL) {
  ------------------
  |  Branch (766:9): [True: 2.34k, False: 179]
  ------------------
  767|       |		/* Compare 'sc_pkcs15_object.auth_id' with 'sc_pkcs15_pin_info.auth_id'.
  768|       |		 * In accordance with PKCS#15 "6.1.8 CommonObjectAttributes" and
  769|       |		 * "6.1.16 CommonAuthenticationObjectAttributes" with the exception that
  770|       |		 * "CommonObjectAttributes.accessControlRules" are not taken into account. */
  771|       |
  772|  2.34k|		if (sc_pkcs15_compare_id(&obj->auth_id, &auth_info->auth_id)) {
  ------------------
  |  Branch (772:7): [True: 279, False: 2.06k]
  ------------------
  773|       |			/* Caching is refused, if the protected object requires user consent */
  774|    279|			if (!p15card->opts.pin_cache_ignore_user_consent) {
  ------------------
  |  Branch (774:8): [True: 279, False: 0]
  ------------------
  775|    279|				if (obj->user_consent > 0) {
  ------------------
  |  Branch (775:9): [True: 8, False: 271]
  ------------------
  776|      8|					sc_log(ctx, "caching refused (user consent)");
  ------------------
  |  |   71|      8|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  777|      8|					return;
  778|      8|				}
  779|    279|			}
  780|    279|		}
  781|       |
  782|  2.33k|		obj = obj->next;
  783|  2.33k|	}
  784|       |
  785|    179|	r = sc_pkcs15_allocate_object_content(ctx, pin_obj, pin, pinlen);
  786|    179|	if (r != SC_SUCCESS)   {
  ------------------
  |  |   28|    179|#define SC_SUCCESS				0
  ------------------
  |  Branch (786:6): [True: 0, False: 179]
  ------------------
  787|      0|		sc_log(ctx, "Failed to allocate object content");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  788|      0|		return;
  789|      0|	}
  790|       |
  791|    179|	pin_obj->usage_counter = 0;
  792|    179|	sc_log(ctx, "PIN(%s) cached", pin_obj->label);
  ------------------
  |  |   71|    179|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  793|    179|}
sc_pkcs15_pincache_revalidate:
  798|     17|{
  799|     17|	struct sc_context *ctx = p15card->card->ctx;
  800|     17|	sc_pkcs15_object_t *pin_obj;
  801|     17|	int r;
  802|       |
  803|     17|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     17|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     17|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     17|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     17|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  804|     17|	if (!p15card->opts.use_pin_cache)
  ------------------
  |  Branch (804:6): [True: 0, False: 17]
  ------------------
  805|      0|		return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  806|       |
  807|       |	/*  Apps that do not support CK_ALWAYS_AUTHENTICATE
  808|       |	 *  may need pin_cache_ignore_user_consent = 1 */
  809|     17|	if (!p15card->opts.pin_cache_ignore_user_consent) {
  ------------------
  |  Branch (809:6): [True: 17, False: 0]
  ------------------
  810|     17|	    if (obj->user_consent)
  ------------------
  |  Branch (810:10): [True: 1, False: 16]
  ------------------
  811|      1|		return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      1|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  812|     17|	}
  813|       |
  814|     16|	if ((p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD
  ------------------
  |  |  376|     32|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (814:7): [True: 0, False: 16]
  ------------------
  815|     16|				|| p15card->card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH))
  ------------------
  |  |  560|     16|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (815:8): [True: 0, False: 16]
  ------------------
  816|      0|		return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  817|       |
  818|     16|	r = sc_pkcs15_find_pin_by_auth_id(p15card, &obj->auth_id, &pin_obj);
  819|     16|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     16|#define SC_SUCCESS				0
  ------------------
  |  Branch (819:6): [True: 1, False: 15]
  ------------------
  820|      1|		sc_log(ctx, "Could not find pin object for auth_id %s", sc_pkcs15_print_id(&obj->auth_id));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  821|      1|		return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      1|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  822|      1|	}
  823|       |
  824|     15|	if (pin_obj->usage_counter >= p15card->opts.pin_cache_counter) {
  ------------------
  |  Branch (824:6): [True: 0, False: 15]
  ------------------
  825|      0|		sc_pkcs15_free_object_content(pin_obj);
  826|      0|		return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  827|      0|	}
  828|       |
  829|     15|	if (!pin_obj->content.value || !pin_obj->content.len)
  ------------------
  |  Branch (829:6): [True: 1, False: 14]
  |  Branch (829:33): [True: 0, False: 14]
  ------------------
  830|      1|		return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      1|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  831|       |
  832|     14|	pin_obj->usage_counter++;
  833|     14|	r = _sc_pkcs15_verify_pin(p15card, pin_obj, pin_obj->content.value, pin_obj->content.len);
  834|     14|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     14|#define SC_SUCCESS				0
  ------------------
  |  Branch (834:6): [True: 5, False: 9]
  ------------------
  835|       |		/* Ensure that wrong PIN isn't used again */
  836|      5|		sc_pkcs15_free_object_content(pin_obj);
  837|       |
  838|      5|		sc_log(ctx, "Verify PIN error %i", r);
  ------------------
  |  |   71|      5|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  839|      5|		return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      5|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  840|      5|	}
  841|       |
  842|      9|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      9|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      9|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      9|	int _ret = r; \
  |  |  |  |  155|      9|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      9|		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: 9]
  |  |  |  |  ------------------
  |  |  |  |  157|      9|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      9|	} 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|      9|	return _ret; \
  |  |  |  |  163|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  843|      9|}
sc_pkcs15_pincache_clear:
  846|  7.36k|{
  847|  7.36k|	struct sc_pkcs15_object *objs[32];
  848|  7.36k|	int i, r;
  849|       |
  850|  7.36k|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|  7.36k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  7.36k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  7.36k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  7.36k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 7.36k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  851|  7.36k|	r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
  ------------------
  |  |  445|  7.36k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  852|  14.5k|	for (i = 0; i < r; i++)
  ------------------
  |  Branch (852:14): [True: 7.16k, False: 7.36k]
  ------------------
  853|  7.16k|		sc_pkcs15_free_object_content(objs[i]);
  854|  7.36k|}
pkcs15-pin.c:_validate_pin:
  260|    645|{
  261|    645|	size_t max_length;
  262|    645|	if (p15card == NULL) {
  ------------------
  |  Branch (262:6): [True: 0, False: 645]
  ------------------
  263|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  264|      0|	}
  265|       |
  266|       |	/* Ignore validation of the non-PIN authentication objects */
  267|    645|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    645|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (267:6): [True: 0, False: 645]
  ------------------
  268|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  269|       |
  270|       |	/* prevent buffer overflow from hostile card */
  271|    645|	if (auth_info->attrs.pin.stored_length > SC_MAX_PIN_SIZE)
  ------------------
  |  |   40|    645|#define SC_MAX_PIN_SIZE			256 /* OpenPGP card has 254 max */
  ------------------
  |  Branch (271:6): [True: 0, False: 645]
  ------------------
  272|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  273|       |
  274|       |	/* if we use pinpad, no more checks are needed */
  275|    645|	if ((p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD
  ------------------
  |  |  376|  1.29k|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (275:7): [True: 0, False: 645]
  ------------------
  276|    645|				|| p15card->card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)
  ------------------
  |  |  560|    645|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (276:8): [True: 0, False: 645]
  ------------------
  277|      0|		   	&& !pinlen)
  ------------------
  |  Branch (277:10): [True: 0, False: 0]
  ------------------
  278|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  279|       |
  280|       |	/* If pin is given, make sure it is within limits */
  281|    645|	max_length = auth_info->attrs.pin.max_length != 0 ? auth_info->attrs.pin.max_length : SC_MAX_PIN_SIZE;
  ------------------
  |  |   40|    645|#define SC_MAX_PIN_SIZE			256 /* OpenPGP card has 254 max */
  ------------------
  |  Branch (281:15): [True: 645, False: 0]
  ------------------
  282|    645|	if (pinlen > max_length || pinlen < auth_info->attrs.pin.min_length)
  ------------------
  |  Branch (282:6): [True: 37, False: 608]
  |  Branch (282:29): [True: 158, False: 450]
  ------------------
  283|    195|		return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|    195|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
  284|       |
  285|    450|	return SC_SUCCESS;
  ------------------
  |  |   28|    450|#define SC_SUCCESS				0
  ------------------
  286|    645|}

sc_pkcs15emu_piv_init_ex:
 1431|  15.5k|{
 1432|  15.5k|	sc_card_t   *card = p15card->card;
 1433|  15.5k|	sc_context_t    *ctx = card->ctx;
 1434|       |
 1435|  15.5k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  15.5k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  15.5k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  15.5k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 15.5k]
  |  |  ------------------
  ------------------
 1436|       |
 1437|  15.5k|	if (piv_detect_card(p15card))
  ------------------
  |  Branch (1437:6): [True: 14.3k, False: 1.23k]
  ------------------
 1438|  14.3k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  14.3k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
 1439|  1.23k|	return sc_pkcs15emu_piv_init(p15card);
 1440|  15.5k|}
pkcs15-piv.c:piv_detect_card:
  237|  15.5k|{
  238|  15.5k|	sc_card_t *card = p15card->card;
  239|       |
  240|  15.5k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  15.5k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  15.5k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  15.5k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 15.5k]
  |  |  ------------------
  ------------------
  241|  15.5k|	if (card->type < SC_CARD_TYPE_PIV_II_BASE
  ------------------
  |  Branch (241:6): [True: 5.74k, False: 9.84k]
  ------------------
  242|  9.84k|		|| card->type >= SC_CARD_TYPE_PIV_II_BASE + 1000)
  ------------------
  |  Branch (242:6): [True: 8.61k, False: 1.23k]
  ------------------
  243|  14.3k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  14.3k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  244|  1.23k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.23k|#define SC_SUCCESS				0
  ------------------
  245|  15.5k|}
pkcs15-piv.c:sc_pkcs15emu_piv_init:
  274|  1.23k|{
  275|       |
  276|       |	/* The cert objects will return all the data */
  277|       |	/* Note: pkcs11 objects do not have CK_ID values */
  278|       |
  279|       |	// clang-format off
  280|  1.23k|	static const objdata objects[] = {
  281|  1.23k|	{"01", "Card Capability Container",
  282|  1.23k|			"2.16.840.1.101.3.7.1.219.0", NULL, "DB00", 0},
  283|  1.23k|	{"02", "Card Holder Unique Identifier",
  284|  1.23k|			"2.16.840.1.101.3.7.2.48.0", NULL, "3000", 0},
  285|  1.23k|	{"03", "Unsigned Card Holder Unique Identifier",
  286|  1.23k|			"2.16.840.1.101.3.7.2.48.2", NULL, "3010", 0},
  287|  1.23k|	{"04", "X.509 Certificate for PIV Authentication",
  288|  1.23k|			"2.16.840.1.101.3.7.2.1.1", NULL, "0101", 0},
  289|  1.23k|	{"05", "Cardholder Fingerprints",
  290|  1.23k|			"2.16.840.1.101.3.7.2.96.16", "01", "6010", SC_PKCS15_CO_FLAG_PRIVATE},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  291|  1.23k|	{"06", "Printed Information",
  292|  1.23k|			"2.16.840.1.101.3.7.2.48.1", "01", "3001", SC_PKCS15_CO_FLAG_PRIVATE},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  293|  1.23k|	{"07", "Cardholder Facial Image",
  294|  1.23k|			"2.16.840.1.101.3.7.2.96.48", "01", "6030", SC_PKCS15_CO_FLAG_PRIVATE},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  295|  1.23k|	{"08", "X.509 Certificate for Digital Signature",
  296|  1.23k|			"2.16.840.1.101.3.7.2.1.0",  NULL, "0100", 0},
  297|  1.23k|	{"09", "X.509 Certificate for Key Management",
  298|  1.23k|			"2.16.840.1.101.3.7.2.1.2", NULL, "0102", 0},
  299|  1.23k|	{"10","X.509 Certificate for Card Authentication",
  300|  1.23k|			"2.16.840.1.101.3.7.2.5.0", NULL, "0500", 0},
  301|  1.23k|	{"11", "Security Object",
  302|  1.23k|			"2.16.840.1.101.3.7.2.144.0", NULL, "9000", 0},
  303|  1.23k|	{"12", "Discovery Object",
  304|  1.23k|			"2.16.840.1.101.3.7.2.96.80", NULL, "6050", 0},
  305|  1.23k|	{"13", "Key History Object",
  306|  1.23k|			"2.16.840.1.101.3.7.2.96.96", NULL, "6060", 0},
  307|  1.23k|	{"14", "Cardholder Iris Image",
  308|  1.23k|			"2.16.840.1.101.3.7.2.16.21", NULL, "1015", SC_PKCS15_CO_FLAG_PRIVATE},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  309|       |
  310|  1.23k|	{"15", "Retired X.509 Certificate for Key Management 1",
  311|  1.23k|			"2.16.840.1.101.3.7.2.16.1", NULL, "1001", 0},
  312|  1.23k|	{"16", "Retired X.509 Certificate for Key Management 2",
  313|  1.23k|			"2.16.840.1.101.3.7.2.16.2", NULL, "1002", 0},
  314|  1.23k|	{"17", "Retired X.509 Certificate for Key Management 3",
  315|  1.23k|			"2.16.840.1.101.3.7.2.16.3", NULL, "1003", 0},
  316|  1.23k|	{"18", "Retired X.509 Certificate for Key Management 4",
  317|  1.23k|			"2.16.840.1.101.3.7.2.16.4", NULL, "1004", 0},
  318|  1.23k|	{"19", "Retired X.509 Certificate for Key Management 5",
  319|  1.23k|			"2.16.840.1.101.3.7.2.16.5", NULL, "1005", 0},
  320|  1.23k|	{"20", "Retired X.509 Certificate for Key Management 6",
  321|  1.23k|			"2.16.840.1.101.3.7.2.16.6", NULL, "1006", 0},
  322|  1.23k|	{"21", "Retired X.509 Certificate for Key Management 7",
  323|  1.23k|			"2.16.840.1.101.3.7.2.16.7", NULL, "1007", 0},
  324|  1.23k|	{"22", "Retired X.509 Certificate for Key Management 8",
  325|  1.23k|			"2.16.840.1.101.3.7.2.16.8", NULL, "1008", 0},
  326|  1.23k|	{"23", "Retired X.509 Certificate for Key Management 9",
  327|  1.23k|			"2.16.840.1.101.3.7.2.16.9", NULL, "1009", 0},
  328|  1.23k|	{"24", "Retired X.509 Certificate for Key Management 10",
  329|  1.23k|			"2.16.840.1.101.3.7.2.16.10", NULL, "100A", 0},
  330|  1.23k|	{"25", "Retired X.509 Certificate for Key Management 11",
  331|  1.23k|			"2.16.840.1.101.3.7.2.16.11", NULL, "100B", 0},
  332|  1.23k|	{"26", "Retired X.509 Certificate for Key Management 12",
  333|  1.23k|			"2.16.840.1.101.3.7.2.16.12", NULL, "100C", 0},
  334|  1.23k|	{"27", "Retired X.509 Certificate for Key Management 13",
  335|  1.23k|			"2.16.840.1.101.3.7.2.16.13", NULL, "100D", 0},
  336|  1.23k|	{"28", "Retired X.509 Certificate for Key Management 14",
  337|  1.23k|			"2.16.840.1.101.3.7.2.16.14", NULL, "100E", 0},
  338|  1.23k|	{"29", "Retired X.509 Certificate for Key Management 15",
  339|  1.23k|			"2.16.840.1.101.3.7.2.16.15", NULL, "100F", 0},
  340|  1.23k|	{"30", "Retired X.509 Certificate for Key Management 16",
  341|  1.23k|			"2.16.840.1.101.3.7.2.16.16", NULL, "1010", 0},
  342|  1.23k|	{"31", "Retired X.509 Certificate for Key Management 17",
  343|  1.23k|			"2.16.840.1.101.3.7.2.16.17", NULL, "1011", 0},
  344|  1.23k|	{"32", "Retired X.509 Certificate for Key Management 18",
  345|  1.23k|			"2.16.840.1.101.3.7.2.16.18", NULL, "1012", 0},
  346|  1.23k|	{"33", "Retired X.509 Certificate for Key Management 19",
  347|  1.23k|			"2.16.840.1.101.3.7.2.16.19", NULL, "1013", 0},
  348|  1.23k|	{"34", "Retired X.509 Certificate for Key Management 20",
  349|  1.23k|			"2.16.840.1.101.3.7.2.16.20", NULL, "1014", 0},
  350|       |	/* new in 800-73-4 */
  351|  1.23k|	{"35", "Biometric Information Templates Group Template",
  352|  1.23k|			"2.16.840.1.101.3.7.2.16.22", NULL, "1016", 0},
  353|  1.23k|	{"36", "Secure Messaging Certificate Signer",
  354|  1.23k|			"2.16.840.1.101.3.7.2.16.23", NULL, "1017", 0},
  355|  1.23k|	{"37", "Pairing Code Reference Data Container",
  356|  1.23k|			"2.16.840.1.101.3.7.2.16.24", NULL, "1018", SC_PKCS15_CO_FLAG_PRIVATE},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  357|  1.23k|	{NULL, NULL, NULL, NULL, NULL, 0}
  358|  1.23k|	};
  359|       |	// clang-format on
  360|       |	/* NIST 800-73-1 lifted the restriction on
  361|       |	 * requiring pin protected certs. Thus the default is to
  362|       |	 * not require this.
  363|       |	 *
  364|       |	 * Certs will be pulled out from the cert objects
  365|       |	 * But there may be extra certs (SM Signer cert) that do
  366|       |	 * not have a private keys on the card. These certs must be last
  367|       |	 */
  368|       |
  369|       |	/* Any certs on card without private key must be last */
  370|  1.23k|#define PIV_NUM_CERTS 25
  371|  1.23k|#define PIV_NUM_KEYS  24
  372|       |
  373|       |	// clang-format off
  374|  1.23k|	static const cdata certs[PIV_NUM_CERTS] = {
  375|  1.23k|		{"01", "Certificate for PIV Authentication", "0101cece", 0, 0},
  376|  1.23k|		{"02", "Certificate for Digital Signature", "0100cece", 0, 0},
  377|  1.23k|		{"03", "Certificate for Key Management", "0102cece", 0, 0},
  378|  1.23k|		{"04", "Certificate for Card Authentication", "0500cece", 0, 0},
  379|  1.23k|		{"05", "Retired Certificate for Key Management 1", "1001cece", 0, 0},
  380|  1.23k|		{"06", "Retired Certificate for Key Management 2", "1002cece", 0, 0},
  381|  1.23k|		{"07", "Retired Certificate for Key Management 3", "1003cece", 0, 0},
  382|  1.23k|		{"08", "Retired Certificate for Key Management 4", "1004cece", 0, 0},
  383|  1.23k|		{"09", "Retired Certificate for Key Management 5", "1005cece", 0, 0},
  384|  1.23k|		{"10", "Retired Certificate for Key Management 6", "1006cece", 0, 0},
  385|  1.23k|		{"11", "Retired Certificate for Key Management 7", "1007cece", 0, 0},
  386|  1.23k|		{"12", "Retired Certificate for Key Management 8", "1008cece", 0, 0},
  387|  1.23k|		{"13", "Retired Certificate for Key Management 9", "1009cece", 0, 0},
  388|  1.23k|		{"14", "Retired Certificate for Key Management 10", "100Acece", 0, 0},
  389|  1.23k|		{"15", "Retired Certificate for Key Management 11", "100Bcece", 0, 0},
  390|  1.23k|		{"16", "Retired Certificate for Key Management 12", "100Ccece", 0, 0},
  391|  1.23k|		{"17", "Retired Certificate for Key Management 13", "100Dcece", 0, 0},
  392|  1.23k|		{"18", "Retired Certificate for Key Management 14", "100Ecece", 0, 0},
  393|  1.23k|		{"19", "Retired Certificate for Key Management 15", "100Fcece", 0, 0},
  394|  1.23k|		{"20", "Retired Certificate for Key Management 16", "1010cece", 0, 0},
  395|  1.23k|		{"21", "Retired Certificate for Key Management 17", "1011cece", 0, 0},
  396|  1.23k|		{"22", "Retired Certificate for Key Management 18", "1012cece", 0, 0},
  397|  1.23k|		{"23", "Retired Certificate for Key Management 19", "1013cece", 0, 0},
  398|  1.23k|		{"24", "Retired Certificate for Key Management 20", "1014cece", 0, 0},
  399|       |		/* Yubikey Attestation uses "25" but not read via GET_DATA */
  400|  1.23k|		{"81", "Secure Messaging Certificate Signer",   "1017cece", 0, 0} /* no keys on card */
  401|  1.23k|	};
  402|       |	// clang-format on
  403|       |
  404|       |	// clang-format off
  405|  1.23k|	static const pindata pins[] = {
  406|  1.23k|		{ "01", "PIN", "", 0x80,
  407|       |		  /* label, flag  and ref will change if using global pin */
  408|  1.23k|		  SC_PKCS15_PIN_TYPE_ASCII_NUMERIC,
  ------------------
  |  |   89|  1.23k|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  409|  1.23k|		  8, 4, 8,
  410|  1.23k|		  SC_PKCS15_PIN_FLAG_NEEDS_PADDING |
  ------------------
  |  |   59|  1.23k|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  411|  1.23k|		  SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   58|  1.23k|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  412|  1.23k|		  SC_PKCS15_PIN_FLAG_LOCAL,
  ------------------
  |  |   55|  1.23k|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  413|  1.23k|		  -1, 0xFF,
  414|  1.23k|		  SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  415|       |
  416|  1.23k|		{ "02", "PIV PUK", "", 0x81,
  417|  1.23k|		  SC_PKCS15_PIN_TYPE_ASCII_NUMERIC,
  ------------------
  |  |   89|  1.23k|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  418|  1.23k|		  8, 4, 8,
  419|  1.23k|		  SC_PKCS15_PIN_FLAG_NEEDS_PADDING |
  ------------------
  |  |   59|  1.23k|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  420|  1.23k|		  SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   58|  1.23k|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  421|  1.23k|		  SC_PKCS15_PIN_FLAG_SO_PIN |
  ------------------
  |  |   61|  1.23k|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  422|  1.23k|		  SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN,
  ------------------
  |  |   60|  1.23k|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  423|  1.23k|		  -1, 0xFF,
  424|  1.23k|		  SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  425|       |
  426|       |		/* only used with minidriver */
  427|  1.23k|		{ "03", "PIN", "", 0x80,
  428|       |		  /* used in minidriver as the sign key and for 9C key */
  429|       |		  /* label, flag  and ref will change if using global pin */
  430|  1.23k|		  SC_PKCS15_PIN_TYPE_ASCII_NUMERIC,
  ------------------
  |  |   89|  1.23k|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  431|  1.23k|		  8, 4, 8,
  432|  1.23k|		  SC_PKCS15_PIN_FLAG_NEEDS_PADDING |
  ------------------
  |  |   59|  1.23k|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  433|  1.23k|		  SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   58|  1.23k|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  434|  1.23k|		  SC_PKCS15_PIN_FLAG_LOCAL,
  ------------------
  |  |   55|  1.23k|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  435|  1.23k|		  -1, 0xFF,
  436|  1.23k|		  SC_PKCS15_CO_FLAG_PRIVATE, 1}, /* only use if cardmod */
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  437|  1.23k|		{ NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  438|  1.23k|	};
  439|       |	// clang-format on
  440|       |
  441|       |
  442|       |	/*
  443|       |	 * The size of the key or the algid is not really known
  444|       |	 * but can be derived from the certificates.
  445|       |	 * the cert, pubkey and privkey are a set.
  446|       |	 * Key usages bits taken from pkcs15v1_1 Table 2
  447|       |	 * RSA and EC have different sets of usage
  448|       |	 */
  449|       |	// clang-format off
  450|  1.23k|	static const pubdata pubkeys[PIV_NUM_KEYS] = {
  451|  1.23k|		{ "01", "PIV AUTH pubkey",
  452|  1.23k|			 	/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT |
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
  453|  1.23k|			 		SC_PKCS15_PRKEY_USAGE_WRAP |
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  454|  1.23k|					SC_PKCS15_PRKEY_USAGE_VERIFY |
  ------------------
  |  |  311|  1.23k|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  455|  1.23k|					SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER,
  ------------------
  |  |  312|  1.23k|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
  456|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_VERIFY,
  ------------------
  |  |  311|  1.23k|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  457|  1.23k|			"9A06", 0x9A, NULL, 0, "PIV_9A_KEY"},
  458|  1.23k|		{ "02", "SIGN pubkey",
  459|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT |
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
  460|  1.23k|					SC_PKCS15_PRKEY_USAGE_VERIFY |
  ------------------
  |  |  311|  1.23k|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  461|  1.23k|					SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER |
  ------------------
  |  |  312|  1.23k|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
  462|  1.23k|					SC_PKCS15_PRKEY_USAGE_NONREPUDIATION,
  ------------------
  |  |  314|  1.23k|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  463|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_VERIFY |
  ------------------
  |  |  311|  1.23k|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  464|  1.23k|					SC_PKCS15_PRKEY_USAGE_NONREPUDIATION,
  ------------------
  |  |  314|  1.23k|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  465|  1.23k|			"9C06", 0x9C, NULL, 0, "PIV_9C_KEY"},
  466|  1.23k|		{ "03", "KEY MAN pubkey",
  467|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT| SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT| SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  468|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  469|  1.23k|			"9D06", 0x9D, NULL, 0, "PIV_9D_KEY"},
  470|  1.23k|		{ "04", "CARD AUTH pubkey",
  471|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_VERIFY |
  ------------------
  |  |  311|  1.23k|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  472|  1.23k|					SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER,
  ------------------
  |  |  312|  1.23k|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
  473|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_VERIFY,
  ------------------
  |  |  311|  1.23k|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  474|  1.23k|			"9E06", 0x9E, NULL, 0, "PIV_9E_KEY"},  /* no pin, and avail in contactless */
  475|       |
  476|  1.23k|		{ "05", "Retired KEY MAN 1",
  477|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  478|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  479|  1.23k|			 "8206", 0x82, NULL, 0, "PIV_82_KEY"},
  480|  1.23k|		{ "06", "Retired KEY MAN 2",
  481|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  482|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  483|  1.23k|			 "8306", 0x83, NULL, 0, "PIV_83_KEY"},
  484|  1.23k|		{ "07", "Retired KEY MAN 3",
  485|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  486|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  487|  1.23k|			 "8406", 0x84, NULL, 0, "PIV_84_KEY"},
  488|  1.23k|		{ "08", "Retired KEY MAN 4",
  489|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  490|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  491|  1.23k|			 "8506", 0x85, NULL, 0, "PIV_85_KEY"},
  492|  1.23k|		{ "09", "Retired KEY MAN 5",
  493|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  494|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  495|  1.23k|			 "8606", 0x86, NULL, 0, "PIV_86_KEY"},
  496|  1.23k|		{ "10", "Retired KEY MAN 6",
  497|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  498|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  499|  1.23k|			 "8706", 0x87, NULL, 0, "PIV_87_KEY"},
  500|  1.23k|		{ "11", "Retired KEY MAN 7",
  501|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  502|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  503|  1.23k|			 "8806", 0x88, NULL, 0, "PIV_88_KEY"},
  504|  1.23k|		{ "12", "Retired KEY MAN 8",
  505|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  506|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  507|  1.23k|			 "8906", 0x89, NULL, 0, "PIV_89_KEY"},
  508|  1.23k|		{ "13", "Retired KEY MAN 9",
  509|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  510|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  511|  1.23k|			 "8A06", 0x8A, NULL, 0, "PIV_8A_KEY"},
  512|  1.23k|		{ "14", "Retired KEY MAN 10",
  513|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  514|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  515|  1.23k|			 "8B06", 0x8B, NULL, 0, "PIV_8B_KEY"},
  516|  1.23k|		{ "15", "Retired KEY MAN 11",
  517|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  518|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  519|  1.23k|			 "8C06", 0x8C, NULL, 0, "PIV_8C_KEY"},
  520|  1.23k|		{ "16", "Retired KEY MAN 12",
  521|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  522|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  523|  1.23k|			 "8D06", 0x8D, NULL, 0, "PIV_8D_KEY"},
  524|  1.23k|		{ "17", "Retired KEY MAN 13",
  525|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  526|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  527|  1.23k|			 "8E06", 0x8E, NULL, 0, "PIV_8E_KEY"},
  528|  1.23k|		{ "18", "Retired KEY MAN 14",
  529|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  530|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  531|  1.23k|			 "8F06", 0x8F, NULL, 0, "PIV_8F_KEY"},
  532|  1.23k|		{ "19", "Retired KEY MAN 15",
  533|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  534|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  535|  1.23k|			 "9006", 0x90, NULL, 0, "PIV_90_KEY"},
  536|  1.23k|		{ "20", "Retired KEY MAN 16",
  537|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  538|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  539|  1.23k|			 "9106", 0x91, NULL, 0, "PIV_91_KEY"},
  540|  1.23k|		{ "21", "Retired KEY MAN 17",
  541|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  542|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  543|  1.23k|			 "9206", 0x92, NULL, 0, "PIV_92_KEY"},
  544|  1.23k|		{ "22", "Retired KEY MAN 18",
  545|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  546|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  547|  1.23k|			 "9306", 0x93, NULL, 0, "PIV_93_KEY"},
  548|  1.23k|		{ "23", "Retired KEY MAN 19",
  549|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  550|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  551|  1.23k|			 "9406", 0x94, NULL, 0, "PIV_94_KEY"},
  552|  1.23k|		{ "24", "Retired KEY MAN 20",
  553|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  305|  1.23k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_WRAP,
  ------------------
  |  |  309|  1.23k|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  554|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  555|  1.23k|			 "9506", 0x95, NULL, 0, "PIV_95_KEY"}
  556|  1.23k|	};
  557|       |	// clang-format on
  558|       |
  559|       |/*
  560|       | * Note some of the SC_PKCS15_PRKEY values are dependent
  561|       | * on the key algorithm, and will be reset.
  562|       |
  563|       | * No SM Signer private Key on card
  564|       | * The 04 SM ECC CVC pubkey is in response to SELECT AID
  565|       | */
  566|       |	// clang-format off
  567|  1.23k|	static const prdata prkeys[PIV_NUM_KEYS] = {
  568|  1.23k|		{ "01", "PIV AUTH key",
  569|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT |
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  570|  1.23k|					SC_PKCS15_PRKEY_USAGE_UNWRAP |
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  571|  1.23k|					SC_PKCS15_PRKEY_USAGE_SIGN |
  ------------------
  |  |  307|  1.23k|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  572|  1.23k|					SC_PKCS15_PRKEY_USAGE_SIGNRECOVER,
  ------------------
  |  |  308|  1.23k|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
  573|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_SIGN,
  ------------------
  |  |  307|  1.23k|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  574|  1.23k|			"", 0x9A, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  575|  1.23k|		{ "02", "SIGN key",
  576|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT |
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  577|  1.23k|					SC_PKCS15_PRKEY_USAGE_SIGN |
  ------------------
  |  |  307|  1.23k|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  578|  1.23k|					SC_PKCS15_PRKEY_USAGE_SIGNRECOVER |
  ------------------
  |  |  308|  1.23k|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
  579|  1.23k|					SC_PKCS15_PRKEY_USAGE_NONREPUDIATION,
  ------------------
  |  |  314|  1.23k|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  580|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_SIGN |
  ------------------
  |  |  307|  1.23k|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  581|  1.23k|					SC_PKCS15_PRKEY_USAGE_NONREPUDIATION,
  ------------------
  |  |  314|  1.23k|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  582|  1.23k|			"", 0x9C, "01", SC_PKCS15_CO_FLAG_PRIVATE, 1}, /* use sign pin and user_consent */
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  583|  1.23k|		{ "03", "KEY MAN key",
  584|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  585|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  586|  1.23k|			"", 0x9D, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  587|  1.23k|		{ "04", "CARD AUTH key",
  588|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_SIGN |
  ------------------
  |  |  307|  1.23k|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  589|  1.23k|				SC_PKCS15_PRKEY_USAGE_SIGNRECOVER,
  ------------------
  |  |  308|  1.23k|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
  590|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_SIGN,
  ------------------
  |  |  307|  1.23k|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  591|  1.23k|			"", 0x9E, NULL, 0, 0}, /* no PIN needed, works with wireless */
  592|  1.23k|		{ "05", "Retired KEY MAN 1",
  593|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  594|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  595|  1.23k|			"", 0x82, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  596|  1.23k|		{ "06", "Retired KEY MAN 2",
  597|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  598|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  599|  1.23k|			"", 0x83, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  600|  1.23k|		{ "07", "Retired KEY MAN 3",
  601|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  602|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  603|  1.23k|			"", 0x84, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  604|  1.23k|		{ "08", "Retired KEY MAN 4",
  605|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  606|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  607|  1.23k|			"", 0x85, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  608|  1.23k|		{ "09", "Retired KEY MAN 5",
  609|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  610|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  611|  1.23k|			"", 0x86, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  612|  1.23k|		{ "10", "Retired KEY MAN 6",
  613|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  614|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  615|  1.23k|			"", 0x87, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  616|  1.23k|		{ "11", "Retired KEY MAN 7",
  617|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  618|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  619|  1.23k|			"", 0x88, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  620|  1.23k|		{ "12", "Retired KEY MAN 8",
  621|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  622|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  623|  1.23k|			"", 0x89, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  624|  1.23k|		{ "13", "Retired KEY MAN 9",
  625|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  626|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  627|  1.23k|			"", 0x8A, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  628|  1.23k|		{ "14", "Retired KEY MAN 10",
  629|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  630|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  631|  1.23k|			"", 0x8B, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  632|  1.23k|		{ "15", "Retired KEY MAN 11",
  633|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  634|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  635|  1.23k|			"", 0x8C, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  636|  1.23k|		{ "16", "Retired KEY MAN 12",
  637|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  638|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  639|  1.23k|			"", 0x8D, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  640|  1.23k|		{ "17", "Retired KEY MAN 13",
  641|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  642|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  643|  1.23k|			"", 0x8E, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  644|  1.23k|		{ "18", "Retired KEY MAN 14",
  645|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  646|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  647|  1.23k|			"", 0x8F, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  648|  1.23k|		{ "19", "Retired KEY MAN 15",
  649|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  650|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  651|  1.23k|			"", 0x90, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  652|  1.23k|		{ "20", "Retired KEY MAN 16",
  653|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  654|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  655|  1.23k|			"", 0x91, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  656|  1.23k|		{ "21", "Retired KEY MAN 17",
  657|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  658|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  659|  1.23k|			"", 0x92, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  660|  1.23k|		{ "22", "Retired KEY MAN 18",
  661|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  662|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  663|  1.23k|			"", 0x93, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  664|  1.23k|		{ "23", "Retired KEY MAN 19",
  665|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  666|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  667|  1.23k|			"", 0x94, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0},
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  668|  1.23k|		{ "24", "Retired KEY MAN 20",
  669|  1.23k|				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  306|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              				/*RSA*/SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP,
  ------------------
  |  |  310|  1.23k|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  670|  1.23k|				/*EC*/SC_PKCS15_PRKEY_USAGE_DERIVE,
  ------------------
  |  |  313|  1.23k|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  671|  1.23k|			"", 0x95, "01", SC_PKCS15_CO_FLAG_PRIVATE, 0}
  ------------------
  |  |   50|  1.23k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  672|       |		/* SM Signer certificate does not have private key on card */
  673|  1.23k|	};
  674|       |	// clang-format on
  675|       |
  676|  1.23k|	int    r, i;
  677|  1.23k|	sc_card_t *card = p15card->card;
  678|  1.23k|	sc_serial_number_t serial;
  679|  1.23k|	char buf[SC_MAX_SERIALNR * 2 + 1];
  680|  1.23k|	common_key_info ckis[PIV_NUM_CERTS];
  681|  1.23k|	int follows_nist_fascn = 0;
  682|  1.23k|	char *token_name = NULL;
  683|       |
  684|  1.23k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.23k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.23k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.23k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.23k]
  |  |  ------------------
  ------------------
  685|       |
  686|  1.23k|	memset(&serial, 0, sizeof(serial));
  687|       |
  688|       |	/* could read this off card if needed */
  689|       |
  690|       |	/* CSP does not like a - in the name */
  691|  1.23k|	set_string(&p15card->tokeninfo->label, "PIV_II");
  692|  1.23k|	set_string(&p15card->tokeninfo->manufacturer_id, MANU_ID);
  ------------------
  |  |   42|  1.23k|#define MANU_ID		"piv_II "
  ------------------
  693|       |
  694|       |	/*
  695|       |	 * get serial number
  696|       |	 * We will use the FASC-N from the CHUID
  697|       |	 * Note we are not verifying CHUID, belongs to this card
  698|       |	 * but need serial number for Mac tokend
  699|       |	 */
  700|       |
  701|  1.23k|	r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
  702|  1.23k|	if (r < 0) {
  ------------------
  |  Branch (702:6): [True: 1.19k, False: 33]
  ------------------
  703|  1.19k|		sc_log(card->ctx, "sc_card_ctl rc=%d",r);
  ------------------
  |  |   71|  1.19k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  704|  1.19k|		set_string(&p15card->tokeninfo->serial_number, "00000000");
  705|  1.19k|	} else {
  706|     33|		sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
  707|     33|		set_string(&p15card->tokeninfo->serial_number, buf);
  708|     33|	}
  709|       |	/* US gov issued PIVs have CHUID with a FASCN that does not start with 9999 */
  710|  1.23k|	if (serial.len == 25 && !(serial.value[0] == 0xD4 && serial.value[1] == 0xE7 && serial.value[2] == 0x39 && (serial.value[3] | 0x7F) == 0xFF)) {
  ------------------
  |  Branch (710:6): [True: 31, False: 1.19k]
  |  Branch (710:28): [True: 19, False: 12]
  |  Branch (710:55): [True: 11, False: 8]
  |  Branch (710:82): [True: 3, False: 8]
  |  Branch (710:109): [True: 1, False: 2]
  ------------------
  711|     30|	    follows_nist_fascn = 1;
  712|     30|	}
  713|       |
  714|  1.23k|	sc_log(card->ctx,  "PIV-II adding objects...");
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  715|       |
  716|       |	/* set other objects */
  717|  46.7k|	for (i = 0; objects[i].label; i++) {
  ------------------
  |  Branch (717:14): [True: 45.5k, False: 1.23k]
  ------------------
  718|  45.5k|		struct sc_pkcs15_data_info obj_info;
  719|  45.5k|		struct sc_pkcs15_object    obj_obj;
  720|       |
  721|  45.5k|		memset(&obj_info, 0, sizeof(obj_info));
  722|  45.5k|		memset(&obj_obj, 0, sizeof(obj_obj));
  723|  45.5k|		sc_pkcs15_format_id(objects[i].id, &obj_info.id);
  724|  45.5k|		sc_format_path(objects[i].path, &obj_info.path);
  725|       |
  726|       |		/* See if the object can not be present on the card */
  727|  45.5k|		r = sc_card_ctl(card, SC_CARDCTL_PIV_OBJECT_PRESENT, &obj_info.path);
  728|  45.5k|		if (r == 1)
  ------------------
  |  Branch (728:7): [True: 24.3k, False: 21.1k]
  ------------------
  729|  24.3k|			continue; /* Not on card, do not define the object */
  730|       |
  731|  21.1k|		strncpy(obj_info.app_label, objects[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|  21.1k|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  732|  21.1k|		r = sc_format_oid(&obj_info.app_oid, objects[i].aoid);
  733|  21.1k|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|  21.1k|#define SC_SUCCESS				0
  ------------------
  |  Branch (733:7): [True: 0, False: 21.1k]
  ------------------
  734|  21.1k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  735|       |
  736|       |		/* We can not read all the objects, as some need the PIN! */
  737|  21.1k|		if (objects[i].auth_id)
  ------------------
  |  Branch (737:7): [True: 3.69k, False: 17.4k]
  ------------------
  738|  3.69k|			sc_pkcs15_format_id(objects[i].auth_id, &obj_obj.auth_id);
  739|       |
  740|  21.1k|		strncpy(obj_obj.label, objects[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|  21.1k|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  741|  21.1k|		obj_obj.flags = objects[i].obj_flags;
  742|       |
  743|  21.1k|		r = sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_DATA_OBJECT,
  ------------------
  |  |  442|  21.1k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  744|  21.1k|			&obj_obj, &obj_info);
  745|       |
  746|  21.1k|		if (r < 0)
  ------------------
  |  Branch (746:7): [True: 0, False: 21.1k]
  ------------------
  747|  21.1k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  748|  21.1k|	}
  749|       |
  750|       |	/*
  751|       |	 * certs, pubkeys and priv keys are related and we assume
  752|       |	 * they are in order
  753|       |	 * We need to read the cert, get modulus and keylen
  754|       |	 * We use those for the pubkey, and priv key objects.
  755|       |	 * If no cert, then see if pubkey (i.e. we are initializing,
  756|       |	 * and the pubkey is in a file,) then add pubkey and privkey
  757|       |	 * If no cert and no pubkey, skip adding them.
  758|       |
  759|       |	 */
  760|       |	/* set certs */
  761|  1.23k|	sc_log(card->ctx,  "PIV-II adding certs...");
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  762|  31.9k|	for (i = 0; i < PIV_NUM_CERTS; i++) {
  ------------------
  |  |  370|  31.9k|#define PIV_NUM_CERTS 25
  ------------------
  |  Branch (762:14): [True: 30.7k, False: 1.23k]
  ------------------
  763|  30.7k|		struct sc_pkcs15_cert_info cert_info;
  764|  30.7k|		struct sc_pkcs15_object    cert_obj;
  765|  30.7k|		sc_pkcs15_der_t   cert_der;
  766|  30.7k|		sc_pkcs15_cert_t *cert_out = NULL;
  767|  30.7k|		int private_obj;
  768|       |
  769|  30.7k|		ckis[i].cert_found = 0;
  770|  30.7k|		ckis[i].key_alg = -1;
  771|  30.7k|		ckis[i].pubkey_found = 0;
  772|  30.7k|		ckis[i].pubkey_from_file = 0;
  773|  30.7k|		ckis[i].pubkey_len = 0;
  774|  30.7k|		ckis[i].pubkey_from_cert = NULL;
  775|  30.7k|		ckis[i].cert_keyUsage = 0;
  776|  30.7k|		ckis[i].cert_keyUsage_present = 0;
  777|  30.7k|		ckis[i].pub_usage = 0;
  778|  30.7k|		ckis[i].priv_usage = 0;
  779|       |
  780|  30.7k|		memset(&cert_info, 0, sizeof(cert_info));
  781|  30.7k|		memset(&cert_obj,  0, sizeof(cert_obj));
  782|       |
  783|  30.7k|		sc_pkcs15_format_id(certs[i].id, &cert_info.id);
  784|  30.7k|		cert_info.authority = certs[i].authority;
  785|  30.7k|		sc_format_path(certs[i].path, &cert_info.path);
  786|       |
  787|  30.7k|		strncpy(cert_obj.label, certs[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|  30.7k|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  788|  30.7k|		cert_obj.flags = certs[i].obj_flags;
  789|       |
  790|       |		/* See if the cert might be present or not. */
  791|  30.7k|		r = sc_card_ctl(card, SC_CARDCTL_PIV_OBJECT_PRESENT, &cert_info.path);
  792|  30.7k|		if (r == 1) {
  ------------------
  |  Branch (792:7): [True: 22.2k, False: 8.52k]
  ------------------
  793|  22.2k|			sc_log(card->ctx,  "Cert can not be present,i=%d", i);
  ------------------
  |  |   71|  22.2k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  794|  22.2k|			continue;
  795|  22.2k|		}
  796|       |
  797|  8.52k|		private_obj = cert_obj.flags & SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|  8.52k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  798|  8.52k|		r = sc_pkcs15_read_file(p15card, &cert_info.path, &cert_der.value, &cert_der.len, private_obj);
  799|       |
  800|  8.52k|		if (r) {
  ------------------
  |  Branch (800:7): [True: 6.75k, False: 1.77k]
  ------------------
  801|  6.75k|			sc_log(card->ctx,  "No cert found,i=%d", i);
  ------------------
  |  |   71|  6.75k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  802|  6.75k|			continue;
  803|  6.75k|		}
  804|       |
  805|  1.77k|		ckis[i].cert_found = 1;
  806|       |		/* cache it using the PKCS15 emulation objects */
  807|       |		/* as it does not change */
  808|  1.77k|		if (cert_der.value) {
  ------------------
  |  Branch (808:7): [True: 1.77k, False: 0]
  ------------------
  809|  1.77k|			cert_info.value.value = cert_der.value;
  810|  1.77k|			cert_info.value.len = cert_der.len;
  811|  1.77k|			if (!p15card->opts.use_file_cache
  ------------------
  |  Branch (811:8): [True: 1.77k, False: 0]
  ------------------
  812|  1.77k|			    || (private_obj && !(p15card->opts.use_file_cache & SC_PKCS15_OPTS_CACHE_ALL_FILES))) {
  ------------------
  |  |  606|      0|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
  |  Branch (812:12): [True: 0, False: 0]
  |  Branch (812:27): [True: 0, False: 0]
  ------------------
  813|  1.77k|				cert_info.path.len = 0; /* use in mem cert from now on */
  814|  1.77k|			}
  815|  1.77k|		}
  816|       |		/* following will find the cached cert in cert_info */
  817|  1.77k|		r =  sc_pkcs15_read_certificate(p15card, &cert_info, private_obj, &cert_out);
  818|  1.77k|		if (r < 0 || cert_out == NULL || cert_out->key == NULL) {
  ------------------
  |  Branch (818:7): [True: 584, False: 1.18k]
  |  Branch (818:16): [True: 0, False: 1.18k]
  |  Branch (818:36): [True: 15, False: 1.17k]
  ------------------
  819|    599|			sc_log(card->ctx,  "Failed to read/parse the certificate r=%d",r);
  ------------------
  |  |   71|    599|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  820|    599|			if (cert_out != NULL)
  ------------------
  |  Branch (820:8): [True: 15, False: 584]
  ------------------
  821|     15|				sc_pkcs15_free_certificate(cert_out);
  822|    599|			free(cert_der.value);
  823|    599|			continue;
  824|    599|		}
  825|       |
  826|       |		/* set the token name to the name of the CN of the first certificate */
  827|  1.17k|		if (!token_name) {
  ------------------
  |  Branch (827:7): [True: 1.13k, False: 39]
  ------------------
  828|  1.13k|			u8 * cn_name = NULL;
  829|  1.13k|			size_t cn_len = 0;
  830|  1.13k|			static const struct sc_object_id cn_oid = {{ 2, 5, 4, 3, -1 }};
  831|  1.13k|			r = sc_pkcs15_get_name_from_dn(card->ctx, cert_out->subject,
  832|  1.13k|				cert_out->subject_len, &cn_oid, &cn_name, &cn_len);
  833|  1.13k|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  1.13k|#define SC_SUCCESS				0
  ------------------
  |  Branch (833:8): [True: 16, False: 1.11k]
  ------------------
  834|     16|				token_name = realloc(cn_name, cn_len + 1);
  835|     16|				if (!token_name) {
  ------------------
  |  Branch (835:9): [True: 0, False: 16]
  ------------------
  836|      0|					sc_pkcs15_free_certificate(cert_out);
  837|      0|					free(cert_info.value.value);
  838|      0|					free(cn_name);
  839|      0|					r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  840|      0|					LOG_TEST_GOTO_ERR(card->ctx, r,
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  841|      0|						"Failed to allocate memory");
  842|      0|				}
  843|     16|				token_name[cn_len] = '\0';
  844|     16|				free(p15card->tokeninfo->label);
  845|     16|				p15card->tokeninfo->label = token_name;
  846|     16|			}
  847|  1.13k|		}
  848|       |
  849|       |		/*
  850|       |		 * get keyUsage if present save in ckis[i]
  851|       |		 * Will only use it if this in a non FED issued card
  852|       |		 * which has a CHUID with FASC-N not starting with 9999
  853|       |		 */
  854|       |
  855|  1.17k|		if (follows_nist_fascn == 0) {
  ------------------
  |  Branch (855:7): [True: 1.15k, False: 20]
  ------------------
  856|  1.15k|			struct sc_object_id keyUsage_oid={{2,5,29,15,-1}};
  857|  1.15k|			int r = 0;
  858|       |
  859|  1.15k|			r = sc_pkcs15_get_bitstring_extension(card->ctx, cert_out,
  860|  1.15k|				&keyUsage_oid,
  861|  1.15k|				&ckis[i].cert_keyUsage, NULL);
  862|  1.15k|			if ( r >= 0)
  ------------------
  |  Branch (862:9): [True: 0, False: 1.15k]
  ------------------
  863|      0|				ckis[i].cert_keyUsage_present = 1;
  864|       |				/* TODO if no key usage, we could set all uses */
  865|  1.15k|		}
  866|       |
  867|       |
  868|  1.17k|		ckis[i].key_alg = cert_out->key->algorithm;
  869|  1.17k|		switch (cert_out->key->algorithm) {
  870|    124|			case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|    124|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (870:4): [True: 124, False: 1.05k]
  ------------------
  871|       |				/* save pubkey_len for pub and priv */
  872|    124|				ckis[i].pubkey_len = cert_out->key->u.rsa.modulus.len * 8;
  873|       |				/* See RFC 5280 and PKCS#11 V2.40 */
  874|    124|				if (ckis[i].cert_keyUsage_present) {
  ------------------
  |  Branch (874:9): [True: 0, False: 124]
  ------------------
  875|      0|					if (ckis[i].cert_keyUsage & SC_X509_DIGITAL_SIGNATURE) {
  ------------------
  |  |  614|      0|#define SC_X509_DIGITAL_SIGNATURE     0x0001UL
  ------------------
  |  Branch (875:10): [True: 0, False: 0]
  ------------------
  876|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT /* extra*/
  ------------------
  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
  877|      0|									|SC_PKCS15_PRKEY_USAGE_WRAP
  ------------------
  |  |  309|      0|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  878|      0|									|SC_PKCS15_PRKEY_USAGE_VERIFY
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  879|      0|									|SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER;
  ------------------
  |  |  312|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
  880|      0|					        ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_DECRYPT /*extra */
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  881|      0|									|SC_PKCS15_PRKEY_USAGE_UNWRAP
  ------------------
  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  882|      0|									|SC_PKCS15_PRKEY_USAGE_SIGN
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  883|      0|									|SC_PKCS15_PRKEY_USAGE_SIGNRECOVER;
  ------------------
  |  |  308|      0|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
  884|      0|					}
  885|      0|					if (ckis[i].cert_keyUsage & SC_X509_NON_REPUDIATION) {
  ------------------
  |  |  615|      0|#define SC_X509_NON_REPUDIATION       0x0002UL
  ------------------
  |  Branch (885:10): [True: 0, False: 0]
  ------------------
  886|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT /* extra */
  ------------------
  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
  887|      0|									|SC_PKCS15_PRKEY_USAGE_NONREPUDIATION
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  888|      0|									|SC_PKCS15_PRKEY_USAGE_VERIFY
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  889|      0|									|SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER;
  ------------------
  |  |  312|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
  890|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_DECRYPT /*extra*/
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  891|      0|									|SC_PKCS15_PRKEY_USAGE_NONREPUDIATION
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  892|      0|									|SC_PKCS15_PRKEY_USAGE_SIGN
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  893|      0|									|SC_PKCS15_PRKEY_USAGE_SIGNRECOVER;
  ------------------
  |  |  308|      0|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
  894|      0|					}
  895|      0|					if (ckis[i].cert_keyUsage & SC_X509_KEY_ENCIPHERMENT) {
  ------------------
  |  |  616|      0|#define SC_X509_KEY_ENCIPHERMENT      0x0004UL
  ------------------
  |  Branch (895:10): [True: 0, False: 0]
  ------------------
  896|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT| SC_PKCS15_PRKEY_USAGE_WRAP;
  ------------------
  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT| SC_PKCS15_PRKEY_USAGE_WRAP;
  ------------------
  |  |  309|      0|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  897|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_DECRYPT| SC_PKCS15_PRKEY_USAGE_UNWRAP;
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_DECRYPT| SC_PKCS15_PRKEY_USAGE_UNWRAP;
  ------------------
  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  898|      0|					}
  899|      0|					if (ckis[i].cert_keyUsage & SC_X509_DATA_ENCIPHERMENT) {
  ------------------
  |  |  617|      0|#define SC_X509_DATA_ENCIPHERMENT     0x0008UL
  ------------------
  |  Branch (899:10): [True: 0, False: 0]
  ------------------
  900|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT;
  ------------------
  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
  901|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  902|      0|					}
  903|      0|					if (ckis[i].cert_keyUsage & SC_X509_KEY_AGREEMENT) {
  ------------------
  |  |  618|      0|#define SC_X509_KEY_AGREEMENT         0x0010UL
  ------------------
  |  Branch (903:10): [True: 0, False: 0]
  ------------------
  904|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  905|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  906|      0|					}
  907|      0|					if (ckis[i].cert_keyUsage & SC_X509_KEY_CERT_SIGN) {
  ------------------
  |  |  619|      0|#define SC_X509_KEY_CERT_SIGN         0x0020UL
  ------------------
  |  Branch (907:10): [True: 0, False: 0]
  ------------------
  908|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_VERIFY|SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER;
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
              						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_VERIFY|SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER;
  ------------------
  |  |  312|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
  909|      0|						ckis[i].priv_usage |=  SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  910|      0|					}
  911|      0|					if (ckis[i].cert_keyUsage & SC_X509_CRL_SIGN) {
  ------------------
  |  |  620|      0|#define SC_X509_CRL_SIGN              0x0040UL
  ------------------
  |  Branch (911:10): [True: 0, False: 0]
  ------------------
  912|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_VERIFY|SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER;
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
              						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_VERIFY|SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER;
  ------------------
  |  |  312|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
  913|      0|						ckis[i].priv_usage |=  SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  914|      0|					}
  915|      0|					if (ckis[i].cert_keyUsage & SC_X509_ENCIPHER_ONLY) {
  ------------------
  |  |  621|      0|#define SC_X509_ENCIPHER_ONLY         0x0080UL
  ------------------
  |  Branch (915:10): [True: 0, False: 0]
  ------------------
  916|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT|SC_PKCS15_PRKEY_USAGE_WRAP;
  ------------------
  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT|SC_PKCS15_PRKEY_USAGE_WRAP;
  ------------------
  |  |  309|      0|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  917|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_DECRYPT|SC_PKCS15_PRKEY_USAGE_UNWRAP;
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_DECRYPT|SC_PKCS15_PRKEY_USAGE_UNWRAP;
  ------------------
  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  918|      0|					}
  919|      0|					if (ckis[i].cert_keyUsage & SC_X509_DECIPHER_ONLY) { /* TODO is this correct */
  ------------------
  |  |  622|      0|#define SC_X509_DECIPHER_ONLY         0x0100UL
  ------------------
  |  Branch (919:10): [True: 0, False: 0]
  ------------------
  920|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_DECRYPT|SC_PKCS15_PRKEY_USAGE_UNWRAP;
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_DECRYPT|SC_PKCS15_PRKEY_USAGE_UNWRAP;
  ------------------
  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  921|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT|SC_PKCS15_PRKEY_USAGE_WRAP;
  ------------------
  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT|SC_PKCS15_PRKEY_USAGE_WRAP;
  ------------------
  |  |  309|      0|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
  922|      0|					}
  923|      0|				}
  924|    124|				break;
  925|       |
  926|  1.05k|			case SC_ALGORITHM_EC:
  ------------------
  |  |   70|  1.05k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (926:4): [True: 1.05k, False: 124]
  ------------------
  927|  1.05k|			case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|  1.05k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (927:4): [True: 0, False: 1.17k]
  ------------------
  928|  1.05k|			case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|  1.05k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (928:4): [True: 0, False: 1.17k]
  ------------------
  929|  1.05k|				ckis[i].pubkey_len = cert_out->key->u.ec.params.field_length;
  930|  1.05k|				if (ckis[i].cert_keyUsage_present) {
  ------------------
  |  Branch (930:9): [True: 0, False: 1.05k]
  ------------------
  931|      0|					if (ckis[i].cert_keyUsage & SC_X509_DIGITAL_SIGNATURE) {
  ------------------
  |  |  614|      0|#define SC_X509_DIGITAL_SIGNATURE     0x0001UL
  ------------------
  |  Branch (931:10): [True: 0, False: 0]
  ------------------
  932|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_VERIFY;
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  933|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  934|      0|					}
  935|      0|					if (ckis[i].cert_keyUsage & SC_X509_NON_REPUDIATION) {
  ------------------
  |  |  615|      0|#define SC_X509_NON_REPUDIATION       0x0002UL
  ------------------
  |  Branch (935:10): [True: 0, False: 0]
  ------------------
  936|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  937|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  938|      0|					}
  939|      0|					if (ckis[i].cert_keyUsage & SC_X509_KEY_ENCIPHERMENT) {
  ------------------
  |  |  616|      0|#define SC_X509_KEY_ENCIPHERMENT      0x0004UL
  ------------------
  |  Branch (939:10): [True: 0, False: 0]
  ------------------
  940|      0|						ckis[i].pub_usage |= 0;
  941|      0|						ckis[i].priv_usage |= 0;
  942|      0|					}
  943|      0|					if (ckis[i].cert_keyUsage & SC_X509_DATA_ENCIPHERMENT) {
  ------------------
  |  |  617|      0|#define SC_X509_DATA_ENCIPHERMENT     0x0008UL
  ------------------
  |  Branch (943:10): [True: 0, False: 0]
  ------------------
  944|      0|						ckis[i].pub_usage |= 0;
  945|      0|						ckis[i].priv_usage |= 0;
  946|      0|					}
  947|      0|					if (ckis[i].cert_keyUsage & SC_X509_KEY_AGREEMENT) {
  ------------------
  |  |  618|      0|#define SC_X509_KEY_AGREEMENT         0x0010UL
  ------------------
  |  Branch (947:10): [True: 0, False: 0]
  ------------------
  948|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  949|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
  950|      0|					}
  951|      0|					if (ckis[i].cert_keyUsage & SC_X509_KEY_CERT_SIGN) {
  ------------------
  |  |  619|      0|#define SC_X509_KEY_CERT_SIGN         0x0020UL
  ------------------
  |  Branch (951:10): [True: 0, False: 0]
  ------------------
  952|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_VERIFY;
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  953|      0|						ckis[i].priv_usage |= SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  954|      0|					}
  955|      0|					if (ckis[i].cert_keyUsage & SC_X509_CRL_SIGN) {
  ------------------
  |  |  620|      0|#define SC_X509_CRL_SIGN              0x0040UL
  ------------------
  |  Branch (955:10): [True: 0, False: 0]
  ------------------
  956|      0|						ckis[i].pub_usage |= SC_PKCS15_PRKEY_USAGE_VERIFY;
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
  957|      0|						ckis[i].priv_usage |=  SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  958|      0|					}
  959|      0|					if (ckis[i].cert_keyUsage & SC_X509_ENCIPHER_ONLY) {
  ------------------
  |  |  621|      0|#define SC_X509_ENCIPHER_ONLY         0x0080UL
  ------------------
  |  Branch (959:10): [True: 0, False: 0]
  ------------------
  960|      0|						ckis[i].pub_usage |= 0;
  961|      0|						ckis[i].priv_usage |= 0;
  962|      0|					}
  963|      0|					if (ckis[i].cert_keyUsage & SC_X509_DECIPHER_ONLY) {
  ------------------
  |  |  622|      0|#define SC_X509_DECIPHER_ONLY         0x0100UL
  ------------------
  |  Branch (963:10): [True: 0, False: 0]
  ------------------
  964|      0|						ckis[i].pub_usage |= 0;
  965|      0|						ckis[i].priv_usage |= 0;
  966|      0|					}
  967|      0|				}
  968|  1.05k|				break;
  969|       |
  970|      0|			default:
  ------------------
  |  Branch (970:4): [True: 0, False: 1.17k]
  ------------------
  971|      0|				sc_log(card->ctx, "Unsupported key.algorithm %lu", cert_out->key->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  972|      0|				ckis[i].pubkey_len = 0; /* set some value for now */
  973|  1.17k|		}
  974|  1.17k|		if (i < PIV_NUM_KEYS) { /* Only save pub key if card can have private key */
  ------------------
  |  |  371|  1.17k|#define PIV_NUM_KEYS  24
  ------------------
  |  Branch (974:7): [True: 1.14k, False: 31]
  ------------------
  975|  1.14k|			ckis[i].pubkey_from_cert = cert_out->key;
  976|  1.14k|			cert_out->key = NULL;
  977|  1.14k|		}
  978|  1.17k|		sc_pkcs15_free_certificate(cert_out);
  979|       |
  980|  1.17k|		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  981|  1.17k|		if (r < 0) {
  ------------------
  |  Branch (981:7): [True: 0, False: 1.17k]
  ------------------
  982|      0|			sc_log(card->ctx,  " Failed to add cert obj r=%d",r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  983|      0|			continue;
  984|      0|		}
  985|  1.17k|	}
  986|       |
  987|       |	/* set pins */
  988|  1.23k|	sc_log(card->ctx,  "PIV-II adding pins...");
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  989|  4.92k|	for (i = 0; pins[i].label; i++) {
  ------------------
  |  Branch (989:14): [True: 3.69k, False: 1.23k]
  ------------------
  990|  3.69k|		struct sc_pkcs15_auth_info pin_info;
  991|  3.69k|		struct sc_pkcs15_object   pin_obj;
  992|  3.69k|		const char * label;
  993|  3.69k|		int pin_ref;
  994|       |
  995|       |		/* the SignPIN is only used with minidriver */
  996|  3.69k|		if (pins[i].cardmod && (strcmp(card->ctx->app_name, "cardmod") != 0))
  ------------------
  |  Branch (996:7): [True: 1.23k, False: 2.46k]
  |  Branch (996:26): [True: 1.23k, False: 0]
  ------------------
  997|  1.23k|			continue;
  998|       |
  999|  2.46k|		memset(&pin_info, 0, sizeof(pin_info));
 1000|  2.46k|		memset(&pin_obj,  0, sizeof(pin_obj));
 1001|       |
 1002|  2.46k|		pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|  2.46k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1003|  2.46k|		sc_pkcs15_format_id(pins[i].id, &pin_info.auth_id);
 1004|  2.46k|		pin_info.attrs.pin.reference     = pins[i].ref;
 1005|  2.46k|		pin_info.attrs.pin.flags         = pins[i].flags;
 1006|  2.46k|		pin_info.attrs.pin.type          = pins[i].type;
 1007|  2.46k|		pin_info.attrs.pin.min_length    = pins[i].minlen;
 1008|  2.46k|		pin_info.attrs.pin.stored_length = pins[i].storedlen;
 1009|  2.46k|		pin_info.attrs.pin.max_length    = pins[i].maxlen;
 1010|  2.46k|		pin_info.attrs.pin.pad_char      = pins[i].pad_char;
 1011|  2.46k|		pin_info.tries_left              = pins[i].tries_left;
 1012|  2.46k|		sc_format_path(pins[i].path, &pin_info.path);
 1013|       |
 1014|  2.46k|		label = pins[i].label;
 1015|  2.46k|		if ((i == 0 || pins[i].cardmod) &&
  ------------------
  |  Branch (1015:8): [True: 1.23k, False: 1.23k]
  |  Branch (1015:18): [True: 0, False: 1.23k]
  ------------------
 1016|  1.23k|			sc_card_ctl(card, SC_CARDCTL_PIV_PIN_PREFERENCE,
  ------------------
  |  Branch (1016:4): [True: 1.23k, False: 0]
  ------------------
 1017|  1.23k|					&pin_ref) == 0 &&
 1018|  1.23k|				pin_ref == 0x00) { /* must be 80 for PIV pin, or 00 for Global PIN */
  ------------------
  |  Branch (1018:5): [True: 1, False: 1.22k]
  ------------------
 1019|      1|			pin_info.attrs.pin.reference = pin_ref;
 1020|      1|			label = "Global PIN";
 1021|      1|		}
 1022|       |
 1023|  2.46k|		strncpy(pin_obj.label, label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|  2.46k|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
 1024|  2.46k|		pin_obj.flags = pins[i].obj_flags;
 1025|  2.46k|		if ((i == 0 || pins[i].cardmod)) {
  ------------------
  |  Branch (1025:8): [True: 1.23k, False: 1.23k]
  |  Branch (1025:18): [True: 0, False: 1.23k]
  ------------------
 1026|       |			/*
 1027|       |			 * according to description of "RESET RETRY COUNTER"
 1028|       |			 * command in specs PUK can only unblock PIV PIN
 1029|       |			 */
 1030|  1.23k|			pin_obj.auth_id.len = 1;
 1031|  1.23k|			pin_obj.auth_id.value[0] = 2;
 1032|  1.23k|		}
 1033|       |
 1034|  2.46k|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
 1035|  2.46k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Failed to add PIN");
  ------------------
  |  |  184|  2.46k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.46k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.46k|	int _ret = (r); \
  |  |  |  |  178|  2.46k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2.46k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  2.46k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1036|  2.46k|	}
 1037|       |
 1038|       |	/* set public keys */
 1039|       |	/* We may only need this during initialization when genkey
 1040|       |	 * gets the pubkey, but it can not be read from the card
 1041|       |	 * at a later time. The piv-tool can stash  pubkey in file
 1042|       |	 */
 1043|  1.23k|	sc_log(card->ctx,  "PIV-II adding pub keys...");
  ------------------
  |  |   71|  1.23k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1044|  30.3k|	for (i = 0; i < PIV_NUM_KEYS; i++) {
  ------------------
  |  |  371|  30.3k|#define PIV_NUM_KEYS  24
  ------------------
  |  Branch (1044:14): [True: 29.1k, False: 1.21k]
  ------------------
 1045|  29.1k|		struct sc_pkcs15_pubkey_info pubkey_info;
 1046|  29.1k|		struct sc_pkcs15_object     pubkey_obj;
 1047|  29.1k|		struct sc_pkcs15_pubkey *p15_key = NULL;
 1048|       |
 1049|  29.1k|		memset(&pubkey_info, 0, sizeof(pubkey_info));
 1050|  29.1k|		memset(&pubkey_obj,  0, sizeof(pubkey_obj));
 1051|       |
 1052|       |
 1053|  29.1k|		sc_pkcs15_format_id(pubkeys[i].id, &pubkey_info.id);
 1054|  29.1k|		pubkey_info.native        = 1;
 1055|  29.1k|		pubkey_info.key_reference = pubkeys[i].ref;
 1056|       |
 1057|       |//		sc_format_path(pubkeys[i].path, &pubkey_info.path);
 1058|       |
 1059|  29.1k|		strncpy(pubkey_obj.label, pubkeys[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|  29.1k|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
 1060|       |
 1061|  29.1k|		pubkey_obj.flags = pubkeys[i].obj_flags;
 1062|       |
 1063|  29.1k|		if (pubkeys[i].auth_id)
  ------------------
  |  Branch (1063:7): [True: 0, False: 29.1k]
  ------------------
 1064|      0|			sc_pkcs15_format_id(pubkeys[i].auth_id, &pubkey_obj.auth_id);
 1065|       |
 1066|       |		/* If no cert found, piv-tool may have stashed the pubkey
 1067|       |		 * so we can use it when generating a certificate request
 1068|       |		 * The file is a OpenSSL DER EVP_KEY, which looks like
 1069|       |		 * a certificate subjectPublicKeyInfo.
 1070|       |		 *
 1071|       |		 */
 1072|  29.1k|		if (ckis[i].cert_found == 0 ) { /*  no cert found */
  ------------------
  |  Branch (1072:7): [True: 27.4k, False: 1.73k]
  ------------------
 1073|  27.4k|			sc_cardctl_piv_pubkey_info_t info = {0};
 1074|       |
 1075|  27.4k|			sc_log(card->ctx, "No cert for this pub key i=%d",i);
  ------------------
  |  |   71|  27.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1076|       |
 1077|       |			/* First try to use yubikey extension to pull missing public key from metadata */
 1078|  27.4k|			info.slot = pubkeys[i].ref;
 1079|  27.4k|			r = sc_card_ctl(card, SC_CARDCTL_PIV_YK_GET_PUBKEY_INFO, &info);
 1080|  27.4k|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  27.4k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1080:8): [True: 39, False: 27.3k]
  ------------------
 1081|     39|				struct sc_pkcs15_pubkey pubkey = {0};
 1082|     39|				const unsigned char *p;
 1083|     39|				unsigned int cla, tag;
 1084|     39|				size_t tag_len;
 1085|     39|				int r;
 1086|       |
 1087|     39|				switch (info.algorithm) {
 1088|      1|				case 0x06: // RSA
  ------------------
  |  Branch (1088:5): [True: 1, False: 38]
  ------------------
 1089|     11|				case 0x07:
  ------------------
  |  Branch (1089:5): [True: 10, False: 29]
  ------------------
 1090|     12|				case 0x08:
  ------------------
  |  Branch (1090:5): [True: 1, False: 38]
  ------------------
 1091|     12|					p = info.pubkey.value;
 1092|     12|					r = sc_asn1_read_tag(&p, info.pubkey.len, &cla, &tag, &tag_len);
 1093|     12|					if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     12|#define SC_SUCCESS				0
  ------------------
  |  Branch (1093:10): [True: 3, False: 9]
  ------------------
 1094|      3|						sc_log(card->ctx, "Failed to parse RSA modulus: %d", r);
  ------------------
  |  |   71|      3|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1095|      3|						goto next_pubkey;
 1096|      3|					}
 1097|      9|					if ((tag | cla) != 0x81) {
  ------------------
  |  Branch (1097:10): [True: 5, False: 4]
  ------------------
 1098|      5|						sc_log(card->ctx, "Unexpected tag %u received, expected 0x81", (tag | cla));
  ------------------
  |  |   71|      5|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1099|      5|						goto next_pubkey;
 1100|      5|					}
 1101|      4|					pubkey.u.rsa.modulus.data = malloc(tag_len);
 1102|      4|					if (pubkey.u.rsa.modulus.data == NULL) {
  ------------------
  |  Branch (1102:10): [True: 0, False: 4]
  ------------------
 1103|      0|						sc_log(card->ctx, "Out of memory");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1104|      0|						goto next_pubkey;
 1105|      0|					}
 1106|      4|					memcpy(pubkey.u.rsa.modulus.data, p, tag_len);
 1107|      4|					pubkey.u.rsa.modulus.len = tag_len;
 1108|       |
 1109|      4|					p += tag_len;
 1110|      4|					r = sc_asn1_read_tag(&p, info.pubkey.len - (p - info.pubkey.value), &cla, &tag, &tag_len);
 1111|      4|					if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  |  Branch (1111:10): [True: 1, False: 3]
  ------------------
 1112|      1|						sc_log(card->ctx, "Failed to parse RSA exponent: %d", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1113|      1|						goto next_pubkey;
 1114|      1|					}
 1115|      3|					if ((tag | cla) != 0x82) {
  ------------------
  |  Branch (1115:10): [True: 1, False: 2]
  ------------------
 1116|      1|						sc_log(card->ctx, "Unexpected tag %u received, expected 0x82", (tag | cla));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1117|      1|						goto next_pubkey;
 1118|      1|					}
 1119|      2|					pubkey.u.rsa.exponent.data = malloc(tag_len);
 1120|      2|					if (pubkey.u.rsa.exponent.data == NULL) {
  ------------------
  |  Branch (1120:10): [True: 0, False: 2]
  ------------------
 1121|      0|						sc_log(card->ctx, "Out of memory");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1122|      0|						goto next_pubkey;
 1123|      0|					}
 1124|      2|					memcpy(pubkey.u.rsa.exponent.data, p, tag_len);
 1125|      2|					pubkey.u.rsa.exponent.len = tag_len;
 1126|       |
 1127|      2|					pubkey.algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|      2|#define SC_ALGORITHM_RSA		0
  ------------------
 1128|      2|					break;
 1129|      2|				case 0x11: // ECDSA
  ------------------
  |  Branch (1129:5): [True: 2, False: 37]
  ------------------
 1130|      7|				case 0x14:
  ------------------
  |  Branch (1130:5): [True: 5, False: 34]
  ------------------
 1131|      7|					r = yk_copy_pubkey_from_tag(&info, &pubkey.u.ec.ecpointQ, 0x86);
 1132|      7|					if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      7|#define SC_SUCCESS				0
  ------------------
  |  Branch (1132:10): [True: 7, False: 0]
  ------------------
 1133|      7|						sc_log(card->ctx, "Failed to parse ECDSA public key. %d", r);
  ------------------
  |  |   71|      7|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1134|      7|						goto next_pubkey;
 1135|      7|					}
 1136|      0|					pubkey.algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
 1137|      0|					break;
 1138|      1|				case 0xE0: // Yubico extension: EDDSA
  ------------------
  |  Branch (1138:5): [True: 1, False: 38]
  ------------------
 1139|      1|					r = yk_copy_pubkey_from_tag(&info, &pubkey.u.ec.ecpointQ, 0x86);
 1140|      1|					if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (1140:10): [True: 1, False: 0]
  ------------------
 1141|      1|						sc_log(card->ctx, "Failed to parse EDDSA public key. %d", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1142|      1|						goto next_pubkey;
 1143|      1|					}
 1144|      0|					pubkey.algorithm = SC_ALGORITHM_EDDSA;
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
 1145|      0|					break;
 1146|      1|				case 0xE1: // Yubico extension: XEDDSA
  ------------------
  |  Branch (1146:5): [True: 1, False: 38]
  ------------------
 1147|      1|					r = yk_copy_pubkey_from_tag(&info, &pubkey.u.ec.ecpointQ, 0x86);
 1148|      1|					if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (1148:10): [True: 1, False: 0]
  ------------------
 1149|      1|						sc_log(card->ctx, "Failed to parse XEDDSA public key. %d", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1150|      1|						goto next_pubkey;
 1151|      1|					}
 1152|      0|					pubkey.algorithm = SC_ALGORITHM_XEDDSA;
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
 1153|      0|					break;
 1154|     18|				default:
  ------------------
  |  Branch (1154:5): [True: 18, False: 21]
  ------------------
 1155|     18|					sc_log(card->ctx, "Got unknown algorithm ID %d", info.algorithm);
  ------------------
  |  |   71|     18|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1156|     18|					goto next_pubkey;
 1157|     39|				}
 1158|       |
 1159|      2|				r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, &pubkey,
 1160|      2|						&pubkey_info.direct.spki.value, &pubkey_info.direct.spki.len);
 1161|      2|				if (r < 0) {
  ------------------
  |  Branch (1161:9): [True: 0, False: 2]
  ------------------
 1162|      0|					goto next_pubkey;
 1163|      0|				}
 1164|      2|				r = sc_pkcs15_pubkey_from_spki_sequence(card->ctx,
 1165|      2|						pubkey_info.direct.spki.value, pubkey_info.direct.spki.len,
 1166|      2|						&p15_key);
 1167|      2|				if (r < 0) {
  ------------------
  |  Branch (1167:9): [True: 0, False: 2]
  ------------------
 1168|      0|					free(p15_key);
 1169|      0|					p15_key = NULL;
 1170|      0|				}
 1171|     39|next_pubkey:
 1172|     39|				sc_pkcs15_erase_pubkey(&pubkey);
 1173|     39|				if (!p15_key)
  ------------------
  |  Branch (1173:9): [True: 37, False: 2]
  ------------------
 1174|     37|					continue;
 1175|  27.3k|			} else {
 1176|  27.3k|				char *filename = NULL;
 1177|       |
 1178|  27.3k|				sc_log(card->ctx, "Failed to get public key. Not a Yubikey? rc=%d", r);
  ------------------
  |  |   71|  27.3k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1179|       |				/*
 1180|       |				 * If we used the piv-tool or ykman to generate a key,
 1181|       |				 * we would have saved the public key as a file.
 1182|       |				 * This code is only used while signing a request
 1183|       |				 * After the certificate is loaded on the card,
 1184|       |				 * the public key is extracted from the certificate.
 1185|       |				 */
 1186|       |
 1187|  27.3k|				sc_log(card->ctx, "DEE look for env %s",
  ------------------
  |  |   71|  54.7k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 27.3k, False: 0]
  |  |  ------------------
  ------------------
 1188|  27.3k|						pubkeys[i].getenvname ? pubkeys[i].getenvname : "NULL");
 1189|       |
 1190|  27.3k|				if (pubkeys[i].getenvname == NULL)
  ------------------
  |  Branch (1190:9): [True: 0, False: 27.3k]
  ------------------
 1191|      0|					continue;
 1192|       |
 1193|  27.3k|				filename = getenv(pubkeys[i].getenvname);
 1194|  27.3k|				sc_log(card->ctx, "DEE look for file %s", filename ? filename : "NULL");
  ------------------
  |  |   71|  54.7k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 0, False: 27.3k]
  |  |  ------------------
  ------------------
 1195|  27.3k|				if (filename == NULL)
  ------------------
  |  Branch (1195:9): [True: 27.3k, False: 0]
  ------------------
 1196|  27.3k|					continue;
 1197|       |
 1198|      0|				sc_log(card->ctx, "Adding pubkey from file %s", filename);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1199|       |
 1200|      0|				r = sc_pkcs15_pubkey_from_spki_file(card->ctx, filename, &p15_key);
 1201|      0|				if (r < 0) {
  ------------------
  |  Branch (1201:9): [True: 0, False: 0]
  ------------------
 1202|      0|					free(p15_key);
 1203|      0|					continue;
 1204|      0|				}
 1205|       |
 1206|       |				/* Lets also try another method. */
 1207|      0|				r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, p15_key,
 1208|      0|						&pubkey_info.direct.spki.value, &pubkey_info.direct.spki.len);
 1209|      0|				LOG_TEST_GOTO_ERR(card->ctx, r, "SPKI encode public key error");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1210|      0|			}
 1211|       |
 1212|       |			/* Only get here if no cert, and the the above found the
 1213|       |			 * pub key file (actually the SPKI version). This only
 1214|       |			 * happens when trying initializing a card and have set
 1215|       |			 * env PIV_9A_KEY or 9C, 9D, 9E to point at the file.
 1216|       |			 * Or with Yubikey 5.3+ pulling this information from
 1217|       |			 * GET METADATA instruction.
 1218|       |			 *
 1219|       |			 * We will cache it using the PKCS15 emulation objects
 1220|       |			 */
 1221|       |
 1222|      2|			pubkey_info.path.len = 0;
 1223|       |
 1224|      2|			ckis[i].key_alg = p15_key->algorithm;
 1225|      2|			switch (p15_key->algorithm) {
 1226|      2|			case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|      2|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1226:4): [True: 2, False: 0]
  ------------------
 1227|       |				/* save pubkey_len in pub and priv */
 1228|      2|				ckis[i].pubkey_len = p15_key->u.rsa.modulus.len * 8;
 1229|      2|				break;
 1230|      0|			case SC_ALGORITHM_EC:
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1230:4): [True: 0, False: 2]
  ------------------
 1231|      0|			case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1231:4): [True: 0, False: 2]
  ------------------
 1232|      0|			case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1232:4): [True: 0, False: 2]
  ------------------
 1233|      0|				ckis[i].key_alg = p15_key->algorithm;
 1234|      0|				ckis[i].pubkey_len = p15_key->u.ec.params.field_length;
 1235|      0|				break;
 1236|      0|			default:
  ------------------
  |  Branch (1236:4): [True: 0, False: 2]
  ------------------
 1237|      0|				sc_log(card->ctx, "Unsupported key_alg %lu", p15_key->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1238|      0|				continue;
 1239|      2|			}
 1240|      2|			ckis[i].pubkey_found = 1;
 1241|      2|			ckis[i].pubkey_from_file = 1;
 1242|      2|			pubkey_obj.emulated = p15_key;
 1243|      2|			p15_key = NULL;
 1244|      2|		}
 1245|  1.73k|		else if (ckis[i].pubkey_from_cert)   {
  ------------------
  |  Branch (1245:12): [True: 1.14k, False: 595]
  ------------------
 1246|  1.14k|			r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, ckis[i].pubkey_from_cert,
 1247|  1.14k|				&pubkey_info.direct.spki.value, &pubkey_info.direct.spki.len);
 1248|  1.14k|			LOG_TEST_GOTO_ERR(card->ctx, r, "SPKI encode public key error");
  ------------------
  |  |  184|  1.14k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.14k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.14k|	int _ret = (r); \
  |  |  |  |  178|  1.14k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 19, False: 1.12k]
  |  |  |  |  ------------------
  |  |  |  |  179|     19|		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|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     19|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     19|		goto err; \
  |  |  |  |  182|     19|	} \
  |  |  |  |  183|  1.14k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.12k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1249|       |
 1250|  1.12k|			pubkey_obj.emulated = ckis[i].pubkey_from_cert;
 1251|  1.12k|			ckis[i].pubkey_from_cert = NULL;
 1252|  1.12k|		}
 1253|       |
 1254|  1.71k|		sc_log(card->ctx, "adding pubkey for %d keyalg=%lu", i, ckis[i].key_alg);
  ------------------
  |  |   71|  1.71k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1255|  1.71k|		switch (ckis[i].key_alg) {
 1256|     96|		case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|     96|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1256:3): [True: 96, False: 1.62k]
  ------------------
 1257|     96|			if (ckis[i].cert_keyUsage_present) {
  ------------------
  |  Branch (1257:8): [True: 0, False: 96]
  ------------------
 1258|      0|				pubkey_info.usage = ckis[i].pub_usage;
 1259|     96|			} else {
 1260|     96|				pubkey_info.usage = pubkeys[i].usage_rsa;
 1261|     96|			}
 1262|     96|			pubkey_info.modulus_length = ckis[i].pubkey_len;
 1263|     96|			strncpy(pubkey_obj.label, pubkeys[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|     96|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
 1264|       |
 1265|       |			/* should not fail */
 1266|     96|			r = sc_pkcs15emu_add_rsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
 1267|     96|			LOG_TEST_GOTO_ERR(card->ctx, r, "Failed to add RSA pubkey");
  ------------------
  |  |  184|     96|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     96|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     96|	int _ret = (r); \
  |  |  |  |  178|     96|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 96]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|     96|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1268|       |
 1269|     96|			ckis[i].pubkey_found = 1;
 1270|     96|			break;
 1271|  1.02k|		case SC_ALGORITHM_EC:
  ------------------
  |  |   70|  1.02k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1271:3): [True: 1.02k, False: 691]
  ------------------
 1272|  1.02k|		case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|  1.02k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1272:3): [True: 0, False: 1.71k]
  ------------------
 1273|  1.02k|		case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|  1.02k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1273:3): [True: 0, False: 1.71k]
  ------------------
 1274|  1.02k|			if (ckis[i].cert_keyUsage_present) {
  ------------------
  |  Branch (1274:8): [True: 0, False: 1.02k]
  ------------------
 1275|      0|				pubkey_info.usage = ckis[i].pub_usage;
 1276|  1.02k|			} else {
 1277|  1.02k|				pubkey_info.usage = pubkeys[i].usage_ec;
 1278|  1.02k|			}
 1279|       |
 1280|  1.02k|			pubkey_info.field_length = ckis[i].pubkey_len;
 1281|  1.02k|			strncpy(pubkey_obj.label, pubkeys[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|  1.02k|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
 1282|       |
 1283|       |			/* should not fail */
 1284|       |
 1285|  1.02k|			if (ckis[i].key_alg == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   72|  1.02k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1285:8): [True: 0, False: 1.02k]
  ------------------
 1286|      0|				r = sc_pkcs15emu_add_eddsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
 1287|  1.02k|			else if (ckis[i].key_alg == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|  1.02k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1287:13): [True: 0, False: 1.02k]
  ------------------
 1288|      0|				r = sc_pkcs15emu_add_xeddsa_pubkey(p15card, &pubkey_obj, &pubkey_info);
 1289|  1.02k|			else
 1290|  1.02k|				r = sc_pkcs15emu_add_ec_pubkey(p15card, &pubkey_obj, &pubkey_info);
 1291|       |
 1292|  1.02k|			LOG_TEST_GOTO_ERR(card->ctx, r, "Failed to add EC pubkey");
  ------------------
  |  |  184|  1.02k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.02k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.02k|	int _ret = (r); \
  |  |  |  |  178|  1.02k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.02k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  1.02k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.02k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1293|       |
 1294|  1.02k|			ckis[i].pubkey_found = 1;
 1295|  1.02k|			break;
 1296|    595|		default:
  ------------------
  |  Branch (1296:3): [True: 595, False: 1.12k]
  ------------------
 1297|    595|			sc_log(card->ctx, "key_alg %lu not supported", ckis[i].key_alg);
  ------------------
  |  |   71|    595|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1298|    595|			continue;
 1299|  1.71k|		}
 1300|  1.12k|		sc_log(card->ctx, "USAGE: cert_keyUsage_present:%d usage:0x%8.8x",
  ------------------
  |  |   71|  1.12k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1301|  1.12k|				ckis[i].cert_keyUsage_present, pubkey_info.usage);
 1302|  1.12k|	}
 1303|       |
 1304|       |
 1305|       |	/* set private keys */
 1306|  1.21k|	sc_log(card->ctx,  "PIV-II adding private keys...");
  ------------------
  |  |   71|  1.21k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1307|  30.2k|	for (i = 0; i < PIV_NUM_KEYS; i++) {
  ------------------
  |  |  371|  30.2k|#define PIV_NUM_KEYS  24
  ------------------
  |  Branch (1307:14): [True: 29.0k, False: 1.21k]
  ------------------
 1308|  29.0k|		struct sc_pkcs15_prkey_info prkey_info;
 1309|  29.0k|		struct sc_pkcs15_object     prkey_obj;
 1310|  29.0k|		u8 pin_policy = prkeys[i].ref;
 1311|       |
 1312|  29.0k|		memset(&prkey_info, 0, sizeof(prkey_info));
 1313|  29.0k|		memset(&prkey_obj,  0, sizeof(prkey_obj));
 1314|       |
 1315|  29.0k|		if (ckis[i].cert_found == 0 && ckis[i].pubkey_found == 0)
  ------------------
  |  Branch (1315:7): [True: 27.3k, False: 1.69k]
  |  Branch (1315:34): [True: 27.3k, False: 2]
  ------------------
 1316|  27.3k|			continue; /* i.e. no cert or pubkey */
 1317|       |
 1318|  1.69k|		sc_pkcs15_format_id(prkeys[i].id, &prkey_info.id);
 1319|  1.69k|		prkey_info.native        = 1;
 1320|  1.69k|		prkey_info.key_reference = prkeys[i].ref;
 1321|  1.69k|		sc_format_path(prkeys[i].path, &prkey_info.path);
 1322|       |
 1323|  1.69k|		strncpy(prkey_obj.label, prkeys[i].label, SC_PKCS15_MAX_LABEL_SIZE - 1);
  ------------------
  |  |   35|  1.69k|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
 1324|  1.69k|		prkey_obj.flags = prkeys[i].obj_flags;
 1325|  1.69k|		prkey_obj.user_consent = prkeys[i].user_consent; /* only Sign key */
 1326|       |
 1327|  1.69k|		r = sc_card_ctl(p15card->card, SC_CARDCTL_PIV_YK_PIN_POLICY, &pin_policy);
 1328|  1.69k|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  1.69k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1328:7): [True: 16, False: 1.68k]
  ------------------
 1329|     16|			switch (pin_policy) {
 1330|      1|			case 0x01:
  ------------------
  |  Branch (1330:4): [True: 1, False: 15]
  ------------------
 1331|      1|				prkey_obj.flags &= ~SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      1|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 1332|      1|				sc_log(card->ctx, "PIN is never checked");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1333|      1|				break;
 1334|      1|			case 0x02:
  ------------------
  |  Branch (1334:4): [True: 1, False: 15]
  ------------------
 1335|      1|				prkey_obj.user_consent = 0;
 1336|      1|				sc_pkcs15_format_id(prkeys[i].auth_id, &prkey_obj.auth_id);
 1337|      1|				sc_log(card->ctx, "PIN is checked once for the session");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1338|      1|				break;
 1339|      1|			case 0x03:
  ------------------
  |  Branch (1339:4): [True: 1, False: 15]
  ------------------
 1340|      1|				prkey_obj.user_consent = 1;
 1341|      1|				sc_pkcs15_format_id(prkeys[i].auth_id, &prkey_obj.auth_id);
 1342|      1|				sc_log(card->ctx, "PIN is verified just before operation");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1343|      1|				break;
 1344|     12|			case 0x00:
  ------------------
  |  Branch (1344:4): [True: 12, False: 4]
  ------------------
 1345|     13|			default:
  ------------------
  |  Branch (1345:4): [True: 1, False: 15]
  ------------------
 1346|     13|				sc_pkcs15_format_id(prkeys[i].auth_id, &prkey_obj.auth_id);
 1347|     13|				break;
 1348|     16|			}
 1349|     16|		} else
 1350|  1.68k|			sc_pkcs15_format_id(prkeys[i].auth_id, &prkey_obj.auth_id);
 1351|       |
 1352|       |		/* If using minidriver, use Sign PIN  for 9C key */
 1353|  1.69k|		if (prkey_obj.user_consent && (strcmp(card->ctx->app_name, "cardmod") == 0))
  ------------------
  |  Branch (1353:7): [True: 241, False: 1.45k]
  |  Branch (1353:33): [True: 0, False: 241]
  ------------------
 1354|      0|			sc_pkcs15_format_id("03", &prkey_obj.auth_id);
 1355|       |
 1356|       |		/*
 1357|       |		 * When no cert is present and a pubkey in a file was found,
 1358|       |		 * means the caller is initializing a card. A sign operation
 1359|       |		 * will be required to sign a certificate request even if
 1360|       |		 * normal usage would not allow it. Set SC_PKCS15_PRKEY_USAGE_SIGN
 1361|       |		 * TODO if code is added to allow key generation and request
 1362|       |		 * sign in the same session, similar code will be needed.
 1363|       |		 * Exclude XEDDSA keys as they are not signing capable
 1364|       |		 */
 1365|       |
 1366|  1.69k|		if (ckis[i].pubkey_from_file == 1) {
  ------------------
  |  Branch (1366:7): [True: 2, False: 1.69k]
  ------------------
 1367|      2|			switch (ckis[i].key_alg) {
 1368|      0|			case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1368:4): [True: 0, False: 2]
  ------------------
 1369|      0|				break;
 1370|      2|			default:
  ------------------
  |  Branch (1370:4): [True: 2, False: 0]
  ------------------
 1371|      2|				prkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|      2|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
 1372|      2|				sc_log(card->ctx, "Adding SC_PKCS15_PRKEY_USAGE_SIGN");
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1373|      2|				break;
 1374|      2|			}
 1375|      2|		}
 1376|       |
 1377|  1.69k|		if (ckis[i].cert_keyUsage_present) {
  ------------------
  |  Branch (1377:7): [True: 0, False: 1.69k]
  ------------------
 1378|      0|			prkey_info.usage |= ckis[i].priv_usage;
 1379|       |			/* If retired key and non gov cert has NONREPUDIATION, treat as user_consent */
 1380|      0|			if (i >= 4 && (ckis[i].priv_usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION)) {
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  |  Branch (1380:8): [True: 0, False: 0]
  |  Branch (1380:18): [True: 0, False: 0]
  ------------------
 1381|      0|				prkey_obj.user_consent = 1;
 1382|      0|			}
 1383|      0|		}
 1384|       |
 1385|  1.69k|		switch (ckis[i].key_alg) {
 1386|     88|		case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|     88|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1386:3): [True: 88, False: 1.61k]
  ------------------
 1387|     88|			if (!ckis[i].cert_keyUsage_present) {
  ------------------
  |  Branch (1387:8): [True: 88, False: 0]
  ------------------
 1388|     88|				prkey_info.usage |= prkeys[i].usage_rsa;
 1389|     88|			}
 1390|     88|			prkey_info.modulus_length = ckis[i].pubkey_len;
 1391|     88|			r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
 1392|     88|			break;
 1393|  1.01k|		case SC_ALGORITHM_EC:
  ------------------
  |  |   70|  1.01k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1393:3): [True: 1.01k, False: 681]
  ------------------
 1394|  1.01k|		case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|  1.01k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1394:3): [True: 0, False: 1.69k]
  ------------------
 1395|  1.01k|		case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|  1.01k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1395:3): [True: 0, False: 1.69k]
  ------------------
 1396|  1.01k|			if (!ckis[i].cert_keyUsage_present) {
  ------------------
  |  Branch (1396:8): [True: 1.01k, False: 0]
  ------------------
 1397|  1.01k|				prkey_info.usage |= prkeys[i].usage_ec;
 1398|  1.01k|			}
 1399|  1.01k|			prkey_info.field_length = ckis[i].pubkey_len;
 1400|  1.01k|			sc_log(card->ctx, "DEE added key_alg %2.2lx prkey_obj.flags %8.8x",
  ------------------
  |  |   71|  1.01k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1401|  1.01k|					ckis[i].key_alg, prkey_obj.flags);
 1402|       |
 1403|  1.01k|			if (ckis[i].key_alg == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   72|  1.01k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1403:8): [True: 0, False: 1.01k]
  ------------------
 1404|      0|				r = sc_pkcs15emu_add_eddsa_prkey(p15card, &prkey_obj, &prkey_info);
 1405|  1.01k|			else if (ckis[i].key_alg == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|  1.01k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1405:13): [True: 0, False: 1.01k]
  ------------------
 1406|      0|				r = sc_pkcs15emu_add_xeddsa_prkey(p15card, &prkey_obj, &prkey_info);
 1407|  1.01k|			else
 1408|  1.01k|				r = sc_pkcs15emu_add_ec_prkey(p15card, &prkey_obj, &prkey_info);
 1409|  1.01k|			break;
 1410|    593|		default:
  ------------------
  |  Branch (1410:3): [True: 593, False: 1.10k]
  ------------------
 1411|    593|			sc_log(card->ctx, "Unsupported key_alg %lu", ckis[i].key_alg);
  ------------------
  |  |   71|    593|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1412|    593|			r = 0; /* we just skip this one */
 1413|  1.69k|		}
 1414|  1.69k|		sc_log(card->ctx, "USAGE: cert_keyUsage_present:%d usage:0x%8.8x", ckis[i].cert_keyUsage_present, prkey_info.usage);
  ------------------
  |  |   71|  1.69k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1415|  1.69k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Failed to add Private key");
  ------------------
  |  |  184|  1.69k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.69k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.69k|	int _ret = (r); \
  |  |  |  |  178|  1.69k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.69k]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|  1.69k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.69k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1416|  1.69k|	}
 1417|       |
 1418|  1.21k|	p15card->ops.get_guid = piv_get_guid;
 1419|       |
 1420|  1.21k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.21k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.21k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.21k|	int _ret = r; \
  |  |  |  |  155|  1.21k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.21k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.21k|		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: 1.21k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.21k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.21k|	} 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|  1.21k|	return _ret; \
  |  |  |  |  163|  1.21k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1421|     19|err:
 1422|    494|	for (i = 0; i < PIV_NUM_CERTS; i++) {
  ------------------
  |  |  370|    494|#define PIV_NUM_CERTS 25
  ------------------
  |  Branch (1422:14): [True: 475, False: 19]
  ------------------
 1423|    475|		sc_pkcs15_free_pubkey(ckis[i].pubkey_from_cert);
 1424|    475|	}
 1425|     19|	sc_pkcs15_card_clear(p15card);
 1426|     19|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     19|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     19|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     19|	int _ret = r; \
  |  |  |  |  155|     19|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 19, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     19|		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|     19|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 19, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     19|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     19|	} 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|     19|	return _ret; \
  |  |  |  |  163|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1427|     19|}
pkcs15-piv.c:yk_copy_pubkey_from_tag:
  249|      9|{
  250|      9|	const unsigned char *p;
  251|      9|	unsigned int cla, tag;
  252|      9|	size_t tag_len;
  253|      9|	int r;
  254|       |
  255|      9|	p = info->pubkey.value;
  256|      9|	r = sc_asn1_read_tag(&p, info->pubkey.len, &cla, &tag, &tag_len);
  257|      9|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      9|#define SC_SUCCESS				0
  ------------------
  |  Branch (257:6): [True: 1, False: 8]
  ------------------
  258|      1|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|      1|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
  259|      1|	}
  260|      8|	if ((tag | cla) != tag_exp) {
  ------------------
  |  Branch (260:6): [True: 8, False: 0]
  ------------------
  261|      8|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      8|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  262|      8|	}
  263|      0|	dst->value = malloc(tag_len);
  264|      0|	if (dst->value == NULL) {
  ------------------
  |  Branch (264:6): [True: 0, False: 0]
  ------------------
  265|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  266|      0|	}
  267|      0|	memcpy(dst->value, p, tag_len);
  268|      0|	dst->len = tag_len;
  269|       |
  270|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  271|      0|}

sc_pkcs15_decode_prkdf_entry:
  156|     20|{
  157|     20|	sc_context_t *ctx = p15card->card->ctx;
  158|     20|	struct sc_pkcs15_prkey_info info;
  159|     20|	int r, i, gostr3410_params[3];
  160|     20|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
  161|     20|	size_t usage_len = sizeof(info.usage);
  162|     20|	size_t af_len = sizeof(info.access_flags);
  163|     20|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  164|     20|	struct sc_asn1_entry asn1_com_prkey_attr[C_ASN1_COM_PRKEY_ATTR_SIZE];
  165|     20|	struct sc_asn1_entry asn1_rsakey_attr[C_ASN1_RSAKEY_ATTR_SIZE];
  166|     20|	struct sc_asn1_entry asn1_prk_rsa_attr[C_ASN1_PRK_RSA_ATTR_SIZE];
  167|     20|	struct sc_asn1_entry asn1_gostr3410key_attr[C_ASN1_GOSTR3410KEY_ATTR_SIZE];
  168|     20|	struct sc_asn1_entry asn1_prk_gostr3410_attr[C_ASN1_PRK_GOSTR3410_ATTR_SIZE];
  169|     20|	struct sc_asn1_entry asn1_ecckey_attr[C_ASN1_ECCKEY_ATTR];
  170|     20|	struct sc_asn1_entry asn1_prk_ecc_attr[C_ASN1_PRK_ECC_ATTR];
  171|     20|	struct sc_asn1_entry asn1_prkey[C_ASN1_PRKEY_SIZE];
  172|     20|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  173|     20|	struct sc_asn1_pkcs15_object rsa_prkey_obj = {obj, asn1_com_key_attr, asn1_com_prkey_attr, asn1_prk_rsa_attr};
  174|     20|	struct sc_asn1_pkcs15_object gostr3410_prkey_obj = {obj, asn1_com_key_attr, asn1_com_prkey_attr, asn1_prk_gostr3410_attr};
  175|     20|	struct sc_asn1_pkcs15_object ecc_prkey_obj = { obj, asn1_com_key_attr, asn1_com_prkey_attr, asn1_prk_ecc_attr };
  176|     20|	u8 ec_domain[32];
  177|     20|	size_t ec_domain_len = sizeof(ec_domain);
  178|       |
  179|     20|	sc_copy_asn1_entry(c_asn1_prkey, asn1_prkey);
  180|     20|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  181|       |
  182|     20|	sc_copy_asn1_entry(c_asn1_prk_rsa_attr, asn1_prk_rsa_attr);
  183|     20|	sc_copy_asn1_entry(c_asn1_rsakey_attr, asn1_rsakey_attr);
  184|     20|	sc_copy_asn1_entry(c_asn1_prk_gostr3410_attr, asn1_prk_gostr3410_attr);
  185|     20|	sc_copy_asn1_entry(c_asn1_gostr3410key_attr, asn1_gostr3410key_attr);
  186|     20|	sc_copy_asn1_entry(c_asn1_prk_ecc_attr, asn1_prk_ecc_attr);
  187|     20|	sc_copy_asn1_entry(c_asn1_ecckey_attr, asn1_ecckey_attr);
  188|       |
  189|     20|	sc_copy_asn1_entry(c_asn1_com_prkey_attr, asn1_com_prkey_attr);
  190|     20|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  191|       |
  192|     20|	sc_format_asn1_entry(asn1_prkey + 0, &rsa_prkey_obj, NULL, 0);
  193|     20|	sc_format_asn1_entry(asn1_prkey + 1, &ecc_prkey_obj, NULL, 0);
  194|     20|	sc_format_asn1_entry(asn1_prkey + 2, &gostr3410_prkey_obj, NULL, 0);
  195|       |
  196|     20|	sc_format_asn1_entry(asn1_prk_rsa_attr + 0, asn1_rsakey_attr, NULL, 0);
  197|     20|	sc_format_asn1_entry(asn1_prk_gostr3410_attr + 0, asn1_gostr3410key_attr, NULL, 0);
  198|     20|	sc_format_asn1_entry(asn1_prk_ecc_attr + 0, asn1_ecckey_attr, NULL, 0);
  199|       |
  200|     20|	sc_format_asn1_entry(asn1_rsakey_attr + 0, &info.path, NULL, 0);
  201|     20|	sc_format_asn1_entry(asn1_rsakey_attr + 1, &info.modulus_length, NULL, 0);
  202|       |
  203|     20|	sc_format_asn1_entry(asn1_gostr3410key_attr + 0, &info.path, NULL, 0);
  204|     20|	sc_format_asn1_entry(asn1_gostr3410key_attr + 1, &gostr3410_params[0], NULL, 0);
  205|     20|	sc_format_asn1_entry(asn1_gostr3410key_attr + 2, &gostr3410_params[1], NULL, 0);
  206|     20|	sc_format_asn1_entry(asn1_gostr3410key_attr + 3, &gostr3410_params[2], NULL, 0);
  207|       |
  208|     20|	sc_format_asn1_entry(asn1_ecckey_attr + 0, &info.path, NULL, 0);
  209|     20|	sc_format_asn1_entry(asn1_ecckey_attr + 1, &info.field_length, NULL, 0);
  210|     20|	sc_format_asn1_entry(asn1_ecckey_attr + 3, ec_domain, &ec_domain_len, 0);
  211|       |
  212|     20|	sc_format_asn1_entry(asn1_com_key_attr + 0, &info.id, NULL, 0);
  213|     20|	sc_format_asn1_entry(asn1_com_key_attr + 1, &info.usage, &usage_len, 0);
  214|     20|	sc_format_asn1_entry(asn1_com_key_attr + 2, &info.native, NULL, 0);
  215|     20|	sc_format_asn1_entry(asn1_com_key_attr + 3, &info.access_flags, &af_len, 0);
  216|     20|	sc_format_asn1_entry(asn1_com_key_attr + 4, &info.key_reference, NULL, 0);
  217|       |
  218|    340|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && (asn1_supported_algorithms + i)->name; i++)
  ------------------
  |  |   61|    680|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (218:12): [True: 320, False: 20]
  |  Branch (218:45): [True: 320, False: 0]
  ------------------
  219|    320|		sc_format_asn1_entry(asn1_supported_algorithms + i, &info.algo_refs[i], NULL, 0);
  220|     20|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, 0);
  221|       |
  222|     20|	sc_format_asn1_entry(asn1_com_prkey_attr + 0, &info.subject.value, &info.subject.len, 0);
  223|       |
  224|       |	/* Fill in defaults */
  225|     20|	memset(&info, 0, sizeof(info));
  226|     20|	info.key_reference = -1;
  227|     20|	info.native = 1;
  228|     20|	memset(gostr3410_params, 0, sizeof(gostr3410_params));
  229|       |
  230|     20|	r = sc_asn1_decode_choice(ctx, asn1_prkey, *buf, *buflen, buf, buflen);
  231|     20|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|     20|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (231:6): [True: 1, False: 19]
  ------------------
  232|      1|		goto err;
  233|     19|	LOG_TEST_GOTO_ERR(ctx, r, "PrKey DF ASN.1 decoding failed");
  ------------------
  |  |  184|     19|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     19|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     19|	int _ret = (r); \
  |  |  |  |  178|     19|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 16, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  179|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     16|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     16|		goto err; \
  |  |  |  |  182|     16|	} \
  |  |  |  |  183|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|      3|	if (asn1_prkey[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      3|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (234:6): [True: 0, False: 3]
  ------------------
  235|      0|		obj->type = SC_PKCS15_TYPE_PRKEY_RSA;
  ------------------
  |  |  419|      0|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  236|      0|	}
  237|      3|	else if (asn1_prkey[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      3|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (237:11): [True: 0, False: 3]
  ------------------
  238|      0|		obj->type = SC_PKCS15_TYPE_PRKEY_EC;
  ------------------
  |  |  421|      0|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  239|      0|#ifdef ENABLE_OPENSSL
  240|      0|		if (!(asn1_ecckey_attr[1].flags & SC_ASN1_PRESENT) && (asn1_ecckey_attr[3].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
              		if (!(asn1_ecckey_attr[1].flags & SC_ASN1_PRESENT) && (asn1_ecckey_attr[3].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (240:7): [True: 0, False: 0]
  |  Branch (240:57): [True: 0, False: 0]
  ------------------
  241|      0|			const unsigned char *p = ec_domain;
  242|      0|			ASN1_OBJECT *object = d2i_ASN1_OBJECT(NULL, &p, ec_domain_len);
  243|      0|			int nid;
  244|      0|			EC_GROUP *group;
  245|      0|			if (!object) {
  ------------------
  |  Branch (245:8): [True: 0, False: 0]
  ------------------
  246|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  247|      0|				goto err;
  248|      0|			}
  249|      0|			nid = OBJ_obj2nid(object);
  250|      0|			ASN1_OBJECT_free(object);
  251|      0|			if (nid == NID_undef) {
  ------------------
  |  Branch (251:8): [True: 0, False: 0]
  ------------------
  252|      0|				sc_log_openssl(ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  253|      0|				r = SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  254|      0|				goto err;
  255|      0|			}
  256|      0|			group = EC_GROUP_new_by_curve_name(nid);
  257|      0|			if (!group) {
  ------------------
  |  Branch (257:8): [True: 0, False: 0]
  ------------------
  258|      0|				sc_log_openssl(ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  259|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  260|      0|				goto err;
  261|      0|			}
  262|      0|			info.field_length = EC_GROUP_order_bits(group);
  263|      0|			EC_GROUP_free(group);
  264|      0|			if (!info.field_length) {
  ------------------
  |  Branch (264:8): [True: 0, False: 0]
  ------------------
  265|      0|				sc_log_openssl(ctx);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  266|      0|				r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      0|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  267|      0|				goto err;
  268|      0|			}
  269|      0|		}
  270|      0|#endif
  271|      0|	}
  272|      3|	else if (asn1_prkey[2].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      3|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (272:11): [True: 0, False: 3]
  ------------------
  273|       |		/* FIXME proper handling of gost parameters without the need of
  274|       |		 * allocating data here. this would also make sc_pkcs15_free_key_params
  275|       |		 * obsolete */
  276|      0|		obj->type = SC_PKCS15_TYPE_PRKEY_GOSTR3410;
  ------------------
  |  |  420|      0|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  277|      0|		if (info.modulus_length != 0 || info.params.len != 0) {
  ------------------
  |  Branch (277:7): [True: 0, False: 0]
  |  Branch (277:35): [True: 0, False: 0]
  ------------------
  278|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  279|      0|			goto err;
  280|      0|		}
  281|      0|		info.modulus_length = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      0|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
  282|      0|		info.params.len = sizeof(struct sc_pkcs15_keyinfo_gostparams);
  283|      0|		info.params.data = malloc(info.params.len);
  284|      0|		if (info.params.data == NULL) {
  ------------------
  |  Branch (284:7): [True: 0, False: 0]
  ------------------
  285|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  286|      0|			goto err;
  287|      0|		}
  288|      0|		keyinfo_gostparams = info.params.data;
  289|      0|		keyinfo_gostparams->gostr3410 = gostr3410_params[0];
  290|      0|		keyinfo_gostparams->gostr3411 = gostr3410_params[1];
  291|      0|		keyinfo_gostparams->gost28147 = gostr3410_params[2];
  292|      0|	}
  293|      3|	else {
  294|      3|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      3|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  295|      3|		LOG_TEST_GOTO_ERR(ctx, r, "Neither RSA or GOSTR3410 or ECC key in PrKDF entry.");
  ------------------
  |  |  184|      3|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      3|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      3|	int _ret = (r); \
  |  |  |  |  178|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      3|		goto err; \
  |  |  |  |  182|      3|	} \
  |  |  |  |  183|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  296|      3|	}
  297|       |
  298|      0|	if (!p15card->app || !p15card->app->ddo.aid.len) {
  ------------------
  |  Branch (298:6): [True: 0, False: 0]
  |  Branch (298:23): [True: 0, False: 0]
  ------------------
  299|      0|		if (!p15card->file_app) {
  ------------------
  |  Branch (299:7): [True: 0, False: 0]
  ------------------
  300|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  301|      0|			goto err;
  302|      0|		}
  303|      0|		r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path);
  304|      0|		if (r < 0) {
  ------------------
  |  Branch (304:7): [True: 0, False: 0]
  ------------------
  305|      0|			goto err;
  306|      0|		}
  307|      0|	}
  308|      0|	else   {
  309|      0|		info.path.aid = p15card->app->ddo.aid;
  310|      0|	}
  311|      0|	sc_log(ctx, "PrivKey path '%s'", sc_print_path(&info.path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  312|       |
  313|       |	/* OpenSC 0.11.4 and older encoded "keyReference" as a negative value.
  314|       |	 * Fixed in 0.11.5 we need to add a hack, so old cards continue to work. */
  315|      0|	if (info.key_reference < -1)
  ------------------
  |  Branch (315:6): [True: 0, False: 0]
  ------------------
  316|      0|		info.key_reference += 256;
  317|       |
  318|       |	/* Check the auth_id - if not present, try and find it in access rules */
  319|      0|	if ((obj->flags & SC_PKCS15_CO_FLAG_PRIVATE) && (obj->auth_id.len == 0)) {
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (319:6): [True: 0, False: 0]
  |  Branch (319:50): [True: 0, False: 0]
  ------------------
  320|      0|		sc_log(ctx, "Private key %s has no auth ID - checking AccessControlRules",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  321|      0|				sc_pkcs15_print_id(&info.id));
  322|       |
  323|       |		/* Search in the access_rules for an appropriate auth ID */
  324|      0|		for (i = 0; i < SC_PKCS15_MAX_ACCESS_RULES; i++) {
  ------------------
  |  |   42|      0|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (324:15): [True: 0, False: 0]
  ------------------
  325|       |			/* If access_mode is one of the private key usage modes */
  326|      0|			if (obj->access_rules[i].access_mode &
  ------------------
  |  Branch (326:8): [True: 0, False: 0]
  ------------------
  327|      0|					(SC_PKCS15_ACCESS_RULE_MODE_EXECUTE |
  ------------------
  |  |  337|      0|#define SC_PKCS15_ACCESS_RULE_MODE_EXECUTE      0x04
  ------------------
  328|      0|					 SC_PKCS15_ACCESS_RULE_MODE_PSO_CDS |
  ------------------
  |  |  340|      0|#define SC_PKCS15_ACCESS_RULE_MODE_PSO_CDS      0x20
  ------------------
  329|      0|					 SC_PKCS15_ACCESS_RULE_MODE_PSO_DECRYPT |
  ------------------
  |  |  342|      0|#define SC_PKCS15_ACCESS_RULE_MODE_PSO_DECRYPT  0x80
  ------------------
  330|      0|					 SC_PKCS15_ACCESS_RULE_MODE_INT_AUTH)) {
  ------------------
  |  |  344|      0|#define SC_PKCS15_ACCESS_RULE_MODE_INT_AUTH     0x200
  ------------------
  331|      0|				if (obj->access_rules[i].auth_id.len != 0) {
  ------------------
  |  Branch (331:9): [True: 0, False: 0]
  ------------------
  332|       |					/* Found an auth ID to use for private key access */
  333|      0|					obj->auth_id = obj->access_rules[i].auth_id;
  334|      0|					sc_log(ctx, "Auth ID found - %s",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  335|      0|						 sc_pkcs15_print_id(&obj->auth_id));
  336|      0|					break;
  337|      0|				}
  338|      0|			}
  339|      0|		}
  340|       |
  341|       |		/* No auth ID found */
  342|      0|		if (i == SC_PKCS15_MAX_ACCESS_RULES)
  ------------------
  |  |   42|      0|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (342:7): [True: 0, False: 0]
  ------------------
  343|      0|			sc_log(ctx, "Warning: No auth ID found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  344|      0|	}
  345|       |
  346|      0|	obj->data = malloc(sizeof(info));
  347|      0|	if (obj->data == NULL) {
  ------------------
  |  Branch (347:6): [True: 0, False: 0]
  ------------------
  348|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  349|      0|		goto err;
  350|      0|	}
  351|      0|	memcpy(obj->data, &info, sizeof(info));
  352|       |
  353|      0|	sc_log(ctx, "Key Subject %s", sc_dump_hex(info.subject.value, info.subject.len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  354|      0|	sc_log(ctx, "Key path %s", sc_print_path(&info.path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  355|       |
  356|      0|	r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  357|       |
  358|     20|err:
  359|     20|	if (r < 0) {
  ------------------
  |  Branch (359:6): [True: 20, False: 0]
  ------------------
  360|       |		/* This might have allocated something. If so, clear it now */
  361|     20|		free(info.subject.value);
  362|     20|		sc_pkcs15_free_key_params(&info.params);
  363|     20|	}
  364|       |
  365|     20|	return r;
  366|      0|}
sc_pkcs15_free_prkey_info:
  592|  3.87k|{
  593|  3.87k|	if (!key)
  ------------------
  |  Branch (593:6): [True: 0, False: 3.87k]
  ------------------
  594|      0|		return;
  595|       |
  596|  3.87k|	if (key->subject.value)
  ------------------
  |  Branch (596:6): [True: 0, False: 3.87k]
  ------------------
  597|      0|		free(key->subject.value);
  598|       |
  599|  3.87k|	sc_pkcs15_free_key_params(&key->params);
  600|       |
  601|  3.87k|	sc_aux_data_free(&key->aux_data);
  602|       |
  603|  3.87k|	free(key);
  604|  3.87k|}

sc_pkcs15emu_pteid_init_ex:
  349|  12.9k|{
  350|  12.9k|	int r=SC_SUCCESS;
  ------------------
  |  |   28|  12.9k|#define SC_SUCCESS				0
  ------------------
  351|  12.9k|	sc_context_t *ctx = p15card->card->ctx;
  352|  12.9k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  12.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  12.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  12.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  12.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 12.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|       |	/* check for proper card */
  355|  12.9k|	r = pteid_detect_card(p15card->card);
  356|  12.9k|	if (r == SC_ERROR_WRONG_CARD)
  ------------------
  |  |   94|  12.9k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  |  Branch (356:6): [True: 12.3k, False: 661]
  ------------------
  357|  12.9k|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  12.3k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  12.3k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  12.3k|	int _ret = r; \
  |  |  |  |  155|  12.3k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  12.3k|		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|  12.3k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 12.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  12.3k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  12.3k|	} 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|  12.3k|	return _ret; \
  |  |  |  |  163|  12.3k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  358|       |	/* ok: initialize and return */
  359|    661|	LOG_FUNC_RETURN(ctx, sc_pkcs15emu_pteid_init(p15card));
  ------------------
  |  |  164|    661|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    661|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    661|	int _ret = r; \
  |  |  |  |  155|    661|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 661, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    661|		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|    630|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 630, False: 31]
  |  |  |  |  ------------------
  |  |  |  |  157|    661|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    661|	} 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|    661|	return _ret; \
  |  |  |  |  163|    661|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  360|    661|}
pkcs15-pteid.c:pteid_detect_card:
  342|  13.6k|{
  343|  13.6k|	if (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID)
  ------------------
  |  Branch (343:6): [True: 1.32k, False: 12.3k]
  ------------------
  344|  1.32k|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.32k|#define SC_SUCCESS				0
  ------------------
  345|  12.3k|	return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.3k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  346|  13.6k|}
pkcs15-pteid.c:sc_pkcs15emu_pteid_init:
  143|    661|{
  144|    661|	u8 buf[1024];
  145|    661|	sc_pkcs15_df_t *df;
  146|    661|	sc_pkcs15_object_t *p15_obj;
  147|    661|	sc_path_t path;
  148|    661|	struct sc_file *file = NULL;
  149|    661|	size_t len;
  150|    661|	int rv;
  151|    661|	int i;
  152|       |
  153|    661|	sc_context_t *ctx = p15card->card->ctx;
  154|    661|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    661|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    661|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    661|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    661|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 661]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  155|       |
  156|       |	/* Check for correct card atr */
  157|    661|	if (pteid_detect_card(p15card->card) != SC_SUCCESS)
  ------------------
  |  |   28|    661|#define SC_SUCCESS				0
  ------------------
  |  Branch (157:6): [True: 0, False: 661]
  ------------------
  158|      0|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  159|       |
  160|    661|	sc_log(p15card->card->ctx, "Selecting application DF");
  ------------------
  |  |   71|    661|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  161|    661|	sc_format_path("4F00", &path);
  162|    661|	rv = sc_select_file(p15card->card, &path, &file);
  163|    661|	if (rv != SC_SUCCESS || !file)
  ------------------
  |  |   28|  1.32k|#define SC_SUCCESS				0
  ------------------
  |  Branch (163:6): [True: 486, False: 175]
  |  Branch (163:26): [True: 0, False: 175]
  ------------------
  164|    486|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    486|#define SC_ERROR_INTERNAL			-1400
  ------------------
  165|       |	/* set the application DF */
  166|    175|	sc_file_free(p15card->file_app);
  167|    175|	p15card->file_app = file;
  168|       |
  169|       |	/* Load TokenInfo */
  170|    175|	len = sizeof(buf);
  171|    175|	rv = dump_ef(p15card->card, "4F005032", buf, &len);
  172|    175|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    175|#define SC_SUCCESS				0
  ------------------
  |  Branch (172:6): [True: 88, False: 87]
  ------------------
  173|     88|		sc_log(ctx, "Reading of EF.TOKENINFO failed: %d", rv);
  ------------------
  |  |   71|     88|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  174|     88|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     88|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     88|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     88|	int _ret = r; \
  |  |  |  |  155|     88|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 88, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     88|		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|     88|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 88, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     88|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     88|	} 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|     88|	return _ret; \
  |  |  |  |  163|     88|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|     88|	}
  176|     87|	rv = sc_pkcs15_parse_tokeninfo(p15card->card->ctx, p15card->tokeninfo,
  177|     87|				       buf, len);
  178|     87|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|     87|#define SC_SUCCESS				0
  ------------------
  |  Branch (178:6): [True: 35, False: 52]
  ------------------
  179|     35|		sc_log(ctx, "Decoding of EF.TOKENINFO failed: %d", rv);
  ------------------
  |  |   71|     35|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  180|     35|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     35|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     35|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     35|	int _ret = r; \
  |  |  |  |  155|     35|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 35, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     35|		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|     35|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 35, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     35|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     35|	} 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|     35|	return _ret; \
  |  |  |  |  163|     35|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  181|     35|	}
  182|       |
  183|     52|	p15card->tokeninfo->flags |= SC_PKCS15_TOKEN_PRN_GENERATION
  ------------------
  |  |  597|     52|#define SC_PKCS15_TOKEN_PRN_GENERATION			0x04
  ------------------
  184|     52|				  | SC_PKCS15_TOKEN_EID_COMPLIANT
  ------------------
  |  |  598|     52|#define SC_PKCS15_TOKEN_EID_COMPLIANT			0x08
  ------------------
  185|     52|				  | SC_PKCS15_TOKEN_READONLY;
  ------------------
  |  |  595|     52|#define SC_PKCS15_TOKEN_READONLY			0x01
  ------------------
  186|       |
  187|       |	/* Load ODF */
  188|     52|	len = sizeof(buf);
  189|     52|	rv = dump_ef(p15card->card, "4F005031", buf, &len);
  190|     52|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|     52|#define SC_SUCCESS				0
  ------------------
  |  Branch (190:6): [True: 15, False: 37]
  ------------------
  191|     15|		sc_log(ctx, "Reading of ODF failed: %d", rv);
  ------------------
  |  |   71|     15|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  192|     15|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     15|	} 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|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  193|     15|	}
  194|     37|	rv = parse_odf(buf, len, p15card);
  195|     37|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|     37|#define SC_SUCCESS				0
  ------------------
  |  Branch (195:6): [True: 6, False: 31]
  ------------------
  196|      6|		sc_log(ctx, "Decoding of ODF failed: %d", rv);
  ------------------
  |  |   71|      6|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  197|      6|		sc_pkcs15_card_clear(p15card);
  198|      6|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      6|		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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      6|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      6|	} 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|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|      6|	}
  200|       |
  201|       |	/* Decode EF.PrKDF, EF.PuKDF, EF.CDF and EF.AODF */
  202|     69|	for (df = p15card->df_list; df != NULL; df = df->next) {
  ------------------
  |  Branch (202:30): [True: 38, False: 31]
  ------------------
  203|     38|		if (df->type == SC_PKCS15_PRKDF) {
  ------------------
  |  |  488|     38|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (203:7): [True: 10, False: 28]
  ------------------
  204|     10|			rv = sc_pkcs15_parse_df(p15card, df);
  205|     10|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
  |  Branch (205:8): [True: 9, False: 1]
  ------------------
  206|      9|				sc_log(ctx,
  ------------------
  |  |   71|      9|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  207|      9|				       "Decoding of EF.PrKDF (%s) failed: %d",
  208|      9|				       sc_print_path(&df->path), rv);
  209|      9|			}
  210|     10|		}
  211|     38|		if (df->type == SC_PKCS15_PUKDF) {
  ------------------
  |  |  489|     38|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (211:7): [True: 4, False: 34]
  ------------------
  212|      4|			rv = sc_pkcs15_parse_df(p15card, df);
  213|      4|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  |  Branch (213:8): [True: 3, False: 1]
  ------------------
  214|      3|				sc_log(ctx,
  ------------------
  |  |   71|      3|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  215|      3|				       "Decoding of EF.PuKDF (%s) failed: %d",
  216|      3|				       sc_print_path(&df->path), rv);
  217|      3|			}
  218|      4|		}
  219|     38|		if (df->type == SC_PKCS15_CDF) {
  ------------------
  |  |  492|     38|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (219:7): [True: 11, False: 27]
  ------------------
  220|     11|			rv = sc_pkcs15_parse_df(p15card, df);
  221|     11|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|     11|#define SC_SUCCESS				0
  ------------------
  |  Branch (221:8): [True: 9, False: 2]
  ------------------
  222|      9|				sc_log(ctx,
  ------------------
  |  |   71|      9|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  223|      9|				       "Decoding of EF.CDF (%s) failed: %d",
  224|      9|				       sc_print_path(&df->path), rv);
  225|      9|			}
  226|     11|		}
  227|     38|		if (df->type == SC_PKCS15_AODF) {
  ------------------
  |  |  496|     38|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (227:7): [True: 5, False: 33]
  ------------------
  228|      5|			rv = sc_pkcs15_parse_df(p15card, df);
  229|      5|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (229:8): [True: 4, False: 1]
  ------------------
  230|      4|				sc_log(ctx,
  ------------------
  |  |   71|      4|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  231|      4|				       "Decoding of EF.AODF (%s) failed: %d",
  232|      4|				       sc_print_path(&df->path), rv);
  233|      4|			}
  234|      5|		}
  235|     38|	}
  236|       |
  237|     31|	p15_obj = p15card->obj_list;
  238|     31|	while (p15_obj != NULL) {
  ------------------
  |  Branch (238:9): [True: 0, False: 31]
  ------------------
  239|      0|		if ( p15_obj->df && (p15_obj->df->type == SC_PKCS15_PRKDF) ) {
  ------------------
  |  |  488|      0|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (239:8): [True: 0, False: 0]
  |  Branch (239:23): [True: 0, False: 0]
  ------------------
  240|      0|			struct sc_pkcs15_prkey_info *prkey_info = (sc_pkcs15_prkey_info_t *) p15_obj->data;
  241|      0|			prkey_info->access_flags = SC_PKCS15_PRKEY_ACCESS_SENSITIVE
  ------------------
  |  |  316|      0|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
  242|      0|					| SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE
  ------------------
  |  |  318|      0|#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE	0x04
  ------------------
  243|      0|					| SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE
  ------------------
  |  |  319|      0|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
  244|      0|					| SC_PKCS15_PRKEY_ACCESS_LOCAL;
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  245|      0|			p15_obj->flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  246|      0|		}
  247|       |
  248|       |
  249|      0|		if ( p15_obj->df && (p15_obj->df->type == SC_PKCS15_AODF) ) {
  ------------------
  |  |  496|      0|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (249:8): [True: 0, False: 0]
  |  Branch (249:23): [True: 0, False: 0]
  ------------------
  250|      0|			static const char *pteid_pin_names[3] = {
  251|      0|			    "Auth PIN",
  252|      0|			    "Sign PIN",
  253|      0|			    "Address PIN"
  254|      0|			};
  255|       |
  256|      0|			struct sc_pin_cmd_data pin_cmd_data;
  257|      0|			struct sc_pkcs15_auth_info *pin_info = (sc_pkcs15_auth_info_t *) p15_obj->data;
  258|       |
  259|      0|			if (pin_info->auth_id.value[0] < 1 || pin_info->auth_id.value[0] > 3) {
  ------------------
  |  Branch (259:8): [True: 0, False: 0]
  |  Branch (259:42): [True: 0, False: 0]
  ------------------
  260|      0|				sc_log(ctx, "Invalid auth_id for PIN: Value %d out of range. Skipping.",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  261|      0|						pin_info->auth_id.value[0]);
  262|      0|				p15_obj = p15_obj->next;
  263|      0|				continue;
  264|      0|			}
  265|       |
  266|      0|			strlcpy(p15_obj->label, pteid_pin_names[pin_info->auth_id.value[0]-1], sizeof(p15_obj->label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  267|       |
  268|      0|			pin_info->attrs.pin.flags |= SC_PKCS15_PIN_FLAG_NEEDS_PADDING;
  ------------------
  |  |   59|      0|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  269|      0|			pin_info->tries_left = -1;
  270|      0|			pin_info->max_tries = 3;
  271|      0|			pin_info->auth_method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  272|       |
  273|      0|			memset(&pin_cmd_data, 0, sizeof(pin_cmd_data));
  274|      0|			pin_cmd_data.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  275|      0|			pin_cmd_data.pin_type = pin_info->attrs.pin.type;
  276|      0|			pin_cmd_data.pin_reference = pin_info->attrs.pin.reference;
  277|      0|			rv = sc_pin_cmd(p15card->card, &pin_cmd_data);
  278|      0|			if (rv == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (278:8): [True: 0, False: 0]
  ------------------
  279|      0|				pin_info->tries_left = pin_cmd_data.pin1.tries_left;
  280|      0|				pin_info->logged_in = pin_cmd_data.pin1.logged_in;
  281|      0|			}
  282|      0|		}
  283|       |		/* Remove found public keys as cannot be read_binary()'d */
  284|      0|		if ( p15_obj->df && (p15_obj->df->type == SC_PKCS15_PUKDF) ) {
  ------------------
  |  |  489|      0|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (284:8): [True: 0, False: 0]
  |  Branch (284:23): [True: 0, False: 0]
  ------------------
  285|      0|			sc_pkcs15_object_t *puk = p15_obj;
  286|      0|			p15_obj = p15_obj->next;
  287|      0|			sc_pkcs15_remove_object(p15card, puk);
  288|      0|			sc_pkcs15_free_object(puk);
  289|      0|		} else {
  290|      0|			p15_obj = p15_obj->next;
  291|      0|		}
  292|      0|	}
  293|       |
  294|       |	/* Add data objects */
  295|    186|	for (i = 0; i < 5; i++) {
  ------------------
  |  Branch (295:14): [True: 155, False: 31]
  ------------------
  296|    155|		static const char *object_labels[5] = {
  297|    155|			"Trace",
  298|    155|			"Citizen Data",
  299|    155|			"Citizen Address Data",
  300|    155|			"SOd",
  301|    155|			"Citizen Notepad",
  302|    155|		};
  303|    155|		static const char *object_authids[5] = {NULL, NULL, "3", NULL, NULL};
  304|    155|		static const char *object_paths[5] = {
  305|    155|			"3f000003",
  306|    155|			"3f005f00ef02",
  307|    155|			"3f005f00ef05",
  308|    155|			"3f005f00ef06",
  309|    155|			"3f005f00ef07",
  310|    155|		};
  311|    155|		static const int object_flags[5] = {
  312|    155|			0,
  313|    155|			0,
  314|    155|			SC_PKCS15_CO_FLAG_PRIVATE,
  ------------------
  |  |   50|    155|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  315|    155|			0,
  316|    155|			0,
  317|    155|		};
  318|    155|		struct sc_pkcs15_data_info obj_info;
  319|    155|		struct sc_pkcs15_object obj_obj;
  320|       |
  321|    155|		memset(&obj_info, 0, sizeof(obj_info));
  322|    155|		memset(&obj_obj, 0, sizeof(obj_obj));
  323|       |
  324|    155|		sc_format_path(object_paths[i], &obj_info.path);
  325|    155|		strlcpy(obj_info.app_label, object_labels[i], SC_PKCS15_MAX_LABEL_SIZE);
  ------------------
  |  |   43|    155|#define strlcpy _strlcpy
  ------------------
              		strlcpy(obj_info.app_label, object_labels[i], SC_PKCS15_MAX_LABEL_SIZE);
  ------------------
  |  |   35|    155|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  326|    155|		if (object_authids[i] != NULL)
  ------------------
  |  Branch (326:7): [True: 31, False: 124]
  ------------------
  327|     31|			sc_pkcs15_format_id(object_authids[i], &obj_obj.auth_id);
  328|    155|		strlcpy(obj_obj.label, object_labels[i], SC_PKCS15_MAX_LABEL_SIZE);
  ------------------
  |  |   43|    155|#define strlcpy _strlcpy
  ------------------
              		strlcpy(obj_obj.label, object_labels[i], SC_PKCS15_MAX_LABEL_SIZE);
  ------------------
  |  |   35|    155|#define SC_PKCS15_MAX_LABEL_SIZE	255
  ------------------
  329|    155|		obj_obj.flags = object_flags[i];
  330|       |
  331|    155|		rv = sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_DATA_OBJECT, &obj_obj, &obj_info);
  ------------------
  |  |  442|    155|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  332|    155|		if (rv != SC_SUCCESS){
  ------------------
  |  |   28|    155|#define SC_SUCCESS				0
  ------------------
  |  Branch (332:7): [True: 0, False: 155]
  ------------------
  333|      0|			sc_log(ctx, "Object add failed: %d", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  334|      0|			break;
  335|      0|		}
  336|    155|	}
  337|       |
  338|     31|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     31|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     31|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     31|	int _ret = r; \
  |  |  |  |  155|     31|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 31, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     31|		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: 31]
  |  |  |  |  ------------------
  |  |  |  |  157|     31|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     31|	} 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|     31|	return _ret; \
  |  |  |  |  163|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  339|     31|}
pkcs15-pteid.c:dump_ef:
   55|    227|{
   56|    227|	int rv;
   57|    227|	sc_file_t *file = NULL;
   58|    227|	sc_path_t scpath;
   59|    227|	sc_format_path(path, &scpath);
   60|    227|	rv = sc_select_file(card, &scpath, &file);
   61|    227|	if (rv < 0) {
  ------------------
  |  Branch (61:6): [True: 52, False: 175]
  ------------------
   62|     52|		sc_file_free(file);
   63|     52|		return rv;
   64|     52|	}
   65|    175|	if (file->size > *buf_len) {
  ------------------
  |  Branch (65:6): [True: 40, False: 135]
  ------------------
   66|     40|		sc_file_free(file);
   67|     40|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|     40|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
   68|     40|	}
   69|    135|	rv = sc_read_binary(card, 0, buf, file->size, 0);
   70|    135|	sc_file_free(file);
   71|    135|	if (rv < 0)
  ------------------
  |  Branch (71:6): [True: 11, False: 124]
  ------------------
   72|     11|		return rv;
   73|    124|	*buf_len = rv;
   74|       |
   75|    124|	return SC_SUCCESS;
  ------------------
  |  |   28|    124|#define SC_SUCCESS				0
  ------------------
   76|    135|}
pkcs15-pteid.c:parse_odf:
  105|     37|{
  106|     37|	const u8 *p = buf;
  107|     37|	size_t left = buflen;
  108|     37|	int r, i, type;
  109|     37|	sc_path_t path;
  110|     37|	struct sc_asn1_entry asn1_obj_or_path[] = {
  111|     37|		{"path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0,
  ------------------
  |  |  174|     37|#define SC_ASN1_PATH			256
  ------------------
              		{"path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0,
  ------------------
  |  |  141|     37|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{"path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0,
  ------------------
  |  |  162|     37|#define SC_ASN1_SEQUENCE                16
  ------------------
  112|     37|		 &path, NULL},
  113|     37|		{NULL, 0, 0, 0, NULL, NULL}
  114|     37|	};
  115|     37|	struct sc_asn1_entry asn1_odf[10];
  116|       |
  117|     37|	sc_path_t path_prefix;
  118|       |
  119|     37|	sc_format_path("3F004F00", &path_prefix);
  120|       |
  121|     37|	sc_copy_asn1_entry(c_asn1_odf, asn1_odf);
  122|    370|	for (i = 0; asn1_odf[i].name != NULL; i++)
  ------------------
  |  Branch (122:14): [True: 333, False: 37]
  ------------------
  123|    333|		sc_format_asn1_entry(asn1_odf + i, asn1_obj_or_path, NULL, 0);
  124|     78|	while (left > 0) {
  ------------------
  |  Branch (124:9): [True: 63, False: 15]
  ------------------
  125|     63|		r = sc_asn1_decode_choice(p15card->card->ctx, asn1_odf, p, left,
  126|     63|					  &p, &left);
  127|     63|		if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|     63|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (127:7): [True: 16, False: 47]
  ------------------
  128|     16|			break;
  129|     47|		if (r < 0)
  ------------------
  |  Branch (129:7): [True: 6, False: 41]
  ------------------
  130|      6|			return r;
  131|     41|		type = r;
  132|     41|		r = sc_pkcs15_make_absolute_path(&path_prefix, &path);
  133|     41|		if (r < 0)
  ------------------
  |  Branch (133:7): [True: 0, False: 41]
  ------------------
  134|      0|			return r;
  135|     41|		r = sc_pkcs15_add_df(p15card, odf_indexes[type], &path);
  136|     41|		if (r)
  ------------------
  |  Branch (136:7): [True: 0, False: 41]
  ------------------
  137|      0|			return r;
  138|     41|	}
  139|     31|	return 0;
  140|     37|}

sc_pkcs15_decode_pukdf_entry:
  201|    142|{
  202|    142|	struct sc_context *ctx = p15card->card->ctx;
  203|    142|	struct sc_pkcs15_pubkey_info *info;
  204|    142|	int r, gostr3410_params[3];
  205|    142|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
  206|    142|	size_t usage_len, af_len;
  207|    142|	struct sc_pkcs15_der *der = &obj->content;
  208|    142|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  209|    142|	struct sc_asn1_entry asn1_com_pubkey_attr[C_ASN1_COM_PUBKEY_ATTR_SIZE];
  210|    142|	struct sc_asn1_entry asn1_rsakey_value_choice[C_ASN1_RSAKEY_VALUE_CHOICE_SIZE];
  211|    142|	struct sc_asn1_entry asn1_rsakey_attr[C_ASN1_RSAKEY_ATTR_SIZE];
  212|    142|	struct sc_asn1_entry asn1_rsa_type_attr[C_ASN1_RSA_TYPE_ATTR_SIZE];
  213|    142|	struct sc_asn1_entry asn1_eckey_value_choice[C_ASN1_ECKEY_VALUE_CHOICE_SIZE];
  214|    142|	struct sc_asn1_entry asn1_eckey_attr[C_ASN1_ECKEY_ATTR_SIZE];
  215|    142|	struct sc_asn1_entry asn1_ec_type_attr[C_ASN1_EC_TYPE_ATTR_SIZE];
  216|    142|	struct sc_asn1_entry asn1_gostr3410key_attr[C_ASN1_GOST3410KEY_ATTR_SIZE];
  217|    142|	struct sc_asn1_entry asn1_gostr3410_type_attr[C_ASN1_GOST3410_TYPE_ATTR_SIZE];
  218|    142|	struct sc_asn1_entry asn1_pubkey_choice[C_ASN1_PUBKEY_CHOICE_SIZE];
  219|    142|	struct sc_asn1_entry asn1_pubkey[C_ASN1_PUBKEY_SIZE];
  220|    142|	struct sc_asn1_pkcs15_object rsakey_obj = { obj, asn1_com_key_attr,
  221|    142|			asn1_com_pubkey_attr, asn1_rsa_type_attr };
  222|    142|	struct sc_asn1_pkcs15_object eckey_obj = { obj, asn1_com_key_attr,
  223|    142|			asn1_com_pubkey_attr, asn1_ec_type_attr };
  224|    142|	struct sc_asn1_pkcs15_object gostr3410key_obj =  { obj, asn1_com_key_attr,
  225|    142|			asn1_com_pubkey_attr, asn1_gostr3410_type_attr };
  226|       |
  227|    142|	info = calloc(1, sizeof *info);
  228|    142|	if (info == NULL) {
  ------------------
  |  Branch (228:6): [True: 0, False: 142]
  ------------------
  229|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  230|      0|		goto err;
  231|      0|	}
  232|    142|	usage_len = sizeof(info->usage);
  233|    142|	af_len = sizeof(info->access_flags);
  234|       |
  235|    142|	sc_copy_asn1_entry(c_asn1_pubkey, asn1_pubkey);
  236|    142|	sc_copy_asn1_entry(c_asn1_pubkey_choice, asn1_pubkey_choice);
  237|    142|	sc_copy_asn1_entry(c_asn1_rsa_type_attr, asn1_rsa_type_attr);
  238|    142|	sc_copy_asn1_entry(c_asn1_rsakey_value_choice, asn1_rsakey_value_choice);
  239|    142|	sc_copy_asn1_entry(c_asn1_rsakey_attr, asn1_rsakey_attr);
  240|    142|	sc_copy_asn1_entry(c_asn1_ec_type_attr, asn1_ec_type_attr);
  241|    142|	sc_copy_asn1_entry(c_asn1_eckey_value_choice, asn1_eckey_value_choice);
  242|    142|	sc_copy_asn1_entry(c_asn1_eckey_attr, asn1_eckey_attr);
  243|    142|	sc_copy_asn1_entry(c_asn1_gostr3410_type_attr, asn1_gostr3410_type_attr);
  244|    142|	sc_copy_asn1_entry(c_asn1_gostr3410key_attr, asn1_gostr3410key_attr);
  245|    142|	sc_copy_asn1_entry(c_asn1_com_pubkey_attr, asn1_com_pubkey_attr);
  246|    142|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  247|       |
  248|    142|	sc_format_asn1_entry(asn1_com_pubkey_attr + 0, &info->subject.value, &info->subject.len, 0);
  249|       |
  250|    142|	sc_format_asn1_entry(asn1_pubkey_choice + 0, &rsakey_obj, NULL, 0);
  251|    142|	sc_format_asn1_entry(asn1_pubkey_choice + 1, &gostr3410key_obj, NULL, 0);
  252|    142|	sc_format_asn1_entry(asn1_pubkey_choice + 2, &eckey_obj, NULL, 0);
  253|       |
  254|    142|	sc_format_asn1_entry(asn1_rsa_type_attr + 0, asn1_rsakey_attr, NULL, 0);
  255|       |
  256|    142|	sc_format_asn1_entry(asn1_rsakey_value_choice + 0, &info->path, NULL, 0);
  257|    142|	sc_format_asn1_entry(asn1_rsakey_value_choice + 1, &der->value, &der->len, 0);
  258|       |
  259|    142|	sc_format_asn1_entry(asn1_rsakey_attr + 0, asn1_rsakey_value_choice, NULL, 0);
  260|    142|	sc_format_asn1_entry(asn1_rsakey_attr + 1, &info->modulus_length, NULL, 0);
  261|       |
  262|    142|	sc_format_asn1_entry(asn1_ec_type_attr + 0, asn1_eckey_attr, NULL, 0);
  263|       |
  264|    142|	sc_format_asn1_entry(asn1_eckey_value_choice + 0, &info->path, NULL, 0);
  265|    142|	sc_format_asn1_entry(asn1_eckey_value_choice + 1, &der->value, &der->len, 0);
  266|       |
  267|    142|	sc_format_asn1_entry(asn1_eckey_attr + 0, asn1_eckey_value_choice, NULL, 0);
  268|       |
  269|    142|	sc_format_asn1_entry(asn1_gostr3410_type_attr + 0, asn1_gostr3410key_attr, NULL, 0);
  270|       |
  271|    142|	sc_format_asn1_entry(asn1_gostr3410key_attr + 0, &info->path, NULL, 0);
  272|    142|	sc_format_asn1_entry(asn1_gostr3410key_attr + 1, &gostr3410_params[0], NULL, 0);
  273|    142|	sc_format_asn1_entry(asn1_gostr3410key_attr + 2, &gostr3410_params[1], NULL, 0);
  274|    142|	sc_format_asn1_entry(asn1_gostr3410key_attr + 3, &gostr3410_params[2], NULL, 0);
  275|       |
  276|    142|	sc_format_asn1_entry(asn1_com_key_attr + 0, &info->id, NULL, 0);
  277|    142|	sc_format_asn1_entry(asn1_com_key_attr + 1, &info->usage, &usage_len, 0);
  278|    142|	sc_format_asn1_entry(asn1_com_key_attr + 2, &info->native, NULL, 0);
  279|    142|	sc_format_asn1_entry(asn1_com_key_attr + 3, &info->access_flags, &af_len, 0);
  280|    142|	sc_format_asn1_entry(asn1_com_key_attr + 4, &info->key_reference, NULL, 0);
  281|       |
  282|    142|	sc_format_asn1_entry(asn1_pubkey + 0, asn1_pubkey_choice, NULL, 0);
  283|       |
  284|       |	/* Fill in defaults */
  285|    142|	info->key_reference = -1;
  286|    142|	info->native = 1;
  287|    142|	memset(gostr3410_params, 0, sizeof(gostr3410_params));
  288|       |
  289|    142|	r = sc_asn1_decode(ctx, asn1_pubkey, *buf, *buflen, buf, buflen);
  290|    142|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|    142|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (290:6): [True: 12, False: 130]
  ------------------
  291|     12|		goto err;
  292|    130|	LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 decoding failed");
  ------------------
  |  |  184|    130|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    130|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    130|	int _ret = (r); \
  |  |  |  |  178|    130|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 130, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    130|		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|    130|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    130|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    130|		goto err; \
  |  |  |  |  182|    130|	} \
  |  |  |  |  183|    130|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|      0|	if (asn1_pubkey_choice[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (293:6): [True: 0, False: 0]
  ------------------
  294|      0|		obj->type = SC_PKCS15_TYPE_PUBKEY_RSA;
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  295|      0|	} else if (asn1_pubkey_choice[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (295:13): [True: 0, False: 0]
  ------------------
  296|      0|		obj->type = SC_PKCS15_TYPE_PUBKEY_GOSTR3410;
  ------------------
  |  |  427|      0|#define SC_PKCS15_TYPE_PUBKEY_GOSTR3410		0x203
  ------------------
  297|      0|		if (info->modulus_length != 0)
  ------------------
  |  Branch (297:7): [True: 0, False: 0]
  ------------------
  298|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  299|      0|		info->modulus_length = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      0|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
  300|      0|		if (info->params.len != 0)
  ------------------
  |  Branch (300:7): [True: 0, False: 0]
  ------------------
  301|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  302|      0|		info->params.len = sizeof(struct sc_pkcs15_keyinfo_gostparams);
  303|      0|		info->params.data = malloc(info->params.len);
  304|      0|		if (info->params.data == NULL) {
  ------------------
  |  Branch (304:7): [True: 0, False: 0]
  ------------------
  305|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  306|      0|			goto err;
  307|      0|		}
  308|      0|		if (sizeof(*keyinfo_gostparams) != info->params.len)
  ------------------
  |  Branch (308:7): [True: 0, False: 0]
  ------------------
  309|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  310|      0|		keyinfo_gostparams = info->params.data;
  311|      0|		keyinfo_gostparams->gostr3410 = (unsigned int)gostr3410_params[0];
  312|      0|		keyinfo_gostparams->gostr3411 = (unsigned int)gostr3410_params[1];
  313|      0|		keyinfo_gostparams->gost28147 = (unsigned int)gostr3410_params[2];
  314|      0|	}
  315|      0|	else if (asn1_pubkey_choice[2].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (315:11): [True: 0, False: 0]
  ------------------
  316|      0|		obj->type = SC_PKCS15_TYPE_PUBKEY_EC;
  ------------------
  |  |  428|      0|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  317|      0|	}
  318|      0|	else {
  319|      0|		goto err;
  320|      0|	}
  321|       |
  322|      0|	if (!p15card->app || !p15card->app->ddo.aid.len) {
  ------------------
  |  Branch (322:6): [True: 0, False: 0]
  |  Branch (322:23): [True: 0, False: 0]
  ------------------
  323|      0|		if (!p15card->file_app) {
  ------------------
  |  Branch (323:7): [True: 0, False: 0]
  ------------------
  324|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  325|      0|			goto err;
  326|      0|		}
  327|      0|		r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info->path);
  328|      0|		if (r < 0) {
  ------------------
  |  Branch (328:7): [True: 0, False: 0]
  ------------------
  329|      0|			goto err;
  330|      0|		}
  331|      0|	}
  332|      0|	else   {
  333|      0|		info->path.aid = p15card->app->ddo.aid;
  334|      0|	}
  335|      0|	sc_log(ctx, "PubKey path '%s'", sc_print_path(&info->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  336|       |
  337|       |	/* OpenSC 0.11.4 and older encoded "keyReference" as a negative
  338|       |	   value. Fixed in 0.11.5 we need to add a hack, so old cards
  339|       |	   continue to work. */
  340|      0|	if (info->key_reference < -1)
  ------------------
  |  Branch (340:6): [True: 0, False: 0]
  ------------------
  341|      0|		info->key_reference += 256;
  342|       |
  343|      0|	obj->data = info;
  344|      0|	info = NULL;
  345|       |
  346|      0|	r = sc_pkcs15_decode_pubkey_direct_value(p15card, obj);
  347|      0|	if (r < 0) {
  ------------------
  |  Branch (347:6): [True: 0, False: 0]
  ------------------
  348|      0|		info = obj->data;
  349|      0|		obj->data = NULL;
  350|      0|	}
  351|      0|	LOG_TEST_GOTO_ERR(ctx, r, "Decode public key direct value failed");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  352|       |
  353|    142|err:
  354|    142|	if (r < 0) {
  ------------------
  |  Branch (354:6): [True: 142, False: 0]
  ------------------
  355|    142|		sc_pkcs15_free_pubkey_info(info);
  356|    142|		if (der->len) {
  ------------------
  |  Branch (356:7): [True: 0, False: 142]
  ------------------
  357|      0|			free(der->value);
  358|       |			/* der points to obj->content */
  359|      0|			obj->content.value = NULL;
  360|      0|			obj->content.len = 0;
  361|      0|		}
  362|    142|	}
  363|       |
  364|    142|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    142|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    142|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    142|	int _ret = r; \
  |  |  |  |  155|    142|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 142, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    142|		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|    142|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 142, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    142|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    142|	} 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|    142|	return _ret; \
  |  |  |  |  163|    142|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  365|    142|}
sc_pkcs15_decode_pubkey_rsa:
  562|    258|{
  563|    258|	struct sc_asn1_entry asn1_public_key[C_ASN1_PUBLIC_KEY_SIZE];
  564|    258|	struct sc_asn1_entry asn1_rsa_pub_coefficients[C_ASN1_RSA_PUB_COEFFICIENTS_SIZE];
  565|    258|	int r;
  566|       |
  567|    258|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    258|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    258|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    258|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    258|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  568|    258|	sc_copy_asn1_entry(c_asn1_public_key, asn1_public_key);
  569|    258|	sc_format_asn1_entry(asn1_public_key + 0, asn1_rsa_pub_coefficients, NULL, 0);
  570|       |
  571|    258|	sc_copy_asn1_entry(c_asn1_rsa_pub_coefficients, asn1_rsa_pub_coefficients);
  572|    258|	sc_format_asn1_entry(asn1_rsa_pub_coefficients + 0, &key->modulus.data, &key->modulus.len, 0);
  573|    258|	sc_format_asn1_entry(asn1_rsa_pub_coefficients + 1, &key->exponent.data, &key->exponent.len, 0);
  574|       |
  575|    258|	r = sc_asn1_decode(ctx, asn1_public_key, buf, buflen, NULL, NULL);
  576|    258|	LOG_TEST_RET(ctx, r, "ASN.1 parsing of public key failed");
  ------------------
  |  |  174|    258|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    258|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    258|	int _ret = (r); \
  |  |  |  |  168|    258|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 26, False: 232]
  |  |  |  |  ------------------
  |  |  |  |  169|     26|		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|     26|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     26|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     26|		return _ret; \
  |  |  |  |  172|     26|	} \
  |  |  |  |  173|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 232]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  577|       |
  578|    232|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    232|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    232|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    232|	int _ret = r; \
  |  |  |  |  155|    232|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 232, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    232|		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: 232]
  |  |  |  |  ------------------
  |  |  |  |  157|    232|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    232|	} 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|    232|	return _ret; \
  |  |  |  |  163|    232|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  579|    232|}
sc_pkcs15_encode_pubkey_rsa:
  585|    211|{
  586|    211|	struct sc_asn1_entry asn1_public_key[C_ASN1_PUBLIC_KEY_SIZE];
  587|    211|	struct sc_asn1_entry asn1_rsa_pub_coefficients[C_ASN1_RSA_PUB_COEFFICIENTS_SIZE];
  588|    211|	int r;
  589|       |
  590|    211|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    211|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    211|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    211|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    211|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 211]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  591|    211|	sc_copy_asn1_entry(c_asn1_public_key, asn1_public_key);
  592|    211|	sc_format_asn1_entry(asn1_public_key + 0, asn1_rsa_pub_coefficients, NULL, 1);
  593|       |
  594|    211|	sc_copy_asn1_entry(c_asn1_rsa_pub_coefficients, asn1_rsa_pub_coefficients);
  595|    211|	sc_format_asn1_entry(asn1_rsa_pub_coefficients + 0, key->modulus.data, &key->modulus.len, 1);
  596|    211|	sc_format_asn1_entry(asn1_rsa_pub_coefficients + 1, key->exponent.data, &key->exponent.len, 1);
  597|       |
  598|    211|	r = sc_asn1_encode(ctx, asn1_public_key, buf, buflen);
  599|    211|	LOG_TEST_RET(ctx, r, "ASN.1 encoding failed");
  ------------------
  |  |  174|    211|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    211|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    211|	int _ret = (r); \
  |  |  |  |  168|    211|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 25, False: 186]
  |  |  |  |  ------------------
  |  |  |  |  169|     25|		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|     25|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     25|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     25|		return _ret; \
  |  |  |  |  172|     25|	} \
  |  |  |  |  173|    211|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 186]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  600|       |
  601|    186|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    186|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    186|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    186|	int _ret = r; \
  |  |  |  |  155|    186|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 186, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    186|		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: 186]
  |  |  |  |  ------------------
  |  |  |  |  157|    186|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    186|	} 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|    186|	return _ret; \
  |  |  |  |  163|    186|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  602|    186|}
sc_pkcs15_encode_pubkey:
  768|    119|{
  769|    119|	if (key->algorithm == SC_ALGORITHM_RSA)
  ------------------
  |  |   69|    119|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (769:6): [True: 119, False: 0]
  ------------------
  770|    119|		return sc_pkcs15_encode_pubkey_rsa(ctx, &key->u.rsa, buf, len);
  771|      0|	if (key->algorithm == SC_ALGORITHM_GOSTR3410)
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (771:6): [True: 0, False: 0]
  ------------------
  772|      0|		return sc_pkcs15_encode_pubkey_gostr3410(ctx, &key->u.gostr3410, buf, len);
  773|      0|	if (key->algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (773:6): [True: 0, False: 0]
  ------------------
  774|      0|		return sc_pkcs15_encode_pubkey_ec(ctx, &key->u.ec, buf, len);
  775|      0|	if (key->algorithm == SC_ALGORITHM_EDDSA || key->algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
              	if (key->algorithm == SC_ALGORITHM_EDDSA || key->algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (775:6): [True: 0, False: 0]
  |  Branch (775:46): [True: 0, False: 0]
  ------------------
  776|      0|		return sc_pkcs15_encode_pubkey_eddsa(ctx, &key->u.ec, buf, len);
  777|       |
  778|      0|	sc_log(ctx, "Encoding of public key type %lu not supported", key->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  779|      0|	LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  780|      0|}
sc_pkcs15_encode_pubkey_as_spki:
  800|  1.15k|{
  801|  1.15k|	int r = 0;
  802|  1.15k|	struct sc_asn1_entry  asn1_spki_key[2], asn1_spki_key_items[3];
  803|  1.15k|	struct sc_pkcs15_u8 pkey;
  804|  1.15k|	size_t key_len;
  805|       |
  806|  1.15k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.15k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.15k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.15k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.15k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  807|  1.15k|	pkey.value =  NULL;
  808|  1.15k|	pkey.len = 0;
  809|       |
  810|  1.15k|	sc_log(ctx, "Encoding public key with algorithm %lu", pubkey->algorithm);
  ------------------
  |  |   71|  1.15k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  811|  1.15k|	if (!pubkey->alg_id)   {
  ------------------
  |  Branch (811:6): [True: 3, False: 1.14k]
  ------------------
  812|      3|		pubkey->alg_id = calloc(1, sizeof(struct sc_algorithm_id));
  813|      3|		if (!pubkey->alg_id)
  ------------------
  |  Branch (813:7): [True: 0, False: 3]
  ------------------
  814|      3|			LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  815|       |
  816|      3|		sc_init_oid(&pubkey->alg_id->oid);
  817|      3|		pubkey->alg_id->algorithm = pubkey->algorithm;
  818|      3|	}
  819|       |
  820|  1.15k|	switch (pubkey->algorithm) {
  821|  1.03k|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|  1.03k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (821:2): [True: 1.03k, False: 119]
  ------------------
  822|  1.03k|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|  1.03k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (822:2): [True: 0, False: 1.15k]
  ------------------
  823|  1.03k|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|  1.03k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (823:2): [True: 0, False: 1.15k]
  ------------------
  824|       |		/*
  825|       |		 * most keys, but not EC have only one encoding.
  826|       |		 * For a SPKI, the ecpoint is placed directly in the
  827|       |		 * BIT STRING
  828|       |		 */
  829|  1.03k|		key_len = pubkey->u.ec.ecpointQ.len * 8;
  830|  1.03k|		pkey.value = pubkey->u.ec.ecpointQ.value;
  831|  1.03k|		pkey.len = 0; /* flag as do not delete */
  832|       |
  833|  1.03k|		if (pubkey->u.ec.params.named_curve || pubkey->u.ec.params.der.value)   {
  ------------------
  |  Branch (833:7): [True: 1.02k, False: 4]
  |  Branch (833:42): [True: 0, False: 4]
  ------------------
  834|  1.02k|			struct sc_ec_parameters *ec_params = NULL;
  835|       |
  836|  1.02k|			r = sc_pkcs15_fix_ec_parameters(ctx, &pubkey->u.ec.params);
  837|  1.02k|			LOG_TEST_RET(ctx, r, "failed to fix EC parameters");
  ------------------
  |  |  174|  1.02k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.02k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.02k|	int _ret = (r); \
  |  |  |  |  168|  1.02k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 1.02k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.02k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.02k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  838|       |
  839|       |			/* EDDSA and XEDDSA only have algo and no param in SPKI */
  840|  1.02k|			if (pubkey->algorithm == SC_ALGORITHM_EC) {
  ------------------
  |  |   70|  1.02k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (840:8): [True: 1.02k, False: 0]
  ------------------
  841|  1.02k|				ec_params = calloc(1, sizeof(struct sc_ec_parameters));
  842|  1.02k|				if (!ec_params)
  ------------------
  |  Branch (842:9): [True: 0, False: 1.02k]
  ------------------
  843|  1.02k|					LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  844|  1.02k|				ec_params->type = 1;
  845|  1.02k|				ec_params->der.value = calloc(1, pubkey->u.ec.params.der.len);
  846|  1.02k|				if (!ec_params->der.value) {
  ------------------
  |  Branch (846:9): [True: 0, False: 1.02k]
  ------------------
  847|      0|					free(ec_params);
  848|      0|					LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  849|      0|				}
  850|  1.02k|				memcpy(ec_params->der.value, pubkey->u.ec.params.der.value, pubkey->u.ec.params.der.len);
  851|  1.02k|				ec_params->der.len = pubkey->u.ec.params.der.len;
  852|  1.02k|			}
  853|       |			/* This could have been already allocated: avoid memory leak */
  854|  1.02k|			sc_asn1_clear_algorithm_id(pubkey->alg_id);
  855|  1.02k|			pubkey->alg_id->params = ec_params; /* NULL for EDDSA and XEDDSA */
  856|  1.02k|		}
  857|  1.03k|		break;
  858|  1.03k|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (858:2): [True: 0, False: 1.15k]
  ------------------
  859|       |		/* TODO is this needed?  does it cause mem leak? */
  860|      0|		pubkey->alg_id->params = &pubkey->u.gostr3410.params;
  861|      0|		r = sc_pkcs15_encode_pubkey(ctx, pubkey, &pkey.value, &pkey.len);
  862|      0|		key_len = pkey.len * 8;
  863|      0|		break;
  864|    119|	default:
  ------------------
  |  Branch (864:2): [True: 119, False: 1.03k]
  ------------------
  865|    119|		r = sc_pkcs15_encode_pubkey(ctx, pubkey, &pkey.value, &pkey.len);
  866|    119|		key_len = pkey.len * 8;
  867|    119|		break;
  868|  1.15k|	}
  869|       |
  870|  1.15k|	if (r == 0) {
  ------------------
  |  Branch (870:6): [True: 1.13k, False: 21]
  ------------------
  871|  1.13k|		sc_copy_asn1_entry(c_asn1_spki_key, asn1_spki_key);
  872|  1.13k|		sc_copy_asn1_entry(c_asn1_spki_key_items, asn1_spki_key_items);
  873|  1.13k|		sc_format_asn1_entry(asn1_spki_key + 0, asn1_spki_key_items, NULL, 1);
  874|  1.13k|		sc_format_asn1_entry(asn1_spki_key_items + 0, pubkey->alg_id, NULL, 1);
  875|  1.13k|		sc_format_asn1_entry(asn1_spki_key_items + 1, pkey.value, &key_len, 1);
  876|       |
  877|  1.13k|		r =  sc_asn1_encode(ctx, asn1_spki_key, buf, len);
  878|  1.13k|	}
  879|       |
  880|       |	/*  pkey.len == 0 is flag to not delete */
  881|  1.15k|	if (pkey.len && pkey.value)
  ------------------
  |  Branch (881:6): [True: 98, False: 1.05k]
  |  Branch (881:18): [True: 98, False: 0]
  ------------------
  882|     98|		free(pkey.value);
  883|       |
  884|  1.15k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  1.15k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.15k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.15k|	int _ret = r; \
  |  |  |  |  155|  1.15k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.15k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.15k|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 21, False: 1.13k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.15k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.15k|	} 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|  1.15k|	return _ret; \
  |  |  |  |  163|  1.15k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  885|  1.15k|}
sc_pkcs15_decode_pubkey:
  891|    314|{
  892|    314|	if (key->algorithm == SC_ALGORITHM_RSA)
  ------------------
  |  |   69|    314|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (892:6): [True: 258, False: 56]
  ------------------
  893|    258|		return sc_pkcs15_decode_pubkey_rsa(ctx, &key->u.rsa, buf, len);
  894|     56|	if (key->algorithm == SC_ALGORITHM_GOSTR3410)
  ------------------
  |  |   71|     56|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (894:6): [True: 0, False: 56]
  ------------------
  895|      0|		return sc_pkcs15_decode_pubkey_gostr3410(ctx, &key->u.gostr3410, buf, len);
  896|     56|	if (key->algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   70|     56|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (896:6): [True: 0, False: 56]
  ------------------
  897|      0|		return sc_pkcs15_decode_pubkey_ec(ctx, &key->u.ec, buf, len);
  898|     56|	if (key->algorithm == SC_ALGORITHM_EDDSA || key->algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   72|    112|#define SC_ALGORITHM_EDDSA		4
  ------------------
              	if (key->algorithm == SC_ALGORITHM_EDDSA || key->algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|     56|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (898:6): [True: 0, False: 56]
  |  Branch (898:46): [True: 0, False: 56]
  ------------------
  899|      0|		return sc_pkcs15_decode_pubkey_eddsa(ctx, &key->u.ec, buf, len);
  900|       |
  901|     56|	sc_log(ctx, "Decoding of public key type %lu not supported", key->algorithm);
  ------------------
  |  |   71|     56|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  902|     56|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     56|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  903|     56|}
sc_pkcs15_read_pubkey:
  912|     61|{
  913|     61|	struct sc_context *ctx;
  914|     61|	const struct sc_pkcs15_pubkey_info *info = NULL;
  915|     61|	struct sc_pkcs15_pubkey *pubkey = NULL;
  916|     61|	unsigned char *data = NULL;
  917|     61|	size_t	len;
  918|     61|	int	algorithm, r;
  919|     61|	int	private_obj;
  920|       |
  921|     61|	if (p15card == NULL || p15card->card == NULL || p15card->card->ops == NULL
  ------------------
  |  Branch (921:6): [True: 0, False: 61]
  |  Branch (921:25): [True: 0, False: 61]
  |  Branch (921:50): [True: 0, False: 61]
  ------------------
  922|     61|			|| obj == NULL || out == NULL) {
  ------------------
  |  Branch (922:7): [True: 0, False: 61]
  |  Branch (922:22): [True: 0, False: 61]
  ------------------
  923|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  924|      0|	}
  925|     61|	ctx = p15card->card->ctx;
  926|       |
  927|     61|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     61|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     61|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     61|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     61|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 61]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  928|     61|	sc_log(ctx, "Public key type 0x%X", obj->type);
  ------------------
  |  |   71|     61|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  929|       |
  930|     61|	switch (obj->type) {
  931|     61|	case SC_PKCS15_TYPE_PUBKEY_RSA:
  ------------------
  |  |  426|     61|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (931:2): [True: 61, False: 0]
  ------------------
  932|     61|		algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|     61|#define SC_ALGORITHM_RSA		0
  ------------------
  933|     61|		break;
  934|      0|	case SC_PKCS15_TYPE_PUBKEY_GOSTR3410:
  ------------------
  |  |  427|      0|#define SC_PKCS15_TYPE_PUBKEY_GOSTR3410		0x203
  ------------------
  |  Branch (934:2): [True: 0, False: 61]
  ------------------
  935|      0|		algorithm = SC_ALGORITHM_GOSTR3410;
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  936|      0|		break;
  937|      0|	case SC_PKCS15_TYPE_PUBKEY_EC:
  ------------------
  |  |  428|      0|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  |  Branch (937:2): [True: 0, False: 61]
  ------------------
  938|      0|		algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  939|      0|		break;
  940|      0|	case SC_PKCS15_TYPE_PUBKEY_EDDSA:
  ------------------
  |  |  429|      0|#define SC_PKCS15_TYPE_PUBKEY_EDDSA		0x205
  ------------------
  |  Branch (940:2): [True: 0, False: 61]
  ------------------
  941|      0|		algorithm = SC_ALGORITHM_EDDSA;
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  942|      0|		break;
  943|      0|	case SC_PKCS15_TYPE_PUBKEY_XEDDSA:
  ------------------
  |  |  430|      0|#define SC_PKCS15_TYPE_PUBKEY_XEDDSA		0x206
  ------------------
  |  Branch (943:2): [True: 0, False: 61]
  ------------------
  944|      0|		algorithm = SC_ALGORITHM_XEDDSA;
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  945|      0|		break;
  946|      0|	default:
  ------------------
  |  Branch (946:2): [True: 0, False: 61]
  ------------------
  947|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported public key type.");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  948|     61|	}
  949|     61|	info = (const struct sc_pkcs15_pubkey_info *) obj->data;
  950|       |
  951|     61|	pubkey = calloc(1, sizeof(struct sc_pkcs15_pubkey));
  952|     61|	if (pubkey == NULL) {
  ------------------
  |  Branch (952:6): [True: 0, False: 61]
  ------------------
  953|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  954|      0|	}
  955|     61|	pubkey->algorithm = algorithm;
  956|       |
  957|       |	/* starting from SPKI direct value
  958|       |	   in a compact form it presents complete public key data */
  959|     61|	if (info->direct.spki.value && info->direct.spki.len)   {
  ------------------
  |  Branch (959:6): [True: 0, False: 61]
  |  Branch (959:33): [True: 0, False: 0]
  ------------------
  960|      0|		sc_log(ctx, "Using direct SPKI value,  tag 0x%X", *(info->direct.spki.value));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  961|      0|		r = sc_pkcs15_pubkey_from_spki_sequence(ctx, info->direct.spki.value, info->direct.spki.len, &pubkey);
  962|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to decode 'SPKI' direct value");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  963|      0|	}
  964|     61|	else if (info->direct.raw.value && info->direct.raw.len)   {
  ------------------
  |  Branch (964:11): [True: 0, False: 61]
  |  Branch (964:37): [True: 0, False: 0]
  ------------------
  965|      0|		sc_log(ctx, "Using direct RAW value");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  966|      0|		r = sc_pkcs15_decode_pubkey(ctx, pubkey, info->direct.raw.value, info->direct.raw.len);
  967|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to decode 'RAW' direct value");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  968|      0|		sc_log(ctx, "TODO: for EC keys 'raw' data needs to be completed with referenced algorithm from TokenInfo");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  969|      0|	}
  970|     61|	else if (obj->content.value && obj->content.len)   {
  ------------------
  |  Branch (970:11): [True: 0, False: 61]
  |  Branch (970:33): [True: 0, False: 0]
  ------------------
  971|      0|		sc_log(ctx, "Using object content");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  972|      0|		r = sc_pkcs15_decode_pubkey(ctx, pubkey, obj->content.value, obj->content.len);
  973|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to decode object content value");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  974|      0|		sc_log(ctx, "TODO: for EC keys 'raw' data needs to be completed with referenced algorithm from TokenInfo");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  975|      0|	}
  976|     61|	else if (p15card->card->ops->read_public_key)   {
  ------------------
  |  Branch (976:11): [True: 0, False: 61]
  ------------------
  977|      0|		sc_log(ctx, "Call card specific 'read-public-key' handle");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  978|      0|		r = p15card->card->ops->read_public_key(p15card->card, algorithm,
  979|      0|				(struct sc_path *)&info->path, info->key_reference, (unsigned)info->modulus_length,
  980|      0|				&data, &len);
  981|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Card specific 'read-public' procedure failed.");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  982|       |
  983|      0|		r = sc_pkcs15_decode_pubkey(ctx, pubkey, data, len);
  984|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Decode public key error");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  985|      0|	}
  986|     61|	else if (info->path.len)   {
  ------------------
  |  Branch (986:11): [True: 61, False: 0]
  ------------------
  987|     61|		sc_log(ctx, "Read from EF and decode");
  ------------------
  |  |   71|     61|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  988|     61|		private_obj = obj->flags & SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|     61|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  989|     61|		r = sc_pkcs15_read_file(p15card, &info->path, &data, &len, private_obj);
  990|     61|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to read public key file.");
  ------------------
  |  |  184|     61|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     61|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     61|	int _ret = (r); \
  |  |  |  |  178|     61|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 44, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  179|     44|		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|     44|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     44|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     44|		goto err; \
  |  |  |  |  182|     44|	} \
  |  |  |  |  183|     61|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  991|       |
  992|     17|		if ((algorithm == SC_ALGORITHM_EC || algorithm == SC_ALGORITHM_EDDSA || algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   70|     34|#define SC_ALGORITHM_EC		2
  ------------------
              		if ((algorithm == SC_ALGORITHM_EC || algorithm == SC_ALGORITHM_EDDSA || algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   72|     34|#define SC_ALGORITHM_EDDSA		4
  ------------------
              		if ((algorithm == SC_ALGORITHM_EC || algorithm == SC_ALGORITHM_EDDSA || algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|     17|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (992:8): [True: 0, False: 17]
  |  Branch (992:40): [True: 0, False: 17]
  |  Branch (992:75): [True: 0, False: 17]
  ------------------
  993|      0|				&& len > 0 && *data == (SC_ASN1_TAG_SEQUENCE | SC_ASN1_TAG_CONSTRUCTED))
  ------------------
  |  |  206|      0|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              				&& len > 0 && *data == (SC_ASN1_TAG_SEQUENCE | SC_ASN1_TAG_CONSTRUCTED))
  ------------------
  |  |  190|      0|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
  |  Branch (993:8): [True: 0, False: 0]
  |  Branch (993:19): [True: 0, False: 0]
  ------------------
  994|      0|			r = sc_pkcs15_pubkey_from_spki_sequence(ctx, data, len, &pubkey);
  995|     17|		else
  996|     17|			r = sc_pkcs15_decode_pubkey(ctx, pubkey, data, len);
  997|     17|		LOG_TEST_GOTO_ERR(ctx, r, "Decode public key error");
  ------------------
  |  |  184|     17|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     17|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     17|	int _ret = (r); \
  |  |  |  |  178|     17|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 16, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  179|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     16|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     16|		goto err; \
  |  |  |  |  182|     16|	} \
  |  |  |  |  183|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  998|     17|	}
  999|      0|	else {
 1000|      0|		r = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
 1001|      0|		LOG_TEST_GOTO_ERR(ctx, r, "No way to get public key");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1002|      0|	}
 1003|       |
 1004|     61|err:
 1005|     61|	if (r) {
  ------------------
  |  Branch (1005:6): [True: 60, False: 1]
  ------------------
 1006|     60|		sc_pkcs15_free_pubkey(pubkey);
 1007|     60|	} else
 1008|      1|		*out = pubkey;
 1009|     61|	free(data);
 1010|       |
 1011|     61|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|     61|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     61|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     61|	int _ret = r; \
  |  |  |  |  155|     61|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 61, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     61|		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|     60|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 60, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|     61|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     61|	} 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|     61|	return _ret; \
  |  |  |  |  163|     61|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1012|     61|}
sc_pkcs15_dup_pubkey:
 1091|  2.21k|{
 1092|  2.21k|	struct sc_pkcs15_pubkey *pubkey = NULL;
 1093|  2.21k|	int rv = SC_SUCCESS;
  ------------------
  |  |   28|  2.21k|#define SC_SUCCESS				0
  ------------------
 1094|  2.21k|	u8* alg;
 1095|  2.21k|	size_t alglen;
 1096|       |
 1097|  2.21k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.21k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.21k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.21k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.21k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.21k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|       |
 1099|  2.21k|	if (!key || !out) {
  ------------------
  |  Branch (1099:6): [True: 0, False: 2.21k]
  |  Branch (1099:14): [True: 0, False: 2.21k]
  ------------------
 1100|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1101|      0|	}
 1102|       |
 1103|  2.21k|	*out = NULL;
 1104|  2.21k|	pubkey = calloc(1, sizeof(struct sc_pkcs15_pubkey));
 1105|  2.21k|	if (!pubkey)
  ------------------
  |  Branch (1105:6): [True: 0, False: 2.21k]
  ------------------
 1106|  2.21k|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1107|       |
 1108|  2.21k|	pubkey->algorithm = key->algorithm;
 1109|       |
 1110|  2.21k|	if (key->alg_id) {
  ------------------
  |  Branch (1110:6): [True: 2.21k, False: 0]
  ------------------
 1111|  2.21k|		rv = sc_asn1_encode_algorithm_id(ctx, &alg, &alglen,key->alg_id, 0);
 1112|  2.21k|		if (rv == SC_SUCCESS) {
  ------------------
  |  |   28|  2.21k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1112:7): [True: 2.21k, False: 0]
  ------------------
 1113|  2.21k|			pubkey->alg_id = (struct sc_algorithm_id *)calloc(1, sizeof(struct sc_algorithm_id));
 1114|  2.21k|			if (pubkey->alg_id == NULL) {
  ------------------
  |  Branch (1114:8): [True: 0, False: 2.21k]
  ------------------
 1115|      0|				free(pubkey);
 1116|      0|				LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1117|      0|			}
 1118|  2.21k|			rv = sc_asn1_decode_algorithm_id(ctx, alg, alglen, pubkey->alg_id, 0);
 1119|  2.21k|			free(alg);
 1120|  2.21k|		}
 1121|  2.21k|	}
 1122|       |
 1123|  2.21k|	switch (key->algorithm) {
 1124|    176|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|    176|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1124:2): [True: 176, False: 2.03k]
  ------------------
 1125|    176|		rv = sc_pkcs15_dup_bignum(&pubkey->u.rsa.modulus, &key->u.rsa.modulus);
 1126|    176|		if (!rv)
  ------------------
  |  Branch (1126:7): [True: 176, False: 0]
  ------------------
 1127|    176|			rv = sc_pkcs15_dup_bignum(&pubkey->u.rsa.exponent, &key->u.rsa.exponent);
 1128|    176|		break;
 1129|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1129:2): [True: 0, False: 2.21k]
  ------------------
 1130|      0|		break;
 1131|  2.03k|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|  2.03k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1131:2): [True: 2.03k, False: 176]
  ------------------
 1132|  2.03k|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|  2.03k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1132:2): [True: 0, False: 2.21k]
  ------------------
 1133|  2.03k|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|  2.03k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1133:2): [True: 0, False: 2.21k]
  ------------------
 1134|  2.03k|		pubkey->u.ec.ecpointQ.value = malloc(key->u.ec.ecpointQ.len);
 1135|  2.03k|		if (!pubkey->u.ec.ecpointQ.value) {
  ------------------
  |  Branch (1135:7): [True: 0, False: 2.03k]
  ------------------
 1136|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1137|      0|			break;
 1138|      0|		}
 1139|  2.03k|		memcpy(pubkey->u.ec.ecpointQ.value, key->u.ec.ecpointQ.value, key->u.ec.ecpointQ.len);
 1140|  2.03k|		pubkey->u.ec.ecpointQ.len = key->u.ec.ecpointQ.len;
 1141|       |
 1142|  2.03k|		if (key->u.ec.params.named_curve) {
  ------------------
  |  Branch (1142:7): [True: 2.02k, False: 8]
  ------------------
 1143|  2.02k|			rv = sc_pkcs15_fix_ec_parameters(ctx, &key->u.ec.params);
 1144|  2.02k|			if (rv)
  ------------------
  |  Branch (1144:8): [True: 0, False: 2.02k]
  ------------------
 1145|      0|				break;
 1146|  2.02k|		}
 1147|       |
 1148|  2.03k|		pubkey->u.ec.params.der.value = malloc(key->u.ec.params.der.len);
 1149|  2.03k|		if (!pubkey->u.ec.params.der.value) {
  ------------------
  |  Branch (1149:7): [True: 0, False: 2.03k]
  ------------------
 1150|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1151|      0|			break;
 1152|      0|		}
 1153|  2.03k|		memcpy(pubkey->u.ec.params.der.value, key->u.ec.params.der.value, key->u.ec.params.der.len);
 1154|  2.03k|		pubkey->u.ec.params.der.len = key->u.ec.params.der.len;
 1155|       |
 1156|       |		/* RFC4810 no named_curve */
 1157|  2.03k|		if ((key->algorithm != SC_ALGORITHM_EDDSA) && (key->algorithm != SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   72|  2.03k|#define SC_ALGORITHM_EDDSA		4
  ------------------
              		if ((key->algorithm != SC_ALGORITHM_EDDSA) && (key->algorithm != SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   73|  2.03k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1157:7): [True: 2.03k, False: 0]
  |  Branch (1157:49): [True: 2.03k, False: 0]
  ------------------
 1158|  2.03k|			if (key->u.ec.params.named_curve) {
  ------------------
  |  Branch (1158:8): [True: 2.02k, False: 8]
  ------------------
 1159|  2.02k|				pubkey->u.ec.params.named_curve = strdup(key->u.ec.params.named_curve);
 1160|  2.02k|				if (!pubkey->u.ec.params.named_curve)
  ------------------
  |  Branch (1160:9): [True: 0, False: 2.02k]
  ------------------
 1161|      0|					rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1162|  2.02k|			} else {
 1163|      8|				sc_log(ctx, "named_curve parameter missing");
  ------------------
  |  |   71|      8|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1164|      8|				rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      8|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1165|      8|			}
 1166|  2.03k|		}
 1167|       |
 1168|  2.03k|		break;
 1169|      0|	default:
  ------------------
  |  Branch (1169:2): [True: 0, False: 2.21k]
  ------------------
 1170|      0|		sc_log(ctx, "Unsupported private key algorithm");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1171|      0|		rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1172|  2.21k|	}
 1173|       |
 1174|  2.21k|	if (rv)
  ------------------
  |  Branch (1174:6): [True: 8, False: 2.20k]
  ------------------
 1175|      8|		sc_pkcs15_free_pubkey(pubkey);
 1176|  2.20k|	else
 1177|  2.20k|		*out = pubkey;
 1178|       |
 1179|  2.21k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  2.21k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.21k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.21k|	int _ret = r; \
  |  |  |  |  155|  2.21k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.21k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.21k|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 8, False: 2.20k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.21k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.21k|	} 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|  2.21k|	return _ret; \
  |  |  |  |  163|  2.21k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1180|  2.21k|}
sc_pkcs15_erase_pubkey:
 1186|  6.53k|{
 1187|  6.53k|	if (key == NULL) {
  ------------------
  |  Branch (1187:6): [True: 0, False: 6.53k]
  ------------------
 1188|      0|		return;
 1189|      0|	}
 1190|  6.53k|	if (key->alg_id) {
  ------------------
  |  Branch (1190:6): [True: 4.75k, False: 1.78k]
  ------------------
 1191|  4.75k|		sc_asn1_clear_algorithm_id(key->alg_id);
 1192|  4.75k|		free(key->alg_id);
 1193|  4.75k|	}
 1194|  6.53k|	switch (key->algorithm) {
  ------------------
  |  Branch (1194:10): [True: 6.46k, False: 70]
  ------------------
 1195|  2.20k|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|  2.20k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1195:2): [True: 2.20k, False: 4.33k]
  ------------------
 1196|  2.20k|		free(key->u.rsa.modulus.data);
 1197|  2.20k|		free(key->u.rsa.exponent.data);
 1198|  2.20k|		break;
 1199|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1199:2): [True: 0, False: 6.53k]
  ------------------
 1200|      0|		free(key->u.gostr3410.xy.data);
 1201|      0|		break;
 1202|  4.26k|	case SC_ALGORITHM_EC:
  ------------------
  |  |   70|  4.26k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1202:2): [True: 4.26k, False: 2.27k]
  ------------------
 1203|  4.26k|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|  4.26k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1203:2): [True: 0, False: 6.53k]
  ------------------
 1204|  4.26k|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|  4.26k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1204:2): [True: 0, False: 6.53k]
  ------------------
 1205|  4.26k|		free(key->u.ec.params.der.value);
 1206|  4.26k|		free(key->u.ec.params.named_curve);
 1207|  4.26k|		free(key->u.ec.ecpointQ.value);
 1208|  4.26k|		break;
 1209|  6.53k|	}
 1210|  6.53k|	sc_mem_clear(key, sizeof(*key));
 1211|  6.53k|}
sc_pkcs15_free_pubkey:
 1216|  11.8k|{
 1217|  11.8k|	if (!key)
  ------------------
  |  Branch (1217:6): [True: 5.36k, False: 6.50k]
  ------------------
 1218|  5.36k|		return;
 1219|  6.50k|	sc_pkcs15_erase_pubkey(key);
 1220|  6.50k|	free(key);
 1221|  6.50k|}
sc_pkcs15_free_pubkey_info:
 1226|  1.41k|{
 1227|  1.41k|	if (info) {
  ------------------
  |  Branch (1227:6): [True: 1.41k, False: 0]
  ------------------
 1228|  1.41k|		free(info->subject.value);
 1229|  1.41k|		free(info->direct.spki.value);
 1230|  1.41k|		free(info->direct.raw.value);
 1231|  1.41k|		sc_pkcs15_free_key_params(&info->params);
 1232|  1.41k|		free(info);
 1233|  1.41k|	}
 1234|  1.41k|}
sc_pkcs15_pubkey_from_spki_fields:
 1325|  2.74k|{
 1326|       |
 1327|  2.74k|	struct sc_pkcs15_pubkey *pubkey = NULL;
 1328|  2.74k|	struct sc_pkcs15_der pk = { NULL, 0 };
 1329|  2.74k|	struct sc_algorithm_id pk_alg;
 1330|  2.74k|	struct sc_asn1_entry asn1_pkinfo[C_ASN1_PKINFO_ATTR_SIZE];
 1331|  2.74k|	unsigned char *tmp_buf = NULL;
 1332|  2.74k|	int r;
 1333|       |
 1334|  2.74k|	sc_log(ctx, "sc_pkcs15_pubkey_from_spki_fields() called: %p:%zu\n%s",
  ------------------
  |  |   71|  2.74k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1335|  2.74k|			buf, buflen, sc_dump_hex(buf, buflen));
 1336|       |
 1337|  2.74k|	if (buflen < 1) {
  ------------------
  |  Branch (1337:6): [True: 10, False: 2.73k]
  ------------------
 1338|     10|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "subjectPublicKeyInfo can not be empty");
  ------------------
  |  |  174|     10|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     10|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     10|	int _ret = (r); \
  |  |  |  |  168|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1339|     10|	}
 1340|       |
 1341|  2.73k|	tmp_buf = malloc(buflen);
 1342|  2.73k|	if (!tmp_buf) {
  ------------------
  |  Branch (1342:6): [True: 0, False: 2.73k]
  ------------------
 1343|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1344|      0|		LOG_TEST_GOTO_ERR(ctx, r, "");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1345|      0|	}
 1346|  2.73k|	memcpy(tmp_buf, buf, buflen);
 1347|       |
 1348|  2.73k|	if (buflen > 0 && (*tmp_buf & SC_ASN1_TAG_CONTEXT))
  ------------------
  |  |  187|  2.73k|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
  |  Branch (1348:6): [True: 2.73k, False: 0]
  |  Branch (1348:20): [True: 52, False: 2.68k]
  ------------------
 1349|     52|		*tmp_buf = SC_ASN1_TAG_CONSTRUCTED | SC_ASN1_TAG_SEQUENCE;
  ------------------
  |  |  190|     52|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
              		*tmp_buf = SC_ASN1_TAG_CONSTRUCTED | SC_ASN1_TAG_SEQUENCE;
  ------------------
  |  |  206|     52|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
 1350|       |
 1351|  2.73k|	memset(&pk_alg, 0, sizeof(pk_alg));
 1352|  2.73k|	pubkey = calloc(1, sizeof(sc_pkcs15_pubkey_t));
 1353|  2.73k|	if (pubkey == NULL) {
  ------------------
  |  Branch (1353:6): [True: 0, False: 2.73k]
  ------------------
 1354|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1355|      0|		LOG_TEST_GOTO_ERR(ctx, r, "");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1356|      0|	}
 1357|       |
 1358|  2.73k|	sc_copy_asn1_entry(c_asn1_pkinfo, asn1_pkinfo);
 1359|       |
 1360|  2.73k|	sc_format_asn1_entry(asn1_pkinfo + 0, &pk_alg, NULL, 0);
 1361|  2.73k|	sc_format_asn1_entry(asn1_pkinfo + 1, &pk.value, &pk.len, 0);
 1362|       |
 1363|  2.73k|	r = sc_asn1_decode(ctx, asn1_pkinfo, tmp_buf, buflen, NULL, NULL);
 1364|  2.73k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  2.73k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1364:6): [True: 194, False: 2.54k]
  ------------------
 1365|    194|		sc_asn1_clear_algorithm_id(&pk_alg);
 1366|    194|		LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 parsing of subjectPubkeyInfo failed");
  ------------------
  |  |  184|    194|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    194|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    194|	int _ret = (r); \
  |  |  |  |  178|    194|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 194, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    194|		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|    194|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    194|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    194|		goto err; \
  |  |  |  |  182|    194|	} \
  |  |  |  |  183|    194|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1367|    194|	}
 1368|       |
 1369|  2.54k|	pubkey->alg_id = calloc(1, sizeof(struct sc_algorithm_id));
 1370|  2.54k|	if (pubkey->alg_id == NULL) {
  ------------------
  |  Branch (1370:6): [True: 0, False: 2.54k]
  ------------------
 1371|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1372|      0|		LOG_TEST_GOTO_ERR(ctx, r, "");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1373|      0|	}
 1374|       |
 1375|  2.54k|	memcpy(pubkey->alg_id, &pk_alg, sizeof(struct sc_algorithm_id));
 1376|  2.54k|	pubkey->algorithm = pk_alg.algorithm;
 1377|  2.54k|	pk_alg.params = NULL;
 1378|  2.54k|	sc_log(ctx, "DEE pk_alg.algorithm=%lu", pk_alg.algorithm);
  ------------------
  |  |   71|  2.54k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1379|       |
 1380|  2.54k|	if (pk.len == 0)
  ------------------
  |  Branch (1380:6): [True: 16, False: 2.52k]
  ------------------
 1381|  2.54k|		LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INTERNAL, "Incorrect length of key");
  ------------------
  |  |  184|     16|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     16|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     16|	int _ret = (r); \
  |  |  |  |  178|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 16, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     16|		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|     16|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     16|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     16|		goto err; \
  |  |  |  |  182|     16|	} \
  |  |  |  |  183|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1382|  2.52k|	pk.len = BYTES4BITS(pk.len); /* convert number of bits to bytes */
  ------------------
  |  |  145|  2.52k|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 1383|       |
 1384|  2.52k|	if (pk_alg.algorithm == SC_ALGORITHM_EC)   {
  ------------------
  |  |   70|  2.52k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1384:6): [True: 2.23k, False: 297]
  ------------------
 1385|       |		/* EC public key is not encapsulated into BIT STRING -- it's a BIT STRING */
 1386|       |		/*
 1387|       |		 * sc_pkcs15_fix_ec_parameters below will set field_length from curve.
 1388|       |		 * if no alg_id->params, assume field_length is multiple of 8
 1389|       |		 */
 1390|  2.23k|		pubkey->u.ec.params.field_length = (pk.len - 1) / 2 * 8;
 1391|       |
 1392|  2.23k|		if (pubkey->alg_id->params) {
  ------------------
  |  Branch (1392:7): [True: 2.21k, False: 14]
  ------------------
 1393|  2.21k|			struct sc_ec_parameters *ecp = (struct sc_ec_parameters *)pubkey->alg_id->params;
 1394|       |
 1395|  2.21k|			pubkey->u.ec.params.der.value = malloc(ecp->der.len);
 1396|  2.21k|			if (pubkey->u.ec.params.der.value == NULL) {
  ------------------
  |  Branch (1396:8): [True: 0, False: 2.21k]
  ------------------
 1397|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1398|      0|				LOG_TEST_GOTO_ERR(ctx, r, "");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1399|      0|			}
 1400|       |
 1401|  2.21k|			memcpy(pubkey->u.ec.params.der.value, ecp->der.value, ecp->der.len);
 1402|  2.21k|			pubkey->u.ec.params.der.len = ecp->der.len;
 1403|  2.21k|			r = sc_pkcs15_fix_ec_parameters(ctx, &pubkey->u.ec.params);
 1404|  2.21k|			LOG_TEST_GOTO_ERR(ctx, r, "failed to fix EC parameters");
  ------------------
  |  |  184|  2.21k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.21k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.21k|	int _ret = (r); \
  |  |  |  |  178|  2.21k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 51, False: 2.16k]
  |  |  |  |  ------------------
  |  |  |  |  179|     51|		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|     51|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     51|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     51|		goto err; \
  |  |  |  |  182|     51|	} \
  |  |  |  |  183|  2.21k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.16k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1405|  2.21k|		}
 1406|       |
 1407|  2.18k|		pubkey->u.ec.ecpointQ.value = malloc(pk.len);
 1408|  2.18k|		if (pubkey->u.ec.ecpointQ.value == NULL) {
  ------------------
  |  Branch (1408:7): [True: 0, False: 2.18k]
  ------------------
 1409|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1410|      0|			LOG_TEST_GOTO_ERR(ctx, r, "failed to malloc() memory");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1411|      0|		}
 1412|  2.18k|		memcpy(pubkey->u.ec.ecpointQ.value, pk.value, pk.len);
 1413|  2.18k|		pubkey->u.ec.ecpointQ.len = pk.len;
 1414|  2.18k|	} else if (pk_alg.algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   72|    594|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1414:13): [True: 0, False: 297]
  ------------------
 1415|    297|		   pk_alg.algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   73|    297|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1415:6): [True: 0, False: 297]
  ------------------
 1416|       |		/*
 1417|       |		 * SPKI will have OID, EDDSA can have ED25519 or ED448 with different sizes
 1418|       |		 * EDDSA/XEDDSA public key is not encapsulated into BIT STRING -- it's a BIT STRING
 1419|       |		 * no params, but oid is the params.
 1420|       |		 */
 1421|      0|		r = sc_encode_oid(ctx, &pk_alg.oid, &pubkey->u.ec.params.der.value, &pubkey->u.ec.params.der.len);
 1422|      0|		LOG_TEST_GOTO_ERR(ctx, r, "failed to encode (X)EDDSA oid");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1423|      0|		r = sc_pkcs15_fix_ec_parameters(ctx, &pubkey->u.ec.params);
 1424|      0|		LOG_TEST_GOTO_ERR(ctx, r, "failed to fix EC parameters");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1425|       |
 1426|      0|		pubkey->u.ec.ecpointQ.value = malloc(pk.len);
 1427|      0|		if (pubkey->u.ec.ecpointQ.value == NULL) {
  ------------------
  |  Branch (1427:7): [True: 0, False: 0]
  ------------------
 1428|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1429|      0|			LOG_TEST_GOTO_ERR(ctx, r, "failed to malloc() memory");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1430|      0|		}
 1431|       |
 1432|      0|		memcpy(pubkey->u.ec.ecpointQ.value, pk.value, pk.len);
 1433|      0|		pubkey->u.ec.ecpointQ.len = pk.len;
 1434|    297|	} else {
 1435|       |		/* Public key is expected to be encapsulated into BIT STRING */
 1436|    297|		r = sc_pkcs15_decode_pubkey(ctx, pubkey, pk.value, pk.len);
 1437|    297|		LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 parsing of subjectPubkeyInfo failed");
  ------------------
  |  |  184|    297|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    297|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    297|	int _ret = (r); \
  |  |  |  |  178|    297|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 66, False: 231]
  |  |  |  |  ------------------
  |  |  |  |  179|     66|		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|     66|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     66|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     66|		goto err; \
  |  |  |  |  182|     66|	} \
  |  |  |  |  183|    297|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 231]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1438|    297|	}
 1439|       |
 1440|  2.41k|	*outpubkey = pubkey;
 1441|  2.41k|	pubkey = NULL;
 1442|       |
 1443|  2.73k|err:
 1444|  2.73k|	sc_pkcs15_free_pubkey(pubkey);
 1445|  2.73k|	free(pk.value);
 1446|  2.73k|	free(tmp_buf);
 1447|       |
 1448|  2.73k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  2.73k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.73k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.73k|	int _ret = r; \
  |  |  |  |  155|  2.73k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.73k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.73k|		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|    311|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 311, False: 2.42k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.73k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.73k|	} 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|  2.73k|	return _ret; \
  |  |  |  |  163|  2.73k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1449|  2.73k|}
sc_pkcs15_pubkey_from_spki_sequence:
 1455|      2|{
 1456|      2|	struct sc_pkcs15_pubkey * pubkey = NULL;
 1457|      2|	struct sc_asn1_entry asn1_spki[] = {
 1458|      2|			{ "subjectPublicKeyInfo", SC_ASN1_CALLBACK, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, sc_pkcs15_pubkey_from_spki_fields, &pubkey},
  ------------------
  |  |  181|      2|#define SC_ASN1_CALLBACK		384
  ------------------
              			{ "subjectPublicKeyInfo", SC_ASN1_CALLBACK, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, sc_pkcs15_pubkey_from_spki_fields, &pubkey},
  ------------------
  |  |  206|      2|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              			{ "subjectPublicKeyInfo", SC_ASN1_CALLBACK, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, sc_pkcs15_pubkey_from_spki_fields, &pubkey},
  ------------------
  |  |  141|      2|#define SC_ASN1_CONS			0x20000000
  ------------------
 1459|      2|			{ NULL, 0, 0, 0, NULL, NULL } };
 1460|      2|	int r;
 1461|       |
 1462|      2|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|      2|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      2|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      2|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      2|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1463|       |
 1464|      2|	r = sc_asn1_decode(ctx, asn1_spki, buf, buflen, NULL, NULL);
 1465|      2|	LOG_TEST_RET(ctx, r, "ASN.1 cannot parse subjectPublicKeyInfo");
  ------------------
  |  |  174|      2|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      2|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      2|	int _ret = (r); \
  |  |  |  |  168|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1466|       |
 1467|      2|	if(outpubkey) {
  ------------------
  |  Branch (1467:5): [True: 2, False: 0]
  ------------------
 1468|      2|		free(*outpubkey);
 1469|      2|		*outpubkey = pubkey;
 1470|      2|	} else
 1471|      0|		free(pubkey);
 1472|       |
 1473|      2|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|      2|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      2|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  155|      2|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      2|		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: 2]
  |  |  |  |  ------------------
  |  |  |  |  157|      2|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      2|	} 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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1474|      2|}
sc_pkcs15_fix_ec_parameters:
 1563|  8.69k|{
 1564|  8.69k|	int rv, ii;
 1565|  8.69k|	int mapped_string = 0; /* der is printable string that can be replaced with der of OID */
 1566|       |
 1567|  8.69k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  8.69k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  8.69k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  8.69k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  8.69k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 8.69k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1568|       |
 1569|       |	/* In PKCS#11 EC parameters arrives in DER encoded form */
 1570|  8.69k|	if (ecparams->der.value && ecparams->der.len && ecparams->der.len > 2) {
  ------------------
  |  Branch (1570:6): [True: 8.69k, False: 0]
  |  Branch (1570:29): [True: 8.69k, False: 0]
  |  Branch (1570:50): [True: 8.69k, False: 0]
  ------------------
 1571|       |
 1572|  8.69k|		switch (ecparams->der.value[0]) {
 1573|  8.68k|		case 0x06: /* der.value is an OID */
  ------------------
  |  Branch (1573:3): [True: 8.68k, False: 10]
  ------------------
 1574|  75.8k|			for (ii = 0; ec_curve_infos[ii].name; ii++) {
  ------------------
  |  Branch (1574:17): [True: 75.8k, False: 41]
  ------------------
 1575|  75.8k|				size_t len = ec_curve_infos[ii].oid_der.len;
 1576|       |
 1577|  75.8k|				if (ecparams->der.len == len &&
  ------------------
  |  Branch (1577:9): [True: 38.9k, False: 36.8k]
  ------------------
 1578|  38.9k|						memcmp(ecparams->der.value, ec_curve_infos[ii].oid_der.value, len) == 0)
  ------------------
  |  Branch (1578:7): [True: 8.63k, False: 30.3k]
  ------------------
 1579|  8.63k|					break; /* found ec_curve_infos[ii] */
 1580|  75.8k|			}
 1581|  8.68k|			break;
 1582|       |
 1583|      0|		case 0x13:
  ------------------
  |  Branch (1583:3): [True: 0, False: 8.69k]
  ------------------
 1584|       |			/* printable string as per PKCS11 V 3.0 for experimental curves */
 1585|      0|			{
 1586|      0|				int r_tag;
 1587|      0|				const u8 *body = ecparams->der.value;
 1588|      0|				size_t len = ecparams->der.len;
 1589|      0|				unsigned int cla_out, tag_out;
 1590|      0|				size_t bodylen;
 1591|       |
 1592|      0|				r_tag = sc_asn1_read_tag(&body, len, &cla_out, &tag_out, &bodylen);
 1593|      0|				if (r_tag != SC_SUCCESS || tag_out != 0x13) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1593:9): [True: 0, False: 0]
  |  Branch (1593:32): [True: 0, False: 0]
  ------------------
 1594|      0|					sc_log(ctx, "Invalid printable string");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1595|      0|					LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1596|      0|				}
 1597|      0|				for (ii = 0; ec_curve_infos[ii].name; ii++) {
  ------------------
  |  Branch (1597:18): [True: 0, False: 0]
  ------------------
 1598|      0|					size_t len = strlen(ec_curve_infos[ii].name);
 1599|      0|					if (bodylen != len || memcmp(ec_curve_infos[ii].name, body, len) != 0)
  ------------------
  |  Branch (1599:10): [True: 0, False: 0]
  |  Branch (1599:28): [True: 0, False: 0]
  ------------------
 1600|      0|						continue;
 1601|       |					/* found replacement of printable string to OID */
 1602|      0|					mapped_string = 1;
 1603|      0|					break;
 1604|      0|				}
 1605|      0|			}
 1606|      0|			break;
 1607|       |
 1608|     10|		default:
  ------------------
  |  Branch (1608:3): [True: 10, False: 8.68k]
  ------------------
 1609|     10|			sc_log(ctx, "Unsupported ec params");
  ------------------
  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1610|     10|			LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     10|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     10|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     10|	int _ret = r; \
  |  |  |  |  155|     10|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     10|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     10|	} 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|     10|	return _ret; \
  |  |  |  |  163|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1611|  8.69k|		}
 1612|       |
 1613|  8.68k|		if (ec_curve_infos[ii].name == NULL) /* end of ec_curve_info */
  ------------------
  |  Branch (1613:7): [True: 41, False: 8.63k]
  ------------------
 1614|  8.68k|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported named curve");
  ------------------
  |  |  174|     41|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     41|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     41|	int _ret = (r); \
  |  |  |  |  168|     41|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 41, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     41|		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|     41|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     41|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     41|		return _ret; \
  |  |  |  |  172|     41|	} \
  |  |  |  |  173|     41|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1615|       |
 1616|       |		/* ii points to entry with matching oid_der or a mapped entry with replacement oid_der */
 1617|  8.63k|		sc_log(ctx, "Found known curve '%s'", ec_curve_infos[ii].name);
  ------------------
  |  |   71|  8.63k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1618|  8.63k|		if (mapped_string) { /* free previous name if any replace below with new name */
  ------------------
  |  Branch (1618:7): [True: 0, False: 8.63k]
  ------------------
 1619|      0|			free(ecparams->named_curve);
 1620|      0|			ecparams->named_curve = NULL;
 1621|      0|		}
 1622|       |
 1623|  8.63k|		if (!ecparams->named_curve) { /* if present,keep the name as some curves have multiple names */
  ------------------
  |  Branch (1623:7): [True: 5.58k, False: 3.05k]
  ------------------
 1624|  5.58k|			ecparams->named_curve = strdup(ec_curve_infos[ii].name);
 1625|  5.58k|			if (!ecparams->named_curve)
  ------------------
  |  Branch (1625:8): [True: 0, False: 5.58k]
  ------------------
 1626|  5.58k|				LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1627|       |
 1628|  5.58k|			sc_log(ctx, "Curve name: '%s'", ecparams->named_curve);
  ------------------
  |  |   71|  5.58k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1629|  5.58k|		}
 1630|       |
 1631|       |		/* fill in object_id based on oid_der */
 1632|  8.63k|		sc_format_oid(&ecparams->id, ec_curve_infos[ii].oid_str);
 1633|       |
 1634|  8.63k|		ecparams->field_length = ec_curve_infos[ii].size;
 1635|  8.63k|		ecparams->key_type = ec_curve_infos[ii].key_type;
 1636|  8.63k|		sc_log(ctx, "Curve length %zu key_type %d", ecparams->field_length, ecparams->key_type);
  ------------------
  |  |   71|  8.63k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1637|  8.63k|		if (mapped_string) {
  ------------------
  |  Branch (1637:7): [True: 0, False: 8.63k]
  ------------------
 1638|       |			/* replace the printable string version with the oid */
 1639|      0|			if (ecparams->der.value)
  ------------------
  |  Branch (1639:8): [True: 0, False: 0]
  ------------------
 1640|      0|				free(ecparams->der.value);
 1641|      0|			ecparams->der.len = ec_curve_infos[ii].oid_der.len;
 1642|      0|			ecparams->der.value = malloc(ecparams->der.len);
 1643|      0|			if (ecparams->der.value == NULL) {
  ------------------
  |  Branch (1643:8): [True: 0, False: 0]
  ------------------
 1644|      0|				LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1645|      0|			}
 1646|      0|			memcpy(ecparams->der.value, ec_curve_infos[ii].oid_der.value, ecparams->der.len);
 1647|      0|		}
 1648|  8.63k|	} else if (ecparams->named_curve) { /* it can be name of curve or OID in ASCII form */
  ------------------
  |  Branch (1648:13): [True: 0, False: 0]
  ------------------
 1649|       |		/* caller did not provide an OID, look for a name or oid_string */
 1650|      0|		for (ii = 0; ec_curve_infos[ii].name; ii++) {
  ------------------
  |  Branch (1650:16): [True: 0, False: 0]
  ------------------
 1651|      0|			if (!strcmp(ec_curve_infos[ii].name, ecparams->named_curve))
  ------------------
  |  Branch (1651:8): [True: 0, False: 0]
  ------------------
 1652|      0|				break;
 1653|      0|			if (!strcmp(ec_curve_infos[ii].oid_str, ecparams->named_curve))
  ------------------
  |  Branch (1653:8): [True: 0, False: 0]
  ------------------
 1654|      0|				break;
 1655|      0|		}
 1656|      0|		if (!ec_curve_infos[ii].name) {
  ------------------
  |  Branch (1656:7): [True: 0, False: 0]
  ------------------
 1657|      0|			sc_log(ctx, "Named curve '%s' not supported", ecparams->named_curve);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1658|      0|			LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1659|      0|		}
 1660|       |
 1661|      0|		rv = sc_format_oid(&ecparams->id, ec_curve_infos[ii].oid_str);
 1662|      0|		LOG_TEST_RET(ctx, rv, "Invalid OID format");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1663|       |
 1664|      0|		ecparams->field_length = ec_curve_infos[ii].size;
 1665|      0|		ecparams->key_type = ec_curve_infos[ii].key_type;
 1666|      0|		sc_log(ctx, "Curve length %zu key_type %d", ecparams->field_length, ecparams->key_type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1667|       |
 1668|      0|		if (ecparams->der.value == NULL || ecparams->der.len == 0) {
  ------------------
  |  Branch (1668:7): [True: 0, False: 0]
  |  Branch (1668:38): [True: 0, False: 0]
  ------------------
 1669|      0|			free(ecparams->der.value); /* just in case */
 1670|      0|			ecparams->der.value = NULL;
 1671|      0|			ecparams->der.len = 0;
 1672|       |			/* if caller did not provide valid der OID, fill in */
 1673|      0|			rv = sc_encode_oid (ctx, &ecparams->id, &ecparams->der.value, &ecparams->der.len);
 1674|      0|			LOG_TEST_RET(ctx, rv, "Cannot encode object ID");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1675|      0|		}
 1676|      0|	} else
 1677|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_IMPLEMENTED, "EC parameters has to be presented as a named curve or explicit data");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1678|       |
 1679|  8.63k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  8.63k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  8.63k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  8.63k|	int _ret = r; \
  |  |  |  |  155|  8.63k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8.63k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  8.63k|		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: 8.63k]
  |  |  |  |  ------------------
  |  |  |  |  157|  8.63k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  8.63k|	} 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|  8.63k|	return _ret; \
  |  |  |  |  163|  8.63k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1680|  8.63k|}
pkcs15-pubkey.c:sc_pkcs15_dup_bignum:
 1017|    352|{
 1018|    352|	if (!dst || !src) {
  ------------------
  |  Branch (1018:6): [True: 0, False: 352]
  |  Branch (1018:14): [True: 0, False: 352]
  ------------------
 1019|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1020|      0|	}
 1021|       |
 1022|    352|	if (src->data && src->len)   {
  ------------------
  |  Branch (1022:6): [True: 352, False: 0]
  |  Branch (1022:19): [True: 352, False: 0]
  ------------------
 1023|    352|		dst->data = calloc(1, src->len);
 1024|    352|		if (!dst->data)
  ------------------
  |  Branch (1024:7): [True: 0, False: 352]
  ------------------
 1025|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1026|    352|		memcpy(dst->data, src->data, src->len);
 1027|    352|		dst->len = src->len;
 1028|    352|	}
 1029|       |
 1030|    352|	return 0;
 1031|    352|}

sc_pkcs15emu_sc_hsm_decode_cvc:
  433|    152|{
  434|    152|	sc_card_t *card = p15card->card;
  435|    152|	struct sc_asn1_entry asn1_req[C_ASN1_REQ_SIZE];
  436|    152|	struct sc_asn1_entry asn1_authreq[C_ASN1_AUTHREQ_SIZE];
  437|    152|	struct sc_asn1_entry asn1_cvc[C_ASN1_CVC_SIZE];
  438|    152|	struct sc_asn1_entry asn1_cvcert[C_ASN1_CVCERT_SIZE];
  439|    152|	struct sc_asn1_entry asn1_cvc_body[C_ASN1_CVC_BODY_SIZE];
  440|    152|	struct sc_asn1_entry asn1_cvc_pubkey[C_ASN1_CVC_PUBKEY_SIZE];
  441|    152|	unsigned int cla = 0, tag = 0;
  442|    152|	size_t taglen;
  443|    152|	const u8 *tbuf;
  444|    152|	int r;
  445|       |
  446|    152|	memset(cvc, 0, sizeof(*cvc));
  447|    152|	sc_copy_asn1_entry(c_asn1_req, asn1_req);
  448|    152|	sc_copy_asn1_entry(c_asn1_cvc, asn1_cvc);
  449|       |
  450|    152|	r = sc_pkcs15emu_sc_hsm_format_asn1_cvcert(
  451|    152|			asn1_cvcert, C_ASN1_CVCERT_SIZE,
  ------------------
  |  |  242|    152|#define C_ASN1_CVCERT_SIZE 3
  ------------------
  452|    152|			asn1_cvc_body, C_ASN1_CVC_BODY_SIZE,
  ------------------
  |  |  233|    152|#define C_ASN1_CVC_BODY_SIZE 5
  ------------------
  453|    152|			asn1_cvc_pubkey, C_ASN1_CVC_PUBKEY_SIZE,
  ------------------
  |  |  219|    152|#define C_ASN1_CVC_PUBKEY_SIZE 10
  ------------------
  454|    152|			cvc);
  455|    152|	LOG_TEST_RET(card->ctx, r, "sc_asn1_entry array too small");
  ------------------
  |  |  174|    152|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    152|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    152|	int _ret = (r); \
  |  |  |  |  168|    152|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 152]
  |  |  |  |  ------------------
  |  |  |  |  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|    152|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 152]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  456|       |
  457|    152|	sc_format_asn1_entry(asn1_cvc, asn1_cvcert, NULL, 0);
  458|       |
  459|    152|	r = sc_pkcs15emu_sc_hsm_format_asn1_req(
  460|    152|			asn1_authreq, C_ASN1_AUTHREQ_SIZE,
  ------------------
  |  |  255|    152|#define C_ASN1_AUTHREQ_SIZE 4
  ------------------
  461|    152|			asn1_cvcert, cvc);
  462|    152|	LOG_TEST_RET(card->ctx, r, "sc_asn1_entry array too small");
  ------------------
  |  |  174|    152|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    152|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    152|	int _ret = (r); \
  |  |  |  |  168|    152|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 152]
  |  |  |  |  ------------------
  |  |  |  |  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|    152|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 152]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  463|       |
  464|    152|	sc_format_asn1_entry(asn1_req, asn1_authreq, NULL, 0);
  465|       |
  466|       |/*	sc_asn1_print_tags(*buf, *buflen); */
  467|       |
  468|    152|	tbuf = *buf;
  469|    152|	r = sc_asn1_read_tag(&tbuf, *buflen, &cla, &tag, &taglen);
  470|    152|	LOG_TEST_RET(card->ctx, r, "Could not decode card verifiable certificate");
  ------------------
  |  |  174|    152|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    152|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    152|	int _ret = (r); \
  |  |  |  |  168|    152|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 89, False: 63]
  |  |  |  |  ------------------
  |  |  |  |  169|     89|		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|     89|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     89|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     89|		return _ret; \
  |  |  |  |  172|     89|	} \
  |  |  |  |  173|    152|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 63]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  471|       |
  472|       |	/*  Determine if we deal with an authenticated request, plain request or certificate */
  473|     63|	if ((cla == (SC_ASN1_TAG_APPLICATION|SC_ASN1_TAG_CONSTRUCTED)) && (tag == 7)) {
  ------------------
  |  |  186|     63|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
              	if ((cla == (SC_ASN1_TAG_APPLICATION|SC_ASN1_TAG_CONSTRUCTED)) && (tag == 7)) {
  ------------------
  |  |  190|     63|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
  |  Branch (473:6): [True: 40, False: 23]
  |  Branch (473:68): [True: 11, False: 29]
  ------------------
  474|     11|		r = sc_asn1_decode(card->ctx, asn1_req, *buf, *buflen, buf, buflen);
  475|     52|	} else {
  476|     52|		r = sc_asn1_decode(card->ctx, asn1_cvc, *buf, *buflen, buf, buflen);
  477|     52|	}
  478|       |
  479|     63|	LOG_TEST_RET(card->ctx, r, "Could not decode card verifiable certificate");
  ------------------
  |  |  174|     63|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     63|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     63|	int _ret = (r); \
  |  |  |  |  168|     63|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 63, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     63|		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|     63|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     63|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     63|		return _ret; \
  |  |  |  |  172|     63|	} \
  |  |  |  |  173|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|       |
  481|      0|	fixup_cvc_printable_string_lengths(cvc);
  482|       |
  483|      0|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  484|      0|}
sc_pkcs15emu_sc_hsm_free_cvc:
 1025|     22|{
 1026|     22|	if (cvc->outerSignature) {
  ------------------
  |  Branch (1026:6): [True: 0, False: 22]
  ------------------
 1027|      0|		free(cvc->outerSignature);
 1028|      0|		cvc->outerSignature = NULL;
 1029|      0|	}
 1030|     22|	if (cvc->signature) {
  ------------------
  |  Branch (1030:6): [True: 0, False: 22]
  ------------------
 1031|      0|		free(cvc->signature);
 1032|      0|		cvc->signature = NULL;
 1033|      0|	}
 1034|     22|	if (cvc->primeOrModulus) {
  ------------------
  |  Branch (1034:6): [True: 0, False: 22]
  ------------------
 1035|      0|		free(cvc->primeOrModulus);
 1036|      0|		cvc->primeOrModulus = NULL;
 1037|      0|	}
 1038|     22|	if (cvc->coefficientAorExponent) {
  ------------------
  |  Branch (1038:6): [True: 0, False: 22]
  ------------------
 1039|      0|		free(cvc->coefficientAorExponent);
 1040|      0|		cvc->coefficientAorExponent = NULL;
 1041|      0|	}
 1042|     22|	if (cvc->coefficientB) {
  ------------------
  |  Branch (1042:6): [True: 0, False: 22]
  ------------------
 1043|      0|		free(cvc->coefficientB);
 1044|      0|		cvc->coefficientB = NULL;
 1045|      0|	}
 1046|     22|	if (cvc->basePointG) {
  ------------------
  |  Branch (1046:6): [True: 0, False: 22]
  ------------------
 1047|      0|		free(cvc->basePointG);
 1048|      0|		cvc->basePointG = NULL;
 1049|      0|	}
 1050|     22|	if (cvc->order) {
  ------------------
  |  Branch (1050:6): [True: 0, False: 22]
  ------------------
 1051|      0|		free(cvc->order);
 1052|      0|		cvc->order = NULL;
 1053|      0|	}
 1054|     22|	if (cvc->publicPoint) {
  ------------------
  |  Branch (1054:6): [True: 0, False: 22]
  ------------------
 1055|      0|		free(cvc->publicPoint);
 1056|      0|		cvc->publicPoint = NULL;
 1057|      0|	}
 1058|     22|	if (cvc->cofactor) {
  ------------------
  |  Branch (1058:6): [True: 0, False: 22]
  ------------------
 1059|      0|		free(cvc->cofactor);
 1060|       |		cvc->cofactor = NULL;
 1061|      0|	}
 1062|     22|}
sc_pkcs15emu_sc_hsm_init_ex:
 1612|  12.9k|{
 1613|  12.9k|	if (p15card->card->type != SC_CARD_TYPE_SC_HSM
  ------------------
  |  Branch (1613:6): [True: 12.9k, False: 0]
  ------------------
 1614|  12.9k|			&& p15card->card->type != SC_CARD_TYPE_SC_HSM_SOC
  ------------------
  |  Branch (1614:7): [True: 12.9k, False: 0]
  ------------------
 1615|  12.9k|			&& p15card->card->type != SC_CARD_TYPE_SC_HSM_GOID) {
  ------------------
  |  Branch (1615:7): [True: 12.5k, False: 337]
  ------------------
 1616|  12.5k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  12.5k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
 1617|  12.5k|	}
 1618|    337|	return sc_pkcs15emu_sc_hsm_init(p15card);
 1619|  12.9k|}
pkcs15-sc-hsm.c:sc_pkcs15emu_sc_hsm_format_asn1_cvcert:
  365|    152|{
  366|    152|	if ((asn1_cvc_pubkey_len < C_ASN1_CVC_PUBKEY_SIZE) ||
  ------------------
  |  |  219|    152|#define C_ASN1_CVC_PUBKEY_SIZE 10
  ------------------
  |  Branch (366:6): [True: 0, False: 152]
  ------------------
  367|    152|		(asn1_cvc_body_len < C_ASN1_CVC_BODY_SIZE) ||
  ------------------
  |  |  233|    152|#define C_ASN1_CVC_BODY_SIZE 5
  ------------------
  |  Branch (367:3): [True: 0, False: 152]
  ------------------
  368|    152|		(asn1_cvcert_len < C_ASN1_CVCERT_SIZE)) {
  ------------------
  |  |  242|    152|#define C_ASN1_CVCERT_SIZE 3
  ------------------
  |  Branch (368:3): [True: 0, False: 152]
  ------------------
  369|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  370|      0|	}
  371|       |
  372|    152|	sc_copy_asn1_entry(c_asn1_cvc_pubkey, asn1_cvc_pubkey);
  373|    152|	sc_copy_asn1_entry(c_asn1_cvc_body, asn1_cvc_body);
  374|    152|	sc_copy_asn1_entry(c_asn1_cvcert, asn1_cvcert);
  375|       |
  376|    152|	sc_format_asn1_entry(asn1_cvc_pubkey    , &cvc->pukoid, NULL, 0);
  377|    152|	sc_format_asn1_entry(asn1_cvc_pubkey + 1, &cvc->primeOrModulus, &cvc->primeOrModuluslen, 0);
  378|    152|	sc_format_asn1_entry(asn1_cvc_pubkey + 2, &cvc->coefficientAorExponent, &cvc->coefficientAorExponentlen, 0);
  379|    152|	sc_format_asn1_entry(asn1_cvc_pubkey + 3, &cvc->coefficientB, &cvc->coefficientBlen, 0);
  380|    152|	sc_format_asn1_entry(asn1_cvc_pubkey + 4, &cvc->basePointG, &cvc->basePointGlen, 0);
  381|    152|	sc_format_asn1_entry(asn1_cvc_pubkey + 5, &cvc->order, &cvc->orderlen, 0);
  382|    152|	sc_format_asn1_entry(asn1_cvc_pubkey + 6, &cvc->publicPoint, &cvc->publicPointlen, 0);
  383|    152|	sc_format_asn1_entry(asn1_cvc_pubkey + 7, &cvc->cofactor, &cvc->cofactorlen, 0);
  384|    152|	sc_format_asn1_entry(asn1_cvc_pubkey + 8, &cvc->modulusSize, NULL, 0);
  385|       |
  386|    152|	sc_format_asn1_entry(asn1_cvc_body    , &cvc->cpi, NULL, 0);
  387|    152|	cvc->carLen = sizeof(cvc->car);
  388|    152|	sc_format_asn1_entry(asn1_cvc_body + 1, &cvc->car, &cvc->carLen, 0);
  389|    152|	sc_format_asn1_entry(asn1_cvc_body + 2, asn1_cvc_pubkey, NULL, 0);
  390|    152|	cvc->chrLen = sizeof(cvc->chr);
  391|    152|	sc_format_asn1_entry(asn1_cvc_body + 3, &cvc->chr, &cvc->chrLen, 0);
  392|       |
  393|    152|	sc_format_asn1_entry(asn1_cvcert    , asn1_cvc_body, NULL, 0);
  394|    152|	sc_format_asn1_entry(asn1_cvcert + 1, &cvc->signature, &cvc->signatureLen, 0);
  395|    152|	return SC_SUCCESS;
  ------------------
  |  |   28|    152|#define SC_SUCCESS				0
  ------------------
  396|    152|}
pkcs15-sc-hsm.c:sc_pkcs15emu_sc_hsm_format_asn1_req:
  413|    152|{
  414|    152|	if (asn1_authreq_len < C_ASN1_AUTHREQ_SIZE) {
  ------------------
  |  |  255|    152|#define C_ASN1_AUTHREQ_SIZE 4
  ------------------
  |  Branch (414:6): [True: 0, False: 152]
  ------------------
  415|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  416|      0|	}
  417|       |
  418|    152|	sc_copy_asn1_entry(c_asn1_authreq, asn1_authreq);
  419|       |
  420|    152|	sc_format_asn1_entry(asn1_authreq    , asn1_cvcert, NULL, 0);
  421|    152|	cvc->outerCARLen = sizeof(cvc->outer_car);
  422|    152|	sc_format_asn1_entry(asn1_authreq + 1, &cvc->outer_car, &cvc->outerCARLen, 0);
  423|    152|	sc_format_asn1_entry(asn1_authreq + 2, &cvc->outerSignature, &cvc->outerSignatureLen, 0);
  424|    152|	return SC_SUCCESS;
  ------------------
  |  |   28|    152|#define SC_SUCCESS				0
  ------------------
  425|    152|}
pkcs15-sc-hsm.c:sc_pkcs15emu_sc_hsm_init:
 1350|    337|{
 1351|    337|	sc_card_t *card = p15card->card;
 1352|    337|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
 1353|    337|	sc_file_t *file = NULL;
 1354|    337|	sc_path_t path;
 1355|    337|	u8 filelist[MAX_EXT_APDU_LENGTH];
 1356|    337|	int filelistlength;
 1357|    337|	int r, i;
 1358|    337|	sc_cvc_t devcert;
 1359|    337|	struct sc_app_info *appinfo;
 1360|    337|	struct sc_pkcs15_auth_info pin_info;
 1361|    337|	struct sc_pkcs15_object pin_obj;
 1362|    337|	struct sc_pin_cmd_data pindata;
 1363|    337|	u8 efbin[1024];
 1364|    337|	u8 *ptr;
 1365|    337|	size_t len;
 1366|       |
 1367|    337|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    337|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    337|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    337|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    337|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 337]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1368|       |
 1369|    337|	appinfo = calloc(1, sizeof(struct sc_app_info));
 1370|       |
 1371|    337|	if (appinfo == NULL) {
  ------------------
  |  Branch (1371:6): [True: 0, False: 337]
  ------------------
 1372|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1373|      0|	}
 1374|       |
 1375|    337|	appinfo->aid = sc_hsm_aid;
 1376|       |
 1377|    337|	appinfo->ddo.aid = sc_hsm_aid;
 1378|    337|	p15card->app = appinfo;
 1379|       |
 1380|    337|	sc_path_set(&path, SC_PATH_TYPE_DF_NAME, sc_hsm_aid.value, sc_hsm_aid.len, 0, 0);
  ------------------
  |  |  118|    337|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 1381|    337|	r = sc_select_file(card, &path, &file);
 1382|    337|	LOG_TEST_RET(card->ctx, r, "Could not select SmartCard-HSM application");
  ------------------
  |  |  174|    337|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    337|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    337|	int _ret = (r); \
  |  |  |  |  168|    337|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 186, False: 151]
  |  |  |  |  ------------------
  |  |  |  |  169|    186|		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|    186|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    186|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    186|		return _ret; \
  |  |  |  |  172|    186|	} \
  |  |  |  |  173|    337|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 151]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1383|       |
 1384|    151|	p15card->card->version.hw_major = 24;	/* JCOP 2.4.1r3 */
 1385|    151|	p15card->card->version.hw_minor = 13;
 1386|    151|	if (file && file->prop_attr && file->prop_attr_len >= 2) {
  ------------------
  |  Branch (1386:6): [True: 151, False: 0]
  |  Branch (1386:14): [True: 23, False: 128]
  |  Branch (1386:33): [True: 12, False: 11]
  ------------------
 1387|     12|		p15card->card->version.fw_major = file->prop_attr[file->prop_attr_len - 2];
 1388|     12|		p15card->card->version.fw_minor = file->prop_attr[file->prop_attr_len - 1];
 1389|     12|	}
 1390|       |
 1391|    151|	sc_file_free(file);
 1392|       |
 1393|       |	/* Read device certificate to determine serial number */
 1394|    151|	if (priv->EF_C_DevAut && priv->EF_C_DevAut_len) {
  ------------------
  |  Branch (1394:6): [True: 21, False: 130]
  |  Branch (1394:27): [True: 21, False: 0]
  ------------------
 1395|     21|		ptr = priv->EF_C_DevAut;
 1396|     21|		len = priv->EF_C_DevAut_len;
 1397|    130|	} else {
 1398|    130|		len = sizeof efbin;
 1399|    130|		r = read_file(p15card, (u8 *) "\x2F\x02", efbin, &len, 1);
 1400|    130|		LOG_TEST_RET(card->ctx, r, "Skipping optional EF.C_DevAut");
  ------------------
  |  |  174|    130|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    130|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    130|	int _ret = (r); \
  |  |  |  |  168|    130|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 130]
  |  |  |  |  ------------------
  |  |  |  |  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|    130|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 130]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1401|       |
 1402|    130|		if (len > 0) {
  ------------------
  |  Branch (1402:7): [True: 46, False: 84]
  ------------------
 1403|       |			/* save EF_C_DevAut for further use */
 1404|     46|			ptr = realloc(priv->EF_C_DevAut, len);
 1405|     46|			if (ptr) {
  ------------------
  |  Branch (1405:8): [True: 46, False: 0]
  ------------------
 1406|     46|				memcpy(ptr, efbin, len);
 1407|     46|				priv->EF_C_DevAut = ptr;
 1408|     46|				priv->EF_C_DevAut_len = len;
 1409|     46|			}
 1410|     46|		}
 1411|       |
 1412|    130|		ptr = efbin;
 1413|    130|	}
 1414|       |
 1415|    151|	memset(&devcert, 0 ,sizeof(devcert));
 1416|    151|	r = sc_pkcs15emu_sc_hsm_decode_cvc(p15card, (const u8 **)&ptr, &len, &devcert);
 1417|    151|	LOG_TEST_RET(card->ctx, r, "Could not decode EF.C_DevAut");
  ------------------
  |  |  174|    151|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    151|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    151|	int _ret = (r); \
  |  |  |  |  168|    151|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 151, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    151|		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|    151|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    151|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    151|		return _ret; \
  |  |  |  |  172|    151|	} \
  |  |  |  |  173|    151|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1418|       |
 1419|      0|	sc_pkcs15emu_sc_hsm_read_tokeninfo(p15card);
 1420|       |
 1421|      0|	if (p15card->tokeninfo->label == NULL) {
  ------------------
  |  Branch (1421:6): [True: 0, False: 0]
  ------------------
 1422|      0|		if (p15card->card->type == SC_CARD_TYPE_SC_HSM_GOID
  ------------------
  |  Branch (1422:7): [True: 0, False: 0]
  ------------------
 1423|      0|				|| p15card->card->type == SC_CARD_TYPE_SC_HSM_SOC) {
  ------------------
  |  Branch (1423:8): [True: 0, False: 0]
  ------------------
 1424|      0|			p15card->tokeninfo->label = strdup("GoID");
 1425|      0|		} else {
 1426|      0|			p15card->tokeninfo->label = strdup("SmartCard-HSM");
 1427|      0|		}
 1428|      0|		if (p15card->tokeninfo->label == NULL)
  ------------------
  |  Branch (1428:7): [True: 0, False: 0]
  ------------------
 1429|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1430|      0|	}
 1431|       |
 1432|      0|	if ((p15card->tokeninfo->manufacturer_id != NULL) && !strcmp("(unknown)", p15card->tokeninfo->manufacturer_id)) {
  ------------------
  |  Branch (1432:6): [True: 0, False: 0]
  |  Branch (1432:55): [True: 0, False: 0]
  ------------------
 1433|      0|		free(p15card->tokeninfo->manufacturer_id);
 1434|      0|		p15card->tokeninfo->manufacturer_id = NULL;
 1435|      0|	}
 1436|       |
 1437|      0|	if (p15card->tokeninfo->manufacturer_id == NULL) {
  ------------------
  |  Branch (1437:6): [True: 0, False: 0]
  ------------------
 1438|      0|		if (p15card->card->type == SC_CARD_TYPE_SC_HSM_GOID
  ------------------
  |  Branch (1438:7): [True: 0, False: 0]
  ------------------
 1439|      0|				|| p15card->card->type == SC_CARD_TYPE_SC_HSM_SOC) {
  ------------------
  |  Branch (1439:8): [True: 0, False: 0]
  ------------------
 1440|      0|			p15card->tokeninfo->manufacturer_id = strdup("Bundesdruckerei GmbH");
 1441|      0|		} else {
 1442|      0|			p15card->tokeninfo->manufacturer_id = strdup("www.CardContact.de");
 1443|      0|		}
 1444|      0|		if (p15card->tokeninfo->manufacturer_id == NULL) {
  ------------------
  |  Branch (1444:7): [True: 0, False: 0]
  ------------------
 1445|      0|			sc_pkcs15_card_clear(p15card);
 1446|      0|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1447|      0|		}
 1448|      0|	}
 1449|       |
 1450|      0|	appinfo->label = strdup(p15card->tokeninfo->label);
 1451|      0|	if (appinfo->label == NULL) {
  ------------------
  |  Branch (1451:6): [True: 0, False: 0]
  ------------------
 1452|      0|		sc_pkcs15_card_clear(p15card);
 1453|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1454|      0|	}
 1455|       |
 1456|      0|	len = strnlen(devcert.chr, sizeof devcert.chr);		/* Strip last 5 digit sequence number from CHR */
 1457|      0|	if (len < 8)
  ------------------
  |  Branch (1457:6): [True: 0, False: 0]
  ------------------
 1458|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1459|      0|	len -= 5;
 1460|       |
 1461|      0|	free(p15card->tokeninfo->serial_number);
 1462|      0|	p15card->tokeninfo->serial_number = calloc(1, len + 1);
 1463|      0|	if (p15card->tokeninfo->serial_number == NULL) {
  ------------------
  |  Branch (1463:6): [True: 0, False: 0]
  ------------------
 1464|      0|		sc_pkcs15_card_clear(p15card);
 1465|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1466|      0|	}
 1467|       |
 1468|      0|	memcpy(p15card->tokeninfo->serial_number, devcert.chr, len);
 1469|      0|	*(p15card->tokeninfo->serial_number + len) = 0;
 1470|       |
 1471|      0|	sc_hsm_set_serialnr(card, p15card->tokeninfo->serial_number);
 1472|       |
 1473|      0|	sc_pkcs15emu_sc_hsm_free_cvc(&devcert);
 1474|       |
 1475|      0|	memset(&pin_info, 0, sizeof(pin_info));
 1476|      0|	memset(&pin_obj, 0, sizeof(pin_obj));
 1477|       |
 1478|      0|	pin_info.auth_id.len = 1;
 1479|      0|	pin_info.auth_id.value[0] = 1;
 1480|      0|	pin_info.path.aid = sc_hsm_aid;
 1481|      0|	pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|      0|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1482|      0|	pin_info.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1483|      0|	pin_info.attrs.pin.reference = 0x81;
 1484|      0|	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_INITIALIZED|SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA;
  ------------------
  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
              	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_INITIALIZED|SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA;
  ------------------
  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
              	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_INITIALIZED|SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA;
  ------------------
  |  |   65|      0|#define SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA		0x0800
  ------------------
 1485|      0|	pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|      0|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
 1486|      0|	pin_info.attrs.pin.min_length = 6;
 1487|      0|	pin_info.attrs.pin.stored_length = 0;
 1488|      0|	pin_info.attrs.pin.max_length = 15;
 1489|      0|	pin_info.attrs.pin.pad_char = '\0';
 1490|      0|	pin_info.tries_left = 3;
 1491|      0|	pin_info.max_tries = 3;
 1492|       |
 1493|      0|	pin_obj.auth_id.len = 1;
 1494|      0|	pin_obj.auth_id.value[0] = 2;
 1495|      0|	strlcpy(pin_obj.label, "UserPIN", sizeof(pin_obj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1496|      0|	pin_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
              	pin_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
 1497|       |
 1498|      0|	pin_obj.data = &pin_info;
 1499|       |
 1500|      0|	r = sc_pkcs15_get_pin_info(p15card, &pin_obj);
 1501|       |
 1502|      0|	if (r != SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (1502:6): [True: 0, False: 0]
  ------------------
 1503|      0|		if (r < 0) {
  ------------------
  |  Branch (1503:7): [True: 0, False: 0]
  ------------------
 1504|      0|			sc_pkcs15_card_clear(p15card);
 1505|      0|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1506|      0|		}
 1507|       |
 1508|      0|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
 1509|      0|		if (r < 0) {
  ------------------
  |  Branch (1509:7): [True: 0, False: 0]
  ------------------
 1510|      0|			sc_pkcs15_card_clear(p15card);
 1511|      0|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1512|      0|		}
 1513|      0|	}
 1514|       |
 1515|      0|	memset(&pin_info, 0, sizeof(pin_info));
 1516|      0|	memset(&pin_obj, 0, sizeof(pin_obj));
 1517|       |
 1518|      0|	pin_info.auth_id.len = 1;
 1519|      0|	pin_info.auth_id.value[0] = 2;
 1520|      0|	pin_info.path.aid = sc_hsm_aid;
 1521|      0|	pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|      0|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1522|      0|	pin_info.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1523|      0|	pin_info.attrs.pin.reference = 0x88;
 1524|      0|	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED|SC_PKCS15_PIN_FLAG_SO_PIN;
  ------------------
  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
              	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED|SC_PKCS15_PIN_FLAG_SO_PIN;
  ------------------
  |  |   57|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED		0x0008
  ------------------
              	pin_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_LOCAL|SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED|SC_PKCS15_PIN_FLAG_SO_PIN;
  ------------------
  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
 1525|      0|	pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_BCD;
  ------------------
  |  |   88|      0|#define SC_PKCS15_PIN_TYPE_BCD				0
  ------------------
 1526|      0|	pin_info.attrs.pin.min_length = 16;
 1527|      0|	pin_info.attrs.pin.stored_length = 0;
 1528|      0|	pin_info.attrs.pin.max_length = 16;
 1529|      0|	pin_info.attrs.pin.pad_char = '\0';
 1530|      0|	pin_info.tries_left = 15;
 1531|      0|	pin_info.max_tries = 15;
 1532|       |
 1533|      0|	strlcpy(pin_obj.label, "SOPIN", sizeof(pin_obj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1534|      0|	pin_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 1535|       |
 1536|      0|	pin_obj.data = &pin_info;
 1537|       |
 1538|      0|	r = sc_pkcs15_get_pin_info(p15card, &pin_obj);
 1539|       |
 1540|      0|	if (r != SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (1540:6): [True: 0, False: 0]
  ------------------
 1541|      0|		pin_info.attrs.pin.flags |= SC_PKCS15_PIN_FLAG_INITIALIZED;
  ------------------
  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
 1542|      0|	} else {
 1543|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1544|      0|	}
 1545|       |
 1546|      0|	if (r < 0) {
  ------------------
  |  Branch (1546:6): [True: 0, False: 0]
  ------------------
 1547|      0|		sc_pkcs15_card_clear(p15card);
 1548|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1549|      0|	}
 1550|       |
 1551|      0|	r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
 1552|      0|	if (r < 0) {
  ------------------
  |  Branch (1552:6): [True: 0, False: 0]
  ------------------
 1553|      0|		sc_pkcs15_card_clear(p15card);
 1554|      0|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1555|      0|	}
 1556|       |
 1557|       |
 1558|      0|	if (card->type == SC_CARD_TYPE_SC_HSM_SOC
  ------------------
  |  Branch (1558:6): [True: 0, False: 0]
  ------------------
 1559|      0|			|| card->type == SC_CARD_TYPE_SC_HSM_GOID) {
  ------------------
  |  Branch (1559:7): [True: 0, False: 0]
  ------------------
 1560|       |		/* SC-HSM of this type always has a PIN-Pad */
 1561|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1562|      0|	} else {
 1563|      0|		memset(&pindata, 0, sizeof(pindata));
 1564|      0|		pindata.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
 1565|      0|		pindata.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1566|      0|		pindata.pin_reference = 0x85;
 1567|       |
 1568|      0|		r = sc_pin_cmd(card, &pindata);
 1569|      0|	}
 1570|      0|	if (r == SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (1570:6): [True: 0, False: 0]
  ------------------
 1571|      0|		memset(&pindata, 0, sizeof(pindata));
 1572|      0|		pindata.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
 1573|      0|		pindata.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1574|      0|		pindata.pin_reference = 0x86;
 1575|       |
 1576|      0|		r = sc_pin_cmd(card, &pindata);
 1577|      0|	}
 1578|       |
 1579|      0|	if ((r != SC_ERROR_DATA_OBJECT_NOT_FOUND) && (r != SC_ERROR_INCORRECT_PARAMETERS) && (r != SC_ERROR_REF_DATA_NOT_USABLE))
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
              	if ((r != SC_ERROR_DATA_OBJECT_NOT_FOUND) && (r != SC_ERROR_INCORRECT_PARAMETERS) && (r != SC_ERROR_REF_DATA_NOT_USABLE))
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
              	if ((r != SC_ERROR_DATA_OBJECT_NOT_FOUND) && (r != SC_ERROR_INCORRECT_PARAMETERS) && (r != SC_ERROR_REF_DATA_NOT_USABLE))
  ------------------
  |  |   70|      0|#define SC_ERROR_REF_DATA_NOT_USABLE	-1220
  ------------------
  |  Branch (1579:6): [True: 0, False: 0]
  |  Branch (1579:47): [True: 0, False: 0]
  |  Branch (1579:87): [True: 0, False: 0]
  ------------------
 1580|      0|		card->caps |= SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH;
  ------------------
  |  |  560|      0|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
 1581|       |
 1582|       |
 1583|      0|	filelistlength = sc_list_files(card, filelist, sizeof(filelist));
 1584|      0|	if (filelistlength < 0)
  ------------------
  |  Branch (1584:6): [True: 0, False: 0]
  ------------------
 1585|      0|		sc_pkcs15_card_clear(p15card);
 1586|      0|	LOG_TEST_RET(card->ctx, filelistlength, "Could not enumerate file and key identifier");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1587|       |
 1588|      0|	for (i = 0; i < filelistlength; i += 2) {
  ------------------
  |  Branch (1588:14): [True: 0, False: 0]
  ------------------
 1589|      0|		switch(filelist[i]) {
  ------------------
  |  Branch (1589:10): [True: 0, False: 0]
  ------------------
 1590|      0|		case KEY_PREFIX:
  ------------------
  |  |   33|      0|#define KEY_PREFIX		0xCC		/* Hi byte in file identifier for key objects */
  ------------------
  |  Branch (1590:3): [True: 0, False: 0]
  ------------------
 1591|      0|			r = sc_pkcs15emu_sc_hsm_add_prkd(p15card, filelist[i + 1]);
 1592|      0|			break;
 1593|      0|		case DCOD_PREFIX:
  ------------------
  |  |   31|      0|#define DCOD_PREFIX		0xC9		/* Hi byte in file identifier for PKCS#15 DCOD objects */
  ------------------
  |  Branch (1593:3): [True: 0, False: 0]
  ------------------
 1594|      0|			r = sc_pkcs15emu_sc_hsm_add_dcod(p15card, filelist[i + 1]);
 1595|      0|			break;
 1596|      0|		case CD_PREFIX:
  ------------------
  |  |   30|      0|#define CD_PREFIX		0xC8		/* Hi byte in file identifier for PKCS#15 CD objects */
  ------------------
  |  Branch (1596:3): [True: 0, False: 0]
  ------------------
 1597|      0|			r = sc_pkcs15emu_sc_hsm_add_cd(p15card, filelist[i + 1]);
 1598|      0|			break;
 1599|      0|		}
 1600|      0|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1600:7): [True: 0, False: 0]
  ------------------
 1601|      0|			sc_log(card->ctx, "Error %d adding elements to framework", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1602|      0|		}
 1603|      0|	}
 1604|       |
 1605|      0|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1606|      0|}
pkcs15-sc-hsm.c:read_file:
  293|    130|{
  294|    130|	sc_path_t path;
  295|    130|	int r;
  296|       |
  297|    130|	sc_path_set(&path, SC_PATH_TYPE_FILE_ID, fid, 2, 0, 0);
  ------------------
  |  |  117|    130|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  298|       |	/* look this up with our AID */
  299|    130|	path.aid = sc_hsm_aid;
  300|       |	/* we don't have a pre-known size of the file */
  301|    130|	path.count = -1;
  302|    130|	if (!p15card->opts.use_file_cache || !efbin
  ------------------
  |  Branch (302:6): [True: 130, False: 0]
  |  Branch (302:39): [True: 0, False: 0]
  ------------------
  303|    130|			|| SC_SUCCESS != sc_pkcs15_read_cached_file(p15card, &path, &efbin, len)) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (303:7): [True: 0, False: 0]
  ------------------
  304|       |		/* avoid re-selection of SC-HSM */
  305|    130|		path.aid.len = 0;
  306|    130|		r = sc_select_file(p15card->card, &path, NULL);
  307|    130|		if (r < 0) {
  ------------------
  |  Branch (307:7): [True: 62, False: 68]
  ------------------
  308|     62|			sc_log(p15card->card->ctx, "Could not select EF");
  ------------------
  |  |   71|     62|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  309|     68|		} else {
  310|     68|			r = sc_read_binary(p15card->card, 0, efbin, *len, 0);
  311|     68|		}
  312|       |
  313|    130|		if (r < 0) {
  ------------------
  |  Branch (313:7): [True: 70, False: 60]
  ------------------
  314|     70|			sc_log(p15card->card->ctx, "Could not read EF");
  ------------------
  |  |   71|     70|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  315|     70|			if (!optional) {
  ------------------
  |  Branch (315:8): [True: 0, False: 70]
  ------------------
  316|      0|				return r;
  317|      0|			}
  318|       |			/* optional files are saved as empty files to avoid card
  319|       |			 * transactions. Parsing the file's data will reveal that they were
  320|       |			 * missing. */
  321|     70|			*len = 0;
  322|     70|		} else {
  323|     60|			*len = r;
  324|     60|		}
  325|       |
  326|    130|		if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (326:7): [True: 0, False: 130]
  ------------------
  327|       |			/* save this with our AID */
  328|      0|			path.aid = sc_hsm_aid;
  329|      0|			sc_pkcs15_cache_file(p15card, &path, efbin, *len);
  330|      0|		}
  331|    130|	}
  332|       |
  333|    130|	return SC_SUCCESS;
  ------------------
  |  |   28|    130|#define SC_SUCCESS				0
  ------------------
  334|    130|}

sc_pkcs15_decipher:
  283|    203|{
  284|    203|	sc_context_t *ctx = p15card->card->ctx;
  285|    203|	int r;
  286|    203|	sc_algorithm_info_t *alg_info = NULL;
  287|    203|	sc_security_env_t senv;
  288|    203|	const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data;
  289|    203|	unsigned long pad_flags = 0, sec_flags = 0;
  290|       |
  291|    203|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    203|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    203|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    203|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    203|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 203]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|       |
  293|    203|	if (!(prkey->usage & (SC_PKCS15_PRKEY_USAGE_DECRYPT|SC_PKCS15_PRKEY_USAGE_UNWRAP)))
  ------------------
  |  |  306|    203|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              	if (!(prkey->usage & (SC_PKCS15_PRKEY_USAGE_DECRYPT|SC_PKCS15_PRKEY_USAGE_UNWRAP)))
  ------------------
  |  |  310|    203|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  |  Branch (293:6): [True: 0, False: 203]
  ------------------
  294|    203|		LOG_TEST_RET(ctx, SC_ERROR_NOT_ALLOWED, "This key cannot be used for decryption");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  295|       |
  296|    203|	r = format_senv(p15card, obj, &senv, &alg_info);
  297|    203|	LOG_TEST_RET(ctx, r, "Could not initialize security environment");
  ------------------
  |  |  174|    203|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    203|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    203|	int _ret = (r); \
  |  |  |  |  168|    203|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 13, False: 190]
  |  |  |  |  ------------------
  |  |  |  |  169|     13|		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|     13|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     13|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     13|		return _ret; \
  |  |  |  |  172|     13|	} \
  |  |  |  |  173|    203|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 190]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|    190|	senv.operation = SC_SEC_OPERATION_DECIPHER;
  ------------------
  |  |   47|    190|#define SC_SEC_OPERATION_DECIPHER	0x0001
  ------------------
  299|       |
  300|    190|	r = sc_get_encoding_flags(ctx, flags, alg_info->flags, &pad_flags, &sec_flags);
  301|    190|	LOG_TEST_RET(ctx, r, "cannot encode security operation flags");
  ------------------
  |  |  174|    190|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    190|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    190|	int _ret = (r); \
  |  |  |  |  168|    190|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 190]
  |  |  |  |  ------------------
  |  |  |  |  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|    190|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 190]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  302|    190|	senv.algorithm_flags = sec_flags;
  303|       |
  304|    190|	r = use_key(p15card, obj, &senv, sc_decipher, in, inlen, out,
  305|    190|			outlen);
  306|    190|	LOG_TEST_RET(ctx, r, "use_key() failed");
  ------------------
  |  |  174|    190|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    190|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    190|	int _ret = (r); \
  |  |  |  |  168|    190|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 99, False: 91]
  |  |  |  |  ------------------
  |  |  |  |  169|     99|		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|     99|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     99|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     99|		return _ret; \
  |  |  |  |  172|     99|	} \
  |  |  |  |  173|    190|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 91]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  307|       |
  308|       |	/* Strip any padding */
  309|     91|	if (pad_flags & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) {
  ------------------
  |  |  110|     91|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  |  Branch (309:6): [True: 70, False: 21]
  ------------------
  310|     70|		unsigned int s = r;
  311|     70|		unsigned int key_size = (unsigned int)alg_info->key_length;
  312|     70|		r = sc_pkcs1_strip_02_padding_constant_time(ctx, key_size / 8, out, s, out, &s);
  313|       |		/* for keeping PKCS#1 v1.5 depadding constant-time, do not log error here */
  314|     70|	}
  315|     21|#ifdef ENABLE_OPENSSL
  316|     21|	else if (pad_flags & SC_ALGORITHM_RSA_PAD_OAEP) {
  ------------------
  |  |  108|     21|#define SC_ALGORITHM_RSA_PAD_OAEP	0x00000020 /* PKCS#1 v2.0 OAEP */
  ------------------
  |  Branch (316:11): [True: 0, False: 21]
  ------------------
  317|      0|		size_t s = r;
  318|      0|		uint8_t *param = NULL;
  319|      0|		size_t paramlen = 0;
  320|      0|		if (pMechanism != NULL) {
  ------------------
  |  Branch (320:7): [True: 0, False: 0]
  ------------------
  321|      0|			CK_MECHANISM *mech = (CK_MECHANISM *)pMechanism;
  322|      0|			if (mech->pParameter && sizeof(CK_RSA_PKCS_OAEP_PARAMS) == mech->ulParameterLen) {
  ------------------
  |  Branch (322:8): [True: 0, False: 0]
  |  Branch (322:28): [True: 0, False: 0]
  ------------------
  323|      0|				CK_RSA_PKCS_OAEP_PARAMS * oaep_params = mech->pParameter;
  324|      0|				if (oaep_params->source == CKZ_DATA_SPECIFIED) {
  ------------------
  |  | 1227|      0|#define CKZ_DATA_SPECIFIED 0x00000001UL
  ------------------
  |  Branch (324:9): [True: 0, False: 0]
  ------------------
  325|      0|					param = oaep_params->pSourceData;
  326|      0|					paramlen = (size_t)oaep_params->ulSourceDataLen;
  327|      0|				}
  328|      0|			}
  329|      0|		}
  330|      0|		r = sc_pkcs1_strip_oaep_padding(ctx, out, s, flags, param, paramlen);
  331|      0|		LOG_TEST_RET(ctx, r, "Invalid OAEP padding");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  332|      0|	}
  333|     91|#endif
  334|       |	/* do not log error code to prevent side channel attack */
  335|     91|	return r;
  336|     91|}
sc_pkcs15_compute_signature:
  597|    243|{
  598|    243|	sc_context_t *ctx = p15card->card->ctx;
  599|    243|	int r;
  600|    243|	sc_security_env_t senv;
  601|    243|	sc_algorithm_info_t *alg_info;
  602|    243|	const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data;
  603|    243|	u8 *buf = NULL, *tmp;
  604|    243|	size_t modlen = 0, buflen = 0;
  605|    243|	unsigned long pad_flags = 0, sec_flags = 0;
  606|       |
  607|    243|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    243|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    243|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    243|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    243|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 243]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  608|       |
  609|    243|	if (!(prkey->usage & (SC_PKCS15_PRKEY_USAGE_SIGN|SC_PKCS15_PRKEY_USAGE_SIGNRECOVER|
  ------------------
  |  |  307|    243|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
              	if (!(prkey->usage & (SC_PKCS15_PRKEY_USAGE_SIGN|SC_PKCS15_PRKEY_USAGE_SIGNRECOVER|
  ------------------
  |  |  308|    243|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
  |  Branch (609:6): [True: 0, False: 243]
  ------------------
  610|    243|					SC_PKCS15_PRKEY_USAGE_NONREPUDIATION)))
  ------------------
  |  |  314|    243|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  611|    243|		LOG_TEST_RET(ctx, SC_ERROR_NOT_ALLOWED, "This key cannot be used for signing");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|       |
  613|    243|	r = format_senv(p15card, obj, &senv, &alg_info);
  614|    243|	LOG_TEST_RET(ctx, r, "Could not initialize security environment");
  ------------------
  |  |  174|    243|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    243|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    243|	int _ret = (r); \
  |  |  |  |  168|    243|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 233]
  |  |  |  |  ------------------
  |  |  |  |  169|     10|		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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     10|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     10|		return _ret; \
  |  |  |  |  172|     10|	} \
  |  |  |  |  173|    243|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 233]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  615|    233|	senv.operation = SC_SEC_OPERATION_SIGN;
  ------------------
  |  |   48|    233|#define SC_SEC_OPERATION_SIGN		0x0002
  ------------------
  616|       |
  617|    233|	switch (obj->type) {
  618|    204|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    204|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (618:3): [True: 204, False: 29]
  ------------------
  619|    204|			modlen = BYTES4BITS(prkey->modulus_length);
  ------------------
  |  |  145|    204|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  620|    204|			break;
  621|      0|		case SC_PKCS15_TYPE_PRKEY_GOSTR3410:
  ------------------
  |  |  420|      0|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  |  Branch (621:3): [True: 0, False: 233]
  ------------------
  622|      0|			modlen = BYTES4BITS(prkey->modulus_length) * 2;
  ------------------
  |  |  145|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  623|      0|			break;
  624|     29|		case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     29|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (624:3): [True: 29, False: 204]
  ------------------
  625|     29|		case SC_PKCS15_TYPE_PRKEY_EDDSA:
  ------------------
  |  |  422|     29|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
  |  Branch (625:3): [True: 0, False: 233]
  ------------------
  626|     29|		case SC_PKCS15_TYPE_PRKEY_XEDDSA:
  ------------------
  |  |  423|     29|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
  |  Branch (626:3): [True: 0, False: 233]
  ------------------
  627|     29|			modlen = BYTES4BITS(prkey->field_length) * 2;  /* 2*nLen */
  ------------------
  |  |  145|     29|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  628|     29|			break;
  629|      0|		default:
  ------------------
  |  Branch (629:3): [True: 0, False: 233]
  ------------------
  630|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Key type not supported");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|    233|	}
  632|       |
  633|       |	/* Probably never happens, but better make sure */
  634|    233|	if (outlen < modlen)
  ------------------
  |  Branch (634:6): [True: 0, False: 233]
  ------------------
  635|    233|		LOG_FUNC_RETURN(ctx, SC_ERROR_BUFFER_TOO_SMALL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|       |
  637|    233|	buflen = inlen + modlen;
  638|    233|	buf = sc_mem_secure_alloc(buflen);
  639|    233|	if (buf == NULL)
  ------------------
  |  Branch (639:6): [True: 0, False: 233]
  ------------------
  640|    233|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  641|    233|	memcpy(buf, in, inlen);
  642|       |
  643|       |	/* revert data to sign when signing with the GOST key.
  644|       |	 * TODO: can it be confirmed by the GOST standard?
  645|       |	 * TODO: tested with RuTokenECP, has to be validated for RuToken. */
  646|    233|	if (obj->type == SC_PKCS15_TYPE_PRKEY_GOSTR3410) {
  ------------------
  |  |  420|    233|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  |  Branch (646:6): [True: 0, False: 233]
  ------------------
  647|      0|		r = sc_mem_reverse(buf, inlen);
  648|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Reverse memory error");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  649|      0|	}
  650|       |
  651|    233|	tmp = buf;
  652|       |
  653|       |	/* flags: the requested algo
  654|       |	 * algo_info->flags: what is supported by the card
  655|       |	 * senv.algorithm_flags: what the card will have to do */
  656|       |
  657|       |	/* if the card has SC_ALGORITHM_NEED_USAGE set, and the
  658|       |	 * key is for signing and decryption, we need to emulate signing */
  659|       |
  660|    233|	sc_log(ctx, "supported algorithm flags 0x%lX, private key usage 0x%X", alg_info->flags, prkey->usage);
  ------------------
  |  |   71|    233|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  661|    233|	if (obj->type == SC_PKCS15_TYPE_PRKEY_RSA) {
  ------------------
  |  |  419|    233|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (661:6): [True: 204, False: 29]
  ------------------
  662|    204|		if ((alg_info->flags & SC_ALGORITHM_NEED_USAGE) &&
  ------------------
  |  |   95|    204|#define SC_ALGORITHM_NEED_USAGE		0x40000000
  ------------------
  |  Branch (662:7): [True: 0, False: 204]
  ------------------
  663|      0|			((prkey->usage & USAGE_ANY_SIGN) &&
  ------------------
  |  |  588|      0|#define USAGE_ANY_SIGN          (SC_PKCS15_PRKEY_USAGE_SIGN|\
  |  |  ------------------
  |  |  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  |  |  ------------------
  |  |  589|      0|                                 SC_PKCS15_PRKEY_USAGE_NONREPUDIATION)
  |  |  ------------------
  |  |  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  |  |  ------------------
  ------------------
  |  Branch (663:5): [True: 0, False: 0]
  ------------------
  664|      0|			(prkey->usage & USAGE_ANY_DECIPHER)) ) {
  ------------------
  |  |  590|      0|#define USAGE_ANY_DECIPHER      (SC_PKCS15_PRKEY_USAGE_DECRYPT|\
  |  |  ------------------
  |  |  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |  591|      0|                                 SC_PKCS15_PRKEY_USAGE_UNWRAP)
  |  |  ------------------
  |  |  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  ------------------
  |  Branch (664:4): [True: 0, False: 0]
  ------------------
  665|      0|			size_t tmplen = buflen;
  666|      0|			if (flags & SC_ALGORITHM_RSA_RAW) {
  ------------------
  |  |  102|      0|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  |  Branch (666:8): [True: 0, False: 0]
  ------------------
  667|      0|				r = sc_pkcs15_decipher(p15card, obj, flags, in, inlen, out, outlen, NULL);
  668|      0|				goto err;
  669|      0|			}
  670|      0|			if (modlen > tmplen)
  ------------------
  |  Branch (670:8): [True: 0, False: 0]
  ------------------
  671|      0|				LOG_TEST_GOTO_ERR(ctx, SC_ERROR_NOT_ALLOWED, "Buffer too small, needs recompile!");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  672|       |
  673|       |			/* XXX Assuming RSA key here */
  674|      0|			r = sc_pkcs1_encode(ctx, flags, in, inlen, buf, &tmplen, prkey->modulus_length, pMechanism);
  675|       |
  676|       |			/* no padding needed - already done */
  677|      0|			flags &= ~SC_ALGORITHM_RSA_PADS;
  ------------------
  |  |  103|      0|#define SC_ALGORITHM_RSA_PADS		0x000000FF
  ------------------
  678|       |			/* instead use raw rsa */
  679|      0|			flags |= SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|      0|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  680|       |
  681|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Unable to add padding");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  682|       |
  683|      0|			r = sc_pkcs15_decipher(p15card, obj, flags, buf, modlen, out, outlen, NULL);
  684|      0|			goto err;
  685|      0|		}
  686|       |
  687|       |
  688|       |		/* If the card doesn't support the requested algorithm, we normally add the
  689|       |		 * padding here in software and ask the card to do a raw signature.  There's
  690|       |		 * one exception to that, where we might be able to get the signature to
  691|       |		 * succeed by stripping padding if the card only offers higher-level
  692|       |		 * signature operations.  The only thing we can strip is the DigestInfo
  693|       |		 * block from PKCS1 padding. */
  694|    204|		if ((flags == (SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_NONE)) &&
  ------------------
  |  |  109|    204|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		if ((flags == (SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_NONE)) &&
  ------------------
  |  |  133|    204|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  |  Branch (694:7): [True: 66, False: 138]
  ------------------
  695|     66|			!(alg_info->flags & SC_ALGORITHM_RSA_RAW) &&
  ------------------
  |  |  102|     66|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  |  Branch (695:4): [True: 20, False: 46]
  ------------------
  696|     20|			!(alg_info->flags & SC_ALGORITHM_RSA_HASH_NONE) &&
  ------------------
  |  |  133|     20|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  |  Branch (696:4): [True: 0, False: 20]
  ------------------
  697|      0|			(alg_info->flags & 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 */
  ------------------
  |  Branch (697:4): [True: 0, False: 0]
  ------------------
  698|      0|			unsigned int algo;
  699|      0|			size_t tmplen = buflen;
  700|       |
  701|      0|			r = sc_pkcs1_strip_digest_info_prefix(&algo, tmp, inlen, tmp, &tmplen);
  702|      0|			if (r != SC_SUCCESS || algo == SC_ALGORITHM_RSA_HASH_NONE) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
              			if (r != SC_SUCCESS || algo == SC_ALGORITHM_RSA_HASH_NONE) {
  ------------------
  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  |  Branch (702:8): [True: 0, False: 0]
  |  Branch (702:27): [True: 0, False: 0]
  ------------------
  703|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  704|      0|				goto err;
  705|      0|			}
  706|      0|			flags &= ~SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  707|      0|			flags |= algo;
  708|      0|			inlen = tmplen;
  709|      0|		}
  710|    204|	}
  711|       |
  712|       |
  713|       |	/* ECDSA software hash has already been done, or is not needed, or card will do hash */
  714|       |	/* if card can not do the hash, will use SC_ALGORITHM_ECDSA_RAW */
  715|    233|	if (obj->type == SC_PKCS15_TYPE_PRKEY_EC) {
  ------------------
  |  |  421|    233|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (715:6): [True: 29, False: 204]
  ------------------
  716|     29|		if ((alg_info->flags & SC_ALGORITHM_ECDSA_RAW)
  ------------------
  |  |  174|     29|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  |  Branch (716:7): [True: 29, False: 0]
  ------------------
  717|     29|				&& !(flags & SC_ALGORITHM_ECDSA_HASHES & alg_info->flags)) {
  ------------------
  |  |  181|     29|#define SC_ALGORITHM_ECDSA_HASHES		(SC_ALGORITHM_ECDSA_HASH_SHA1 | \
  |  |  ------------------
  |  |  |  |  176|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  |  |  ------------------
  |  |  |  |  |  |  134|     29|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  182|     29|							SC_ALGORITHM_ECDSA_HASH_SHA224 | \
  |  |  ------------------
  |  |  |  |  177|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA224		SC_ALGORITHM_RSA_HASH_SHA224
  |  |  |  |  ------------------
  |  |  |  |  |  |  141|     29|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  183|     29|							SC_ALGORITHM_ECDSA_HASH_SHA256 | \
  |  |  ------------------
  |  |  |  |  178|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|     29|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  184|     29|							SC_ALGORITHM_ECDSA_HASH_SHA384 | \
  |  |  ------------------
  |  |  |  |  179|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA384		SC_ALGORITHM_RSA_HASH_SHA384
  |  |  |  |  ------------------
  |  |  |  |  |  |  139|     29|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  185|     29|							SC_ALGORITHM_ECDSA_HASH_SHA512)
  |  |  ------------------
  |  |  |  |  180|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA512		SC_ALGORITHM_RSA_HASH_SHA512
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|     29|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (717:8): [True: 29, False: 0]
  ------------------
  718|     29|			sc_log(ctx, "ECDSA using SC_ALGORITHM_ECDSA_RAW flags before 0x%8.8lx", flags);
  ------------------
  |  |   71|     29|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  719|     29|				flags |= SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  174|     29|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  720|     29|				flags &= ~SC_ALGORITHM_ECDSA_HASHES;
  ------------------
  |  |  181|     29|#define SC_ALGORITHM_ECDSA_HASHES		(SC_ALGORITHM_ECDSA_HASH_SHA1 | \
  |  |  ------------------
  |  |  |  |  176|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  |  |  ------------------
  |  |  |  |  |  |  134|     29|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  182|     29|							SC_ALGORITHM_ECDSA_HASH_SHA224 | \
  |  |  ------------------
  |  |  |  |  177|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA224		SC_ALGORITHM_RSA_HASH_SHA224
  |  |  |  |  ------------------
  |  |  |  |  |  |  141|     29|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  183|     29|							SC_ALGORITHM_ECDSA_HASH_SHA256 | \
  |  |  ------------------
  |  |  |  |  178|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|     29|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  184|     29|							SC_ALGORITHM_ECDSA_HASH_SHA384 | \
  |  |  ------------------
  |  |  |  |  179|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA384		SC_ALGORITHM_RSA_HASH_SHA384
  |  |  |  |  ------------------
  |  |  |  |  |  |  139|     29|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  185|     29|							SC_ALGORITHM_ECDSA_HASH_SHA512)
  |  |  ------------------
  |  |  |  |  180|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA512		SC_ALGORITHM_RSA_HASH_SHA512
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|     29|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  721|     29|		}
  722|     29|	}
  723|       |
  724|    233|	r = sc_get_encoding_flags(ctx, flags, alg_info->flags, &pad_flags, &sec_flags);
  725|    233|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    233|#define SC_SUCCESS				0
  ------------------
  |  Branch (725:6): [True: 0, False: 233]
  ------------------
  726|      0|		goto err;
  727|      0|	}
  728|       |	/* senv now has flags card or driver will do */
  729|    233|	senv.algorithm_flags = sec_flags;
  730|       |
  731|    233|	sc_log(ctx, "DEE flags:0x%8.8lx alg_info->flags:0x%8.8lx pad:0x%8.8lx sec:0x%8.8lx",
  ------------------
  |  |   71|    233|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  732|    233|		flags, alg_info->flags, pad_flags, sec_flags);
  733|       |
  734|       |	/* add the padding bytes (if necessary) */
  735|    233|	if (pad_flags != 0) {
  ------------------
  |  Branch (735:6): [True: 113, False: 120]
  ------------------
  736|    113|		size_t tmplen = buflen;
  737|       |
  738|       |		/* XXX Assuming RSA key here */
  739|    113|		r = sc_pkcs1_encode(ctx, pad_flags, tmp, inlen, tmp, &tmplen,
  740|    113|		    prkey->modulus_length, pMechanism);
  741|    113|		LOG_TEST_GOTO_ERR(ctx, r, "Unable to add padding");
  ------------------
  |  |  184|    113|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    113|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    113|	int _ret = (r); \
  |  |  |  |  178|    113|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 113]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|    113|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 113]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|    113|		inlen = tmplen;
  743|    113|	}
  744|    120|	else if ( senv.algorithm == SC_ALGORITHM_RSA &&
  ------------------
  |  |   69|    240|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (744:12): [True: 91, False: 29]
  ------------------
  745|     91|	          (flags & SC_ALGORITHM_RSA_PADS) == SC_ALGORITHM_RSA_PAD_NONE) {
  ------------------
  |  |  103|     91|#define SC_ALGORITHM_RSA_PADS		0x000000FF
  ------------------
              	          (flags & SC_ALGORITHM_RSA_PADS) == SC_ALGORITHM_RSA_PAD_NONE) {
  ------------------
  |  |  104|     91|#define SC_ALGORITHM_RSA_PAD_NONE	0x00000001
  ------------------
  |  Branch (745:12): [True: 17, False: 74]
  ------------------
  746|       |		/* Add zero-padding if input is shorter than the modulus */
  747|     17|		if (inlen < modlen) {
  ------------------
  |  Branch (747:7): [True: 16, False: 1]
  ------------------
  748|     16|			if (modlen > buflen) {
  ------------------
  |  Branch (748:8): [True: 0, False: 16]
  ------------------
  749|      0|				r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  750|      0|				goto err;
  751|      0|			}
  752|     16|			memmove(tmp+modlen-inlen, tmp, inlen);
  753|     16|			memset(tmp, 0, modlen-inlen);
  754|     16|		}
  755|     17|		inlen = modlen;
  756|     17|	}
  757|       |	/* PKCS#11 MECHANISMS V2.30: 6.3.1 EC Signatures
  758|       |	 * If the length of the hash value is larger than the bit length of n, only
  759|       |	 * the leftmost bits of the hash up to the length of n will be used. Any
  760|       |	 * truncation is done by the token.
  761|       |	 * But if card is going to do the hash, pass in all the data
  762|       |	 */
  763|    103|	else if (senv.algorithm == SC_ALGORITHM_EC &&
  ------------------
  |  |   70|    206|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (763:11): [True: 29, False: 74]
  ------------------
  764|     29|			(senv.algorithm_flags & SC_ALGORITHM_ECDSA_HASHES) == 0) {
  ------------------
  |  |  181|     29|#define SC_ALGORITHM_ECDSA_HASHES		(SC_ALGORITHM_ECDSA_HASH_SHA1 | \
  |  |  ------------------
  |  |  |  |  176|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  |  |  ------------------
  |  |  |  |  |  |  134|     29|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  182|     29|							SC_ALGORITHM_ECDSA_HASH_SHA224 | \
  |  |  ------------------
  |  |  |  |  177|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA224		SC_ALGORITHM_RSA_HASH_SHA224
  |  |  |  |  ------------------
  |  |  |  |  |  |  141|     29|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  183|     29|							SC_ALGORITHM_ECDSA_HASH_SHA256 | \
  |  |  ------------------
  |  |  |  |  178|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  |  |  ------------------
  |  |  |  |  |  |  138|     29|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  184|     29|							SC_ALGORITHM_ECDSA_HASH_SHA384 | \
  |  |  ------------------
  |  |  |  |  179|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA384		SC_ALGORITHM_RSA_HASH_SHA384
  |  |  |  |  ------------------
  |  |  |  |  |  |  139|     29|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  185|     29|							SC_ALGORITHM_ECDSA_HASH_SHA512)
  |  |  ------------------
  |  |  |  |  180|     29|#define SC_ALGORITHM_ECDSA_HASH_SHA512		SC_ALGORITHM_RSA_HASH_SHA512
  |  |  |  |  ------------------
  |  |  |  |  |  |  140|     29|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (764:4): [True: 29, False: 0]
  ------------------
  765|     29|		inlen = MIN(inlen, BYTES4BITS(prkey->field_length));
  ------------------
  |  |   69|     29|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 2, False: 27]
  |  |  ------------------
  ------------------
  766|     29|	}
  767|       |
  768|       |
  769|    233|	r = use_key(p15card, obj, &senv, sc_compute_signature, tmp, inlen,
  770|    233|			out, outlen);
  771|    233|	LOG_TEST_GOTO_ERR(ctx, r, "use_key() failed");
  ------------------
  |  |  184|    233|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    233|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    233|	int _ret = (r); \
  |  |  |  |  178|    233|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 200, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  179|    200|		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|    200|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    200|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    200|		goto err; \
  |  |  |  |  182|    200|	} \
  |  |  |  |  183|    233|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 33]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  772|       |
  773|       |	/* Some cards may return RSA signature as integer without leading zero bytes */
  774|       |	/* Already know outlen >= modlen and r >= 0 */
  775|     33|	if (obj->type == SC_PKCS15_TYPE_PRKEY_RSA && (unsigned)r < modlen) {
  ------------------
  |  |  419|     66|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (775:6): [True: 33, False: 0]
  |  Branch (775:47): [True: 25, False: 8]
  ------------------
  776|     25|		memmove(out + modlen - r, out, r);
  777|     25|		memset(out, 0, modlen - r);
  778|     25|		r = (int)modlen;
  779|     25|	}
  780|       |
  781|    233|err:
  782|    233|	sc_mem_secure_clear_free(buf, buflen);
  ------------------
  |  | 1580|    233|#define sc_mem_secure_clear_free(ptr, len) do { \
  |  | 1581|    233|	sc_mem_clear(ptr, len); \
  |  | 1582|    233|	sc_mem_secure_free(ptr, len); \
  |  | 1583|    233|} while (0);
  |  |  ------------------
  |  |  |  Branch (1583:10): [Folded, False: 233]
  |  |  ------------------
  ------------------
  783|       |
  784|    233|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    233|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    233|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    233|	int _ret = r; \
  |  |  |  |  155|    233|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 200, False: 33]
  |  |  |  |  ------------------
  |  |  |  |  156|    200|		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|    200|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 200, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    200|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    200|	} else { \
  |  |  |  |  159|     33|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     33|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     33|	} \
  |  |  |  |  162|    233|	return _ret; \
  |  |  |  |  163|    233|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  785|    233|}
pkcs15-sec.c:format_senv:
  175|    446|{
  176|    446|	sc_context_t *ctx = p15card->card->ctx;
  177|    446|	const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data;
  178|    446|	const struct sc_pkcs15_skey_info *skey = (const struct sc_pkcs15_skey_info *) obj->data;
  179|       |
  180|    446|	memset(senv_out, 0, sizeof(*senv_out));
  181|       |
  182|       |	/* Card driver should have the access to supported algorithms from 'tokenInfo'. So that
  183|       |	 * it can get value of card specific 'AlgorithmInfo::algRef'. */
  184|    446|	memcpy(senv_out->supported_algos, &p15card->tokeninfo->supported_algos, sizeof(senv_out->supported_algos));
  185|       |
  186|    446|	if (!((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY || (obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_SKEY))
  ------------------
  |  |  416|    446|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              	if (!((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY || (obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_SKEY))
  ------------------
  |  |  418|    892|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
              	if (!((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY || (obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_SKEY))
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              	if (!((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY || (obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_SKEY))
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (186:8): [True: 446, False: 0]
  |  Branch (186:75): [True: 0, False: 0]
  ------------------
  187|    446|		LOG_TEST_RET(ctx, SC_ERROR_NOT_ALLOWED, "This is not a private or secret key");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|       |
  189|       |	/* If the key is not native, we can't operate with it. */
  190|    446|	if (!prkey->native)
  ------------------
  |  Branch (190:6): [True: 0, False: 446]
  ------------------
  191|    446|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "This key is not native, cannot operate with it");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|       |
  193|    446|	switch (obj->type) {
  194|    414|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    414|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (194:3): [True: 414, False: 32]
  ------------------
  195|    414|			*alg_info_out = sc_card_find_rsa_alg(p15card->card, prkey->modulus_length);
  196|    414|			if (*alg_info_out == NULL) {
  ------------------
  |  Branch (196:8): [True: 20, False: 394]
  ------------------
  197|     20|				sc_log(ctx, "Card does not support RSA with key length %zu",
  ------------------
  |  |   71|     20|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  198|     20|						prkey->modulus_length);
  199|     20|				LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     20|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     20|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     20|	int _ret = r; \
  |  |  |  |  155|     20|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     20|		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|     20|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     20|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     20|	} 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|     20|	return _ret; \
  |  |  |  |  163|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  200|     20|			}
  201|    394|			senv_out->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|    394|#define SC_ALGORITHM_RSA		0
  ------------------
  202|    394|			senv_out->key_size_bits = prkey->modulus_length;
  203|    394|			break;
  204|       |
  205|      0|		case SC_PKCS15_TYPE_PRKEY_GOSTR3410:
  ------------------
  |  |  420|      0|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  |  Branch (205:3): [True: 0, False: 446]
  ------------------
  206|      0|			*alg_info_out = sc_card_find_gostr3410_alg(p15card->card, prkey->modulus_length);
  207|      0|			if (*alg_info_out == NULL) {
  ------------------
  |  Branch (207:8): [True: 0, False: 0]
  ------------------
  208|      0|				sc_log(ctx, "Card does not support GOSTR3410 with key length %zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  209|      0|						prkey->modulus_length);
  210|      0|				LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  211|      0|			}
  212|      0|			senv_out->algorithm = SC_ALGORITHM_GOSTR3410;
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  213|      0|			senv_out->key_size_bits = prkey->modulus_length;
  214|      0|			break;
  215|       |
  216|      0|		case SC_PKCS15_TYPE_PRKEY_EDDSA:
  ------------------
  |  |  422|      0|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
  |  Branch (216:3): [True: 0, False: 446]
  ------------------
  217|      0|			*alg_info_out = sc_card_find_eddsa_alg(p15card->card, prkey->field_length, NULL);
  218|      0|			if (*alg_info_out == NULL) {
  ------------------
  |  Branch (218:8): [True: 0, False: 0]
  ------------------
  219|      0|				sc_log(ctx, "Card does not support EDDSA with field_size %zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  220|      0|						prkey->field_length);
  221|      0|				LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|      0|			}
  223|      0|			senv_out->algorithm = SC_ALGORITHM_EDDSA;
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  224|      0|			senv_out->key_size_bits = prkey->field_length;
  225|      0|			break;
  226|       |
  227|      0|		case SC_PKCS15_TYPE_PRKEY_XEDDSA:
  ------------------
  |  |  423|      0|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
  |  Branch (227:3): [True: 0, False: 446]
  ------------------
  228|      0|			*alg_info_out = sc_card_find_xeddsa_alg(p15card->card, prkey->field_length, NULL);
  229|      0|			if (*alg_info_out == NULL) {
  ------------------
  |  Branch (229:8): [True: 0, False: 0]
  ------------------
  230|      0|				sc_log(ctx, "Card does not support XEDDSA with field_size %zu",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  231|      0|						prkey->field_length);
  232|      0|				LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|      0|			}
  234|      0|			senv_out->algorithm = SC_ALGORITHM_XEDDSA;
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  235|      0|			senv_out->key_size_bits = prkey->field_length;
  236|      0|			break;
  237|       |
  238|     32|		case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     32|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (238:3): [True: 32, False: 414]
  ------------------
  239|     32|			*alg_info_out = sc_card_find_ec_alg(p15card->card, prkey->field_length, NULL);
  240|     32|			if (*alg_info_out == NULL) {
  ------------------
  |  Branch (240:8): [True: 3, False: 29]
  ------------------
  241|      3|				sc_log(ctx, "Card does not support EC with field_size %zu",
  ------------------
  |  |   71|      3|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  242|      3|						prkey->field_length);
  243|      3|				LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} 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|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  244|      3|			}
  245|     29|			senv_out->algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   70|     29|#define SC_ALGORITHM_EC		2
  ------------------
  246|     29|			senv_out->key_size_bits = prkey->field_length;
  247|       |
  248|     29|			senv_out->flags |= SC_SEC_ENV_ALG_REF_PRESENT;
  ------------------
  |  |   56|     29|#define SC_SEC_ENV_ALG_REF_PRESENT	0x0001
  ------------------
  249|     29|			senv_out->algorithm_ref = prkey->field_length;
  250|     29|			break;
  251|      0|		case SC_PKCS15_TYPE_SKEY_GENERIC:
  ------------------
  |  |  433|      0|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  |  Branch (251:3): [True: 0, False: 446]
  ------------------
  252|      0|			if (skey->key_type != CKK_AES)
  ------------------
  |  |  485|      0|#define CKK_AES 0x0000001FUL
  ------------------
  |  Branch (252:8): [True: 0, False: 0]
  ------------------
  253|      0|				LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Key type not supported");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  254|      0|			*alg_info_out = sc_card_find_alg(p15card->card, SC_ALGORITHM_AES,
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_AES		67
  ------------------
  255|      0|					skey->value_len, NULL);
  256|      0|			if (*alg_info_out == NULL) {
  ------------------
  |  Branch (256:8): [True: 0, False: 0]
  ------------------
  257|      0|				sc_log(ctx, "Card does not support AES with key length %zu", skey->value_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  258|      0|				LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  259|      0|			}
  260|      0|			senv_out->algorithm = SC_ALGORITHM_AES;
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_AES		67
  ------------------
  261|      0|			senv_out->key_size_bits = skey->value_len;
  262|      0|			break;
  263|       |			/* add other crypto types here */
  264|      0|		default:
  ------------------
  |  Branch (264:3): [True: 0, False: 446]
  ------------------
  265|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Key type not supported");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  266|    446|	}
  267|    423|	senv_out->flags |= SC_SEC_ENV_ALG_PRESENT;
  ------------------
  |  |   60|    423|#define SC_SEC_ENV_ALG_PRESENT		0x0010
  ------------------
  268|       |
  269|       |	/* optional keyReference attribute (the default value is -1) */
  270|    423|	if (prkey->key_reference >= 0) {
  ------------------
  |  Branch (270:6): [True: 423, False: 0]
  ------------------
  271|    423|		senv_out->key_ref_len = 1;
  272|    423|		senv_out->key_ref[0] = prkey->key_reference & 0xFF;
  273|    423|		senv_out->flags |= SC_SEC_ENV_KEY_REF_PRESENT;
  ------------------
  |  |   58|    423|#define SC_SEC_ENV_KEY_REF_PRESENT	0x0004
  ------------------
  274|    423|	}
  275|       |
  276|    423|	return SC_SUCCESS;
  ------------------
  |  |   28|    423|#define SC_SUCCESS				0
  ------------------
  277|    446|}
pkcs15-sec.c:use_key:
  133|    423|{
  134|    423|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    423|#define SC_SUCCESS				0
  ------------------
  135|    423|	int revalidated_cached_pin = 0;
  136|    423|	sc_path_t path;
  137|    423|	LOG_TEST_RET(p15card->card->ctx, get_file_path(obj, &path), "Failed to get key file path.");
  ------------------
  |  |  174|    423|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    423|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    423|	int _ret = (r); \
  |  |  |  |  168|    423|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 423]
  |  |  |  |  ------------------
  |  |  |  |  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|    423|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 423]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  138|       |
  139|    423|	r = sc_lock(p15card->card);
  140|    423|	LOG_TEST_RET(p15card->card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|    423|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    423|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    423|	int _ret = (r); \
  |  |  |  |  168|    423|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 423]
  |  |  |  |  ------------------
  |  |  |  |  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|    423|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 423]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|       |
  142|    432|	do {
  143|    432|		if (path.len != 0 || path.aid.len != 0) {
  ------------------
  |  Branch (143:7): [True: 62, False: 370]
  |  Branch (143:24): [True: 2, False: 368]
  ------------------
  144|     64|			r = select_key_file(p15card, obj, senv);
  145|     64|			if (r < 0) {
  ------------------
  |  Branch (145:8): [True: 8, False: 56]
  ------------------
  146|      8|				sc_log(p15card->card->ctx,
  ------------------
  |  |   71|      8|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  147|      8|						"Unable to select private key file");
  148|      8|			}
  149|     64|		}
  150|    432|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|    432|#define SC_SUCCESS				0
  ------------------
  |  Branch (150:7): [True: 424, False: 8]
  ------------------
  151|    424|			r = sc_set_security_env(p15card->card, senv, 0);
  152|       |
  153|    432|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|    432|#define SC_SUCCESS				0
  ------------------
  |  Branch (153:7): [True: 335, False: 97]
  ------------------
  154|    335|			r = card_command(p15card->card, in, inlen, out, outlen);
  155|       |
  156|    432|		if (revalidated_cached_pin)
  ------------------
  |  Branch (156:7): [True: 9, False: 423]
  ------------------
  157|       |			/* only re-validate once */
  158|      9|			break;
  159|    423|		if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {
  ------------------
  |  |   61|    423|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (159:7): [True: 17, False: 406]
  ------------------
  160|     17|			r = sc_pkcs15_pincache_revalidate(p15card, obj);
  161|     17|			if (r < 0)
  ------------------
  |  Branch (161:8): [True: 8, False: 9]
  ------------------
  162|      8|				break;
  163|      9|			revalidated_cached_pin = 1;
  164|      9|		}
  165|    423|	} while (revalidated_cached_pin);
  ------------------
  |  Branch (165:11): [True: 9, False: 406]
  ------------------
  166|       |
  167|    423|	sc_unlock(p15card->card);
  168|       |
  169|    423|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  164|    423|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    423|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    423|	int _ret = r; \
  |  |  |  |  155|    423|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 316, False: 107]
  |  |  |  |  ------------------
  |  |  |  |  156|    316|		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|    299|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 299, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  157|    316|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    316|	} else { \
  |  |  |  |  159|    107|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    107|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    107|	} \
  |  |  |  |  162|    423|	return _ret; \
  |  |  |  |  163|    423|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  170|    423|}
pkcs15-sec.c:get_file_path:
   57|    487|{
   58|    487|	if (!path)
  ------------------
  |  Branch (58:6): [True: 0, False: 487]
  ------------------
   59|      0|		return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
   60|       |
   61|    487|	const struct sc_pkcs15_prkey_info *prkey = (const struct sc_pkcs15_prkey_info *) obj->data;
   62|    487|	const struct sc_pkcs15_skey_info *skey = (const struct sc_pkcs15_skey_info *) obj->data;
   63|       |
   64|    487|	if ((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY) {
  ------------------
  |  |  416|    487|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              	if ((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY) {
  ------------------
  |  |  418|    487|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (64:6): [True: 487, False: 0]
  ------------------
   65|    487|		*path = prkey->path;
   66|    487|	}
   67|      0|	else if ((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_SKEY) {
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              	else if ((obj->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_SKEY) {
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (67:11): [True: 0, False: 0]
  ------------------
   68|      0|		*path = skey->path;
   69|      0|	}
   70|      0|	else
   71|      0|		return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
   72|       |
   73|    487|	return SC_SUCCESS;
  ------------------
  |  |   28|    487|#define SC_SUCCESS				0
  ------------------
   74|    487|}
pkcs15-sec.c:select_key_file:
   80|     64|{
   81|     64|	sc_context_t *ctx = p15card->card->ctx;
   82|     64|	sc_path_t orig_path;
   83|     64|	sc_path_t path, file_id;
   84|     64|	int r;
   85|       |
   86|     64|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     64|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     64|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     64|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     64|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 64]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   87|       |
   88|     64|	LOG_TEST_RET(ctx, get_file_path(key, &orig_path), "Could not get key file path.");
  ------------------
  |  |  174|     64|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     64|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     64|	int _ret = (r); \
  |  |  |  |  168|     64|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 64]
  |  |  |  |  ------------------
  |  |  |  |  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|     64|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 64]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   89|     64|	memset(&path, 0, sizeof(sc_path_t));
   90|     64|	memset(&file_id, 0, sizeof(sc_path_t));
   91|       |
   92|       |	/* TODO: Why file_app may be NULL -- at least 3F00 has to be present?
   93|       |	 * Check validity of the following assumption. */
   94|       |	/* For pkcs15-emulated cards, the file_app may be NULL,
   95|       |	 * in that case we always assume an absolute path */
   96|     64|	if (!orig_path.len && orig_path.aid.len) {
  ------------------
  |  Branch (96:6): [True: 2, False: 62]
  |  Branch (96:24): [True: 2, False: 0]
  ------------------
   97|       |		/* Private key is a SDO allocated in application DF */
   98|      2|		path = orig_path;
   99|      2|	}
  100|     62|	else if (orig_path.len == 2 && p15card->file_app != NULL) {
  ------------------
  |  Branch (100:11): [True: 0, False: 62]
  |  Branch (100:33): [True: 0, False: 0]
  ------------------
  101|       |		/* Path is relative to app. DF */
  102|      0|		path = p15card->file_app->path;
  103|      0|		file_id = orig_path;
  104|      0|		sc_append_path(&path, &file_id);
  105|      0|		senv->file_ref = file_id;
  106|      0|		senv->flags |= SC_SEC_ENV_FILE_REF_PRESENT;
  ------------------
  |  |   57|      0|#define SC_SEC_ENV_FILE_REF_PRESENT	0x0002
  ------------------
  107|      0|	}
  108|     62|	else if (orig_path.len > 2) {
  ------------------
  |  Branch (108:11): [True: 62, False: 0]
  ------------------
  109|     62|		path = orig_path;
  110|     62|		memcpy(file_id.value, orig_path.value + orig_path.len - 2, 2);
  111|     62|		file_id.len = 2;
  112|     62|		file_id.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     62|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  113|     62|		senv->file_ref = file_id;
  114|     62|		senv->flags |= SC_SEC_ENV_FILE_REF_PRESENT;
  ------------------
  |  |   57|     62|#define SC_SEC_ENV_FILE_REF_PRESENT	0x0002
  ------------------
  115|     62|	}
  116|      0|	else {
  117|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "invalid private key path");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  118|      0|	}
  119|       |
  120|     64|	r = sc_select_file(p15card->card, &path, NULL);
  121|     64|	LOG_TEST_RET(ctx, r, "sc_select_file() failed");
  ------------------
  |  |  174|     64|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     64|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     64|	int _ret = (r); \
  |  |  |  |  168|     64|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 56]
  |  |  |  |  ------------------
  |  |  |  |  169|      8|		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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      8|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      8|		return _ret; \
  |  |  |  |  172|      8|	} \
  |  |  |  |  173|     64|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|       |
  123|     56|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     56|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     56|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     56|	int _ret = r; \
  |  |  |  |  155|     56|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 56, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     56|		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: 56]
  |  |  |  |  ------------------
  |  |  |  |  157|     56|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     56|	} 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|     56|	return _ret; \
  |  |  |  |  163|     56|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  124|     56|}

sc_pkcs15emu_skeid_init_ex:
  181|  10.2k|{
  182|  10.2k|	int r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  10.2k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  183|       |
  184|  10.2k|	if (p15card->card->type == SC_CARD_TYPE_SKEID_V3
  ------------------
  |  Branch (184:6): [True: 8, False: 10.2k]
  ------------------
  185|      8|		&& (aid == NULL || (aid->len == skeid_aid_qes.len && !memcmp(aid->value, &skeid_aid_qes.value, skeid_aid_qes.len))))
  ------------------
  |  Branch (185:7): [True: 8, False: 0]
  |  Branch (185:23): [True: 0, False: 0]
  |  Branch (185:56): [True: 0, False: 0]
  ------------------
  186|      8|		r = sc_pkcs15emu_skeid_init(p15card);
  187|       |
  188|  10.2k|	return r;
  189|  10.2k|}
pkcs15-skeid.c:sc_pkcs15emu_skeid_init:
   39|      8|{
   40|      8|	int r;
   41|      8|	int i;
   42|      8|	size_t sn_len;
   43|      8|	char *buf;
   44|       |
   45|      8|	set_string(&p15card->tokeninfo->label, "eID karta");
   46|      8|	set_string(&p15card->tokeninfo->manufacturer_id, "Atos Information Technology GmbH");
   47|       |
   48|      8|	sn_len = p15card->card->serialnr.len;
   49|      8|	if (sn_len > 0) {
  ------------------
  |  Branch (49:6): [True: 8, False: 0]
  ------------------
   50|      8|		buf = malloc(2 * sn_len + 1);
   51|      8|		if (!buf) return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  |  Branch (51:7): [True: 0, False: 8]
  ------------------
   52|      8|		sc_bin_to_hex(p15card->card->serialnr.value, sn_len, buf,
   53|      8|			2 * sn_len + 1, 0);
   54|      8|		p15card->tokeninfo->serial_number = buf;
   55|      8|	}
   56|       |
   57|      8|	p15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_READONLY;
  ------------------
  |  |  597|      8|#define SC_PKCS15_TOKEN_PRN_GENERATION			0x04
  ------------------
              	p15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_READONLY;
  ------------------
  |  |  595|      8|#define SC_PKCS15_TOKEN_READONLY			0x01
  ------------------
   58|       |
   59|       |	/* add certificates */
   60|      8|	const char *skeid_cert_names[3] = {
   61|      8|		"Kvalifikovany certifikat pre elektronicky podpis",
   62|      8|		"Certifikat pre elektronicky podpis",
   63|      8|		"Sifrovaci certifikat"
   64|      8|	};
   65|       |
   66|      8|	const char *skeid_cert_paths[3] = {
   67|      8|		"3f0001030201",
   68|      8|		"3f0001030202",
   69|      8|		"3f0001030203"
   70|      8|	};
   71|       |
   72|     32|	for (i = 0; i < 3; i++) {
  ------------------
  |  Branch (72:14): [True: 24, False: 8]
  ------------------
   73|     24|		struct sc_pkcs15_cert_info cert_info;
   74|     24|		struct sc_pkcs15_object cert_obj;
   75|       |
   76|     24|		memset(&cert_info, 0, sizeof(cert_info));
   77|     24|		memset(&cert_obj, 0, sizeof(cert_obj));
   78|       |
   79|     24|		cert_info.id.value[0] = i + 1;
   80|     24|		cert_info.id.len = 1;
   81|       |
   82|     24|		sc_format_path(skeid_cert_paths[i], &cert_info.path);
   83|     24|		strlcpy(cert_obj.label, skeid_cert_names[i], sizeof(cert_obj.label));
  ------------------
  |  |   43|     24|#define strlcpy _strlcpy
  ------------------
   84|       |
   85|     24|		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
   86|       |
   87|     24|		LOG_TEST_RET(p15card->card->ctx, r, "Error adding certificate.");
  ------------------
  |  |  174|     24|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     24|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     24|	int _ret = (r); \
  |  |  |  |  168|     24|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   88|     24|	}
   89|       |
   90|       |	/* add pins */
   91|      8|	const char *skeid_pin_names[2] = {
   92|      8|		"BOK",
   93|      8|		"Podpisovy PIN"
   94|      8|	};
   95|       |
   96|      8|	const unsigned int skeid_pin_max_length[2] = {6, 10};
   97|      8|	const unsigned int skeid_pin_max_tries[2] = {5, 3};
   98|      8|	const int skeid_pin_ref[2] = {0x03, 0x87};
   99|      8|	const char *skeid_pin_paths[2] = {"3F00", "3F000101"};
  100|       |
  101|      8|	const unsigned int skeid_pin_flags[2] =	{SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA | SC_PKCS15_PIN_FLAG_INITIALIZED,
  ------------------
  |  |   54|      8|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              	const unsigned int skeid_pin_flags[2] =	{SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA | SC_PKCS15_PIN_FLAG_INITIALIZED,
  ------------------
  |  |   65|      8|#define SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA		0x0800
  ------------------
              	const unsigned int skeid_pin_flags[2] =	{SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA | SC_PKCS15_PIN_FLAG_INITIALIZED,
  ------------------
  |  |   58|      8|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  102|      8|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA | SC_PKCS15_PIN_FLAG_INITIALIZED};
  ------------------
  |  |   54|      8|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA | SC_PKCS15_PIN_FLAG_INITIALIZED};
  ------------------
  |  |   55|      8|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA | SC_PKCS15_PIN_FLAG_INITIALIZED};
  ------------------
  |  |   65|      8|#define SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA		0x0800
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA | SC_PKCS15_PIN_FLAG_INITIALIZED};
  ------------------
  |  |   58|      8|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  103|       |
  104|     24|	for (i = 0; i < 2; i++) {
  ------------------
  |  Branch (104:14): [True: 16, False: 8]
  ------------------
  105|     16|		struct sc_pkcs15_auth_info pin_info;
  106|     16|		struct sc_pkcs15_object pin_obj;
  107|       |
  108|     16|		memset(&pin_info, 0, sizeof(pin_info));
  109|     16|		memset(&pin_obj, 0, sizeof(pin_obj));
  110|       |
  111|     16|		pin_info.auth_id.len = 1;
  112|     16|		pin_info.auth_id.value[0] = i + 1;
  113|     16|		pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|     16|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  114|     16|		pin_info.attrs.pin.reference = skeid_pin_ref[i];
  115|     16|		pin_info.attrs.pin.flags = skeid_pin_flags[i];
  116|     16|		pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|     16|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  117|     16|		pin_info.attrs.pin.min_length = 6;
  118|     16|		pin_info.attrs.pin.max_length = skeid_pin_max_length[i];
  119|     16|		pin_info.max_tries = skeid_pin_max_tries[i];
  120|       |
  121|     16|		strlcpy(pin_obj.label, skeid_pin_names[i], sizeof(pin_obj.label));
  ------------------
  |  |   43|     16|#define strlcpy _strlcpy
  ------------------
  122|     16|		pin_obj.flags = skeid_pin_flags[i];
  123|       |
  124|     16|		sc_format_path(skeid_pin_paths[i], &pin_info.path);
  125|       |
  126|     16|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  127|       |
  128|     16|		LOG_TEST_RET(p15card->card->ctx, r, "Error adding PIN.");
  ------------------
  |  |  174|     16|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     16|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     16|	int _ret = (r); \
  |  |  |  |  168|     16|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  129|     16|	}
  130|       |
  131|       |	/* add private keys */
  132|      8|	const u8 skeid_prkey_pin[3] = {2, 1, 1};
  133|       |
  134|       |	/* store seIdentifier rather than keyReference */
  135|      8|	const int skeid_prkey_ref[3] = {0x01, 0x34, 0x44};
  136|      8|	const int skeid_prkey_usage[3] =
  137|      8|		{ SC_PKCS15_PRKEY_USAGE_NONREPUDIATION | SC_PKCS15_PRKEY_USAGE_SIGN,
  ------------------
  |  |  314|      8|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
              		{ SC_PKCS15_PRKEY_USAGE_NONREPUDIATION | SC_PKCS15_PRKEY_USAGE_SIGN,
  ------------------
  |  |  307|      8|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  138|      8|		  SC_PKCS15_PRKEY_USAGE_SIGN,
  ------------------
  |  |  307|      8|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  139|      8|		  SC_PKCS15_PRKEY_USAGE_DECRYPT
  ------------------
  |  |  306|      8|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  140|      8|		};
  141|       |
  142|      8|	const char *skeid_prkey_paths[3] = {"3F000101", "3F000102", "3F000102"};
  143|       |
  144|      8|	const char *skeid_prkey_name[3] = {
  145|      8|		"Podpisovy kluc (KEP)",
  146|      8|		"Podpisovy kluc",
  147|      8|		"Sifrovaci kluc",
  148|      8|	};
  149|       |
  150|     32|	for (i = 0; i < 3; i++) {
  ------------------
  |  Branch (150:14): [True: 24, False: 8]
  ------------------
  151|     24|		struct sc_pkcs15_prkey_info prkey_info;
  152|     24|		struct sc_pkcs15_object prkey_obj;
  153|       |
  154|     24|		memset(&prkey_info, 0, sizeof(prkey_info));
  155|     24|		memset(&prkey_obj, 0, sizeof(prkey_obj));
  156|       |
  157|     24|		prkey_info.id.len = 1;
  158|     24|		prkey_info.id.value[0] = i + 1;
  159|     24|		prkey_info.native = 1;
  160|     24|		prkey_info.key_reference = skeid_prkey_ref[i];
  161|     24|		prkey_info.modulus_length = 3072;
  162|     24|		sc_format_path(skeid_prkey_paths[i], &prkey_info.path);
  163|       |
  164|     24|		prkey_info.usage = skeid_prkey_usage[i];
  165|       |
  166|     24|		strlcpy(prkey_obj.label, skeid_prkey_name[i], sizeof(prkey_obj.label));
  ------------------
  |  |   43|     24|#define strlcpy _strlcpy
  ------------------
  167|     24|		prkey_obj.auth_id.len = 1;
  168|     24|		prkey_obj.auth_id.value[0] = skeid_prkey_pin[i];
  169|     24|		if (i == 0) prkey_obj.user_consent = 1;
  ------------------
  |  Branch (169:7): [True: 8, False: 16]
  ------------------
  170|       |
  171|     24|		prkey_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|     24|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  172|       |
  173|     24|		r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  174|       |
  175|     24|		LOG_TEST_RET(p15card->card->ctx, r, "Error adding private key.");
  ------------------
  |  |  174|     24|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     24|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     24|	int _ret = (r); \
  |  |  |  |  168|     24|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  176|     24|	}
  177|      8|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|      8|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      8|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      8|	int _ret = r; \
  |  |  |  |  155|      8|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      8|		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: 8]
  |  |  |  |  ------------------
  |  |  |  |  157|      8|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      8|	} 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|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  178|      8|}

sc_pkcs15_decode_skdf_entry:
  101|      2|{
  102|      2|        struct sc_context *ctx = p15card->card->ctx;
  103|      2|        struct sc_pkcs15_skey_info info;
  104|      2|	int r, i, ii;
  105|      2|	size_t usage_len = sizeof(info.usage);
  106|      2|	size_t af_len = sizeof(info.access_flags);
  107|      2|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  108|      2|	struct sc_asn1_entry asn1_com_skey_attr[C_ASN1_COM_SKEY_ATTR_SIZE];
  109|      2|	struct sc_asn1_entry asn1_generic_skey_attr[C_ASN1_COM_SKEY_GENERIC_ATTR_SIZE];
  110|      2|	struct sc_asn1_entry asn1_generic_skey_value_attr[C_ASN1_COM_SKEY_GENERIC_VALUE_ATTR_SIZE];
  111|      2|	struct sc_asn1_entry asn1_skey_choice[C_ASN1_SKEY_CHOICE_SIZE];
  112|      2|	struct sc_asn1_entry asn1_skey[C_ASN1_SKEY_SIZE];
  113|      2|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  114|      2|	struct sc_asn1_pkcs15_object skey_des_obj = {
  115|      2|		obj, asn1_com_key_attr, asn1_com_skey_attr, asn1_generic_skey_attr
  116|      2|	};
  117|      2|	static const struct sc_object_id id_aes = { { 2, 16, 840, 1, 101, 3, 4, 1, -1 } };
  118|      2|	struct sc_object_id temp_oid;
  119|       |
  120|      2|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_ASN1);
  ------------------
  |  |  148|      2|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|      2|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|      2|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2]
  |  |  ------------------
  ------------------
  121|       |
  122|      2|	sc_copy_asn1_entry(c_asn1_skey, asn1_skey);
  123|      2|	sc_copy_asn1_entry(c_asn1_skey_choice, asn1_skey_choice);
  124|      2|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  125|       |
  126|      2|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  127|      2|	sc_copy_asn1_entry(c_asn1_com_skey_attr, asn1_com_skey_attr);
  128|      2|	sc_copy_asn1_entry(c_asn1_generic_skey_attr, asn1_generic_skey_attr);
  129|      2|	sc_copy_asn1_entry(c_asn1_generic_skey_value_attr, asn1_generic_skey_value_attr);
  130|       |
  131|      2|	sc_format_asn1_entry(asn1_skey + 0, asn1_skey_choice, NULL, 0);
  132|      2|	sc_format_asn1_entry(asn1_skey_choice + 0, &skey_des_obj, NULL, 0);
  133|      2|	sc_format_asn1_entry(asn1_skey_choice + 1, &skey_des_obj, NULL, 0);
  134|      2|	sc_format_asn1_entry(asn1_skey_choice + 2, &skey_des_obj, NULL, 0);
  135|      2|	sc_format_asn1_entry(asn1_skey_choice + 3, &skey_des_obj, NULL, 0);
  136|       |
  137|      2|	sc_format_asn1_entry(asn1_com_key_attr + 0, &info.id, NULL, 0);
  138|      2|	sc_format_asn1_entry(asn1_com_key_attr + 1, &info.usage, &usage_len, 0);
  139|      2|	sc_format_asn1_entry(asn1_com_key_attr + 2, &info.native, NULL, 0);
  140|      2|	sc_format_asn1_entry(asn1_com_key_attr + 3, &info.access_flags, &af_len, 0);
  141|      2|	sc_format_asn1_entry(asn1_com_key_attr + 4, &info.key_reference, NULL, 0);
  142|     34|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && (asn1_supported_algorithms + i)->name; i++)
  ------------------
  |  |   61|     68|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (142:12): [True: 32, False: 2]
  |  Branch (142:45): [True: 32, False: 0]
  ------------------
  143|     32|		sc_format_asn1_entry(asn1_supported_algorithms + i, &info.algo_refs[i], NULL, 0);
  144|      2|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, 0);
  145|       |
  146|      2|	sc_format_asn1_entry(asn1_com_skey_attr + 0, &info.value_len, NULL, 0);
  147|       |
  148|      2|	sc_format_asn1_entry(asn1_generic_skey_attr + 0, asn1_generic_skey_value_attr, NULL, 0);
  149|      2|	sc_format_asn1_entry(asn1_generic_skey_value_attr + 0, &info.path, NULL, 0);
  150|       |
  151|       |        /* Fill in defaults */
  152|      2|	memset(&info, 0, sizeof(info));
  153|      2|	info.native = 1;
  154|       |
  155|      2|	r = sc_asn1_decode(ctx, asn1_skey, *buf, *buflen, buf, buflen);
  156|      2|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|      2|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (156:6): [True: 1, False: 1]
  ------------------
  157|      1|		return r;
  158|      1|	LOG_TEST_RET(ctx, r, "ASN.1 decoding failed");
  ------------------
  |  |  174|      1|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      1|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      1|	int _ret = (r); \
  |  |  |  |  168|      1|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      1|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      1|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      1|		return _ret; \
  |  |  |  |  172|      1|	} \
  |  |  |  |  173|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|      0|	if (asn1_skey_choice[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (159:6): [True: 0, False: 0]
  ------------------
  160|      0|		obj->type = SC_PKCS15_TYPE_SKEY_GENERIC;
  ------------------
  |  |  433|      0|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  161|       |
  162|       |		/* Check key type. framework-pkcs15 recognizes one type per key, and AES is the only algorithm supported for
  163|       |		* SKEY_GENERIC type keys, so just check if this key is AES compatible. */
  164|       |
  165|      0|		for (i = 0; i < SC_MAX_SUPPORTED_ALGORITHMS && info.algo_refs[i] != 0 && info.key_type == 0; i++) {
  ------------------
  |  |   61|      0|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (165:15): [True: 0, False: 0]
  |  Branch (165:50): [True: 0, False: 0]
  |  Branch (165:76): [True: 0, False: 0]
  ------------------
  166|      0|			for (ii = 0; ii < SC_MAX_SUPPORTED_ALGORITHMS && p15card->tokeninfo != 0; ii++) {
  ------------------
  |  |   61|      0|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (166:17): [True: 0, False: 0]
  |  Branch (166:53): [True: 0, False: 0]
  ------------------
  167|      0|				if (info.algo_refs[i] == p15card->tokeninfo->supported_algos[ii].reference) {
  ------------------
  |  Branch (167:9): [True: 0, False: 0]
  ------------------
  168|      0|					temp_oid = p15card->tokeninfo->supported_algos[ii].algo_id;
  169|      0|					temp_oid.value[8] = -1; /* strip off AES subtype octet*/
  170|       |
  171|      0|					if (sc_compare_oid(&id_aes, &temp_oid)) {
  ------------------
  |  Branch (171:10): [True: 0, False: 0]
  ------------------
  172|      0|						info.key_type = CKK_AES;
  ------------------
  |  |  485|      0|#define CKK_AES 0x0000001FUL
  ------------------
  173|      0|						break;
  174|      0|					}
  175|      0|				}
  176|      0|			}
  177|      0|		}
  178|      0|	}
  179|      0|	else if (asn1_skey_choice[1].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (179:11): [True: 0, False: 0]
  ------------------
  180|      0|		obj->type = SC_PKCS15_TYPE_SKEY_DES;
  ------------------
  |  |  434|      0|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
  181|      0|	else if (asn1_skey_choice[2].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (181:11): [True: 0, False: 0]
  ------------------
  182|      0|		obj->type = SC_PKCS15_TYPE_SKEY_2DES;
  ------------------
  |  |  435|      0|#define SC_PKCS15_TYPE_SKEY_2DES		0x303
  ------------------
  183|      0|	else if (asn1_skey_choice[3].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (183:11): [True: 0, False: 0]
  ------------------
  184|      0|		obj->type = SC_PKCS15_TYPE_SKEY_3DES;
  ------------------
  |  |  436|      0|#define SC_PKCS15_TYPE_SKEY_3DES		0x304
  ------------------
  185|      0|	else
  186|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "unsupported secret key type");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  187|       |
  188|      0|	obj->data = malloc(sizeof(info));
  189|      0|	if (obj->data == NULL)
  ------------------
  |  Branch (189:6): [True: 0, False: 0]
  ------------------
  190|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  191|      0|	memcpy(obj->data, &info, sizeof(info));
  192|       |
  193|      0|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  194|      0|}

sc_pkcs15emu_srbeid_init_ex:
  572|  10.1k|{
  573|  10.1k|	(void)aid;
  574|       |
  575|  10.1k|	if (p15card->card->type != SC_CARD_TYPE_SRBEID_BASE)
  ------------------
  |  Branch (575:6): [True: 9.85k, False: 296]
  ------------------
  576|  9.85k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  9.85k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  577|       |
  578|    296|	return sc_pkcs15emu_srbeid_init(p15card);
  579|  10.1k|}
pkcs15-srbeid.c:sc_pkcs15emu_srbeid_init:
  417|    296|{
  418|    296|	sc_card_t *card = p15card->card;
  419|    296|	cert_entry_t *certs = NULL;
  420|    296|	int ncerts, i, r = SC_SUCCESS;
  ------------------
  |  |   28|    296|#define SC_SUCCESS				0
  ------------------
  421|       |
  422|    296|	sc_log(card->ctx, "srbeid: pkcs15 bind");
  ------------------
  |  |   71|    296|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  423|       |
  424|    296|	ncerts = srbeid_enum_certs(card, &certs);
  425|    296|	if (ncerts < 0) {
  ------------------
  |  Branch (425:6): [True: 147, False: 149]
  ------------------
  426|    147|		sc_log(card->ctx, "srbeid: cert enumeration failed: %d", ncerts);
  ------------------
  |  |   71|    147|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  427|    147|		return ncerts;
  428|    147|	}
  429|    149|	if (ncerts == 0) {
  ------------------
  |  Branch (429:6): [True: 68, False: 81]
  ------------------
  430|     68|		sc_log(card->ctx, "srbeid: no certificates found");
  ------------------
  |  |   71|     68|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  431|     68|		goto out;
  432|     68|	}
  433|       |
  434|       |	/* Set card label and manufacturer. */
  435|     81|	set_string(&p15card->tokeninfo->label, "Serbian CardEdge");
  436|     81|	set_string(&p15card->tokeninfo->manufacturer_id, "CardEdge");
  437|       |
  438|       |	/* Query PIN tries_left via card driver's pin_cmd. */
  439|     81|	{
  440|     81|		struct sc_pin_cmd_data pin_data = {0};
  441|       |
  442|     81|		pin_data.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  418|     81|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  443|     81|		pin_data.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|     81|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  444|     81|		pin_data.pin_reference = CE_PIN_REFERENCE;
  ------------------
  |  |   51|     81|#define CE_PIN_REFERENCE  0x80u
  ------------------
  445|     81|		pin_data.pin1.tries_left = -1;
  446|       |
  447|       |		/* Best-effort: failure to query PIN status is not fatal. */
  448|     81|		sc_pin_cmd(card, &pin_data);
  449|     81|		sc_log(card->ctx, "srbeid: PIN tries_left=%d", pin_data.pin1.tries_left);
  ------------------
  |  |   71|     81|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  450|       |
  451|       |		/* ---- PIN auth object ----
  452|       |		 * Must be registered before private keys so auth_id links work. */
  453|     81|		{
  454|     81|			sc_pkcs15_auth_info_t auth_info = {0};
  455|     81|			sc_pkcs15_object_t auth_obj = {0};
  456|       |
  457|     81|			auth_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|     81|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  458|     81|			auth_info.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|     81|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  459|     81|			auth_info.tries_left = pin_data.pin1.tries_left;
  460|     81|			auth_info.attrs.pin.reference = CE_PIN_REFERENCE;
  ------------------
  |  |   51|     81|#define CE_PIN_REFERENCE  0x80u
  ------------------
  461|     81|			auth_info.attrs.pin.min_length = 4;
  462|     81|			auth_info.attrs.pin.max_length = CE_PIN_MAX_LENGTH;
  ------------------
  |  |   52|     81|#define CE_PIN_MAX_LENGTH 8u
  ------------------
  463|     81|			auth_info.attrs.pin.stored_length = CE_PIN_MAX_LENGTH;
  ------------------
  |  |   52|     81|#define CE_PIN_MAX_LENGTH 8u
  ------------------
  464|     81|			auth_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|     81|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  465|     81|			auth_info.attrs.pin.pad_char = 0x00;
  466|     81|			auth_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_NEEDS_PADDING;
  ------------------
  |  |   58|     81|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
              			auth_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_NEEDS_PADDING;
  ------------------
  |  |   55|     81|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
              			auth_info.attrs.pin.flags = SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_NEEDS_PADDING;
  ------------------
  |  |   59|     81|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  467|     81|			auth_info.path.aid.len = AID_PKCS15_LEN;
  ------------------
  |  |   30|     81|#define AID_PKCS15_LEN (sizeof(AID_PKCS15))
  ------------------
  468|     81|			memcpy(auth_info.path.aid.value, AID_PKCS15, AID_PKCS15_LEN);
  ------------------
  |  |   30|     81|#define AID_PKCS15_LEN (sizeof(AID_PKCS15))
  ------------------
  469|     81|			auth_info.auth_id.len = 1;
  470|     81|			auth_info.auth_id.value[0] = 1;
  471|       |
  472|     81|			strncpy(auth_obj.label, "User PIN", sizeof(auth_obj.label) - 1);
  473|     81|			auth_obj.auth_id.len = 0;
  474|     81|			auth_obj.flags = SC_PKCS15_CO_FLAG_MODIFIABLE;
  ------------------
  |  |   51|     81|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  475|       |
  476|     81|			r = sc_pkcs15emu_add_pin_obj(p15card, &auth_obj, &auth_info);
  477|     81|			if (r < 0) {
  ------------------
  |  Branch (477:8): [True: 0, False: 81]
  ------------------
  478|      0|				sc_log(card->ctx, "srbeid: add PIN obj failed: %d", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  479|      0|				goto out;
  480|      0|			}
  481|     81|		}
  482|     81|	}
  483|       |
  484|    259|	for (i = 0; i < ncerts; i++) {
  ------------------
  |  Branch (484:14): [True: 178, False: 81]
  ------------------
  485|    178|		sc_pkcs15_prkey_info_t key_info = {0};
  486|    178|		sc_pkcs15_object_t key_obj = {0};
  487|    178|		sc_pkcs15_cert_info_t cert_info = {0};
  488|    178|		sc_pkcs15_object_t cert_obj = {0};
  489|    178|		u8 *der = NULL;
  490|    178|		size_t der_len = 0;
  491|    178|		int is_kxc = (certs[i].key_pair_id == CE_AT_KEYEXCHANGE);
  ------------------
  |  |   44|    178|#define CE_AT_KEYEXCHANGE	1u
  ------------------
  492|       |
  493|       |		/* ---- Private key object ---- */
  494|       |
  495|    178|		key_info.id.len = 1;
  496|    178|		key_info.id.value[0] = (u8)(i + 1);
  497|    178|		key_info.native = 1;
  498|    178|		key_info.key_reference = (int)certs[i].key_fid;
  499|    178|		key_info.modulus_length = certs[i].key_size_bits
  ------------------
  |  Branch (499:29): [True: 2, False: 176]
  ------------------
  500|    178|							  ? certs[i].key_size_bits
  501|    178|							  : 2048;
  502|       |
  503|       |		/*
  504|       |		 * Key usage flags by type:
  505|       |		 *   kxc (AT_KEYEXCHANGE) — encryption / key wrapping / decryption + signing
  506|       |		 *                          (TLS client auth uses the key exchange cert for signing)
  507|       |		 *   ksc (AT_SIGNATURE)   — digital signature / non-repudiation only
  508|       |		 */
  509|    178|		if (is_kxc) {
  ------------------
  |  Branch (509:7): [True: 152, False: 26]
  ------------------
  510|    152|			key_info.usage = SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_WRAP | SC_PKCS15_PRKEY_USAGE_UNWRAP | SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  305|    152|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              			key_info.usage = SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_WRAP | SC_PKCS15_PRKEY_USAGE_UNWRAP | SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  306|    152|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              			key_info.usage = SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_WRAP | SC_PKCS15_PRKEY_USAGE_UNWRAP | SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  309|    152|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
              			key_info.usage = SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_WRAP | SC_PKCS15_PRKEY_USAGE_UNWRAP | SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  310|    152|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
              			key_info.usage = SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_WRAP | SC_PKCS15_PRKEY_USAGE_UNWRAP | SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|    152|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  511|    152|		} else {
  512|     26|			key_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
  ------------------
  |  |  307|     26|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
              			key_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
  ------------------
  |  |  314|     26|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  513|     26|		}
  514|       |
  515|       |		/*
  516|       |		 * Set only the AID on key_info.path (path.len stays 0).
  517|       |		 * This makes select_key_file() select the PKI applet via AID
  518|       |		 * before calling set_security_env(), without appending a file
  519|       |		 * path that would fail on CardEdge's non-TLV FCI.
  520|       |		 *
  521|       |		 * The key FID is passed via key_info.key_reference and
  522|       |		 * reconstructed in set_security_env() from the low byte.
  523|       |		 */
  524|    178|		key_info.path.aid.len = AID_PKCS15_LEN;
  ------------------
  |  |   30|    178|#define AID_PKCS15_LEN (sizeof(AID_PKCS15))
  ------------------
  525|    178|		memcpy(key_info.path.aid.value, AID_PKCS15, AID_PKCS15_LEN);
  ------------------
  |  |   30|    178|#define AID_PKCS15_LEN (sizeof(AID_PKCS15))
  ------------------
  526|       |
  527|    178|		strncpy(key_obj.label, certs[i].label, sizeof(key_obj.label) - 1);
  528|    178|		key_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    178|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  529|    178|		key_obj.auth_id.len = 1;
  530|    178|		key_obj.auth_id.value[0] = 1;
  531|       |
  532|    178|		r = sc_pkcs15emu_add_rsa_prkey(p15card, &key_obj, &key_info);
  533|    178|		if (r < 0) {
  ------------------
  |  Branch (533:7): [True: 0, False: 178]
  ------------------
  534|      0|			sc_log(card->ctx, "srbeid: add prkey[%d] failed: %d", i, r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  535|      0|			goto out;
  536|      0|		}
  537|       |
  538|       |		/* ---- Certificate object ---- */
  539|    178|		if (srbeid_read_cert_der(card, certs[i].cert_fid, &der, &der_len) < 0) {
  ------------------
  |  Branch (539:7): [True: 177, False: 1]
  ------------------
  540|    177|			sc_log(card->ctx, "srbeid: could not read cert[%d] DER", i);
  ------------------
  |  |   71|    177|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  541|    177|			continue;
  542|    177|		}
  543|       |
  544|      1|		cert_info.id.len = 1;
  545|      1|		cert_info.id.value[0] = (u8)(i + 1);
  546|      1|		cert_info.authority = 0;
  547|       |
  548|       |		/* Store DER directly in the PKCS#15 value buffer. */
  549|      1|		cert_info.value.value = der; /* ownership transferred */
  550|      1|		cert_info.value.len = der_len;
  551|       |
  552|      1|		strncpy(cert_obj.label, certs[i].label, sizeof(cert_obj.label) - 1);
  553|       |
  554|      1|		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  555|      1|		if (r < 0) {
  ------------------
  |  Branch (555:7): [True: 0, False: 1]
  ------------------
  556|      0|			sc_log(card->ctx, "srbeid: add cert[%d] failed: %d", i, r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  557|      0|			free(der);
  558|      0|			goto out;
  559|      0|		}
  560|       |		/* der ownership now belongs to p15card; do not free. */
  561|      1|	}
  562|       |
  563|     81|	sc_log(card->ctx, "srbeid: pkcs15 bind OK (%d certs)", ncerts);
  ------------------
  |  |   71|     81|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  564|       |
  565|    149|out:
  566|    149|	free(certs);
  567|    149|	return r;
  568|     81|}
pkcs15-srbeid.c:srbeid_enum_certs:
  190|    296|{
  191|    296|	u8 *dir_buf = NULL, *mscp_buf = NULL, *cmap_buf = NULL;
  192|    296|	size_t dir_len = 0, mscp_len = 0, cmap_len = 0;
  193|    296|	ce_dir_entry_t *root_entries = NULL, *mscp_entries = NULL;
  194|    296|	int root_count = 0, mscp_count = 0;
  195|    296|	unsigned mscp_fid = 0, cmap_fid = 0;
  196|    296|	cert_entry_t *certs = NULL;
  197|    296|	int ncerts = 0, cap = 8;
  198|    296|	int r, i;
  199|    296|	size_t cmap_offset = 0, cmap_nrec = 0;
  200|       |
  201|    296|	*certs_out = NULL;
  202|       |
  203|       |	/* Select PKI applet. */
  204|    296|	if (iso7816_select_aid(card, AID_PKCS15, AID_PKCS15_LEN, NULL, NULL) != SC_SUCCESS) {
  ------------------
  |  |   30|    296|#define AID_PKCS15_LEN (sizeof(AID_PKCS15))
  ------------------
              	if (iso7816_select_aid(card, AID_PKCS15, AID_PKCS15_LEN, NULL, NULL) != SC_SUCCESS) {
  ------------------
  |  |   28|    296|#define SC_SUCCESS				0
  ------------------
  |  Branch (204:6): [True: 20, False: 276]
  ------------------
  205|     20|		r = SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|     20|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  206|     20|		goto out;
  207|     20|	}
  208|       |
  209|       |	/* Read root directory (FID 0x7000). */
  210|    276|	r = srbeid_read_file(card, CE_PKI_ROOT_DIR_FID, &dir_buf, &dir_len);
  ------------------
  |  |   46|    276|#define CE_PKI_ROOT_DIR_FID	0x7000u
  ------------------
  211|    276|	if (r < 0)
  ------------------
  |  Branch (211:6): [True: 32, False: 244]
  ------------------
  212|     32|		goto out;
  213|       |
  214|    244|	root_count = ce_parse_dir(dir_buf, dir_len, &root_entries);
  215|    244|	if (root_count < 0) {
  ------------------
  |  Branch (215:6): [True: 22, False: 222]
  ------------------
  216|     22|		r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     22|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  217|     22|		goto out;
  218|     22|	}
  219|       |
  220|  4.13k|	for (i = 0; i < root_count; i++) {
  ------------------
  |  Branch (220:14): [True: 4.06k, False: 63]
  ------------------
  221|  4.06k|		if (root_entries[i].is_dir && strcmp(root_entries[i].name, "mscp") == 0) {
  ------------------
  |  Branch (221:7): [True: 2.92k, False: 1.14k]
  |  Branch (221:33): [True: 159, False: 2.76k]
  ------------------
  222|    159|			mscp_fid = root_entries[i].fid;
  223|    159|			break;
  224|    159|		}
  225|  4.06k|	}
  226|    222|	if (mscp_fid == 0) {
  ------------------
  |  Branch (226:6): [True: 63, False: 159]
  ------------------
  227|     63|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     63|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  228|     63|		goto out;
  229|     63|	}
  230|       |
  231|       |	/* Read mscp directory. */
  232|    159|	r = srbeid_read_file(card, mscp_fid, &mscp_buf, &mscp_len);
  233|    159|	if (r < 0)
  ------------------
  |  Branch (233:6): [True: 8, False: 151]
  ------------------
  234|      8|		goto out;
  235|       |
  236|    151|	mscp_count = ce_parse_dir(mscp_buf, mscp_len, &mscp_entries);
  237|    151|	if (mscp_count < 0) {
  ------------------
  |  Branch (237:6): [True: 2, False: 149]
  ------------------
  238|      2|		r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      2|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  239|      2|		goto out;
  240|      2|	}
  241|       |
  242|    149|	certs = calloc((size_t)cap, sizeof(cert_entry_t));
  243|    149|	if (!certs) {
  ------------------
  |  Branch (243:6): [True: 0, False: 149]
  ------------------
  244|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  245|      0|		goto out;
  246|      0|	}
  247|       |
  248|  2.49k|	for (i = 0; i < mscp_count; i++) {
  ------------------
  |  Branch (248:14): [True: 2.34k, False: 149]
  ------------------
  249|  2.34k|		ce_dir_entry_t *e = &mscp_entries[i];
  250|  2.34k|		if (e->is_dir)
  ------------------
  |  Branch (250:7): [True: 1.53k, False: 811]
  ------------------
  251|  1.53k|			continue;
  252|       |
  253|    811|		if (strcmp(e->name, "cmapfile") == 0) {
  ------------------
  |  Branch (253:7): [True: 70, False: 741]
  ------------------
  254|     70|			cmap_fid = e->fid;
  255|    741|		} else if (strlen(e->name) == 5) {
  ------------------
  |  Branch (255:14): [True: 259, False: 482]
  ------------------
  256|    259|			unsigned kp_id;
  257|    259|			const char *lbl;
  258|       |
  259|    259|			if (strncmp(e->name, "kxc", 3) == 0) {
  ------------------
  |  Branch (259:8): [True: 152, False: 107]
  ------------------
  260|    152|				kp_id = CE_AT_KEYEXCHANGE;
  ------------------
  |  |   44|    152|#define CE_AT_KEYEXCHANGE	1u
  ------------------
  261|    152|				lbl = "Key Exchange Certificate";
  262|    152|			} else if (strncmp(e->name, "ksc", 3) == 0) {
  ------------------
  |  Branch (262:15): [True: 26, False: 81]
  ------------------
  263|     26|				kp_id = CE_AT_SIGNATURE;
  ------------------
  |  |   45|     26|#define CE_AT_SIGNATURE		2u
  ------------------
  264|     26|				lbl = "Digital Signature Certificate";
  265|     81|			} else {
  266|     81|				continue;
  267|     81|			}
  268|       |
  269|    178|			if (ncerts >= cap) {
  ------------------
  |  Branch (269:8): [True: 0, False: 178]
  ------------------
  270|      0|				cert_entry_t *tmp = realloc(certs,
  271|      0|						(size_t)(cap * 2) * sizeof(cert_entry_t));
  272|      0|				if (!tmp) {
  ------------------
  |  Branch (272:9): [True: 0, False: 0]
  ------------------
  273|      0|					r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  274|      0|					goto out;
  275|      0|				}
  276|      0|				certs = tmp;
  277|       |				/* realloc() leaves the new tail uninitialised */
  278|      0|				memset(certs + cap, 0, (size_t)cap * sizeof(cert_entry_t));
  279|      0|				cap *= 2;
  280|      0|			}
  281|       |
  282|    178|			certs[ncerts].cont_id = (unsigned)(e->name[3] - '0') * 10 + (unsigned)(e->name[4] - '0');
  283|    178|			certs[ncerts].cert_fid = e->fid;
  284|    178|			certs[ncerts].key_pair_id = kp_id;
  285|    178|			snprintf(certs[ncerts].label, sizeof(certs[ncerts].label), "%s", lbl);
  286|    178|			ncerts++;
  287|    178|		}
  288|    811|	}
  289|       |
  290|       |	/* Read cmapfile and resolve key FIDs. */
  291|    149|	if (cmap_fid != 0) {
  ------------------
  |  Branch (291:6): [True: 57, False: 92]
  ------------------
  292|     57|		r = srbeid_read_file(card, cmap_fid, &cmap_buf, &cmap_len);
  293|     57|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
  |  Branch (293:7): [True: 19, False: 38]
  ------------------
  294|       |			/* Optional 2-byte prefix present when (len-2) is a multiple of 86. */
  295|     19|			if (cmap_len >= 2 && (cmap_len - 2) % CE_CMAP_RECORD_SIZE == 0)
  ------------------
  |  |   38|     15|#define CE_CMAP_RECORD_SIZE	86u
  ------------------
  |  Branch (295:8): [True: 15, False: 4]
  |  Branch (295:25): [True: 1, False: 14]
  ------------------
  296|      1|				cmap_offset = 2;
  297|     19|			cmap_nrec = (cmap_len - cmap_offset) / CE_CMAP_RECORD_SIZE;
  ------------------
  |  |   38|     19|#define CE_CMAP_RECORD_SIZE	86u
  ------------------
  298|     19|		}
  299|     57|	}
  300|       |
  301|    327|	for (i = 0; i < ncerts; i++) {
  ------------------
  |  Branch (301:14): [True: 178, False: 149]
  ------------------
  302|    178|		unsigned ci = certs[i].cont_id;
  303|       |
  304|    178|		if (cmap_buf && ci < cmap_nrec) {
  ------------------
  |  Branch (304:7): [True: 29, False: 149]
  |  Branch (304:19): [True: 4, False: 25]
  ------------------
  305|      4|			size_t rec = cmap_offset + (size_t)ci * CE_CMAP_RECORD_SIZE;
  ------------------
  |  |   38|      4|#define CE_CMAP_RECORD_SIZE	86u
  ------------------
  306|      4|			u8 flags = cmap_buf[rec + CE_CMAP_FLAGS_OFFSET];
  ------------------
  |  |   39|      4|#define CE_CMAP_FLAGS_OFFSET	80u
  ------------------
  307|       |
  308|      4|			if (flags & CE_CMAP_VALID_CONTAINER) {
  ------------------
  |  |   42|      4|#define CE_CMAP_VALID_CONTAINER 0x01u
  ------------------
  |  Branch (308:8): [True: 3, False: 1]
  ------------------
  309|      3|				size_t sz_off = (certs[i].key_pair_id == CE_AT_KEYEXCHANGE)
  ------------------
  |  |   44|      3|#define CE_AT_KEYEXCHANGE	1u
  ------------------
  |  Branch (309:21): [True: 3, False: 0]
  ------------------
  310|      3|								? rec + CE_CMAP_KX_SIZE_OFFSET
  ------------------
  |  |   41|      3|#define CE_CMAP_KX_SIZE_OFFSET	84u
  ------------------
  311|      3|								: rec + CE_CMAP_SIG_SIZE_OFFSET;
  ------------------
  |  |   40|      0|#define CE_CMAP_SIG_SIZE_OFFSET 82u
  ------------------
  312|      3|				unsigned kbits = (unsigned)cmap_buf[sz_off] | ((unsigned)cmap_buf[sz_off + 1] << 8);
  313|      3|				if (kbits != 0) {
  ------------------
  |  Branch (313:9): [True: 2, False: 1]
  ------------------
  314|      2|					certs[i].key_size_bits = kbits;
  315|      2|					certs[i].key_fid = ce_private_key_fid(ci, certs[i].key_pair_id);
  316|      2|				}
  317|      3|			}
  318|      4|		}
  319|    178|		sc_log(card->ctx,
  ------------------
  |  |   71|    178|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  320|    178|				"srbeid: cert[%d] \"%s\" cert_fid=0x%04x key_fid=0x%04x key_size=%u",
  321|    178|				i, certs[i].label, certs[i].cert_fid,
  322|    178|				certs[i].key_fid, certs[i].key_size_bits);
  323|    178|	}
  324|       |
  325|    149|	*certs_out = certs;
  326|    149|	certs = NULL;
  327|    149|	r = ncerts;
  328|       |
  329|    296|out:
  330|    296|	free(dir_buf);
  331|    296|	free(mscp_buf);
  332|    296|	free(cmap_buf);
  333|    296|	free(root_entries);
  334|    296|	free(mscp_entries);
  335|    296|	free(certs);
  336|    296|	return r;
  337|    149|}
pkcs15-srbeid.c:srbeid_read_file:
   73|    670|{
   74|    670|	sc_path_t path = {0};
   75|    670|	sc_file_t *file = NULL;
   76|    670|	u8 *buf;
   77|    670|	int r;
   78|       |
   79|    670|	*buf_out = NULL;
   80|    670|	*out_len = 0;
   81|       |
   82|    670|	path.value[0] = (u8)((fid >> 8) & 0xFF);
   83|    670|	path.value[1] = (u8)(fid & 0xFF);
   84|    670|	path.len = 2;
   85|    670|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    670|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
   86|       |
   87|    670|	r = sc_select_file(card, &path, &file);
   88|    670|	if (r < 0)
  ------------------
  |  Branch (88:6): [True: 184, False: 486]
  ------------------
   89|    184|		return r;
   90|       |
   91|    486|	if (!file || file->size == 0) {
  ------------------
  |  Branch (91:6): [True: 0, False: 486]
  |  Branch (91:15): [True: 9, False: 477]
  ------------------
   92|      9|		sc_file_free(file);
   93|      9|		return SC_SUCCESS;
  ------------------
  |  |   28|      9|#define SC_SUCCESS				0
  ------------------
   94|      9|	}
   95|       |
   96|    477|	if (file->size > 65536) {
  ------------------
  |  Branch (96:6): [True: 0, False: 477]
  ------------------
   97|      0|		sc_file_free(file);
   98|      0|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
   99|      0|	}
  100|       |
  101|    477|	buf = malloc(file->size);
  102|    477|	if (!buf) {
  ------------------
  |  Branch (102:6): [True: 0, False: 477]
  ------------------
  103|      0|		sc_file_free(file);
  104|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  105|      0|	}
  106|       |
  107|    477|	r = sc_read_binary(card, 0, buf, file->size, 0);
  108|    477|	sc_file_free(file);
  109|    477|	if (r < 0) {
  ------------------
  |  Branch (109:6): [True: 31, False: 446]
  ------------------
  110|     31|		free(buf);
  111|     31|		return r;
  112|     31|	}
  113|       |
  114|    446|	*buf_out = buf;
  115|    446|	*out_len = (size_t)r;
  116|    446|	return SC_SUCCESS;
  ------------------
  |  |   28|    446|#define SC_SUCCESS				0
  ------------------
  117|    477|}
pkcs15-srbeid.c:ce_parse_dir:
  138|    395|{
  139|    395|	size_t count, i;
  140|    395|	ce_dir_entry_t *entries;
  141|       |
  142|    395|	*entries_out = NULL;
  143|    395|	if (len < CE_DIR_HEADER_SIZE)
  ------------------
  |  |   47|    395|#define CE_DIR_HEADER_SIZE	10u
  ------------------
  |  Branch (143:6): [True: 4, False: 391]
  ------------------
  144|      4|		return -1;
  145|       |
  146|    391|	count = (size_t)data[6] | ((size_t)data[7] << 8);
  147|    391|	if (count == 0)
  ------------------
  |  Branch (147:6): [True: 3, False: 388]
  ------------------
  148|      3|		return 0;
  149|       |
  150|       |	/* Bound count against buffer size before allocation. */
  151|    388|	if (count > (len - CE_DIR_HEADER_SIZE) / CE_DIR_ENTRY_SIZE)
  ------------------
  |  |   47|    388|#define CE_DIR_HEADER_SIZE	10u
  ------------------
              	if (count > (len - CE_DIR_HEADER_SIZE) / CE_DIR_ENTRY_SIZE)
  ------------------
  |  |   48|    388|#define CE_DIR_ENTRY_SIZE	12u
  ------------------
  |  Branch (151:6): [True: 20, False: 368]
  ------------------
  152|     20|		return -1;
  153|       |
  154|    368|	entries = calloc(count, sizeof(ce_dir_entry_t));
  155|    368|	if (!entries)
  ------------------
  |  Branch (155:6): [True: 0, False: 368]
  ------------------
  156|      0|		return -1;
  157|       |
  158|  6.78k|	for (i = 0; i < count; i++) {
  ------------------
  |  Branch (158:14): [True: 6.42k, False: 368]
  ------------------
  159|  6.42k|		size_t off = CE_DIR_HEADER_SIZE + i * CE_DIR_ENTRY_SIZE;
  ------------------
  |  |   47|  6.42k|#define CE_DIR_HEADER_SIZE	10u
  ------------------
              		size_t off = CE_DIR_HEADER_SIZE + i * CE_DIR_ENTRY_SIZE;
  ------------------
  |  |   48|  6.42k|#define CE_DIR_ENTRY_SIZE	12u
  ------------------
  160|  6.42k|		int k;
  161|       |
  162|       |		/* Name: up to 8 ASCII chars, may not be NUL-terminated on card. */
  163|  6.42k|		memcpy(entries[i].name, data + off, 8);
  164|  6.42k|		entries[i].name[8] = '\0';
  165|       |		/* Strip trailing spaces/NULs. */
  166|  6.42k|		k = 7;
  167|  13.4k|		while (k >= 0 && (entries[i].name[k] == ' ' || entries[i].name[k] == '\0'))
  ------------------
  |  Branch (167:10): [True: 12.9k, False: 511]
  |  Branch (167:21): [True: 241, False: 12.6k]
  |  Branch (167:50): [True: 6.77k, False: 5.90k]
  ------------------
  168|  7.01k|			entries[i].name[k--] = '\0';
  169|  6.42k|		entries[i].fid = (unsigned)data[off + 8] | ((unsigned)data[off + 9] << 8);
  170|  6.42k|		entries[i].is_dir = (data[off + 10] != 0);
  171|  6.42k|	}
  172|       |
  173|    368|	*entries_out = entries;
  174|    368|	return (int)count;
  175|    368|}
pkcs15-srbeid.c:ce_private_key_fid:
   58|      2|{
   59|      2|	return CE_KEYS_BASE_FID | ((cont_idx << 4) & 0x0FF0u) | ((key_pair_id << 2) & 0x000Cu) | CE_KEY_KIND_PRIVATE;
  ------------------
  |  |   33|      2|#define CE_KEYS_BASE_FID 0x6000u
  ------------------
              	return CE_KEYS_BASE_FID | ((cont_idx << 4) & 0x0FF0u) | ((key_pair_id << 2) & 0x000Cu) | CE_KEY_KIND_PRIVATE;
  ------------------
  |  |   43|      2|#define CE_KEY_KIND_PRIVATE	1u
  ------------------
   60|      2|}
pkcs15-srbeid.c:srbeid_read_cert_der:
  350|    178|{
  351|    178|	u8 *raw = NULL;
  352|    178|	size_t raw_len = 0;
  353|    178|	const u8 *data;
  354|    178|	size_t dlen;
  355|    178|	int r;
  356|       |
  357|    178|	*der_out = NULL;
  358|    178|	*der_len_out = 0;
  359|       |
  360|    178|	r = srbeid_read_file(card, cert_fid, &raw, &raw_len);
  361|    178|	if (r < 0)
  ------------------
  |  Branch (361:6): [True: 137, False: 41]
  ------------------
  362|    137|		return r;
  363|       |
  364|     41|	if (raw_len < 6) {
  ------------------
  |  Branch (364:6): [True: 9, False: 32]
  ------------------
  365|      9|		free(raw);
  366|      9|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      9|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  367|      9|	}
  368|       |
  369|       |	/* Skip 2-byte CardFS length prefix. */
  370|     32|	data = raw + 2;
  371|     32|	dlen = raw_len - 2;
  372|       |
  373|     32|	if (dlen >= 4 && data[0] == 0x01 && data[1] == 0x00) {
  ------------------
  |  Branch (373:6): [True: 32, False: 0]
  |  Branch (373:19): [True: 4, False: 28]
  |  Branch (373:38): [True: 1, False: 3]
  ------------------
  374|       |		/* zlib-compressed DER */
  375|      1|#ifdef ENABLE_ZLIB
  376|      1|		size_t uncompressed_len = (size_t)data[2] | ((size_t)data[3] << 8);
  377|      1|		u8 *der = NULL;
  378|       |
  379|      1|		r = sc_decompress_alloc(&der, &uncompressed_len,
  380|      1|				data + 4, dlen - 4, COMPRESSION_ZLIB);
  ------------------
  |  |   27|      1|#define COMPRESSION_ZLIB	1
  ------------------
  381|      1|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (381:7): [True: 1, False: 0]
  ------------------
  382|      1|			sc_log(card->ctx, "srbeid: zlib decompress failed (ret=%d)", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  383|      1|			free(raw);
  384|      1|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  385|      1|		}
  386|      0|		*der_out = der;
  387|      0|		*der_len_out = uncompressed_len;
  388|       |#else
  389|       |		sc_log(card->ctx, "srbeid: cert is zlib-compressed but zlib not available");
  390|       |		free(raw);
  391|       |		return SC_ERROR_NOT_SUPPORTED;
  392|       |#endif
  393|     31|	} else if (dlen >= 1 && data[0] == 0x30) {
  ------------------
  |  Branch (393:13): [True: 31, False: 0]
  |  Branch (393:26): [True: 1, False: 30]
  ------------------
  394|       |		/* Uncompressed DER (ASN.1 SEQUENCE tag). */
  395|      1|		u8 *der = malloc(dlen);
  396|      1|		if (!der) {
  ------------------
  |  Branch (396:7): [True: 0, False: 1]
  ------------------
  397|      0|			free(raw);
  398|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  399|      0|		}
  400|      1|		memcpy(der, data, dlen);
  401|      1|		*der_out = der;
  402|      1|		*der_len_out = dlen;
  403|     30|	} else {
  404|     30|		sc_log(card->ctx,
  ------------------
  |  |   71|     30|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  405|     30|				"srbeid: cert FID 0x%04x: unknown format (byte0=0x%02x)",
  406|     30|				cert_fid, data[0]);
  407|     30|		free(raw);
  408|     30|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     30|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  409|     30|	}
  410|       |
  411|      1|	free(raw);
  412|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  413|     32|}

sc_pkcs15emu_starcert_init_ex:
  274|  15.9k|{
  275|  15.9k|	if (starcert_detect_card(p15card))
  ------------------
  |  Branch (275:6): [True: 15.8k, False: 125]
  ------------------
  276|  15.8k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  15.8k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  277|    125|	return sc_pkcs15emu_starcert_init(p15card);
  278|  15.9k|}
pkcs15-starcert.c:starcert_detect_card:
  101|  15.9k|{
  102|  15.9k|	int       r;
  103|  15.9k|	u8        buf[128];
  104|  15.9k|	sc_path_t path;
  105|  15.9k|	sc_card_t *card = p15card->card;
  106|       |
  107|       |	/* check if we have the correct card OS */
  108|  15.9k|	if (strcmp(card->name, "STARCOS"))
  ------------------
  |  Branch (108:6): [True: 15.4k, False: 502]
  ------------------
  109|  15.4k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  15.4k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  110|       |	/* read EF_Info file */
  111|    502|	sc_format_path("3F00FE13", &path);
  112|    502|	r = sc_select_file(card, &path, NULL);
  113|    502|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    502|#define SC_SUCCESS				0
  ------------------
  |  Branch (113:6): [True: 336, False: 166]
  ------------------
  114|    336|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|    336|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  115|    166|	r = sc_read_binary(card, 0, buf, 64, 0);
  116|    166|	if (r != 64)
  ------------------
  |  Branch (116:6): [True: 27, False: 139]
  ------------------
  117|     27|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|     27|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  118|    139|	if (memcmp(buf + 24, STARCERT, strlen(STARCERT)))
  ------------------
  |  |   35|    139|#define STARCERT	"StarCertV2201"
  ------------------
              	if (memcmp(buf + 24, STARCERT, strlen(STARCERT)))
  ------------------
  |  |   35|    139|#define STARCERT	"StarCertV2201"
  ------------------
  |  Branch (118:6): [True: 14, False: 125]
  ------------------
  119|     14|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|     14|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  120|       |
  121|    125|	return SC_SUCCESS;
  ------------------
  |  |   28|    125|#define SC_SUCCESS				0
  ------------------
  122|    139|}
pkcs15-starcert.c:sc_pkcs15emu_starcert_init:
  125|    125|{
  126|    125|	const cdata certs[] = {
  127|    125|		{"DS certificate", 0, "3F00DF01C000","1",
  128|    125|			SC_PKCS15_CO_FLAG_MODIFIABLE},
  ------------------
  |  |   51|    125|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  129|    125|		{"CA certificate", 1, "3F00DF01C008","2",
  130|    125|			SC_PKCS15_CO_FLAG_MODIFIABLE},
  ------------------
  |  |   51|    125|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  131|    125|		{"KE certificate", 0, "3F00DF01C200","3",
  132|    125|			SC_PKCS15_CO_FLAG_MODIFIABLE},
  ------------------
  |  |   51|    125|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  133|    125|		{"AUT certificate",0, "3F00DF01C500","4",
  134|    125|			SC_PKCS15_CO_FLAG_MODIFIABLE},
  ------------------
  |  |   51|    125|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  135|    125|		{NULL, 0, NULL, NULL, 0}
  136|    125|	};
  137|       |
  138|    125|	const pindata pins[] = {
  139|    125|		{ "99", "DS pin", "3F00DF01", 0x99,
  140|    125|		  SC_PKCS15_PIN_TYPE_ASCII_NUMERIC,
  ------------------
  |  |   89|    125|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  141|    125|		  8, 8, 8, SC_PKCS15_PIN_FLAG_NEEDS_PADDING |
  ------------------
  |  |   59|    125|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  142|    125|		  SC_PKCS15_PIN_FLAG_LOCAL, -1, 0x00,
  ------------------
  |  |   55|    125|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  143|    125|		  SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE },
  ------------------
  |  |   51|    125|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              		  SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE },
  ------------------
  |  |   50|    125|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  144|    125|		{ NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  145|    125|	};
  146|       |
  147|    125|	const prdata prkeys[] = {
  148|    125|		{ "01", "DS key", 1024, USAGE_NONREP, "3F00DF01",
  ------------------
  |  |   71|    125|#define USAGE_NONREP	SC_PKCS15_PRKEY_USAGE_NONREPUDIATION
  |  |  ------------------
  |  |  |  |  314|    125|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  |  |  ------------------
  ------------------
  149|    125|		  0x84, "99", SC_PKCS15_CO_FLAG_PRIVATE},
  ------------------
  |  |   50|    125|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  150|    125|		{ "03", "KE key", 1024, USAGE_KE, "3F00DF01",
  ------------------
  |  |   72|    125|#define USAGE_KE	SC_PKCS15_PRKEY_USAGE_ENCRYPT | \
  |  |  ------------------
  |  |  |  |  305|    125|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  |  |  ------------------
  |  |   73|    125|			SC_PKCS15_PRKEY_USAGE_DECRYPT | \
  |  |  ------------------
  |  |  |  |  306|    125|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |   74|    125|			SC_PKCS15_PRKEY_USAGE_WRAP    | \
  |  |  ------------------
  |  |  |  |  309|    125|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  |  |  ------------------
  |  |   75|    125|			SC_PKCS15_PRKEY_USAGE_UNWRAP
  |  |  ------------------
  |  |  |  |  310|    125|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  ------------------
  151|    125|		  0x85, NULL, SC_PKCS15_CO_FLAG_PRIVATE},
  ------------------
  |  |   50|    125|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  152|    125|		{ "04", "AUT key", 1024, USAGE_AUT, "3F00DF01",
  ------------------
  |  |   76|    125|#define USAGE_AUT	SC_PKCS15_PRKEY_USAGE_ENCRYPT | \
  |  |  ------------------
  |  |  |  |  305|    125|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  |  |  ------------------
  |  |   77|    125|			SC_PKCS15_PRKEY_USAGE_DECRYPT | \
  |  |  ------------------
  |  |  |  |  306|    125|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |   78|    125|			SC_PKCS15_PRKEY_USAGE_WRAP    | \
  |  |  ------------------
  |  |  |  |  309|    125|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  |  |  ------------------
  |  |   79|    125|			SC_PKCS15_PRKEY_USAGE_UNWRAP  | \
  |  |  ------------------
  |  |  |  |  310|    125|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  |  |   80|    125|			SC_PKCS15_PRKEY_USAGE_SIGN
  |  |  ------------------
  |  |  |  |  307|    125|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  |  |  ------------------
  ------------------
  153|    125|		  0x82, NULL, SC_PKCS15_CO_FLAG_PRIVATE},
  ------------------
  |  |   50|    125|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  154|    125|		{ NULL, NULL, 0, 0, NULL, 0, NULL, 0}
  155|    125|	};
  156|       |
  157|    125|	int    r, i;
  158|    125|	char   buf[256];
  159|    125|	sc_path_t path;
  160|    125|	sc_file_t *file = NULL;
  161|    125|	sc_card_t *card = p15card->card;
  162|    125|	sc_serial_number_t serial;
  163|       |
  164|       |	/* get serial number */
  165|    125|	r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
  166|    125|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    125|#define SC_SUCCESS				0
  ------------------
  |  Branch (166:6): [True: 17, False: 108]
  ------------------
  167|     17|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     17|#define SC_ERROR_INTERNAL			-1400
  ------------------
  168|    108|	r = sc_bin_to_hex(serial.value, serial.len, buf, sizeof(buf), 0);
  169|    108|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    108|#define SC_SUCCESS				0
  ------------------
  |  Branch (169:6): [True: 0, False: 108]
  ------------------
  170|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  171|       |
  172|    108|	set_string(&p15card->tokeninfo->serial_number, buf);
  173|    108|	if (!p15card->tokeninfo->serial_number)
  ------------------
  |  Branch (173:6): [True: 0, False: 108]
  ------------------
  174|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  175|       |	/* the manufacturer ID, in this case Giesecke & Devrient GmbH */
  176|    108|	set_string(&p15card->tokeninfo->manufacturer_id, MANU_ID);
  ------------------
  |  |   34|    108|#define MANU_ID		"Giesecke & Devrient GmbH"
  ------------------
  177|    108|	if (!p15card->tokeninfo->manufacturer_id)
  ------------------
  |  Branch (177:6): [True: 0, False: 108]
  ------------------
  178|      0|		goto err;
  179|       |
  180|       |	/* set certs */
  181|    540|	for (i = 0; certs[i].label; i++) {
  ------------------
  |  Branch (181:14): [True: 432, False: 108]
  ------------------
  182|    432|		struct sc_pkcs15_cert_info cert_info;
  183|    432|		struct sc_pkcs15_object    cert_obj;
  184|       |
  185|    432|		memset(&cert_info, 0, sizeof(cert_info));
  186|    432|		memset(&cert_obj,  0, sizeof(cert_obj));
  187|       |
  188|    432|		sc_pkcs15_format_id(certs[i].id, &cert_info.id);
  189|    432|		cert_info.authority = certs[i].authority;
  190|    432|		sc_format_path(certs[i].path, &cert_info.path);
  191|    432|		if (!get_cert_len(card, &cert_info.path))
  ------------------
  |  Branch (191:7): [True: 431, False: 1]
  ------------------
  192|       |			/* skip errors */
  193|    431|			continue;
  194|       |
  195|      1|		strlcpy(cert_obj.label, certs[i].label, sizeof(cert_obj.label));
  ------------------
  |  |   43|      1|#define strlcpy _strlcpy
  ------------------
  196|      1|		cert_obj.flags = certs[i].obj_flags;
  197|       |
  198|      1|		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  199|      1|		if (r < 0)
  ------------------
  |  Branch (199:7): [True: 0, False: 1]
  ------------------
  200|      0|			goto err;
  201|      1|	}
  202|       |	/* set pins */
  203|    216|	for (i = 0; pins[i].label; i++) {
  ------------------
  |  Branch (203:14): [True: 108, False: 108]
  ------------------
  204|    108|		struct sc_pkcs15_auth_info pin_info;
  205|    108|		struct sc_pkcs15_object   pin_obj;
  206|       |
  207|    108|		memset(&pin_info, 0, sizeof(pin_info));
  208|    108|		memset(&pin_obj,  0, sizeof(pin_obj));
  209|       |
  210|       |
  211|    108|		sc_pkcs15_format_id(pins[i].id, &pin_info.auth_id);
  212|    108|		pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    108|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  213|    108|		pin_info.attrs.pin.reference     = pins[i].ref;
  214|    108|		pin_info.attrs.pin.flags         = pins[i].flags;
  215|    108|		pin_info.attrs.pin.type          = pins[i].type;
  216|    108|		pin_info.attrs.pin.min_length    = pins[i].minlen;
  217|    108|		pin_info.attrs.pin.stored_length = pins[i].storedlen;
  218|    108|		pin_info.attrs.pin.max_length    = pins[i].maxlen;
  219|    108|		pin_info.attrs.pin.pad_char      = pins[i].pad_char;
  220|    108|		sc_format_path(pins[i].path, &pin_info.path);
  221|    108|		pin_info.tries_left    = -1;
  222|    108|		pin_info.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|    108|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
  223|       |
  224|    108|		strlcpy(pin_obj.label, pins[i].label, sizeof(pin_obj.label));
  ------------------
  |  |   43|    108|#define strlcpy _strlcpy
  ------------------
  225|    108|		pin_obj.flags = pins[i].obj_flags;
  226|       |
  227|    108|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  228|    108|		if (r < 0)
  ------------------
  |  Branch (228:7): [True: 0, False: 108]
  ------------------
  229|      0|			goto err;
  230|    108|	}
  231|       |	/* set private keys */
  232|    432|	for (i = 0; prkeys[i].label; i++) {
  ------------------
  |  Branch (232:14): [True: 324, False: 108]
  ------------------
  233|    324|		struct sc_pkcs15_prkey_info prkey_info;
  234|    324|		struct sc_pkcs15_object     prkey_obj;
  235|       |
  236|    324|		memset(&prkey_info, 0, sizeof(prkey_info));
  237|    324|		memset(&prkey_obj,  0, sizeof(prkey_obj));
  238|       |
  239|    324|		sc_pkcs15_format_id(prkeys[i].id, &prkey_info.id);
  240|    324|		prkey_info.usage         = prkeys[i].usage;
  241|    324|		prkey_info.native        = 1;
  242|    324|		prkey_info.key_reference = prkeys[i].ref;
  243|    324|		prkey_info.modulus_length= prkeys[i].modulus_len;
  244|    324|		sc_format_path(prkeys[i].path, &prkey_info.path);
  245|       |
  246|    324|		strlcpy(prkey_obj.label, prkeys[i].label, sizeof(prkey_obj.label));
  ------------------
  |  |   43|    324|#define strlcpy _strlcpy
  ------------------
  247|    324|		prkey_obj.flags = prkeys[i].obj_flags;
  248|    324|		if (prkeys[i].auth_id)
  ------------------
  |  Branch (248:7): [True: 108, False: 216]
  ------------------
  249|    108|			sc_pkcs15_format_id(prkeys[i].auth_id, &prkey_obj.auth_id);
  250|       |
  251|    324|		r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  252|    324|		if (r < 0)
  ------------------
  |  Branch (252:7): [True: 0, False: 324]
  ------------------
  253|      0|			goto err;
  254|    324|	}
  255|       |
  256|       |	/* select the application DF */
  257|    108|	sc_format_path("3F00DF01", &path);
  258|    108|	r = sc_select_file(card, &path, &file);
  259|    108|	if (r != SC_SUCCESS || !file)
  ------------------
  |  |   28|    216|#define SC_SUCCESS				0
  ------------------
  |  Branch (259:6): [True: 72, False: 36]
  |  Branch (259:25): [True: 0, False: 36]
  ------------------
  260|     72|		goto err;
  261|       |	/* set the application DF */
  262|     36|	sc_file_free(p15card->file_app);
  263|     36|	p15card->file_app = file;
  264|       |
  265|     36|	return SC_SUCCESS;
  ------------------
  |  |   28|     36|#define SC_SUCCESS				0
  ------------------
  266|       |
  267|     72|err:
  268|     72|	sc_pkcs15_card_clear(p15card);
  269|     72|	return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     72|#define SC_ERROR_INTERNAL			-1400
  ------------------
  270|    108|}
pkcs15-starcert.c:get_cert_len:
   83|    432|{
   84|    432|	int r;
   85|    432|	u8  buf[8];
   86|       |
   87|    432|	r = sc_select_file(card, path, NULL);
   88|    432|	if (r < 0)
  ------------------
  |  Branch (88:6): [True: 365, False: 67]
  ------------------
   89|    365|		return 0;
   90|     67|	r = sc_read_binary(card, 0, buf, sizeof(buf), 0);
   91|     67|	if (r < 4)
  ------------------
  |  Branch (91:6): [True: 24, False: 43]
  ------------------
   92|     24|		return 0;
   93|     43|	if (buf[0] != 0x30 || buf[1] != 0x82)
  ------------------
  |  Branch (93:6): [True: 27, False: 16]
  |  Branch (93:24): [True: 15, False: 1]
  ------------------
   94|     42|		return 0;
   95|      1|	path->index = 0;
   96|      1|	path->count = ((buf[2] << 8) | buf[3]) + 4;
   97|      1|	return 1;
   98|     43|}

sc_pkcs15emu_starcos_esign_init_ex:
  355|  10.1k|{
  356|  10.1k|	int r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  10.1k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  357|       |
  358|  10.1k|	if (!p15card || !p15card->card || !p15card->card->ctx)
  ------------------
  |  Branch (358:6): [True: 0, False: 10.1k]
  |  Branch (358:18): [True: 0, False: 10.1k]
  |  Branch (358:36): [True: 0, False: 10.1k]
  ------------------
  359|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  360|       |
  361|  10.1k|	r = starcos_esign_init(p15card, aid);
  362|  10.1k|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  164|  10.1k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  10.1k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  10.1k|	int _ret = r; \
  |  |  |  |  155|  10.1k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10.1k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  10.1k|		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|  10.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10.1k, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  157|  10.1k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  10.1k|	} 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|  10.1k|	return _ret; \
  |  |  |  |  163|  10.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|  10.1k|}
pkcs15-starcos-esign.c:starcos_esign_init:
  286|  10.1k|{
  287|  10.1k|	sc_card_t *card = p15card->card;
  288|  10.1k|	sc_context_t *ctx = card->ctx;
  289|  10.1k|	const char *label = name_Card;
  290|  10.1k|	int r;
  291|  10.1k|	int apps_added = 0;
  292|       |
  293|  10.1k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
  ------------------
  |  |  148|  10.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  10.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  10.1k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 10.1k]
  |  |  ------------------
  ------------------
  294|       |
  295|  10.1k|	if (card->type != SC_CARD_TYPE_STARCOS_V3_4_ESIGN && card->type != SC_CARD_TYPE_STARCOS_V3_5_ESIGN) {
  ------------------
  |  Branch (295:6): [True: 10.1k, False: 45]
  |  Branch (295:55): [True: 10.1k, False: 9]
  ------------------
  296|  10.1k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  10.1k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  297|  10.1k|	}
  298|       |
  299|     54|	if (aid == NULL) {
  ------------------
  |  Branch (299:6): [True: 54, False: 0]
  ------------------
  300|       |		// no aid: in this case all emulated apps are added, currently only the esign_app
  301|     54|		r = starcos_add_esign_app(p15card);
  302|     54|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|     54|#define SC_SUCCESS				0
  ------------------
  |  Branch (302:7): [True: 20, False: 34]
  ------------------
  303|     20|			apps_added++;
  304|     54|	} else {
  305|       |		// aid specified: only the matching app is added
  306|      0|		if (aid->len == sizeof(aid_ESIGN) && memcmp(aid->value, aid_ESIGN, sizeof(aid_ESIGN)) == 0) {
  ------------------
  |  Branch (306:7): [True: 0, False: 0]
  |  Branch (306:40): [True: 0, False: 0]
  ------------------
  307|      0|			r = starcos_add_esign_app(p15card);
  308|      0|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (308:8): [True: 0, False: 0]
  ------------------
  309|      0|				label = name_ESign;
  310|      0|				apps_added++;
  311|      0|			}
  312|      0|		}
  313|       |
  314|      0|		if (apps_added > 0) {
  ------------------
  |  Branch (314:7): [True: 0, False: 0]
  ------------------
  315|       |			// pkcs11 requires the file_app
  316|      0|			struct sc_path path;
  317|      0|			struct sc_file *file = NULL;
  318|      0|			sc_path_set(&path, SC_PATH_TYPE_DF_NAME, aid->value, aid->len, 0, 0);
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  319|      0|			r = sc_select_file(card, &path, &file);
  320|      0|			if (r != SC_SUCCESS || !file)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (320:8): [True: 0, False: 0]
  |  Branch (320:27): [True: 0, False: 0]
  ------------------
  321|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  322|      0|			sc_file_free(p15card->file_app);
  323|      0|			p15card->file_app = file;
  324|      0|		}
  325|      0|	}
  326|       |
  327|     54|	if (apps_added == 0) {
  ------------------
  |  Branch (327:6): [True: 34, False: 20]
  ------------------
  328|     34|		LOG_TEST_RET(ctx, SC_ERROR_WRONG_CARD, "No supported app found on this card");
  ------------------
  |  |  174|     34|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     34|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     34|	int _ret = (r); \
  |  |  |  |  168|     34|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 34, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     34|		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|     34|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     34|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     34|		return _ret; \
  |  |  |  |  172|     34|	} \
  |  |  |  |  173|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  329|     34|	}
  330|       |
  331|     20|	sc_pkcs15_free_tokeninfo(p15card->tokeninfo);
  332|       |
  333|     20|	p15card->tokeninfo = sc_pkcs15_tokeninfo_new();
  334|     20|	if (!p15card->tokeninfo) {
  ------------------
  |  Branch (334:6): [True: 0, False: 20]
  ------------------
  335|      0|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "unable to create tokeninfo struct");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  336|     20|	} else {
  337|     20|		sc_serial_number_t serial;
  338|     20|		char serial_hex[SC_MAX_SERIALNR * 2 + 2];
  339|     20|		r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serial);
  340|     20|		LOG_TEST_RET(ctx, r, "Failed to query card serial number");
  ------------------
  |  |  174|     20|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     20|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     20|	int _ret = (r); \
  |  |  |  |  168|     20|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|       |
  342|      9|		r = sc_bin_to_hex(serial.value, serial.len, serial_hex, sizeof serial_hex, 0);
  343|      9|		LOG_TEST_RET(ctx, r, "Failed to convert S/N to hex");
  ------------------
  |  |  174|      9|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      9|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      9|	int _ret = (r); \
  |  |  |  |  168|      9|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  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|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  344|      9|		p15card->tokeninfo->serial_number = strdup(serial_hex);
  345|      9|		p15card->tokeninfo->label = strdup(label);
  346|      9|		p15card->tokeninfo->manufacturer_id = strdup(name_Vendor);
  347|      9|		p15card->tokeninfo->flags = SC_PKCS15_TOKEN_READONLY;
  ------------------
  |  |  595|      9|#define SC_PKCS15_TOKEN_READONLY			0x01
  ------------------
  348|      9|	}
  349|       |
  350|      9|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|      9|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      9|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      9|	int _ret = r; \
  |  |  |  |  155|      9|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      9|		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: 9]
  |  |  |  |  ------------------
  |  |  |  |  157|      9|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      9|	} 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|      9|	return _ret; \
  |  |  |  |  163|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|      9|}
pkcs15-starcos-esign.c:starcos_add_esign_app:
  253|     54|{
  254|     54|	static cdata auth_cert = {"C.CH.AUT", 0, "3F00060843F1", "1", 0};
  255|     54|	static cdata encr_cert = {"C.CH.ENC", 0, "3F0006084301", "2", 0};
  256|       |#ifdef ENABLE_ESIGN_ISSUER_CONTAINERS
  257|       |	const cdata auth_root_cert = { "C.RootCA_Auth", 1, "3F00060843F0", "3", 0 };
  258|       |	const cdata encr_root_cert = { "C.RootCA_Enc", 1, "3F0006084300", "4", 0 };
  259|       |#endif
  260|       |
  261|     54|	static prdata auth_key = {"1", "PrK.CH.AUT", 2048, USAGE_AUT, "3F000608", 0x81, "1", SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   89|     54|#define USAGE_AUT SC_PKCS15_PRKEY_USAGE_ENCRYPT | \
  |  |  ------------------
  |  |  |  |  305|     54|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  |  |  ------------------
  |  |   90|     54|				  SC_PKCS15_PRKEY_USAGE_DECRYPT | \
  |  |  ------------------
  |  |  |  |  306|     54|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |   91|     54|				  SC_PKCS15_PRKEY_USAGE_WRAP | \
  |  |  ------------------
  |  |  |  |  309|     54|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  |  |  ------------------
  |  |   92|     54|				  SC_PKCS15_PRKEY_USAGE_UNWRAP | \
  |  |  ------------------
  |  |  |  |  310|     54|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  |  |   93|     54|				  SC_PKCS15_PRKEY_USAGE_SIGN
  |  |  ------------------
  |  |  |  |  307|     54|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  |  |  ------------------
  ------------------
              	static prdata auth_key = {"1", "PrK.CH.AUT", 2048, USAGE_AUT, "3F000608", 0x81, "1", SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   50|     54|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  262|     54|	static prdata encr_key = {"2", "PrK.CH.ENC", 2048, USAGE_KE, "3F000608", 0x83, "1", SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   85|     54|#define USAGE_KE     SC_PKCS15_PRKEY_USAGE_ENCRYPT | \
  |  |  ------------------
  |  |  |  |  305|     54|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  |  |  ------------------
  |  |   86|     54|				 SC_PKCS15_PRKEY_USAGE_DECRYPT | \
  |  |  ------------------
  |  |  |  |  306|     54|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |   87|     54|				 SC_PKCS15_PRKEY_USAGE_WRAP | \
  |  |  ------------------
  |  |  |  |  309|     54|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  |  |  ------------------
  |  |   88|     54|				 SC_PKCS15_PRKEY_USAGE_UNWRAP
  |  |  ------------------
  |  |  |  |  310|     54|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  ------------------
              	static prdata encr_key = {"2", "PrK.CH.ENC", 2048, USAGE_KE, "3F000608", 0x83, "1", SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   50|     54|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  263|       |
  264|     54|	static pindata auth_pin = {"1", "UserPIN", "3F00", 0x01, SC_PKCS15_PIN_TYPE_UTF8, 16, 6, 0,
  ------------------
  |  |   90|     54|#define SC_PKCS15_PIN_TYPE_UTF8				2
  ------------------
  265|     54|			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   94|     54|#define USER_PIN  SC_PKCS15_PIN_FLAG_INITIALIZED | \
  |  |  ------------------
  |  |  |  |   58|     54|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   95|     54|				SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | \
  |  |  ------------------
  |  |  |  |   54|     54|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  |  |  ------------------
  |  |   96|     54|				SC_PKCS15_PIN_TYPE_FLAGS_PIN_GLOBAL | \
  |  |  ------------------
  |  |  |  |   75|     54|	( SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|     54|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   97|     54|				SC_PKCS15_PIN_AUTH_TYPE_PIN
  |  |  ------------------
  |  |  |  |   94|     54|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  |  |  ------------------
  ------------------
              			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   51|     54|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   50|     54|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  266|       |
  267|     54|	static pindata auth_pin_v35 = {"1", "UserPIN", "3F00", 0x06, SC_PKCS15_PIN_TYPE_UTF8, 16, 6, 0,
  ------------------
  |  |   90|     54|#define SC_PKCS15_PIN_TYPE_UTF8				2
  ------------------
  268|     54|			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   94|     54|#define USER_PIN  SC_PKCS15_PIN_FLAG_INITIALIZED | \
  |  |  ------------------
  |  |  |  |   58|     54|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   95|     54|				SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | \
  |  |  ------------------
  |  |  |  |   54|     54|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  |  |  ------------------
  |  |   96|     54|				SC_PKCS15_PIN_TYPE_FLAGS_PIN_GLOBAL | \
  |  |  ------------------
  |  |  |  |   75|     54|	( SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|     54|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   97|     54|				SC_PKCS15_PIN_AUTH_TYPE_PIN
  |  |  ------------------
  |  |  |  |   94|     54|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  |  |  ------------------
  ------------------
              			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   51|     54|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   50|     54|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  269|       |
  270|     54|	ppindata auth = (p15card->card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN) ? &auth_pin_v35 : &auth_pin;
  ------------------
  |  Branch (270:18): [True: 9, False: 45]
  ------------------
  271|       |
  272|     54|	const container containers[] = {
  273|     54|			{"1", &auth_cert, auth, &auth_key},
  274|     54|			{"2", &encr_cert, auth, &encr_key},
  275|       |#ifdef ENABLE_ESIGN_ISSUER_CONTAINERS
  276|       |			{ "3", &auth_root_cert, 0, 0 },
  277|       |			{ "4", &encr_root_cert, 0, 0 },
  278|       |#endif
  279|     54|	};
  280|       |
  281|     54|	return add_app(p15card, containers, sizeof(containers) / sizeof(container));
  282|     54|}
pkcs15-starcos-esign.c:add_app:
  116|     54|{
  117|     54|	int i, containers_added = 0, r = SC_SUCCESS;
  ------------------
  |  |   28|     54|#define SC_SUCCESS				0
  ------------------
  118|     54|	ppindata installed_pins[4];
  119|     54|	size_t installed_pin_count = 0;
  120|     54|	sc_card_t *card = p15card->card;
  121|       |
  122|     54|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     54|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     54|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     54|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     54|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  123|       |
  124|    162|	for (i = 0; i < container_count; i++) {
  ------------------
  |  Branch (124:14): [True: 108, False: 54]
  ------------------
  125|    108|		struct sc_pkcs15_cert_info cert_info;
  126|    108|		struct sc_pkcs15_object cert_obj;
  127|    108|		size_t cert_size;
  128|       |
  129|    108|		memset(&cert_info, 0, sizeof(cert_info));
  130|    108|		memset(&cert_obj, 0, sizeof(cert_obj));
  131|       |
  132|    108|		sc_pkcs15_format_id(containers[i].id, &cert_info.id);
  133|    108|		cert_info.authority = containers[i].certdata->authority;
  134|    108|		sc_format_path(containers[i].certdata->path, &cert_info.path);
  135|       |
  136|    108|		r = get_cert_size(card, &cert_info.path, &cert_size);
  137|    108|		if ( r != SC_SUCCESS ) {
  ------------------
  |  |   28|    108|#define SC_SUCCESS				0
  ------------------
  |  Branch (137:8): [True: 84, False: 24]
  ------------------
  138|     84|			sc_log(card->ctx, "Failed to determine size of certificate %s, ignoring container", containers[i].certdata->label);
  ------------------
  |  |   71|     84|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  139|     84|			continue;
  140|     84|		}
  141|       |
  142|     24|		strlcpy(cert_obj.label, containers[i].certdata->label, sizeof(cert_obj.label));
  ------------------
  |  |   43|     24|#define strlcpy _strlcpy
  ------------------
  143|     24|		cert_obj.flags = containers[i].certdata->obj_flags;
  144|       |
  145|     24|		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  146|     24|		LOG_TEST_RET(card->ctx, r, "Failed to add certificate");
  ------------------
  |  |  174|     24|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     24|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     24|	int _ret = (r); \
  |  |  |  |  168|     24|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  147|       |
  148|     24|		if (containers[i].pindata != 0) {
  ------------------
  |  Branch (148:7): [True: 24, False: 0]
  ------------------
  149|     24|			size_t j;
  150|     24|			int is_pin_installed = 0;
  151|       |
  152|       |			/* A pin object could be used by more than 1 container, ensure it is added only once */
  153|     24|			for (j = 0; j < installed_pin_count; j++) {
  ------------------
  |  Branch (153:16): [True: 4, False: 20]
  ------------------
  154|      4|				if (installed_pins[j] == containers[i].pindata) {
  ------------------
  |  Branch (154:9): [True: 4, False: 0]
  ------------------
  155|      4|					is_pin_installed = 1;
  156|      4|					break;
  157|      4|				}
  158|      4|			}
  159|       |
  160|     24|			if (!is_pin_installed) {
  ------------------
  |  Branch (160:8): [True: 20, False: 4]
  ------------------
  161|     20|				struct sc_pkcs15_auth_info pin_info;
  162|     20|				struct sc_pkcs15_object pin_obj;
  163|       |
  164|     20|				if (installed_pin_count < (int)(sizeof(installed_pins) / sizeof(ppindata))) {
  ------------------
  |  Branch (164:9): [True: 20, False: 0]
  ------------------
  165|     20|					installed_pins[installed_pin_count++] = containers[i].pindata;
  166|     20|				} else {
  167|      0|					sc_log(card->ctx, "Warning: cannot add more than 4 pins");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  168|      0|					continue;
  169|      0|				}
  170|       |
  171|     20|				memset(&pin_info, 0, sizeof(pin_info));
  172|     20|				memset(&pin_obj, 0, sizeof(pin_obj));
  173|       |
  174|     20|				sc_pkcs15_format_id(containers[i].pindata->id, &pin_info.auth_id);
  175|     20|				pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|     20|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  176|     20|				pin_info.attrs.pin.reference = containers[i].pindata->ref;
  177|     20|				pin_info.attrs.pin.flags = containers[i].pindata->flags;
  178|     20|				pin_info.attrs.pin.type = containers[i].pindata->type;
  179|     20|				pin_info.attrs.pin.min_length = containers[i].pindata->minlen;
  180|     20|				pin_info.attrs.pin.stored_length = containers[i].pindata->storedlen;
  181|     20|				pin_info.attrs.pin.max_length = containers[i].pindata->maxlen;
  182|     20|				pin_info.attrs.pin.pad_char = containers[i].pindata->pad_char;
  183|     20|				if (containers[i].pindata->path != NULL)
  ------------------
  |  Branch (183:9): [True: 20, False: 0]
  ------------------
  184|     20|					sc_format_path(containers[i].pindata->path, &pin_info.path);
  185|     20|				pin_info.tries_left = -1;
  186|     20|				pin_info.max_tries = containers[i].pindata->max_tries;
  187|       |
  188|     20|				strlcpy(pin_obj.label, containers[i].pindata->label, sizeof(pin_obj.label));
  ------------------
  |  |   43|     20|#define strlcpy _strlcpy
  ------------------
  189|     20|				pin_obj.flags = containers[i].pindata->obj_flags;
  190|       |
  191|     20|				r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  192|     20|				LOG_TEST_RET(card->ctx, r, "Failed to add PIN object");
  ------------------
  |  |  174|     20|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     20|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     20|	int _ret = (r); \
  |  |  |  |  168|     20|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  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|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 20]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  193|     20|			}
  194|     24|		}
  195|       |
  196|     24|		if (containers[i].prdata != 0) {
  ------------------
  |  Branch (196:7): [True: 24, False: 0]
  ------------------
  197|     24|			struct sc_pkcs15_prkey_info prkey_info;
  198|     24|			struct sc_pkcs15_object prkey_obj;
  199|     24|			int modulus_len = containers[i].prdata->modulus_len;
  200|     24|			memset(&prkey_info, 0, sizeof(prkey_info));
  201|     24|			memset(&prkey_obj, 0, sizeof(prkey_obj));
  202|       |
  203|     24|			sc_pkcs15_format_id(containers[i].id, &prkey_info.id);
  204|     24|			prkey_info.usage = containers[i].prdata->usage;
  205|     24|			prkey_info.native = 1;
  206|     24|			prkey_info.key_reference = containers[i].prdata->ref;
  207|     24|			prkey_info.modulus_length = modulus_len;
  208|     24|			sc_format_path(containers[i].prdata->path, &prkey_info.path);
  209|       |
  210|     24|			strlcpy(prkey_obj.label, containers[i].prdata->label, sizeof(prkey_obj.label));
  ------------------
  |  |   43|     24|#define strlcpy _strlcpy
  ------------------
  211|     24|			prkey_obj.flags = containers[i].prdata->obj_flags;
  212|     24|			if (containers[i].prdata->auth_id) {
  ------------------
  |  Branch (212:8): [True: 24, False: 0]
  ------------------
  213|     24|				sc_pkcs15_format_id(containers[i].prdata->auth_id, &prkey_obj.auth_id);
  214|     24|			}
  215|       |
  216|     24|			r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  217|     24|			LOG_TEST_RET(card->ctx, r, "Failed to add RSA prkey");
  ------------------
  |  |  174|     24|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     24|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     24|	int _ret = (r); \
  |  |  |  |  168|     24|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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|     24|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  218|     24|		}
  219|       |
  220|     24|		containers_added++;
  221|     24|	}
  222|       |
  223|     54|	if (containers_added == 0) {
  ------------------
  |  Branch (223:6): [True: 34, False: 20]
  ------------------
  224|     34|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     34|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  225|     34|	} else {
  226|     20|		r = SC_SUCCESS;
  ------------------
  |  |   28|     20|#define SC_SUCCESS				0
  ------------------
  227|     20|	}
  228|       |
  229|     54|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     54|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     54|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     54|	int _ret = r; \
  |  |  |  |  155|     54|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 54, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     54|		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|     34|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 34, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  157|     54|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     54|	} 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|     54|	return _ret; \
  |  |  |  |  163|     54|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  230|     54|}
pkcs15-starcos-esign.c:get_cert_size:
  101|    108|{
  102|    108|	int r;
  103|    108|	sc_file_t *file = NULL;
  104|       |
  105|    108|	r = sc_select_file(card, path, &file);
  106|    108|	LOG_TEST_RET(card->ctx, r, "Failed to select EF certificate");
  ------------------
  |  |  174|    108|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    108|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    108|	int _ret = (r); \
  |  |  |  |  168|    108|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 84, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  169|     84|		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|     84|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     84|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     84|		return _ret; \
  |  |  |  |  172|     84|	} \
  |  |  |  |  173|    108|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|       |
  108|     24|	*psize = file->size;
  109|     24|	sc_file_free(file);
  110|       |
  111|     24|	return SC_SUCCESS;
  ------------------
  |  |   28|     24|#define SC_SUCCESS				0
  ------------------
  112|    108|}

sc_pkcs15_is_emulation_only:
   90|  16.4k|{
   91|  16.4k|	switch (card->type) {
   92|    687|		case SC_CARD_TYPE_GEMSAFEV1_PTEID:
  ------------------
  |  Branch (92:3): [True: 687, False: 15.7k]
  ------------------
   93|    689|		case SC_CARD_TYPE_OPENPGP_V1:
  ------------------
  |  Branch (93:3): [True: 2, False: 16.4k]
  ------------------
   94|    694|		case SC_CARD_TYPE_OPENPGP_V2:
  ------------------
  |  Branch (94:3): [True: 5, False: 16.4k]
  ------------------
   95|    701|		case SC_CARD_TYPE_OPENPGP_GNUK:
  ------------------
  |  Branch (95:3): [True: 7, False: 16.3k]
  ------------------
   96|    712|		case SC_CARD_TYPE_OPENPGP_V3:
  ------------------
  |  Branch (96:3): [True: 11, False: 16.3k]
  ------------------
   97|    712|		case SC_CARD_TYPE_SC_HSM:
  ------------------
  |  Branch (97:3): [True: 0, False: 16.4k]
  ------------------
   98|    712|		case SC_CARD_TYPE_SC_HSM_SOC:
  ------------------
  |  Branch (98:3): [True: 0, False: 16.4k]
  ------------------
   99|    712|		case SC_CARD_TYPE_DNIE_BASE:
  ------------------
  |  Branch (99:3): [True: 0, False: 16.4k]
  ------------------
  100|    712|		case SC_CARD_TYPE_DNIE_BLANK:
  ------------------
  |  Branch (100:3): [True: 0, False: 16.4k]
  ------------------
  101|    712|		case SC_CARD_TYPE_DNIE_ADMIN:
  ------------------
  |  Branch (101:3): [True: 0, False: 16.4k]
  ------------------
  102|  1.45k|		case SC_CARD_TYPE_DNIE_USER:
  ------------------
  |  Branch (102:3): [True: 743, False: 15.6k]
  ------------------
  103|  1.45k|		case SC_CARD_TYPE_DNIE_TERMINATED:
  ------------------
  |  Branch (103:3): [True: 0, False: 16.4k]
  ------------------
  104|  1.61k|		case SC_CARD_TYPE_IASECC_GEMALTO:
  ------------------
  |  Branch (104:3): [True: 163, False: 16.2k]
  ------------------
  105|  1.73k|		case SC_CARD_TYPE_IASECC_CPX:
  ------------------
  |  Branch (105:3): [True: 119, False: 16.2k]
  ------------------
  106|  1.75k|		case SC_CARD_TYPE_IASECC_CPXCL:
  ------------------
  |  Branch (106:3): [True: 19, False: 16.3k]
  ------------------
  107|  1.75k|		case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (107:3): [True: 0, False: 16.4k]
  ------------------
  108|  1.75k|		case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (108:3): [True: 1, False: 16.4k]
  ------------------
  109|  1.83k|		case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (109:3): [True: 74, False: 16.3k]
  ------------------
  110|  2.01k|		case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (110:3): [True: 180, False: 16.2k]
  ------------------
  111|  2.01k|		case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (111:3): [True: 0, False: 16.4k]
  ------------------
  112|  2.01k|		case SC_CARD_TYPE_ESTEID_2018:
  ------------------
  |  Branch (112:3): [True: 0, False: 16.4k]
  ------------------
  113|  2.03k|		case SC_CARD_TYPE_CARDOS_V5_0:
  ------------------
  |  Branch (113:3): [True: 19, False: 16.3k]
  ------------------
  114|  2.85k|		case SC_CARD_TYPE_CARDOS_V5_3:
  ------------------
  |  Branch (114:3): [True: 822, False: 15.5k]
  ------------------
  115|  2.99k|		case SC_CARD_TYPE_NQ_APPLET:
  ------------------
  |  Branch (115:3): [True: 143, False: 16.2k]
  ------------------
  116|  2.99k|		case SC_CARD_TYPE_NQ_APPLET_RFID:
  ------------------
  |  Branch (116:3): [True: 0, False: 16.4k]
  ------------------
  117|  3.07k|		case SC_CARD_TYPE_STARCOS_V3_4_ESIGN:
  ------------------
  |  Branch (117:3): [True: 75, False: 16.3k]
  ------------------
  118|  3.08k|		case SC_CARD_TYPE_STARCOS_V3_5_ESIGN:
  ------------------
  |  Branch (118:3): [True: 12, False: 16.3k]
  ------------------
  119|  3.09k|		case SC_CARD_TYPE_SKEID_V3:
  ------------------
  |  Branch (119:3): [True: 8, False: 16.3k]
  ------------------
  120|  3.11k|		case SC_CARD_TYPE_EOI:
  ------------------
  |  Branch (120:3): [True: 25, False: 16.3k]
  ------------------
  121|  3.11k|		case SC_CARD_TYPE_EOI_CONTACTLESS:
  ------------------
  |  Branch (121:3): [True: 0, False: 16.4k]
  ------------------
  122|  3.11k|		case SC_CARD_TYPE_CHIPDOC_IT:
  ------------------
  |  Branch (122:3): [True: 0, False: 16.4k]
  ------------------
  123|  3.11k|		case SC_CARD_TYPE_DTRUST_V4_1_STD:
  ------------------
  |  Branch (123:3): [True: 0, False: 16.4k]
  ------------------
  124|  3.11k|		case SC_CARD_TYPE_DTRUST_V4_4_STD:
  ------------------
  |  Branch (124:3): [True: 0, False: 16.4k]
  ------------------
  125|  3.11k|		case SC_CARD_TYPE_DTRUST_V4_1_MULTI:
  ------------------
  |  Branch (125:3): [True: 0, False: 16.4k]
  ------------------
  126|  3.11k|		case SC_CARD_TYPE_DTRUST_V4_1_M100:
  ------------------
  |  Branch (126:3): [True: 0, False: 16.4k]
  ------------------
  127|  3.11k|		case SC_CARD_TYPE_DTRUST_V4_4_MULTI:
  ------------------
  |  Branch (127:3): [True: 0, False: 16.4k]
  ------------------
  128|  3.11k|		case SC_CARD_TYPE_DTRUST_V5_1_STD:
  ------------------
  |  Branch (128:3): [True: 0, False: 16.4k]
  ------------------
  129|  3.11k|		case SC_CARD_TYPE_DTRUST_V5_4_STD:
  ------------------
  |  Branch (129:3): [True: 0, False: 16.4k]
  ------------------
  130|  3.11k|		case SC_CARD_TYPE_DTRUST_V5_1_MULTI:
  ------------------
  |  Branch (130:3): [True: 0, False: 16.4k]
  ------------------
  131|  3.11k|		case SC_CARD_TYPE_DTRUST_V5_1_M100:
  ------------------
  |  Branch (131:3): [True: 0, False: 16.4k]
  ------------------
  132|  3.11k|		case SC_CARD_TYPE_DTRUST_V5_4_MULTI:
  ------------------
  |  Branch (132:3): [True: 0, False: 16.4k]
  ------------------
  133|  3.11k|		case SC_CARD_TYPE_LTEID:
  ------------------
  |  Branch (133:3): [True: 0, False: 16.4k]
  ------------------
  134|  3.20k|		case SC_CARD_TYPE_CEDULAUY:
  ------------------
  |  Branch (134:3): [True: 90, False: 16.3k]
  ------------------
  135|  3.20k|			return 1;
  136|  13.2k|		default:
  ------------------
  |  Branch (136:3): [True: 13.2k, False: 3.20k]
  ------------------
  137|  13.2k|			return 0;
  138|  16.4k|	}
  139|  16.4k|}
sc_pkcs15_bind_synthetic:
  143|  15.9k|{
  144|  15.9k|	sc_context_t		*ctx = p15card->card->ctx;
  145|  15.9k|	scconf_block		*conf_block, **blocks, *blk;
  146|  15.9k|	int			i, r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  15.9k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  147|       |
  148|  15.9k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  15.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  15.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  15.9k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 15.9k]
  |  |  ------------------
  ------------------
  149|  15.9k|	conf_block = NULL;
  150|       |
  151|  15.9k|	conf_block = sc_get_conf_block(ctx, "framework", "pkcs15", 1);
  152|       |
  153|  15.9k|	if (!conf_block) {
  ------------------
  |  Branch (153:6): [True: 15.9k, False: 0]
  ------------------
  154|       |		/* no conf file found => try builtin drivers  */
  155|  15.9k|		sc_log(ctx, "no conf file (or section), trying all builtin emulators");
  ------------------
  |  |   71|  15.9k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  156|   383k|		for (i = 0; builtin_emulators[i].name; i++) {
  ------------------
  |  Branch (156:15): [True: 373k, False: 9.99k]
  ------------------
  157|   373k|			sc_log(ctx, "trying %s", builtin_emulators[i].name);
  ------------------
  |  |   71|   373k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  158|   373k|			r = builtin_emulators[i].handler(p15card, aid);
  159|   373k|			if (r == SC_SUCCESS)
  ------------------
  |  |   28|   373k|#define SC_SUCCESS				0
  ------------------
  |  Branch (159:8): [True: 5.92k, False: 367k]
  ------------------
  160|       |				/* we got a hit */
  161|  5.92k|				goto out;
  162|   373k|		}
  163|  15.9k|	} else {
  164|       |		/* we have a conf file => let's use it */
  165|      0|		int builtin_enabled;
  166|      0|		const scconf_list *list;
  167|       |
  168|      0|		builtin_enabled = scconf_get_bool(conf_block, "enable_builtin_emulation", 1);
  169|      0|		list = scconf_find_list(conf_block, "builtin_emulators"); /* FIXME: rename to enabled_emulators */
  170|       |
  171|      0|		if (builtin_enabled && list) {
  ------------------
  |  Branch (171:7): [True: 0, False: 0]
  |  Branch (171:26): [True: 0, False: 0]
  ------------------
  172|       |			/* filter enabled emulation drivers from conf file */
  173|      0|			struct _sc_pkcs15_emulators filtered_emulators;
  174|      0|			struct sc_pkcs15_emulator_handler** lst;
  175|      0|			int ret;
  176|       |
  177|      0|			filtered_emulators.ccount = 0;
  178|      0|			ret = set_emulators(ctx, &filtered_emulators, list, builtin_emulators, old_emulators);
  179|      0|			if (ret == SC_SUCCESS || ret == SC_ERROR_TOO_MANY_OBJECTS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
              			if (ret == SC_SUCCESS || ret == SC_ERROR_TOO_MANY_OBJECTS) {
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  |  Branch (179:8): [True: 0, False: 0]
  |  Branch (179:29): [True: 0, False: 0]
  ------------------
  180|      0|				lst = filtered_emulators.list_of_handlers;
  181|       |
  182|      0|				if (ret == SC_ERROR_TOO_MANY_OBJECTS)
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  |  Branch (182:9): [True: 0, False: 0]
  ------------------
  183|      0|					sc_log(ctx, "trying first %d emulators from conf file", SC_MAX_PKCS15_EMULATORS);
  ------------------
  |  |   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)
  |  |  ------------------
  |  |  |  |  183|      0|					sc_log(ctx, "trying first %d emulators from conf file", SC_MAX_PKCS15_EMULATORS);
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|      0|#define SC_MAX_PKCS15_EMULATORS	48
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  184|       |
  185|      0|				for (i = 0; lst[i]; i++) {
  ------------------
  |  Branch (185:17): [True: 0, False: 0]
  ------------------
  186|      0|					sc_log(ctx, "trying %s", lst[i]->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__
  |  |  ------------------
  ------------------
  187|      0|					r = lst[i]->handler(p15card, aid);
  188|      0|					if (r == SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (188:10): [True: 0, False: 0]
  ------------------
  189|       |						/* we got a hit */
  190|      0|						goto out;
  191|      0|				}
  192|      0|			} else {
  193|      0|				sc_log(ctx, "failed to filter enabled card emulators: %s", sc_strerror(ret));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  194|      0|			}
  195|      0|		}
  196|      0|		else if (builtin_enabled) {
  ------------------
  |  Branch (196:12): [True: 0, False: 0]
  ------------------
  197|      0|			sc_log(ctx, "no emulator list in config file, trying all builtin emulators");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  198|      0|			for (i = 0; builtin_emulators[i].name; i++) {
  ------------------
  |  Branch (198:16): [True: 0, False: 0]
  ------------------
  199|      0|				sc_log(ctx, "trying %s", builtin_emulators[i].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__
  |  |  ------------------
  ------------------
  200|      0|				r = builtin_emulators[i].handler(p15card, aid);
  201|      0|				if (r == SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (201:9): [True: 0, False: 0]
  ------------------
  202|       |					/* we got a hit */
  203|      0|					goto out;
  204|      0|			}
  205|      0|		}
  206|       |
  207|       |		/* search for 'emulate foo { ... }' entries in the conf file */
  208|      0|		sc_log(ctx, "searching for 'emulate foo { ... }' blocks");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  209|      0|		blocks = scconf_find_blocks(ctx->conf, conf_block, "emulate", NULL);
  210|      0|		sc_log(ctx, "Blocks: %p", blocks);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  211|      0|		for (i = 0; blocks && (blk = blocks[i]) != NULL; i++) {
  ------------------
  |  Branch (211:15): [True: 0, False: 0]
  |  Branch (211:25): [True: 0, False: 0]
  ------------------
  212|      0|			const char *name = blk->name->data;
  213|      0|			sc_log(ctx, "trying %s", 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__
  |  |  ------------------
  ------------------
  214|      0|			r = parse_emu_block(p15card, aid, blk);
  215|      0|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (215:8): [True: 0, False: 0]
  ------------------
  216|      0|				free(blocks);
  217|      0|				goto out;
  218|      0|			}
  219|      0|		}
  220|      0|		if (blocks)
  ------------------
  |  Branch (220:7): [True: 0, False: 0]
  ------------------
  221|      0|			free(blocks);
  222|      0|	}
  223|       |
  224|  15.9k|out:
  225|  15.9k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  15.9k|#define SC_SUCCESS				0
  ------------------
  |  Branch (225:6): [True: 5.92k, False: 9.99k]
  ------------------
  226|  5.92k|		p15card->magic  = SC_PKCS15_CARD_MAGIC;
  ------------------
  |  |  519|  5.92k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  227|  5.92k|		p15card->flags |= SC_PKCS15_CARD_FLAG_EMULATED;
  ------------------
  |  |  601|  5.92k|#define SC_PKCS15_CARD_FLAG_EMULATED			0x02000000
  ------------------
  228|  9.99k|	} else {
  229|  9.99k|		if (r != SC_ERROR_WRONG_CARD)
  ------------------
  |  |   94|  9.99k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  |  Branch (229:7): [True: 147, False: 9.85k]
  ------------------
  230|    147|			sc_log(ctx, "Failed to load card emulator: %s", sc_strerror(r));
  ------------------
  |  |   71|    147|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  231|  9.99k|	}
  232|       |
  233|  15.9k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  15.9k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  15.9k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  15.9k|	int _ret = r; \
  |  |  |  |  155|  15.9k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  15.9k|		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|  9.99k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9.99k, False: 5.92k]
  |  |  |  |  ------------------
  |  |  |  |  157|  15.9k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  15.9k|	} 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|  15.9k|	return _ret; \
  |  |  |  |  163|  15.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|  15.9k|}
sc_pkcs15emu_add_pin_obj:
  370|  6.62k|{
  371|  6.62k|	sc_pkcs15_auth_info_t pin = *in_pin;
  372|       |
  373|  6.62k|	pin.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|  6.62k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  374|  6.62k|	if(!pin.auth_method) /* or SC_AC_NONE */
  ------------------
  |  Branch (374:5): [True: 6.09k, False: 529]
  ------------------
  375|  6.09k|		pin.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|  6.09k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  376|       |
  377|  6.62k|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_AUTH_PIN, obj, &pin);
  ------------------
  |  |  445|  6.62k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  378|  6.62k|}
sc_pkcs15emu_add_rsa_prkey:
  382|  1.50k|{
  383|  1.50k|	sc_pkcs15_prkey_info_t key = *in_key;
  384|       |
  385|  1.50k|	if (key.access_flags == 0)
  ------------------
  |  Branch (385:6): [True: 1.50k, False: 0]
  ------------------
  386|  1.50k|		key.access_flags = SC_PKCS15_PRKEY_ACCESS_SENSITIVE
  ------------------
  |  |  316|  1.50k|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
  387|  1.50k|				| SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE
  ------------------
  |  |  318|  1.50k|#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE	0x04
  ------------------
  388|  1.50k|				| SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE
  ------------------
  |  |  319|  1.50k|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
  389|  1.50k|				| SC_PKCS15_PRKEY_ACCESS_LOCAL;
  ------------------
  |  |  320|  1.50k|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  390|       |
  391|  1.50k|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_PRKEY_RSA, obj, &key);
  ------------------
  |  |  419|  1.50k|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  392|  1.50k|}
sc_pkcs15emu_add_rsa_pubkey:
  396|    242|{
  397|    242|	sc_pkcs15_pubkey_info_t key = *in_key;
  398|       |
  399|    242|	if (key.access_flags == 0)
  ------------------
  |  Branch (399:6): [True: 242, False: 0]
  ------------------
  400|    242|		key.access_flags = SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE;
  ------------------
  |  |  317|    242|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  401|       |
  402|    242|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_PUBKEY_RSA, obj, &key);
  ------------------
  |  |  426|    242|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  403|    242|}
sc_pkcs15emu_add_ec_prkey:
  407|  1.01k|{
  408|  1.01k|	sc_pkcs15_prkey_info_t key = *in_key;
  409|       |
  410|  1.01k|	if (key.access_flags == 0)
  ------------------
  |  Branch (410:6): [True: 1.01k, False: 0]
  ------------------
  411|  1.01k|		key.access_flags = SC_PKCS15_PRKEY_ACCESS_SENSITIVE
  ------------------
  |  |  316|  1.01k|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
  412|  1.01k|				| SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE
  ------------------
  |  |  318|  1.01k|#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE	0x04
  ------------------
  413|  1.01k|				| SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE
  ------------------
  |  |  319|  1.01k|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
  414|  1.01k|				| SC_PKCS15_PRKEY_ACCESS_LOCAL;
  ------------------
  |  |  320|  1.01k|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  415|       |
  416|  1.01k|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_PRKEY_EC, obj, &key);
  ------------------
  |  |  421|  1.01k|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  417|  1.01k|}
sc_pkcs15emu_add_ec_pubkey:
  421|  1.02k|{
  422|  1.02k|	sc_pkcs15_pubkey_info_t key = *in_key;
  423|       |
  424|  1.02k|	if (key.access_flags == 0)
  ------------------
  |  Branch (424:6): [True: 1.02k, False: 0]
  ------------------
  425|  1.02k|		key.access_flags = SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE;
  ------------------
  |  |  317|  1.02k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  426|       |
  427|  1.02k|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_PUBKEY_EC, obj, &key);
  ------------------
  |  |  428|  1.02k|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  428|  1.02k|}
sc_pkcs15emu_add_x509_cert:
  482|  2.30k|{
  483|  2.30k|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_CERT_X509, obj, cert);
  ------------------
  |  |  439|  2.30k|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  484|  2.30k|}
sc_pkcs15emu_add_data_object:
  488|  3.90k|{
  489|  3.90k|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_DATA_OBJECT, obj, data);
  ------------------
  |  |  442|  3.90k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  490|  3.90k|}
sc_pkcs15emu_object_add:
  494|  40.0k|{
  495|  40.0k|	sc_pkcs15_object_t *obj;
  496|  40.0k|	unsigned int	df_type;
  497|  40.0k|	size_t		data_len;
  498|       |
  499|  40.0k|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  40.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  40.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  40.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 40.0k]
  |  |  ------------------
  ------------------
  500|       |
  501|  40.0k|	obj = calloc(1, sizeof(*obj));
  502|  40.0k|	if (!obj) {
  ------------------
  |  Branch (502:6): [True: 0, False: 40.0k]
  ------------------
  503|      0|		LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  504|      0|	}
  505|       |
  506|  40.0k|	memcpy(obj, in_obj, sizeof(*obj));
  507|  40.0k|	obj->type = type;
  508|       |
  509|  40.0k|	switch (type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  40.0k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  510|  6.62k|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|  6.62k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (510:2): [True: 6.62k, False: 33.3k]
  ------------------
  511|  6.62k|		df_type  = SC_PKCS15_AODF;
  ------------------
  |  |  496|  6.62k|#define SC_PKCS15_AODF			8
  ------------------
  512|  6.62k|		data_len = sizeof(struct sc_pkcs15_auth_info);
  513|  6.62k|		break;
  514|  3.87k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  3.87k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (514:2): [True: 3.87k, False: 36.1k]
  ------------------
  515|  3.87k|		df_type  = SC_PKCS15_PRKDF;
  ------------------
  |  |  488|  3.87k|#define SC_PKCS15_PRKDF			0
  ------------------
  516|  3.87k|		data_len = sizeof(struct sc_pkcs15_prkey_info);
  517|  3.87k|		break;
  518|  1.27k|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|  1.27k|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (518:2): [True: 1.27k, False: 38.7k]
  ------------------
  519|  1.27k|		df_type = SC_PKCS15_PUKDF;
  ------------------
  |  |  489|  1.27k|#define SC_PKCS15_PUKDF			1
  ------------------
  520|  1.27k|		data_len = sizeof(struct sc_pkcs15_pubkey_info);
  521|  1.27k|		break;
  522|  2.64k|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|  2.64k|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (522:2): [True: 2.64k, False: 37.3k]
  ------------------
  523|  2.64k|		df_type = SC_PKCS15_CDF;
  ------------------
  |  |  492|  2.64k|#define SC_PKCS15_CDF			4
  ------------------
  524|  2.64k|		data_len = sizeof(struct sc_pkcs15_cert_info);
  525|  2.64k|		break;
  526|  25.5k|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|  25.5k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (526:2): [True: 25.5k, False: 14.4k]
  ------------------
  527|  25.5k|		df_type = SC_PKCS15_DODF;
  ------------------
  |  |  495|  25.5k|#define SC_PKCS15_DODF			7
  ------------------
  528|  25.5k|		data_len = sizeof(struct sc_pkcs15_data_info);
  529|  25.5k|		break;
  530|      0|	default:
  ------------------
  |  Branch (530:2): [True: 0, False: 40.0k]
  ------------------
  531|      0|		sc_log(p15card->card->ctx, "Unknown PKCS15 object type %d", type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  532|      0|		free(obj);
  533|      0|		LOG_FUNC_RETURN(p15card->card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  534|  40.0k|	}
  535|       |
  536|  40.0k|	obj->data = calloc(1, data_len);
  537|  40.0k|	if (obj->data == NULL) {
  ------------------
  |  Branch (537:6): [True: 0, False: 40.0k]
  ------------------
  538|      0|		free(obj);
  539|      0|		LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  540|      0|	}
  541|  40.0k|	memcpy(obj->data, data, data_len);
  542|       |
  543|  40.0k|	obj->df = sc_pkcs15emu_get_df(p15card, df_type);
  544|  40.0k|	sc_pkcs15_add_object(p15card, obj);
  545|       |
  546|       |	/* release memory ownership of buffers that are now contained in `p15card` */
  547|  40.0k|	switch (type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  40.0k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  548|  6.62k|	default:
  ------------------
  |  Branch (548:2): [True: 6.62k, False: 33.3k]
  ------------------
  549|       |		/* `data`'s members copied by value, no buffer to release */
  550|  6.62k|		break;
  551|  6.62k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  3.87k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (551:2): [True: 3.87k, False: 36.1k]
  ------------------
  552|  3.87k|		((struct sc_pkcs15_prkey_info *)data)->subject.value = NULL;
  553|  3.87k|		break;
  554|  1.27k|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|  1.27k|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (554:2): [True: 1.27k, False: 38.7k]
  ------------------
  555|  1.27k|		((struct sc_pkcs15_pubkey_info *)data)->subject.value = NULL;
  556|  1.27k|		((struct sc_pkcs15_pubkey_info *)data)->direct.raw.value = NULL;
  557|  1.27k|		((struct sc_pkcs15_pubkey_info *)data)->direct.spki.value = NULL;
  558|  1.27k|		break;
  559|  2.64k|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|  2.64k|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (559:2): [True: 2.64k, False: 37.3k]
  ------------------
  560|  2.64k|		((struct sc_pkcs15_cert_info *)data)->value.value = NULL;
  561|  2.64k|		break;
  562|  25.5k|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|  25.5k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (562:2): [True: 25.5k, False: 14.4k]
  ------------------
  563|  25.5k|		((struct sc_pkcs15_data_info *)data)->data.value = NULL;
  564|  25.5k|		break;
  565|  40.0k|	}
  566|       |
  567|  40.0k|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  40.0k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  40.0k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  40.0k|	int _ret = r; \
  |  |  |  |  155|  40.0k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 40.0k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  40.0k|		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: 40.0k]
  |  |  |  |  ------------------
  |  |  |  |  157|  40.0k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  40.0k|	} 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|  40.0k|	return _ret; \
  |  |  |  |  163|  40.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  568|  40.0k|}
pkcs15-syn.c:sc_pkcs15emu_get_df:
  341|  40.0k|{
  342|  40.0k|	sc_pkcs15_df_t	*df;
  343|  40.0k|	sc_file_t	*file;
  344|  40.0k|	int		created = 0;
  345|       |
  346|  49.5k|	while (1) {
  ------------------
  |  Branch (346:9): [True: 49.5k, Folded]
  ------------------
  347|  75.8k|		for (df = p15card->df_list; df; df = df->next) {
  ------------------
  |  Branch (347:31): [True: 66.3k, False: 9.58k]
  ------------------
  348|  66.3k|			if (df->type == type) {
  ------------------
  |  Branch (348:8): [True: 40.0k, False: 26.3k]
  ------------------
  349|  40.0k|				if (created)
  ------------------
  |  Branch (349:9): [True: 9.58k, False: 30.4k]
  ------------------
  350|  9.58k|					df->enumerated = 1;
  351|  40.0k|				return df;
  352|  40.0k|			}
  353|  66.3k|		}
  354|       |
  355|  9.58k|		if (created != 0)
  ------------------
  |  Branch (355:7): [True: 0, False: 9.58k]
  ------------------
  356|      0|			return NULL;
  357|       |
  358|  9.58k|		file = sc_file_new();
  359|  9.58k|		if (!file)
  ------------------
  |  Branch (359:7): [True: 0, False: 9.58k]
  ------------------
  360|      0|			return NULL;
  361|  9.58k|		sc_format_path("11001101", &file->path);
  362|  9.58k|		sc_pkcs15_add_df(p15card, type, &file->path);
  363|  9.58k|		sc_file_free(file);
  364|  9.58k|		created++;
  365|  9.58k|	}
  366|  40.0k|}

sc_pkcs15emu_tcos_init_ex:
  522|  15.8k|){
  523|  15.8k|	sc_card_t         *card = p15card->card;
  524|  15.8k|	sc_context_t      *ctx = p15card->card->ctx;
  525|  15.8k|	sc_serial_number_t serialnr;
  526|  15.8k|	char               serial[30];
  527|  15.8k|	int r;
  528|       |
  529|       |	/* check if we have the correct card OS unless SC_PKCS15EMU_FLAGS_NO_CHECK */
  530|  15.8k|	if (card->type!=SC_CARD_TYPE_TCOS_V2 && card->type!=SC_CARD_TYPE_TCOS_V3) return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  14.9k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  |  Branch (530:6): [True: 14.9k, False: 958]
  |  Branch (530:42): [True: 14.9k, False: 0]
  ------------------
  531|       |
  532|       |	/* get the card serial number */
  533|    958|	r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serialnr);
  534|    958|	if (r < 0) {
  ------------------
  |  Branch (534:6): [True: 526, False: 432]
  ------------------
  535|    526|		sc_log(ctx, "unable to get ICCSN");
  ------------------
  |  |   71|    526|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  536|    526|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|    526|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  537|    526|	}
  538|    432|	r = sc_bin_to_hex(serialnr.value, serialnr.len, serial, sizeof(serial), 0);
  539|    432|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    432|#define SC_SUCCESS				0
  ------------------
  |  Branch (539:6): [True: 11, False: 421]
  ------------------
  540|     11|		sc_log(ctx, "serial number invalid");
  ------------------
  |  |   71|     11|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  541|     11|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     11|#define SC_ERROR_INTERNAL			-1400
  ------------------
  542|     11|	}
  543|       |
  544|    421|	serial[19] = '\0';
  545|    421|	set_string(&p15card->tokeninfo->serial_number, serial);
  546|       |
  547|    421|	if(!detect_netkey(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|    128|#define SC_SUCCESS				0
  ------------------
  |  Branch (547:5): [True: 128, False: 293]
  ------------------
  548|    293|	if(!detect_idkey(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|     93|#define SC_SUCCESS				0
  ------------------
  |  Branch (548:5): [True: 93, False: 200]
  ------------------
  549|    200|	if(!detect_unicard(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|     49|#define SC_SUCCESS				0
  ------------------
  |  Branch (549:5): [True: 49, False: 151]
  ------------------
  550|    151|	if(!detect_signtrust(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|     14|#define SC_SUCCESS				0
  ------------------
  |  Branch (550:5): [True: 14, False: 137]
  ------------------
  551|    137|	if(!detect_datev(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  |  Branch (551:5): [True: 3, False: 134]
  ------------------
  552|       |
  553|    134|	sc_pkcs15_card_clear(p15card);
  554|    134|	return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    134|#define SC_ERROR_INTERNAL			-1400
  ------------------
  555|    137|}
pkcs15-tcos.c:detect_netkey:
  296|    421|){
  297|    421|	sc_card_t *card=p15card->card;
  298|    421|	sc_path_t p;
  299|    421|	sc_file_t *f;
  300|    421|	int keylen;
  301|    421|	char dir[10];
  302|    421|	const char *c_auth;
  303|       |
  304|       |	/* NKS-Applikation ? */
  305|    421|	memset(&p, 0, sizeof(sc_path_t));
  306|    421|	p.type=SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    421|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  307|    421|	memcpy(p.value, "\xD2\x76\x00\x00\x03\x01\x02", p.len=7);
  308|    421|	if (sc_select_file(card,&p,&f)!=SC_SUCCESS) return 1;
  ------------------
  |  |   28|    421|#define SC_SUCCESS				0
  ------------------
  |  Branch (308:6): [True: 293, False: 128]
  ------------------
  309|    128|	sprintf(dir,"%04X", f->id);
  310|    128|	sc_file_free(f);
  311|       |
  312|    128|	set_string(&p15card->tokeninfo->manufacturer_id, "TeleSec GmbH");
  313|    128|	set_string(&p15card->tokeninfo->label, card->type==SC_CARD_TYPE_TCOS_V3 ? "NetKey V3 Card" : "NetKey Card");
  ------------------
  |  Branch (313:41): [True: 0, False: 128]
  ------------------
  314|    128|	keylen= card->type==SC_CARD_TYPE_TCOS_V3 ? 2048 : 1024;
  ------------------
  |  Branch (314:10): [True: 0, False: 128]
  ------------------
  315|    128|	c_auth= card->type==SC_CARD_TYPE_TCOS_V3 ? "C500" : "C100";
  ------------------
  |  Branch (315:10): [True: 0, False: 128]
  ------------------
  316|       |
  317|    128|	insert_cert(p15card, dirpath(dir,"4331"), 0x45, 1, "Signatur Zertifikat 1");
  318|    128|	insert_cert(p15card, dirpath(dir,"4332"), 0x45, 1, "Signatur Zertifikat 2");
  319|    128|	insert_cert(p15card, dirpath(dir,"C000"), 0x45, 0, "Telesec Signatur Zertifikat");
  320|    128|	insert_cert(p15card, dirpath(dir,"43B1"), 0x46, 1, "Verschluesselungs Zertifikat 1");
  321|    128|	insert_cert(p15card, dirpath(dir,"43B2"), 0x46, 1, "Verschluesselungs Zertifikat 2");
  322|    128|	insert_cert(p15card, dirpath(dir,"C200"), 0x46, 0, "Telesec Verschluesselungs Zertifikat");
  323|    128|	insert_cert(p15card, dirpath(dir,"4371"), 0x47, 1, "Authentifizierungs Zertifikat 1");
  324|    128|	insert_cert(p15card, dirpath(dir,"4372"), 0x47, 1, "Authentifizierungs Zertifikat 2");
  325|    128|	insert_cert(p15card, dirpath(dir,c_auth), 0x47, 0, "Telesec Authentifizierungs Zertifikat");
  326|    128|	insert_cert(p15card, dirpath(dir,"C201"), 0x48, 0, "Telesec 1024bit Zertifikat");
  327|       |
  328|    128|	insert_key(p15card, dirpath(dir,"5331"), 0x45, 0x80, keylen, 4, "Signatur Schluessel");
  329|    128|	insert_key(p15card, dirpath(dir,"53B1"), 0x46, 0x81, keylen, 3, "Verschluesselungs Schluessel");
  330|    128|	insert_key(p15card, dirpath(dir,"5371"), 0x47, 0x82, keylen, 3, "Authentifizierungs Schluessel");
  331|    128|	insert_key(p15card, dirpath(dir,"0000"), 0x48, 0x83, 1024,   3, "1024bit Schluessel");
  332|       |
  333|    128|	insert_pin(p15card, "5000", 1, 2, 0x00, 6, "PIN",
  334|    128|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   54|    128|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|    128|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  335|    128|	);
  336|    128|	insert_pin(p15card, "5001", 2, 0, 0x01, 8, "PUK",
  337|    128|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   54|    128|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   58|    128|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  338|    128|		SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN
  ------------------
  |  |   60|    128|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
              		SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN
  ------------------
  |  |   61|    128|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  339|    128|	);
  340|    128|	if(card->type==SC_CARD_TYPE_TCOS_V3){
  ------------------
  |  Branch (340:5): [True: 0, False: 128]
  ------------------
  341|      0|		insert_pin(p15card, dirpath(dir,"0000"), 3, 1, 0x83, 6, "NetKey PIN2",
  342|      0|			SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   54|      0|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              			SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  343|      0|			SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  344|      0|		);
  345|    128|	} else {
  346|    128|		insert_pin(p15card, dirpath(dir,"5080"), 3, 1, 0x80, 6, "NetKey PIN0",
  347|    128|			SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   54|    128|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              			SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   55|    128|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  348|    128|			SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|    128|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  349|    128|		);
  350|    128|	}
  351|    128|	insert_pin(p15card, dirpath(dir,"5081"), 4, 1, 0x81, 6, "NetKey PIN1",
  352|    128|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   54|    128|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   55|    128|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  353|    128|		SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|    128|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  354|    128|	);
  355|       |
  356|       |	/* SigG-Applikation */
  357|    128|	p.len=7; p.type=SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    128|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  358|    128|	memcpy(p.value, "\xD2\x76\x00\x00\x66\x01", p.len=6);
  359|    128|	if (sc_select_file(card,&p,&f)==SC_SUCCESS){
  ------------------
  |  |   28|    128|#define SC_SUCCESS				0
  ------------------
  |  Branch (359:6): [True: 16, False: 112]
  ------------------
  360|     16|		sprintf(dir,"%04X", f->id);
  361|     16|		sc_file_free(f);
  362|       |
  363|     16|		insert_cert(p15card, dirpath(dir,"C000"), 0x49, 1, "SigG Zertifikat 1");
  364|     16|		insert_cert(p15card, dirpath(dir,"4331"), 0x49, 1, "SigG Zertifikat 2");
  365|     16|		insert_cert(p15card, dirpath(dir,"4332"), 0x49, 1, "SigG Zertifikat 3");
  366|       |
  367|     16|		if(card->type==SC_CARD_TYPE_TCOS_V3){
  ------------------
  |  Branch (367:6): [True: 0, False: 16]
  ------------------
  368|      0|			insert_key(p15card, dirpath(dir,"0000"), 0x49, 0x84, 2048, 5, "SigG Schluessel");
  369|     16|		} else {
  370|     16|			insert_key(p15card, dirpath(dir,"5331"), 0x49, 0x80, 1024, 5, "SigG Schluessel");
  371|     16|		}
  372|       |
  373|     16|		insert_pin(p15card, dirpath(dir,"5081"), 5, 0, 0x81, 6, "SigG PIN",
  374|     16|			SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   54|     16|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              			SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   55|     16|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  375|     16|			SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|     16|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  376|     16|		);
  377|     16|		if(card->type==SC_CARD_TYPE_TCOS_V3){
  ------------------
  |  Branch (377:6): [True: 0, False: 16]
  ------------------
  378|      0|			insert_pin(p15card, dirpath(dir,"0000"), 6, 0, 0x83, 8, "SigG PIN2",
  379|      0|				SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   54|      0|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              				SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  380|      0|				SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  381|      0|			);
  382|      0|		}
  383|     16|	}
  384|       |
  385|    128|	return 0;
  386|    421|}
pkcs15-tcos.c:insert_cert:
   42|  2.67k|){
   43|  2.67k|	sc_card_t *card=p15card->card;
   44|  2.67k|	sc_context_t *ctx=p15card->card->ctx;
   45|  2.67k|	struct sc_pkcs15_cert_info cert_info;
   46|  2.67k|	struct sc_pkcs15_object cert_obj;
   47|  2.67k|	unsigned char cert[20];
   48|  2.67k|	size_t cert_len = 0;
   49|  2.67k|	int r;
   50|       |
   51|  2.67k|	memset(&cert_info, 0, sizeof(cert_info));
   52|  2.67k|	cert_info.id.len      = 1;
   53|  2.67k|	cert_info.id.value[0] = id;
   54|  2.67k|	cert_info.authority   = 0;
   55|  2.67k|	sc_format_path(path, &cert_info.path);
   56|       |
   57|  2.67k|	memset(&cert_obj, 0, sizeof(cert_obj));
   58|  2.67k|	strlcpy(cert_obj.label, label, sizeof(cert_obj.label));
  ------------------
  |  |   43|  2.67k|#define strlcpy _strlcpy
  ------------------
   59|  2.67k|	cert_obj.flags = writable ? SC_PKCS15_CO_FLAG_MODIFIABLE : 0;
  ------------------
  |  |   51|  2.01k|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
  |  Branch (59:19): [True: 2.01k, False: 655]
  ------------------
   60|       |
   61|  2.67k|	if (sc_select_file(card, &cert_info.path, NULL) != SC_SUCCESS) {
  ------------------
  |  |   28|  2.67k|#define SC_SUCCESS				0
  ------------------
  |  Branch (61:6): [True: 1.82k, False: 849]
  ------------------
   62|  1.82k|		sc_log(ctx, "Select(%s) failed", path);
  ------------------
  |  |   71|  1.82k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   63|  1.82k|		return 1;
   64|  1.82k|	}
   65|    849|	r = sc_read_binary(card, 0, cert, sizeof(cert), 0);
   66|    849|	if (r <= 0) {
  ------------------
  |  Branch (66:6): [True: 578, False: 271]
  ------------------
   67|    578|		sc_log(ctx, "ReadBinary(%s) failed\n", path);
  ------------------
  |  |   71|    578|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   68|    578|		return 2;
   69|    578|	}
   70|    271|	cert_len = r; /* actual number of read bytes */
   71|    271|	if (cert_len < 4) {
  ------------------
  |  Branch (71:6): [True: 21, False: 250]
  ------------------
   72|     21|		sc_log(ctx, "Invalid certificate length");
  ------------------
  |  |   71|     21|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   73|     21|		return 3;
   74|     21|	}
   75|    250|	if (cert[0] != 0x30 || cert[1] != 0x82) {
  ------------------
  |  Branch (75:6): [True: 98, False: 152]
  |  Branch (75:25): [True: 19, False: 133]
  ------------------
   76|    117|		sc_log(ctx, "Invalid Cert: %02X:%02X:...\n", cert[0], cert[1]);
  ------------------
  |  |   71|    117|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   77|    117|		return 3;
   78|    117|	}
   79|       |
   80|       |	/* some certificates are prefixed by an OID */
   81|    133|	if (cert_len > 9 && (size_t)(7 + cert[5]) <= cert_len &&
  ------------------
  |  Branch (81:6): [True: 123, False: 10]
  |  Branch (81:22): [True: 84, False: 39]
  ------------------
   82|     84|			cert[4] == 0x06 && cert[5] < 10 && cert[6 + cert[5]] == 0x30 &&
  ------------------
  |  Branch (82:4): [True: 27, False: 57]
  |  Branch (82:23): [True: 17, False: 10]
  |  Branch (82:39): [True: 7, False: 10]
  ------------------
   83|      7|			cert[7 + cert[5]] == 0x82) {
  ------------------
  |  Branch (83:4): [True: 2, False: 5]
  ------------------
   84|      2|		if ((size_t)(9 + cert[5]) > cert_len) {
  ------------------
  |  Branch (84:7): [True: 1, False: 1]
  ------------------
   85|      1|			sc_log(ctx, "Invalid certificate length");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   86|      1|			return 3;
   87|      1|		}
   88|      1|		cert_info.path.index=6+cert[5];
   89|      1|		cert_info.path.count=(cert[8+cert[5]]<<8) + cert[9+cert[5]] + 4;
   90|    131|	} else {
   91|    131|		cert_info.path.index=0;
   92|    131|		cert_info.path.count=(cert[2]<<8) + cert[3] + 4;
   93|    131|	}
   94|       |
   95|    132|	r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
   96|    132|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    132|#define SC_SUCCESS				0
  ------------------
  |  Branch (96:6): [True: 0, False: 132]
  ------------------
   97|      0|		sc_log(ctx, "sc_pkcs15emu_add_x509_cert(%s) failed", path);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   98|      0|		return 4;
   99|      0|	}
  100|    132|	sc_log(ctx, "%s: OK, Index=%d, Count=%d", path, cert_info.path.index, cert_info.path.count);
  ------------------
  |  |   71|    132|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  101|    132|	return 0;
  102|    132|}
pkcs15-tcos.c:dirpath:
  286|  2.12k|static char *dirpath(char *dir, const char *path){
  287|  2.12k|	static char buf[SC_MAX_PATH_STRING_SIZE];
  288|       |
  289|  2.12k|	strlcpy(buf,dir,sizeof buf);
  ------------------
  |  |   43|  2.12k|#define strlcpy _strlcpy
  ------------------
  290|  2.12k|	strlcat(buf,path,sizeof buf);
  291|  2.12k|	return buf;
  292|  2.12k|}
pkcs15-tcos.c:insert_key:
  113|  1.56k|{
  114|  1.56k|	sc_card_t *card = p15card->card;
  115|  1.56k|	sc_context_t *ctx = p15card->card->ctx;
  116|  1.56k|	sc_file_t *f;
  117|  1.56k|	struct sc_pkcs15_prkey_info prkey_info;
  118|  1.56k|	struct sc_pkcs15_object prkey_obj;
  119|  1.56k|	int r, can_sign, can_crypt;
  120|       |
  121|  1.56k|	memset(&prkey_info, 0, sizeof(prkey_info));
  122|  1.56k|	prkey_info.id.len         = 1;
  123|  1.56k|	prkey_info.id.value[0]    = id;
  124|  1.56k|	prkey_info.native         = 1;
  125|  1.56k|	prkey_info.key_reference  = key_reference;
  126|  1.56k|	prkey_info.modulus_length = key_length;
  127|  1.56k|	sc_format_path(path, &prkey_info.path);
  128|       |
  129|  1.56k|	memset(&prkey_obj, 0, sizeof(prkey_obj));
  130|  1.56k|	strlcpy(prkey_obj.label, label, sizeof(prkey_obj.label));
  ------------------
  |  |   43|  1.56k|#define strlcpy _strlcpy
  ------------------
  131|  1.56k|	prkey_obj.flags            = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|  1.56k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  132|  1.56k|	prkey_obj.auth_id.len      = 1;
  133|  1.56k|	prkey_obj.auth_id.value[0] = auth_id;
  134|       |
  135|  1.56k|	can_sign = can_crypt = 0;
  136|  1.56k|	if (card->type == SC_CARD_TYPE_TCOS_V3) {
  ------------------
  |  Branch (136:6): [True: 0, False: 1.56k]
  ------------------
  137|      0|		unsigned char buf[256];
  138|      0|		int i, rec_no = 0;
  139|      0|		if (prkey_info.path.len >= 2)
  ------------------
  |  Branch (139:7): [True: 0, False: 0]
  ------------------
  140|      0|			prkey_info.path.len -= 2;
  141|      0|		sc_append_file_id(&prkey_info.path, 0x5349);
  142|      0|		if (sc_select_file(card, &prkey_info.path, NULL) != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (142:7): [True: 0, False: 0]
  ------------------
  143|      0|			sc_log(ctx, "Select(%s) failed", sc_print_path(&prkey_info.path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  144|      0|			return 1;
  145|      0|		}
  146|      0|		sc_log(ctx, "Searching for Key-Ref %02X", key_reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  147|      0|		while ((r = sc_read_record(card, ++rec_no, 0, buf, sizeof(buf), SC_RECORD_BY_REC_NR)) > 0) {
  ------------------
  |  | 1298|      0|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (147:10): [True: 0, False: 0]
  ------------------
  148|      0|			int found = 0;
  149|      0|			if (buf[0] != 0xA0 || r < 2)
  ------------------
  |  Branch (149:8): [True: 0, False: 0]
  |  Branch (149:26): [True: 0, False: 0]
  ------------------
  150|      0|				continue;
  151|      0|			for (i = 2; i < buf[1] + 2 && i < r - 2; i += 2 + buf[i + 1]) {
  ------------------
  |  Branch (151:16): [True: 0, False: 0]
  |  Branch (151:34): [True: 0, False: 0]
  ------------------
  152|      0|				if (buf[i] == 0x83 && buf[i + 1] == 1 && buf[i + 2] == key_reference)
  ------------------
  |  Branch (152:9): [True: 0, False: 0]
  |  Branch (152:27): [True: 0, False: 0]
  |  Branch (152:46): [True: 0, False: 0]
  ------------------
  153|      0|					++found;
  154|      0|			}
  155|      0|			if (found)
  ------------------
  |  Branch (155:8): [True: 0, False: 0]
  ------------------
  156|      0|				break;
  157|      0|		}
  158|      0|		if (r <= 0) {
  ------------------
  |  Branch (158:7): [True: 0, False: 0]
  ------------------
  159|      0|			sc_log(ctx, "No EF_KEYD-Record found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  160|      0|			return 1;
  161|      0|		}
  162|      0|		for (i = 0; i + 1 < r; i += 2 + buf[i + 1]) {
  ------------------
  |  Branch (162:15): [True: 0, False: 0]
  ------------------
  163|      0|			if (buf[i] == 0xB6)
  ------------------
  |  Branch (163:8): [True: 0, False: 0]
  ------------------
  164|      0|				can_sign++;
  165|      0|			if (buf[i] == 0xB8)
  ------------------
  |  Branch (165:8): [True: 0, False: 0]
  ------------------
  166|      0|				can_crypt++;
  167|      0|		}
  168|  1.56k|	} else {
  169|  1.56k|		if (sc_select_file(card, &prkey_info.path, &f) != SC_SUCCESS
  ------------------
  |  |   28|  3.12k|#define SC_SUCCESS				0
  ------------------
  |  Branch (169:7): [True: 1.39k, False: 165]
  ------------------
  170|  1.46k|			   	|| !f->prop_attr || f->prop_attr_len < 2){
  ------------------
  |  Branch (170:11): [True: 57, False: 108]
  |  Branch (170:28): [True: 11, False: 97]
  ------------------
  171|  1.46k|			sc_log(ctx, "Select(%s) failed", sc_print_path(&prkey_info.path));
  ------------------
  |  |   71|  1.46k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  172|  1.46k|			sc_file_free(f);
  173|  1.46k|			return 1;
  174|  1.46k|		}
  175|     97|		if (f->prop_attr[1] & 0x04)
  ------------------
  |  Branch (175:7): [True: 63, False: 34]
  ------------------
  176|     63|			can_crypt = 1;
  177|     97|		if (f->prop_attr[1] & 0x08)
  ------------------
  |  Branch (177:7): [True: 49, False: 48]
  ------------------
  178|     49|			can_sign = 1;
  179|     97|		sc_file_free(f);
  180|     97|	}
  181|     97|	prkey_info.usage = SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|     97|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  182|     97|	if (can_crypt)
  ------------------
  |  Branch (182:6): [True: 63, False: 34]
  ------------------
  183|     63|		prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  305|     63|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              		prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  306|     63|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  184|     97|	if (can_sign)
  ------------------
  |  Branch (184:6): [True: 49, False: 48]
  ------------------
  185|     49|		prkey_info.usage |= SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
  ------------------
  |  |  314|     49|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  186|       |
  187|     97|	r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  188|     97|	if(r != SC_SUCCESS) {
  ------------------
  |  |   28|     97|#define SC_SUCCESS				0
  ------------------
  |  Branch (188:5): [True: 0, False: 97]
  ------------------
  189|      0|		sc_log(ctx,  "sc_pkcs15emu_add_rsa_prkey(%s) failed\n", path);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  190|      0|		return 4;
  191|      0|	}
  192|     97|	sc_log(ctx,  "%s: OK%s%s\n", path, can_sign ? ", Sign" : "", can_crypt ? ", Crypt" : "");
  ------------------
  |  |   71|    388|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 49, False: 48]
  |  |  |  Branch (71:122): [True: 63, False: 34]
  |  |  ------------------
  ------------------
  193|     97|	return 0;
  194|     97|}
pkcs15-tcos.c:insert_pin:
  205|    857|){
  206|    857|	sc_card_t *card=p15card->card;
  207|    857|	sc_context_t *ctx=p15card->card->ctx;
  208|    857|	sc_file_t *f = NULL;
  209|    857|	struct sc_pkcs15_auth_info pin_info;
  210|    857|	struct sc_pkcs15_object pin_obj;
  211|    857|	int r;
  212|       |
  213|    857|	memset(&pin_info, 0, sizeof(pin_info));
  214|    857|	pin_info.auth_id.len      = 1;
  215|    857|	pin_info.auth_id.value[0] = id;
  216|    857|	pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    857|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  217|    857|	pin_info.attrs.pin.reference        = pin_reference;
  218|    857|	pin_info.attrs.pin.flags            = pin_flags;
  219|    857|	pin_info.attrs.pin.type             = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|    857|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  220|    857|	pin_info.attrs.pin.min_length       = min_length;
  221|    857|	pin_info.attrs.pin.stored_length    = 16;
  222|    857|	pin_info.attrs.pin.max_length       = 16;
  223|    857|	pin_info.attrs.pin.pad_char         = '\0';
  224|    857|	pin_info.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  430|    857|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
  225|    857|	sc_format_path(path, &pin_info.path);
  226|       |
  227|    857|	memset(&pin_obj, 0, sizeof(pin_obj));
  228|    857|	strlcpy(pin_obj.label, label, sizeof(pin_obj.label));
  ------------------
  |  |   43|    857|#define strlcpy _strlcpy
  ------------------
  229|    857|	pin_obj.flags            = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   51|    857|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              	pin_obj.flags            = SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|    857|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  230|    857|	pin_obj.auth_id.len      = auth_id ? 0 : 1;
  ------------------
  |  Branch (230:29): [True: 526, False: 331]
  ------------------
  231|    857|	pin_obj.auth_id.value[0] = auth_id;
  232|       |
  233|    857|	if(card->type == SC_CARD_TYPE_TCOS_V3) {
  ------------------
  |  Branch (233:5): [True: 0, False: 857]
  ------------------
  234|      0|		unsigned char buf[256];
  235|      0|		int i, rec_no=0;
  236|      0|		if (pin_info.path.len >= 2) {
  ------------------
  |  Branch (236:7): [True: 0, False: 0]
  ------------------
  237|      0|			pin_info.path.len -= 2;
  238|      0|		}
  239|      0|		sc_append_file_id(&pin_info.path, 0x5049);
  240|      0|		if (sc_select_file(card, &pin_info.path, NULL) != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (240:7): [True: 0, False: 0]
  ------------------
  241|      0|			sc_log(ctx, "Select(%s) failed", sc_print_path(&pin_info.path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  242|      0|			return 1;
  243|      0|		}
  244|      0|		sc_log(ctx, "Searching for PIN-Ref %02X", pin_reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  245|      0|		while ((r = sc_read_record(card, ++rec_no, 0, buf, sizeof(buf), SC_RECORD_BY_REC_NR)) > 0) {
  ------------------
  |  | 1298|      0|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (245:10): [True: 0, False: 0]
  ------------------
  246|      0|			int found = 0, fbz = -1;
  247|      0|			if (r < 2 || buf[0] != 0xA0)
  ------------------
  |  Branch (247:8): [True: 0, False: 0]
  |  Branch (247:17): [True: 0, False: 0]
  ------------------
  248|      0|				continue;
  249|      0|			for (i = 2; i < buf[1] + 2 && (i + 2) < r; i += 2 + buf[i + 1]) {
  ------------------
  |  Branch (249:16): [True: 0, False: 0]
  |  Branch (249:34): [True: 0, False: 0]
  ------------------
  250|      0|				if (buf[i] == 0x83 && buf[i + 1] == 1 && buf[i + 2] == pin_reference) {
  ------------------
  |  Branch (250:9): [True: 0, False: 0]
  |  Branch (250:27): [True: 0, False: 0]
  |  Branch (250:46): [True: 0, False: 0]
  ------------------
  251|      0|					++found;
  252|      0|				}
  253|      0|				if (buf[i] == 0x90 && (i + 1 + buf[i + 1]) < r) {
  ------------------
  |  Branch (253:9): [True: 0, False: 0]
  |  Branch (253:27): [True: 0, False: 0]
  ------------------
  254|      0|					fbz = buf[i + 1 + buf[i + 1]];
  255|      0|				}
  256|      0|			}
  257|      0|			if (found) {
  ------------------
  |  Branch (257:8): [True: 0, False: 0]
  ------------------
  258|      0|				pin_info.tries_left = fbz;
  259|      0|				break;
  260|      0|			}
  261|      0|		}
  262|      0|		if (r <= 0) {
  ------------------
  |  Branch (262:7): [True: 0, False: 0]
  ------------------
  263|      0|			sc_log(ctx, "No EF_PWDD-Record found\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  264|      0|			return 1;
  265|      0|		}
  266|    857|	} else {
  267|    857|		if (sc_select_file(card, &pin_info.path, &f) != SC_SUCCESS
  ------------------
  |  |   28|  1.71k|#define SC_SUCCESS				0
  ------------------
  |  Branch (267:7): [True: 756, False: 101]
  ------------------
  268|    809|			   	|| !f->prop_attr || f->prop_attr_len < 4){
  ------------------
  |  Branch (268:11): [True: 42, False: 59]
  |  Branch (268:28): [True: 11, False: 48]
  ------------------
  269|    809|			sc_log(ctx, "Select(%s) failed\n", path);
  ------------------
  |  |   71|    809|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  270|    809|			sc_file_free(f);
  271|    809|			return 1;
  272|    809|		}
  273|     48|		pin_info.tries_left = f->prop_attr[3];
  274|     48|		sc_file_free(f);
  275|     48|	}
  276|       |
  277|     48|	r=sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
  278|     48|	if(r!=SC_SUCCESS){
  ------------------
  |  |   28|     48|#define SC_SUCCESS				0
  ------------------
  |  Branch (278:5): [True: 0, False: 48]
  ------------------
  279|      0|		sc_log(ctx,  "sc_pkcs15emu_add_pin_obj(%s) failed\n", path);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  280|      0|		return 4;
  281|      0|	}
  282|     48|	sc_log(ctx,  "%s: OK, FBZ=%d\n", path, pin_info.tries_left);
  ------------------
  |  |   71|     48|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  283|     48|	return 0;
  284|     48|}
pkcs15-tcos.c:detect_idkey:
  390|    293|){
  391|    293|	sc_card_t *card=p15card->card;
  392|    293|	sc_path_t p;
  393|       |
  394|       |	/* TCKEY-Applikation ? */
  395|    293|	memset(&p, 0, sizeof(sc_path_t));
  396|    293|	p.type=SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    293|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  397|    293|	memcpy(p.value, "\xD2\x76\x00\x00\x03\x0C\x01", p.len=7);
  398|    293|	if (sc_select_file(card,&p,NULL)!=SC_SUCCESS) return 1;
  ------------------
  |  |   28|    293|#define SC_SUCCESS				0
  ------------------
  |  Branch (398:6): [True: 200, False: 93]
  ------------------
  399|       |
  400|     93|	set_string(&p15card->tokeninfo->manufacturer_id, "TeleSec GmbH");
  401|     93|	set_string(&p15card->tokeninfo->label, "IDKey Card");
  402|       |
  403|     93|	insert_cert(p15card, "DF074331", 0x45, 1, "Signatur Zertifikat 1");
  404|     93|	insert_cert(p15card, "DF074332", 0x46, 1, "Signatur Zertifikat 2");
  405|     93|	insert_cert(p15card, "DF074333", 0x47, 1, "Signatur Zertifikat 3");
  406|     93|	insert_cert(p15card, "DF084331", 0x4B, 1, "Verschluesselungs Zertifikat 1");
  407|     93|	insert_cert(p15card, "DF084332", 0x4C, 1, "Verschluesselungs Zertifikat 2");
  408|     93|	insert_cert(p15card, "DF084333", 0x4D, 1, "Verschluesselungs Zertifikat 3");
  409|       |	/* TODO should others come here too? */
  410|       |
  411|     93|	insert_key(p15card, "DF074E03", 0x45, 0x84, 2048, 1, "IDKey1");
  412|     93|	insert_key(p15card, "DF074E04", 0x46, 0x85, 2048, 1, "IDKey2");
  413|     93|	insert_key(p15card, "DF074E05", 0x47, 0x86, 2048, 1, "IDKey3");
  414|     93|	insert_key(p15card, "DF074E06", 0x48, 0x87, 2048, 1, "IDKey4");
  415|     93|	insert_key(p15card, "DF074E07", 0x49, 0x88, 2048, 1, "IDKey5");
  416|     93|	insert_key(p15card, "DF074E08", 0x4A, 0x89, 2048, 1, "IDKey6");
  417|     93|	insert_key(p15card, "DF084E01", 0x4B, 0x81, 2048, 1, "IDKey7");
  418|     93|	insert_key(p15card, "DF084E02", 0x4C, 0x82, 2048, 1, "IDKey8");
  419|     93|	insert_key(p15card, "DF084E03", 0x4D, 0x83, 2048, 1, "IDKey9");
  420|       |
  421|     93|	insert_pin(p15card, "5000", 1, 2, 0x00, 6, "PIN",
  422|     93|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   54|     93|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|     93|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  423|     93|	);
  424|     93|	insert_pin(p15card, "5001", 2, 0, 0x01, 8, "PUK",
  425|     93|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   54|     93|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   58|     93|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  426|     93|		SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN
  ------------------
  |  |   60|     93|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
              		SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN
  ------------------
  |  |   61|     93|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  427|     93|	);
  428|       |
  429|     93|	return 0;
  430|    293|}
pkcs15-tcos.c:detect_unicard:
  485|    200|){
  486|    200|	if(!insert_cert(p15card,"41004352", 0x45, 1, "Zertifikat 1")){
  ------------------
  |  Branch (486:5): [True: 36, False: 164]
  ------------------
  487|     36|		set_string(&p15card->tokeninfo->manufacturer_id, "JLU Giessen");
  488|     36|		set_string(&p15card->tokeninfo->label, "JLU Giessen Card");
  489|       |
  490|     36|		insert_cert(p15card,"41004353", 0x46, 1, "Zertifikat 2");
  491|     36|		insert_cert(p15card,"41004354", 0x47, 1, "Zertifikat 3");
  492|     36|		insert_key(p15card,"41005103", 0x45, 0x83, 1024, 1, "Schluessel 1");
  493|     36|		insert_key(p15card,"41005104", 0x46, 0x84, 1024, 1, "Schluessel 2");
  494|     36|		insert_key(p15card,"41005105", 0x47, 0x85, 1024, 1, "Schluessel 3");
  495|       |
  496|    164|	} else if(!insert_cert(p15card,"41014352", 0x45, 1, "Zertifikat 1")){
  ------------------
  |  Branch (496:12): [True: 13, False: 151]
  ------------------
  497|     13|		set_string(&p15card->tokeninfo->manufacturer_id, "TU Darmstadt");
  498|     13|		set_string(&p15card->tokeninfo->label, "TUD Card");
  499|       |
  500|     13|		insert_cert(p15card,"41014353", 0x46, 1, "Zertifikat 2");
  501|     13|		insert_cert(p15card,"41014354", 0x47, 1, "Zertifikat 3");
  502|     13|		insert_key(p15card,"41015103", 0x45, 0x83, 1024, 1, "Schluessel 1");
  503|     13|		insert_key(p15card,"41015104", 0x46, 0x84, 1024, 1, "Schluessel 2");
  504|     13|		insert_key(p15card,"41015105", 0x47, 0x85, 1024, 1, "Schluessel 3");
  505|       |
  506|    151|	} else return 1;
  507|       |
  508|     49|	insert_pin(p15card,"5000", 1, 2, 0x00, 6, "PIN",
  509|     49|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   54|     49|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|     49|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  510|     49|	);
  511|     49|	insert_pin(p15card,"5008", 2, 0, 0x01, 8, "PUK",
  512|     49|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   54|     49|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED |
  ------------------
  |  |   58|     49|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  513|     49|		SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN
  ------------------
  |  |   60|     49|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
              		SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN
  ------------------
  |  |   61|     49|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  514|     49|	);
  515|       |
  516|     49|	return 0;
  517|    200|}
pkcs15-tcos.c:detect_signtrust:
  434|    151|){
  435|    151|	if(insert_cert(p15card,"8000DF01C000", 0x45, 1, "Signatur Zertifikat")) return 1;
  ------------------
  |  Branch (435:5): [True: 137, False: 14]
  ------------------
  436|     14|	set_string(&p15card->tokeninfo->manufacturer_id, "Deutsche Post");
  437|     14|	set_string(&p15card->tokeninfo->label, "SignTrust Card");
  438|       |
  439|     14|	insert_cert(p15card,"800082008220", 0x46, 1, "Verschluesselungs Zertifikat");
  440|     14|	insert_cert(p15card,"800083008320", 0x47, 1, "Authentifizierungs Zertifikat");
  441|       |
  442|     14|	insert_key(p15card,"8000DF015331", 0x45, 0x80, 1024, 1, "Signatur Schluessel");
  443|     14|	insert_key(p15card,"800082008210", 0x46, 0x80, 1024, 2, "Verschluesselungs Schluessel");
  444|     14|	insert_key(p15card,"800083008310", 0x47, 0x80, 1024, 3, "Authentifizierungs Schluessel");
  445|       |
  446|     14|	insert_pin(p15card,"8000DF010000", 1, 0, 0x81, 6, "Signatur PIN",
  447|     14|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   54|     14|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   55|     14|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  448|     14|		SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|     14|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  449|     14|	);
  450|     14|	insert_pin(p15card,"800082000040", 2, 0, 0x81, 6, "Verschluesselungs PIN",
  451|     14|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   54|     14|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   55|     14|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  452|     14|		SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|     14|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  453|     14|	);
  454|     14|	insert_pin(p15card,"800083000040", 3, 0, 0x81, 6, "Authentifizierungs PIN",
  455|     14|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   54|     14|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_LOCAL |
  ------------------
  |  |   55|     14|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  456|     14|		SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|     14|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  457|     14|	);
  458|       |
  459|     14|	return 0;
  460|    151|}
pkcs15-tcos.c:detect_datev:
  464|    137|){
  465|    137|	if(insert_cert(p15card,"3000C500", 0x45, 0, "Signatur Zertifikat")) return 1;
  ------------------
  |  Branch (465:5): [True: 134, False: 3]
  ------------------
  466|      3|	set_string(&p15card->tokeninfo->manufacturer_id, "DATEV");
  467|      3|	set_string(&p15card->tokeninfo->label, "DATEV Classic");
  468|       |
  469|      3|	insert_cert(p15card,"DF02C200", 0x46, 0, "Verschluesselungs Zertifikat");
  470|      3|	insert_cert(p15card,"DF02C500", 0x47, 0, "Authentifizierungs Zertifikat");
  471|       |
  472|      3|	insert_key(p15card,"30005371", 0x45, 0x82, 1024, 1, "Signatur Schluessel");
  473|      3|	insert_key(p15card,"DF0253B1", 0x46, 0x81, 1024, 1, "Verschluesselungs Schluessel");
  474|      3|	insert_key(p15card,"DF025371", 0x47, 0x82, 1024, 1, "Authentifizierungs Schluessel");
  475|       |
  476|      3|	insert_pin(p15card,"5001", 1, 0, 0x01, 6, "PIN",
  477|      3|		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   54|      3|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  ------------------
              		SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | SC_PKCS15_PIN_FLAG_INITIALIZED
  ------------------
  |  |   58|      3|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
  478|      3|	);
  479|       |
  480|      3|	return 0;
  481|    137|}

sc_pkcs15_parse_tokeninfo:
  144|    616|{
  145|    616|	int r;
  146|    616|	size_t ii;
  147|    616|	u8 serial[128];
  148|    616|	size_t serial_len = sizeof(serial);
  149|    616|	u8 mnfid[SC_PKCS15_MAX_LABEL_SIZE];
  150|    616|	size_t mnfid_len  = sizeof(mnfid) - 1;
  151|    616|	u8 label[SC_PKCS15_MAX_LABEL_SIZE];
  152|    616|	size_t label_len = sizeof(label) - 1;
  153|    616|	u8 last_update[32], profile_indication[SC_PKCS15_MAX_LABEL_SIZE];
  154|    616|	size_t lupdate_len = sizeof(last_update) - 1, pi_len = sizeof(profile_indication) - 1;
  155|    616|	size_t flags_len   = sizeof(ti->flags);
  156|    616|	u8 preferred_language[64];
  157|    616|	size_t lang_length = sizeof(preferred_language) - 1;
  158|    616|	struct sc_asn1_entry asn1_supported_algorithms[SC_MAX_SUPPORTED_ALGORITHMS + 1],
  159|    616|			asn1_algo_infos[SC_MAX_SUPPORTED_ALGORITHMS][7],
  160|    616|			asn1_algo_infos_parameters[SC_MAX_SUPPORTED_ALGORITHMS][3];
  161|    616|	size_t reference_len = sizeof(ti->supported_algos[0].reference);
  162|    616|	size_t mechanism_len = sizeof(ti->supported_algos[0].mechanism);
  163|    616|	size_t parameter_len = sizeof(ti->supported_algos[0].parameters);
  164|    616|	size_t operations_len = sizeof(ti->supported_algos[0].operations);
  165|    616|	size_t algo_ref_len = sizeof(ti->supported_algos[0].algo_ref);
  166|       |
  167|    616|	struct sc_asn1_entry asn1_last_update[C_ASN1_LAST_UPDATE_SIZE];
  168|    616|	struct sc_asn1_entry asn1_profile_indication[C_ASN1_PROFILE_INDICATION_SIZE];
  169|    616|	struct sc_asn1_entry asn1_toki_attrs[C_ASN1_TOKI_ATTRS_SIZE], asn1_tokeninfo[3], asn1_twlabel[3];
  170|       |
  171|    616|	memset(last_update, 0, sizeof(last_update));
  172|    616|	memset(label, 0, sizeof(label));
  173|    616|	memset(profile_indication, 0, sizeof(profile_indication));
  174|    616|	memset(mnfid, 0, sizeof(mnfid));
  175|       |
  176|    616|	sc_copy_asn1_entry(c_asn1_twlabel, asn1_twlabel);
  177|    616|	sc_copy_asn1_entry(c_asn1_toki_attrs, asn1_toki_attrs);
  178|    616|	sc_copy_asn1_entry(c_asn1_tokeninfo, asn1_tokeninfo);
  179|    616|	sc_copy_asn1_entry(c_asn1_last_update, asn1_last_update);
  180|    616|	sc_format_asn1_entry(asn1_twlabel, label, &label_len, 0);
  181|    616|	sc_copy_asn1_entry(c_asn1_profile_indication, asn1_profile_indication);
  182|       |
  183|  10.4k|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS; ii++) {
  ------------------
  |  |   61|  10.4k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (183:13): [True: 9.85k, False: 616]
  ------------------
  184|  9.85k|		sc_copy_asn1_entry(c_asn1_algorithm_info, asn1_algo_infos[ii]);
  185|  9.85k|		sc_copy_asn1_entry(c_asn1_algorithm_info_parameters,
  186|  9.85k|			asn1_algo_infos_parameters[ii]);
  187|  9.85k|	}
  188|    616|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  189|       |
  190|  10.4k|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS; ii++)   {
  ------------------
  |  |   61|  10.4k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (190:13): [True: 9.85k, False: 616]
  ------------------
  191|  9.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 0, &ti->supported_algos[ii].reference, &reference_len, 0);
  192|  9.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 1, &ti->supported_algos[ii].mechanism, &mechanism_len, 0);
  193|  9.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 2,
  194|  9.85k|			asn1_algo_infos_parameters[ii], NULL, 0);
  195|  9.85k|		sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 0,
  196|  9.85k|			NULL, NULL, 0);
  197|  9.85k|		sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 1,
  198|  9.85k|			&ti->supported_algos[ii].parameters, &parameter_len, 0);
  199|  9.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 3, &ti->supported_algos[ii].operations, &operations_len, 0);
  200|  9.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 4, &ti->supported_algos[ii].algo_id, NULL, 1);
  201|  9.85k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 5, &ti->supported_algos[ii].algo_ref, &algo_ref_len, 0);
  202|  9.85k|		sc_format_asn1_entry(asn1_supported_algorithms + ii, asn1_algo_infos[ii], NULL, 0);
  203|  9.85k|	}
  204|       |
  205|    616|	sc_format_asn1_entry(asn1_last_update + 0, last_update, &lupdate_len, 0);
  206|    616|	sc_format_asn1_entry(asn1_last_update + 1, &ti->last_update.path, NULL, 0);
  207|       |
  208|    616|	sc_format_asn1_entry(asn1_profile_indication + 0, &ti->profile_indication.oid, NULL, 0);
  209|    616|	sc_format_asn1_entry(asn1_profile_indication + 1, profile_indication, &pi_len, 0);
  210|       |
  211|    616|	sc_format_asn1_entry(asn1_toki_attrs + 0, &ti->version, NULL, 0);
  212|    616|	sc_format_asn1_entry(asn1_toki_attrs + 1, serial, &serial_len, 0);
  213|    616|	sc_format_asn1_entry(asn1_toki_attrs + 2, mnfid, &mnfid_len, 0);
  214|    616|	sc_format_asn1_entry(asn1_toki_attrs + 3, label, &label_len, 0);
  215|    616|	sc_format_asn1_entry(asn1_toki_attrs + 4, asn1_twlabel, NULL, 0);
  216|    616|	sc_format_asn1_entry(asn1_toki_attrs + 5, &ti->flags, &flags_len, 0);
  217|    616|	sc_format_asn1_entry(asn1_toki_attrs + 6, &ti->seInfo, &ti->num_seInfo, 0);
  218|    616|	sc_format_asn1_entry(asn1_toki_attrs + 7, NULL, NULL, 0);
  219|    616|	sc_format_asn1_entry(asn1_toki_attrs + 8, asn1_supported_algorithms, NULL, 0);
  220|    616|	sc_format_asn1_entry(asn1_toki_attrs + 9, NULL, NULL, 0);
  221|    616|	sc_format_asn1_entry(asn1_toki_attrs + 10, NULL, NULL, 0);
  222|    616|	sc_format_asn1_entry(asn1_toki_attrs + 11, asn1_last_update, NULL, 0);
  223|    616|	sc_format_asn1_entry(asn1_toki_attrs + 12, preferred_language, &lang_length, 0);
  224|    616|	sc_format_asn1_entry(asn1_toki_attrs + 13, asn1_profile_indication, NULL, 0);
  225|    616|	sc_format_asn1_entry(asn1_tokeninfo, asn1_toki_attrs, NULL, 0);
  226|       |
  227|    616|	r = sc_asn1_decode(ctx, asn1_tokeninfo, buf, blen, NULL, NULL);
  228|    616|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    616|#define SC_SUCCESS				0
  ------------------
  |  Branch (228:6): [True: 511, False: 105]
  ------------------
  229|       |		/* The decoding could have allocated something we need to free */
  230|    511|		sc_pkcs15_clear_tokeninfo(ti);
  231|    511|		LOG_TEST_RET(ctx, r, "ASN.1 parsing of EF(TokenInfo) failed");
  ------------------
  |  |  174|    511|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    511|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    511|	int _ret = (r); \
  |  |  |  |  168|    511|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 511, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    511|		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|    511|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    511|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    511|		return _ret; \
  |  |  |  |  172|    511|	} \
  |  |  |  |  173|    511|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  232|    511|	}
  233|       |
  234|    105|	if (asn1_toki_attrs[1].flags & SC_ASN1_PRESENT && serial_len > 0)   {
  ------------------
  |  |  147|    210|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (234:6): [True: 38, False: 67]
  |  Branch (234:52): [True: 20, False: 18]
  ------------------
  235|     20|		free(ti->serial_number);
  236|     20|		ti->serial_number = malloc(serial_len * 2 + 1);
  237|     20|		if (ti->serial_number == NULL)
  ------------------
  |  Branch (237:7): [True: 0, False: 20]
  ------------------
  238|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  239|     20|		sc_bin_to_hex(serial, serial_len, ti->serial_number, serial_len * 2 + 1, 0);
  240|     20|		sc_log(ctx, "TokenInfo.serialNunmber '%s'", ti->serial_number);
  ------------------
  |  |   71|     20|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  241|     20|	}
  242|       |
  243|    105|	if (ti->manufacturer_id == NULL) {
  ------------------
  |  Branch (243:6): [True: 105, False: 0]
  ------------------
  244|    105|		if (asn1_toki_attrs[2].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|    105|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (244:7): [True: 4, False: 101]
  ------------------
  245|      4|			ti->manufacturer_id = strdup((char *) mnfid);
  246|    101|		else
  247|    101|			ti->manufacturer_id = strdup("(unknown)");
  248|    105|		if (ti->manufacturer_id == NULL)
  ------------------
  |  Branch (248:7): [True: 0, False: 105]
  ------------------
  249|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  250|    105|	}
  251|    105|	if (ti->label == NULL) {
  ------------------
  |  Branch (251:6): [True: 105, False: 0]
  ------------------
  252|    105|		if (asn1_toki_attrs[3].flags & SC_ASN1_PRESENT ||
  ------------------
  |  |  147|    210|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (252:7): [True: 1, False: 104]
  ------------------
  253|    104|		    asn1_toki_attrs[4].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|    104|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (253:7): [True: 0, False: 104]
  ------------------
  254|      1|			ti->label = strdup((char *) label);
  255|    104|		else
  256|    104|			ti->label = strdup("(unknown)");
  257|    105|		if (ti->label == NULL)
  ------------------
  |  Branch (257:7): [True: 0, False: 105]
  ------------------
  258|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  259|    105|	}
  260|    105|	if (asn1_toki_attrs[11].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    105|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (260:6): [True: 1, False: 104]
  ------------------
  261|      1|		if (asn1_last_update[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|      1|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (261:7): [True: 0, False: 1]
  ------------------
  262|      0|			sc_log(ctx, "LastUpdate.generalizedTime present");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  263|      0|			ti->last_update.gtime = strdup((char *)last_update);
  264|      0|			if (ti->last_update.gtime == NULL)
  ------------------
  |  Branch (264:8): [True: 0, False: 0]
  ------------------
  265|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  266|      0|		}
  267|      1|		else if (asn1_last_update[1].flags & SC_ASN1_PRESENT)  {
  ------------------
  |  |  147|      1|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (267:12): [True: 0, False: 1]
  ------------------
  268|      0|			sc_log(ctx, "LastUpdate.referencedTime present");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  269|      0|		}
  270|      1|	}
  271|    105|	if (asn1_toki_attrs[12].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    105|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (271:6): [True: 3, False: 102]
  ------------------
  272|      3|		preferred_language[lang_length] = 0;
  273|      3|		ti->preferred_language = strdup((char *)preferred_language);
  274|      3|		if (ti->preferred_language == NULL)
  ------------------
  |  Branch (274:7): [True: 0, False: 3]
  ------------------
  275|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  276|      3|	}
  277|       |
  278|    105|	sc_init_oid(&ti->profile_indication.oid);
  279|    105|	if (asn1_toki_attrs[13].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    105|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (279:6): [True: 3, False: 102]
  ------------------
  280|      3|		if (asn1_profile_indication[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|      3|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (280:7): [True: 0, False: 3]
  ------------------
  281|      0|			sc_log(ctx, "ProfileIndication.oid present");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  282|      0|		}
  283|      3|		else if (asn1_profile_indication[1].flags & SC_ASN1_PRESENT)  {
  ------------------
  |  |  147|      3|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (283:12): [True: 0, False: 3]
  ------------------
  284|      0|			sc_log(ctx, "ProfileIndication.name present");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  285|      0|			ti->profile_indication.name = strdup((char *)profile_indication);
  286|      0|			if (ti->profile_indication.name == NULL)
  ------------------
  |  Branch (286:8): [True: 0, False: 0]
  ------------------
  287|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  288|      0|		}
  289|      3|	}
  290|       |
  291|    105|	sc_log(ctx, "LastUpdate.path '%s'", sc_print_path(&ti->last_update.path));
  ------------------
  |  |   71|    105|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  292|    105|	sc_log(ctx, "ProfileIndication.name '%s'",  ti->profile_indication.name);
  ------------------
  |  |   71|    105|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  293|    105|	return SC_SUCCESS;
  ------------------
  |  |   28|    105|#define SC_SUCCESS				0
  ------------------
  294|    105|}
sc_pkcs15_card_new:
  718|  16.6k|{
  719|  16.6k|	struct sc_pkcs15_card *p15card;
  720|       |
  721|  16.6k|	p15card = calloc(1, sizeof(struct sc_pkcs15_card));
  722|  16.6k|	if (p15card == NULL)
  ------------------
  |  Branch (722:6): [True: 0, False: 16.6k]
  ------------------
  723|      0|		return NULL;
  724|       |
  725|  16.6k|	p15card->tokeninfo = calloc(1, sizeof(struct sc_pkcs15_tokeninfo));
  726|  16.6k|	if (p15card->tokeninfo == NULL) {
  ------------------
  |  Branch (726:6): [True: 0, False: 16.6k]
  ------------------
  727|      0|		free(p15card);
  728|      0|		return NULL;
  729|      0|	}
  730|       |
  731|  16.6k|	p15card->magic = SC_PKCS15_CARD_MAGIC;
  ------------------
  |  |  519|  16.6k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  732|  16.6k|	return p15card;
  733|  16.6k|}
sc_pkcs15_tokeninfo_new:
  738|  12.2k|{
  739|  12.2k|	struct sc_pkcs15_tokeninfo *tokeninfo;
  740|       |
  741|  12.2k|	tokeninfo = calloc(1, sizeof(struct sc_pkcs15_tokeninfo));
  742|  12.2k|	if (tokeninfo == NULL) {
  ------------------
  |  Branch (742:6): [True: 0, False: 12.2k]
  ------------------
  743|      0|		return NULL;
  744|      0|	}
  745|       |
  746|  12.2k|	sc_init_oid(&tokeninfo->profile_indication.oid);
  747|       |
  748|  12.2k|	return tokeninfo;
  749|  12.2k|}
sc_pkcs15_free_tokeninfo:
  780|  30.6k|{
  781|  30.6k|	if (!tokeninfo)
  ------------------
  |  Branch (781:6): [True: 1.76k, False: 28.8k]
  ------------------
  782|  1.76k|		return;
  783|       |
  784|  28.8k|	sc_pkcs15_clear_tokeninfo(tokeninfo);
  785|  28.8k|	free(tokeninfo);
  786|  28.8k|}
sc_pkcs15_free_app:
  790|  58.2k|{
  791|  58.2k|	if (p15card && p15card->app) {
  ------------------
  |  Branch (791:6): [True: 58.2k, False: 0]
  |  Branch (791:17): [True: 5.29k, False: 52.9k]
  ------------------
  792|  5.29k|		free(p15card->app->label);
  793|  5.29k|		free(p15card->app->ddo.value);
  794|  5.29k|		free(p15card->app);
  795|       |		p15card->app = NULL;
  796|  5.29k|	}
  797|  58.2k|}
sc_pkcs15_card_free:
  802|  16.6k|{
  803|  16.6k|	if (p15card == NULL || p15card->magic != SC_PKCS15_CARD_MAGIC)
  ------------------
  |  |  519|  16.6k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  |  Branch (803:6): [True: 0, False: 16.6k]
  |  Branch (803:25): [True: 0, False: 16.6k]
  ------------------
  804|      0|		return;
  805|       |
  806|  16.6k|	if (p15card->ops.clear)
  ------------------
  |  Branch (806:6): [True: 852, False: 15.8k]
  ------------------
  807|    852|		p15card->ops.clear(p15card);
  808|       |
  809|       |	/* For more complicated MD data a dedicated release procedure
  810|       |	 * has to be implemented. */
  811|  16.6k|	if (p15card->md_data)
  ------------------
  |  Branch (811:6): [True: 0, False: 16.6k]
  ------------------
  812|      0|		free(p15card->md_data);
  813|       |
  814|  16.6k|	sc_pkcs15_free_app(p15card);
  815|  16.6k|	sc_pkcs15_remove_objects(p15card);
  816|  16.6k|	sc_pkcs15_remove_dfs(p15card);
  817|  16.6k|	sc_pkcs15_free_unusedspace(p15card);
  818|  16.6k|	p15card->unusedspace_read = 0;
  819|       |
  820|  16.6k|	sc_file_free(p15card->file_app);
  821|  16.6k|	sc_file_free(p15card->file_tokeninfo);
  822|  16.6k|	sc_file_free(p15card->file_odf);
  823|  16.6k|	sc_file_free(p15card->file_unusedspace);
  824|       |
  825|  16.6k|	p15card->magic = 0;
  826|  16.6k|	sc_pkcs15_free_tokeninfo(p15card->tokeninfo);
  827|  16.6k|	sc_pkcs15_free_app(p15card);
  828|  16.6k|	free(p15card);
  829|  16.6k|}
sc_pkcs15_card_clear:
  834|  20.0k|{
  835|  20.0k|	if (p15card == NULL)
  ------------------
  |  Branch (835:6): [True: 0, False: 20.0k]
  ------------------
  836|      0|		return;
  837|       |
  838|  20.0k|	if (p15card->ops.clear)
  ------------------
  |  Branch (838:6): [True: 803, False: 19.2k]
  ------------------
  839|    803|		p15card->ops.clear(p15card);
  840|       |
  841|  20.0k|	p15card->flags = 0;
  842|  20.0k|	p15card->tokeninfo->version = 0;
  843|  20.0k|	p15card->tokeninfo->flags   = 0;
  844|       |
  845|  20.0k|	sc_pkcs15_remove_objects(p15card);
  846|  20.0k|	sc_pkcs15_remove_dfs(p15card);
  847|       |
  848|  20.0k|	p15card->df_list = NULL;
  849|  20.0k|	sc_file_free(p15card->file_app);
  850|  20.0k|	p15card->file_app = NULL;
  851|  20.0k|	sc_file_free(p15card->file_tokeninfo);
  852|  20.0k|	p15card->file_tokeninfo = NULL;
  853|  20.0k|	sc_file_free(p15card->file_odf);
  854|  20.0k|	p15card->file_odf = NULL;
  855|  20.0k|	sc_file_free(p15card->file_unusedspace);
  856|  20.0k|	p15card->file_unusedspace = NULL;
  857|       |
  858|  20.0k|	free(p15card->tokeninfo->label);
  859|  20.0k|	p15card->tokeninfo->label = NULL;
  860|  20.0k|	free(p15card->tokeninfo->serial_number);
  861|  20.0k|	p15card->tokeninfo->serial_number = NULL;
  862|  20.0k|	free(p15card->tokeninfo->manufacturer_id);
  863|  20.0k|	p15card->tokeninfo->manufacturer_id = NULL;
  864|  20.0k|	free(p15card->tokeninfo->last_update.gtime);
  865|  20.0k|	p15card->tokeninfo->last_update.gtime = NULL;
  866|  20.0k|	free(p15card->tokeninfo->preferred_language);
  867|  20.0k|	p15card->tokeninfo->preferred_language = NULL;
  868|  20.0k|	free(p15card->tokeninfo->profile_indication.name);
  869|  20.0k|	p15card->tokeninfo->profile_indication.name = NULL;
  870|  20.0k|	if (p15card->tokeninfo->seInfo != NULL) {
  ------------------
  |  Branch (870:6): [True: 3, False: 20.0k]
  ------------------
  871|      3|		size_t i;
  872|      3|		for (i = 0; i < p15card->tokeninfo->num_seInfo; i++)
  ------------------
  |  Branch (872:15): [True: 0, False: 3]
  ------------------
  873|      0|			free(p15card->tokeninfo->seInfo[i]);
  874|      3|		free(p15card->tokeninfo->seInfo);
  875|      3|		p15card->tokeninfo->seInfo     = NULL;
  876|      3|		p15card->tokeninfo->num_seInfo = 0;
  877|      3|	}
  878|       |
  879|  20.0k|	sc_pkcs15_free_app(p15card);
  880|  20.0k|}
sc_find_app:
  885|  17.1k|{
  886|  17.1k|	int ii;
  887|       |
  888|  17.1k|	if (card->app_count <= 0)
  ------------------
  |  Branch (888:6): [True: 12.2k, False: 4.87k]
  ------------------
  889|  12.2k|		return NULL;
  890|       |
  891|  4.87k|	if (!aid || !aid->len)
  ------------------
  |  Branch (891:6): [True: 0, False: 4.87k]
  |  Branch (891:14): [True: 1.36k, False: 3.50k]
  ------------------
  892|  1.36k|		return card->app[0];
  893|       |
  894|  5.24k|	for (ii=0; ii < card->app_count; ii++) {
  ------------------
  |  Branch (894:13): [True: 5.24k, False: 0]
  ------------------
  895|  5.24k|		if (card->app[ii]->aid.len != aid->len)
  ------------------
  |  Branch (895:7): [True: 434, False: 4.80k]
  ------------------
  896|    434|			continue;
  897|  4.80k|		if (memcmp(card->app[ii]->aid.value, aid->value, aid->len))
  ------------------
  |  Branch (897:7): [True: 1.30k, False: 3.50k]
  ------------------
  898|  1.30k|			continue;
  899|  3.50k|		return card->app[ii];
  900|  4.80k|	}
  901|      0|	return NULL;
  902|  3.50k|}
sc_pkcs15_get_application_by_type:
  939|  13.8k|{
  940|  13.8k|	struct sc_app_info *out = NULL;
  941|  13.8k|	scconf_block *conf_block = NULL;
  942|  13.8k|	int i, rv;
  943|       |
  944|  13.8k|	if (!card)
  ------------------
  |  Branch (944:6): [True: 0, False: 13.8k]
  ------------------
  945|      0|		return NULL;
  946|       |
  947|  13.8k|	if (card->app_count < 0)   {
  ------------------
  |  Branch (947:6): [True: 13.8k, False: 0]
  ------------------
  948|  13.8k|		rv = sc_enum_apps(card);
  949|  13.8k|		if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|  12.8k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (949:7): [True: 12.8k, False: 1.05k]
  |  Branch (949:17): [True: 10.8k, False: 1.93k]
  ------------------
  950|  10.8k|			return NULL;
  951|  13.8k|	}
  952|       |
  953|  2.99k|	conf_block = sc_get_conf_block(card->ctx, "framework", "pkcs15", 1);
  954|  2.99k|	if (!conf_block)
  ------------------
  |  Branch (954:6): [True: 2.99k, False: 0]
  ------------------
  955|  2.99k|		return NULL;
  956|       |
  957|      0|	for (i = 0; i < card->app_count; i++)   {
  ------------------
  |  Branch (957:14): [True: 0, False: 0]
  ------------------
  958|      0|		struct sc_app_info *app_info = card->app[i];
  959|      0|		scconf_block **blocks = NULL;
  960|      0|		char str_path[SC_MAX_AID_STRING_SIZE];
  961|       |
  962|      0|		sc_bin_to_hex(app_info->aid.value, app_info->aid.len, str_path, sizeof(str_path), 0);
  963|      0|		blocks = scconf_find_blocks(card->ctx->conf, conf_block, "application", str_path);
  964|      0|		if (blocks)   {
  ------------------
  |  Branch (964:7): [True: 0, False: 0]
  ------------------
  965|      0|			if (blocks[0])   {
  ------------------
  |  Branch (965:8): [True: 0, False: 0]
  ------------------
  966|      0|				char *type = (char *)scconf_get_str(blocks[0], "type", app_type);
  967|      0|				if (!strcmp(type, app_type))   {
  ------------------
  |  Branch (967:9): [True: 0, False: 0]
  ------------------
  968|      0|					out = app_info;
  969|      0|					free(blocks);
  970|      0|					break;
  971|      0|				}
  972|      0|			}
  973|      0|			free(blocks);
  974|      0|		}
  975|      0|	}
  976|       |
  977|      0|	return out;
  978|  2.99k|}
sc_pkcs15_bind_internal_odf:
  982|  1.01k|{
  983|  1.01k|	struct sc_path tmppath;
  984|  1.01k|	struct sc_card    *card = p15card->card;
  985|  1.01k|	struct sc_context *ctx = card->ctx;
  986|  1.01k|	struct sc_pkcs15_df *df;
  987|  1.01k|	unsigned char *buf = NULL;
  988|  1.01k|	size_t len;
  989|  1.01k|	int    err, ok = 0;
  990|       |
  991|  1.01k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.01k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.01k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.01k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.01k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.01k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  992|  1.01k|	if (p15card->file_odf == NULL) {
  ------------------
  |  Branch (992:6): [True: 967, False: 49]
  ------------------
  993|       |		/* check if an ODF is present; we don't know yet whether we have a pkcs15 card */
  994|    967|		sc_format_path("5031", &tmppath);
  995|    967|		err = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &tmppath);
  996|    967|		if (err != SC_SUCCESS)   {
  ------------------
  |  |   28|    967|#define SC_SUCCESS				0
  ------------------
  |  Branch (996:7): [True: 0, False: 967]
  ------------------
  997|      0|			sc_log(ctx, "Cannot make absolute path to EF(ODF); error:%i", err);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  998|      0|			goto end;
  999|      0|		}
 1000|    967|		sc_log(ctx, "absolute path to EF(ODF) %s", sc_print_path(&tmppath));
  ------------------
  |  |   71|    967|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1001|    967|		err = sc_select_file(card, &tmppath, &p15card->file_odf);
 1002|    967|	}
 1003|     49|	else {
 1004|     49|		tmppath = p15card->file_odf->path;
 1005|     49|		sc_file_free(p15card->file_odf);
 1006|     49|		p15card->file_odf = NULL;
 1007|     49|		err = sc_select_file(card, &tmppath, &p15card->file_odf);
 1008|     49|	}
 1009|       |
 1010|  1.01k|	if (err != SC_SUCCESS) {
  ------------------
  |  |   28|  1.01k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1010:6): [True: 353, False: 663]
  ------------------
 1011|    353|		sc_log(ctx, "EF(ODF) not found in '%s'", sc_print_path(&tmppath));
  ------------------
  |  |   71|    353|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1012|    353|		goto end;
 1013|    353|	}
 1014|       |
 1015|    663|	len = p15card->file_odf->size;
 1016|    663|	if (!len) {
  ------------------
  |  Branch (1016:6): [True: 287, False: 376]
  ------------------
 1017|    287|		sc_log(ctx, "EF(ODF) is empty");
  ------------------
  |  |   71|    287|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1018|    287|		goto end;
 1019|    287|	}
 1020|    376|	if (len > MAX_FILE_SIZE) {
  ------------------
  |  |  220|    376|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (1020:6): [True: 36, False: 340]
  ------------------
 1021|     36|		sc_log(ctx, "EF(ODF) too large");
  ------------------
  |  |   71|     36|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1022|     36|		goto end;
 1023|     36|	}
 1024|    340|	buf = malloc(len);
 1025|    340|	if(buf == NULL) {
  ------------------
  |  Branch (1025:5): [True: 0, False: 340]
  ------------------
 1026|      0|		err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1027|      0|		goto end;
 1028|      0|	}
 1029|       |
 1030|    340|	err = -1; /* file state: not in cache */
 1031|    340|	if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1031:6): [True: 179, False: 161]
  ------------------
 1032|    179|		err = sc_pkcs15_read_cached_file(p15card, &tmppath, &buf, &len);
 1033|    179|		if (err == SC_SUCCESS)
  ------------------
  |  |   28|    179|#define SC_SUCCESS				0
  ------------------
  |  Branch (1033:7): [True: 0, False: 179]
  ------------------
 1034|      0|			err = (int)len;
 1035|    179|	}
 1036|    340|	if (err < 0) {
  ------------------
  |  Branch (1036:6): [True: 340, False: 0]
  ------------------
 1037|    340|		err = sc_read_binary(card, 0, buf, len, 0);
 1038|    340|		if (err < 2) {
  ------------------
  |  Branch (1038:7): [True: 58, False: 282]
  ------------------
 1039|     58|			if (err < 0) {
  ------------------
  |  Branch (1039:8): [True: 47, False: 11]
  ------------------
 1040|     47|				sc_log(ctx, "read EF(ODF) file error: %s", sc_strerror(err));
  ------------------
  |  |   71|     47|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1041|     47|			} else {
 1042|     11|				err = SC_ERROR_PKCS15_APP_NOT_FOUND;
  ------------------
  |  |  131|     11|#define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
  ------------------
 1043|     11|				sc_log(ctx, "Invalid content of EF(ODF): %s", sc_strerror(err));
  ------------------
  |  |   71|     11|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1044|     11|			}
 1045|     58|			goto end;
 1046|     58|		}
 1047|       |		/* sc_read_binary may return less than requested */
 1048|    282|		len = err;
 1049|       |
 1050|    282|		if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1050:7): [True: 145, False: 137]
  ------------------
 1051|    145|			sc_pkcs15_cache_file(p15card, &tmppath, buf, len);
 1052|    145|		}
 1053|    282|	}
 1054|       |
 1055|    282|	if (parse_odf(buf, len, p15card)) {
  ------------------
  |  Branch (1055:6): [True: 44, False: 238]
  ------------------
 1056|     44|		err = SC_ERROR_PKCS15_APP_NOT_FOUND;
  ------------------
  |  |  131|     44|#define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
  ------------------
 1057|     44|		sc_log(ctx, "Unable to parse ODF");
  ------------------
  |  |   71|     44|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1058|     44|		goto end;
 1059|     44|	}
 1060|    238|	free(buf);
 1061|    238|	buf = NULL;
 1062|       |
 1063|    238|	sc_log(ctx, "The following DFs were found:");
  ------------------
  |  |   71|    238|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1064|  2.75k|	for (df = p15card->df_list; df; df = df->next)
  ------------------
  |  Branch (1064:30): [True: 2.51k, False: 238]
  ------------------
 1065|  2.51k|		sc_log(ctx, "  DF type %u, path %s, index %u, count %d", df->type,
  ------------------
  |  |   71|  2.75k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1066|    238|				sc_print_path(&df->path), df->path.index, df->path.count);
 1067|       |
 1068|    238|	ok = 1;
 1069|  1.01k|end:
 1070|  1.01k|	if (buf != NULL)
  ------------------
  |  Branch (1070:6): [True: 102, False: 914]
  ------------------
 1071|    102|		free(buf);
 1072|  1.01k|	if (!ok) {
  ------------------
  |  Branch (1072:6): [True: 778, False: 238]
  ------------------
 1073|    778|		LOG_FUNC_RETURN(ctx, err);
  ------------------
  |  |  164|    778|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    778|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    778|	int _ret = r; \
  |  |  |  |  155|    778|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 778, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    778|		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|    455|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 455, False: 323]
  |  |  |  |  ------------------
  |  |  |  |  157|    778|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    778|	} 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|    778|	return _ret; \
  |  |  |  |  163|    778|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1074|    778|	}
 1075|       |
 1076|    238|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    238|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    238|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    238|	int _ret = r; \
  |  |  |  |  155|    238|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 238, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    238|		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: 238]
  |  |  |  |  ------------------
  |  |  |  |  157|    238|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    238|	} 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|    238|	return _ret; \
  |  |  |  |  163|    238|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1077|    238|}
sc_pkcs15_bind_internal_tokeninfo:
 1081|  14.1k|{
 1082|  14.1k|	struct sc_path tmppath;
 1083|  14.1k|	struct sc_card *card = p15card->card;
 1084|  14.1k|	struct sc_context *ctx = card->ctx;
 1085|  14.1k|	struct sc_pkcs15_tokeninfo tokeninfo;
 1086|  14.1k|	unsigned char *buf = NULL;
 1087|  14.1k|	size_t len;
 1088|  14.1k|	int err, ok = 0;
 1089|       |
 1090|  14.1k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  14.1k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  14.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  14.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  14.1k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 14.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1091|       |
 1092|  14.1k|	if (p15card->file_tokeninfo == NULL) {
  ------------------
  |  Branch (1092:6): [True: 13.9k, False: 136]
  ------------------
 1093|  13.9k|		sc_format_path("5032", &tmppath);
 1094|  13.9k|		err = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &tmppath);
 1095|  13.9k|		if (err != SC_SUCCESS)   {
  ------------------
  |  |   28|  13.9k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1095:7): [True: 10, False: 13.9k]
  ------------------
 1096|     10|			sc_log(ctx, "Cannot make absolute path to EF(TokenInfo); error:%i", err);
  ------------------
  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1097|     10|			goto end;
 1098|     10|		}
 1099|  13.9k|		sc_log(ctx, "absolute path to EF(TokenInfo) %s", sc_print_path(&tmppath));
  ------------------
  |  |   71|  13.9k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1100|  13.9k|	}
 1101|    136|	else {
 1102|    136|		tmppath = p15card->file_tokeninfo->path;
 1103|    136|		sc_file_free(p15card->file_tokeninfo);
 1104|    136|		p15card->file_tokeninfo = NULL;
 1105|    136|	}
 1106|       |
 1107|  14.1k|	err = sc_select_file(card, &tmppath, &p15card->file_tokeninfo);
 1108|  14.1k|	if (err)   {
  ------------------
  |  Branch (1108:6): [True: 12.4k, False: 1.70k]
  ------------------
 1109|  12.4k|		sc_log(ctx, "cannot select EF(TokenInfo) file: %s", sc_strerror(err));
  ------------------
  |  |   71|  12.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1110|  12.4k|		goto end;
 1111|  12.4k|	}
 1112|       |
 1113|  1.70k|	len = p15card->file_tokeninfo->size;
 1114|  1.70k|	if (!len) {
  ------------------
  |  Branch (1114:6): [True: 916, False: 789]
  ------------------
 1115|    916|		sc_log(ctx, "EF(TokenInfo) is empty");
  ------------------
  |  |   71|    916|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1116|    916|		goto end;
 1117|    916|	}
 1118|    789|	if (len > MAX_FILE_SIZE) {
  ------------------
  |  |  220|    789|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (1118:6): [True: 67, False: 722]
  ------------------
 1119|     67|		sc_log(ctx, "EF(TokenInfo) too large");
  ------------------
  |  |   71|     67|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1120|     67|		goto end;
 1121|     67|	}
 1122|    722|	buf = malloc(len);
 1123|    722|	if(buf == NULL) {
  ------------------
  |  Branch (1123:5): [True: 0, False: 722]
  ------------------
 1124|      0|		err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1125|      0|		goto end;
 1126|      0|	}
 1127|       |
 1128|    722|	err = -1; /* file state: not in cache */
 1129|    722|	if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1129:6): [True: 235, False: 487]
  ------------------
 1130|    235|		err = sc_pkcs15_read_cached_file(p15card, &tmppath, &buf, &len);
 1131|    235|		if (err == SC_SUCCESS)
  ------------------
  |  |   28|    235|#define SC_SUCCESS				0
  ------------------
  |  Branch (1131:7): [True: 0, False: 235]
  ------------------
 1132|      0|			err = (int)len;
 1133|    235|	}
 1134|    722|	if (err < 0) {
  ------------------
  |  Branch (1134:6): [True: 722, False: 0]
  ------------------
 1135|    722|		err = sc_read_binary(card, 0, buf, len, 0);
 1136|    722|		if (err <= 2) {
  ------------------
  |  Branch (1136:7): [True: 523, False: 199]
  ------------------
 1137|    523|			if (err < 0)   {
  ------------------
  |  Branch (1137:8): [True: 471, False: 52]
  ------------------
 1138|    471|				sc_log(ctx, "read EF(TokenInfo) file error: %s", sc_strerror(err));
  ------------------
  |  |   71|    471|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1139|    471|			} else {
 1140|     52|				err = SC_ERROR_PKCS15_APP_NOT_FOUND;
  ------------------
  |  |  131|     52|#define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
  ------------------
 1141|     52|				sc_log(ctx, "Invalid content of EF(TokenInfo): %s", sc_strerror(err));
  ------------------
  |  |   71|     52|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1142|     52|			}
 1143|    523|			goto end;
 1144|    523|		}
 1145|       |		/* sc_read_binary may return less than requested */
 1146|    199|		len = err;
 1147|       |
 1148|    199|		if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1148:7): [True: 88, False: 111]
  ------------------
 1149|     88|			sc_pkcs15_cache_file(p15card, &tmppath, buf, len);
 1150|     88|		}
 1151|    199|	}
 1152|       |
 1153|    199|	memset(&tokeninfo, 0, sizeof(tokeninfo));
 1154|    199|	err = sc_pkcs15_parse_tokeninfo(ctx, &tokeninfo, buf, (size_t)err);
 1155|    199|	if (err != SC_SUCCESS)   {
  ------------------
  |  |   28|    199|#define SC_SUCCESS				0
  ------------------
  |  Branch (1155:6): [True: 166, False: 33]
  ------------------
 1156|    166|		sc_log(ctx, "cannot parse TokenInfo content: %s", sc_strerror(err));
  ------------------
  |  |   71|    166|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1157|    166|		goto end;
 1158|    166|	}
 1159|       |
 1160|     33|	sc_pkcs15_clear_tokeninfo(p15card->tokeninfo);
 1161|     33|	*(p15card->tokeninfo) = tokeninfo;
 1162|       |
 1163|     33|	if (!p15card->tokeninfo->serial_number && 0 == card->serialnr.len) {
  ------------------
  |  Branch (1163:6): [True: 26, False: 7]
  |  Branch (1163:44): [True: 25, False: 1]
  ------------------
 1164|     25|		sc_card_ctl(p15card->card, SC_CARDCTL_GET_SERIALNR, &card->serialnr);
 1165|     25|	}
 1166|       |
 1167|     33|	if (!p15card->tokeninfo->serial_number && card->serialnr.len)   {
  ------------------
  |  Branch (1167:6): [True: 26, False: 7]
  |  Branch (1167:44): [True: 17, False: 9]
  ------------------
 1168|     17|		char *serial = calloc(1, card->serialnr.len*2 + 1);
 1169|     17|		size_t ii;
 1170|     17|		if (!serial) {
  ------------------
  |  Branch (1170:7): [True: 0, False: 17]
  ------------------
 1171|      0|			err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1172|      0|			goto end;
 1173|      0|		}
 1174|       |
 1175|    331|		for(ii=0;ii<card->serialnr.len;ii++)
  ------------------
  |  Branch (1175:12): [True: 314, False: 17]
  ------------------
 1176|    314|			sprintf(serial + ii*2, "%02X", *(card->serialnr.value + ii));
 1177|       |
 1178|     17|		p15card->tokeninfo->serial_number = serial;
 1179|     17|		sc_log(ctx, "p15card->tokeninfo->serial_number %s", p15card->tokeninfo->serial_number);
  ------------------
  |  |   71|     17|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1180|     17|	}
 1181|       |
 1182|     33|	ok = 1;
 1183|  14.1k|end:
 1184|  14.1k|	if (buf != NULL)
  ------------------
  |  Branch (1184:6): [True: 722, False: 13.4k]
  ------------------
 1185|    722|		free(buf);
 1186|  14.1k|	if (!ok) {
  ------------------
  |  Branch (1186:6): [True: 14.0k, False: 33]
  ------------------
 1187|  14.0k|		LOG_FUNC_RETURN(ctx, err);
  ------------------
  |  |  164|  14.0k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  14.0k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  14.0k|	int _ret = r; \
  |  |  |  |  155|  14.0k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14.0k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  14.0k|		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|  13.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 13.1k, False: 983]
  |  |  |  |  ------------------
  |  |  |  |  157|  14.0k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  14.0k|	} 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|  14.0k|	return _ret; \
  |  |  |  |  163|  14.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1188|  14.0k|	}
 1189|       |
 1190|     33|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     33|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     33|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     33|	int _ret = r; \
  |  |  |  |  155|     33|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 33, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     33|		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: 33]
  |  |  |  |  ------------------
  |  |  |  |  157|     33|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     33|	} 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|     33|	return _ret; \
  |  |  |  |  163|     33|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1191|     33|}
sc_pkcs15_bind_internal:
 1195|  17.1k|{
 1196|  17.1k|	struct sc_card *card = p15card->card;
 1197|  17.1k|	struct sc_context *ctx = card->ctx;
 1198|  17.1k|	const struct sc_app_info *info = NULL;
 1199|  17.1k|	int err, ok = 0;
 1200|       |
 1201|  17.1k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  17.1k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  17.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  17.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  17.1k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 17.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1202|       |	/* Enumerate apps now */
 1203|  17.1k|	if (card->app_count < 0) {
  ------------------
  |  Branch (1203:6): [True: 0, False: 17.1k]
  ------------------
 1204|      0|		err = sc_enum_apps(card);
 1205|      0|		if (err != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1205:7): [True: 0, False: 0]
  ------------------
 1206|      0|			sc_log(ctx, "unable to enumerate apps: %s", sc_strerror(err));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1207|      0|	}
 1208|  17.1k|	sc_file_free(p15card->file_app);
 1209|  17.1k|	p15card->file_app = sc_file_new();
 1210|  17.1k|	if (p15card->file_app == NULL) {
  ------------------
  |  Branch (1210:6): [True: 0, False: 17.1k]
  ------------------
 1211|      0|		err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1212|      0|		goto end;
 1213|      0|	}
 1214|       |
 1215|  17.1k|	sc_format_path("3F005015", &p15card->file_app->path);
 1216|       |
 1217|  17.1k|	info = sc_find_app(card, aid);
 1218|  17.1k|	if (info) {
  ------------------
  |  Branch (1218:6): [True: 4.87k, False: 12.2k]
  ------------------
 1219|  4.87k|		sc_log(ctx, "bind to application('%s',aid:'%s')", info->label, sc_dump_hex(info->aid.value, info->aid.len));
  ------------------
  |  |   71|  4.87k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1220|  4.87k|		sc_pkcs15_free_app(p15card);
 1221|  4.87k|		p15card->app = sc_dup_app_info(info);
 1222|  4.87k|		if (!p15card->app) {
  ------------------
  |  Branch (1222:7): [True: 0, False: 4.87k]
  ------------------
 1223|      0|			err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1224|      0|			goto end;
 1225|      0|		}
 1226|       |
 1227|  4.87k|		if (info->path.len)
  ------------------
  |  Branch (1227:7): [True: 3.90k, False: 966]
  ------------------
 1228|  3.90k|			p15card->file_app->path = info->path;
 1229|       |
 1230|  4.87k|		if (info->ddo.value && info->ddo.len)
  ------------------
  |  Branch (1230:7): [True: 893, False: 3.97k]
  |  Branch (1230:26): [True: 861, False: 32]
  ------------------
 1231|    861|			parse_ddo(p15card, info->ddo.value, info->ddo.len);
 1232|       |
 1233|  12.2k|	} else if (aid) {
  ------------------
  |  Branch (1233:13): [True: 0, False: 12.2k]
  ------------------
 1234|      0|		sc_log(ctx, "Application '%s' not found", sc_dump_hex(aid->value, aid->len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1235|      0|		err = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1236|      0|		goto end;
 1237|      0|	}
 1238|  17.1k|	sc_log(ctx, "application path '%s'", sc_print_path(&p15card->file_app->path));
  ------------------
  |  |   71|  17.1k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1239|       |
 1240|       |	/* Check if pkcs15 directory exists */
 1241|  17.1k|	err = sc_select_file(card, &p15card->file_app->path, NULL);
 1242|       |
 1243|       |	/* If the above test failed on cards without EF(DIR),
 1244|       |	 * try to continue read ODF from 3F005031. -aet
 1245|       |	 */
 1246|  17.1k|	if ((err != SC_SUCCESS) && (card->app_count < 1)) {
  ------------------
  |  |   28|  17.1k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1246:6): [True: 13.6k, False: 3.47k]
  |  Branch (1246:29): [True: 10.6k, False: 3.02k]
  ------------------
 1247|  10.6k|		sc_format_path("3F00", &p15card->file_app->path);
 1248|  10.6k|		err = SC_SUCCESS;
  ------------------
  |  |   28|  10.6k|#define SC_SUCCESS				0
  ------------------
 1249|  10.6k|	}
 1250|       |
 1251|  17.1k|	if (err < 0) {
  ------------------
  |  Branch (1251:6): [True: 3.02k, False: 14.1k]
  ------------------
 1252|  3.02k|		sc_log(ctx, "Cannot select application path");
  ------------------
  |  |   71|  3.02k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1253|  3.02k|		goto end;
 1254|  3.02k|	}
 1255|       |
 1256|  14.1k|	err = sc_pkcs15_bind_internal_tokeninfo(p15card);
 1257|  14.1k|	if (err < 0) {
  ------------------
  |  Branch (1257:6): [True: 13.1k, False: 1.01k]
  ------------------
 1258|  13.1k|		sc_log(ctx, "Cannot bind tokeninfo");
  ------------------
  |  |   71|  13.1k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1259|  13.1k|		goto end;
 1260|  13.1k|	}
 1261|       |
 1262|  1.01k|	err = sc_pkcs15_bind_internal_odf(p15card);
 1263|  1.01k|	if (err < 0) {
  ------------------
  |  Branch (1263:6): [True: 455, False: 561]
  ------------------
 1264|    455|		sc_log(ctx, "Cannot bind ODF");
  ------------------
  |  |   71|    455|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1265|    455|		goto end;
 1266|    455|	}
 1267|       |
 1268|    561|	ok = 1;
 1269|  17.1k|end:
 1270|  17.1k|	if (!ok) {
  ------------------
  |  Branch (1270:6): [True: 16.5k, False: 561]
  ------------------
 1271|  16.5k|		sc_pkcs15_card_clear(p15card);
 1272|  16.5k|		if (err == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|  16.5k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (1272:7): [True: 1.98k, False: 14.6k]
  ------------------
 1273|  1.98k|			err = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  1.98k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
 1274|  16.5k|		LOG_FUNC_RETURN(ctx, err);
  ------------------
  |  |  164|  16.5k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  16.5k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  16.5k|	int _ret = r; \
  |  |  |  |  155|  16.5k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 16.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  16.5k|		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|  16.5k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 16.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  16.5k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  16.5k|	} 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|  16.5k|	return _ret; \
  |  |  |  |  163|  16.5k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1275|  16.5k|	}
 1276|       |
 1277|    561|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    561|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    561|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    561|	int _ret = r; \
  |  |  |  |  155|    561|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 561, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    561|		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: 561]
  |  |  |  |  ------------------
  |  |  |  |  157|    561|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    561|	} 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|    561|	return _ret; \
  |  |  |  |  163|    561|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1278|    561|}
pkcs15_get_default_use_file_cache:
 1281|  16.4k|{
 1282|       |	/* enable file caching by default for cards with static content to avoid
 1283|       |	 * synchronization problems.
 1284|       |	 *
 1285|       |	 * The following list was initialized with the cards that can't be modified
 1286|       |	 * with OpenSC i.e. which don't have a profile/driver for pkcs15-init. */
 1287|  16.4k|	const char *card_drivers_with_file_cache[] = {
 1288|  16.4k|			"atrust-acos",
 1289|  16.4k|			"belpic",
 1290|  16.4k|			"cac1",
 1291|  16.4k|			"cac",
 1292|  16.4k|			"cedulauy",
 1293|  16.4k|			"coolkey",
 1294|  16.4k|			"edo",
 1295|  16.4k|			"esteid2018",
 1296|  16.4k|			"esteid2025",
 1297|  16.4k|			"flex",
 1298|  16.4k|			"cyberflex",
 1299|  16.4k|			"gemsafeV1",
 1300|  16.4k|			"idprime",
 1301|  16.4k|			"itacns",
 1302|  16.4k|			"jpki",
 1303|  16.4k|			"MaskTech",
 1304|  16.4k|			"mcrd",
 1305|  16.4k|			"myeid",
 1306|  16.4k|			"npa",
 1307|  16.4k|			"nqapplet",
 1308|  16.4k|			"tcos",
 1309|  16.4k|			"dtrust",
 1310|  16.4k|			"lteid",
 1311|  16.4k|	};
 1312|       |
 1313|  16.4k|	if (NULL == card || NULL == card->driver || NULL == card->driver->short_name)
  ------------------
  |  Branch (1313:6): [True: 0, False: 16.4k]
  |  Branch (1313:22): [True: 0, False: 16.4k]
  |  Branch (1313:46): [True: 0, False: 16.4k]
  ------------------
 1314|      0|		return "no";
 1315|   314k|	for (size_t i = 0; i < (sizeof card_drivers_with_file_cache / sizeof *card_drivers_with_file_cache); i++) {
  ------------------
  |  Branch (1315:21): [True: 304k, False: 10.4k]
  ------------------
 1316|   304k|		if (0 == strcmp(card->driver->short_name, card_drivers_with_file_cache[i]))
  ------------------
  |  Branch (1316:7): [True: 5.93k, False: 298k]
  ------------------
 1317|  5.93k|			return "public";
 1318|   304k|	}
 1319|       |
 1320|  10.4k|	return "no";
 1321|  16.4k|}
sc_pkcs15_bind:
 1326|  16.4k|{
 1327|  16.4k|	struct sc_pkcs15_card *p15card = NULL;
 1328|  16.4k|	struct sc_context *ctx;
 1329|  16.4k|	scconf_block *conf_block = NULL;
 1330|  16.4k|	int r, emu_first, enable_emu;
 1331|  16.4k|	const char *use_file_cache;
 1332|  16.4k|	const char *pin_protected_certificate, *private_certificate;
 1333|       |
 1334|  16.4k|	if (card == NULL || p15card_out == NULL) {
  ------------------
  |  Branch (1334:6): [True: 0, False: 16.4k]
  |  Branch (1334:22): [True: 0, False: 16.4k]
  ------------------
 1335|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1336|      0|	}
 1337|  16.4k|	ctx = card->ctx;
 1338|       |
 1339|  16.4k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  16.4k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  16.4k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  16.4k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  16.4k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 16.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1340|  16.4k|	sc_log(ctx, "application(aid:'%s')", aid ? sc_dump_hex(aid->value, aid->len) : "empty");
  ------------------
  |  |   71|  32.8k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 4.19k, False: 12.2k]
  |  |  ------------------
  ------------------
 1341|       |
 1342|  16.4k|	p15card = sc_pkcs15_card_new();
 1343|  16.4k|	if (p15card == NULL)
  ------------------
  |  Branch (1343:6): [True: 0, False: 16.4k]
  ------------------
 1344|  16.4k|		LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1345|       |
 1346|  16.4k|	p15card->card = card;
 1347|  16.4k|	p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_NO_FILES;
  ------------------
  |  |  604|  16.4k|#define SC_PKCS15_OPTS_CACHE_NO_FILES			0
  ------------------
 1348|  16.4k|	use_file_cache = pkcs15_get_default_use_file_cache(card);
 1349|  16.4k|	p15card->opts.use_pin_cache = 1;
 1350|  16.4k|	p15card->opts.pin_cache_counter = 10;
 1351|  16.4k|	p15card->opts.pin_cache_ignore_user_consent = 0;
 1352|  16.4k|	pin_protected_certificate = "protect";
 1353|  16.4k|	private_certificate = "";
 1354|       |
 1355|  16.4k|	conf_block = sc_get_conf_block(ctx, "framework", "pkcs15", 1);
 1356|  16.4k|	if (conf_block) {
  ------------------
  |  Branch (1356:6): [True: 0, False: 16.4k]
  ------------------
 1357|      0|		use_file_cache = scconf_get_str(conf_block, "use_file_caching", use_file_cache);
 1358|      0|		p15card->opts.use_pin_cache = scconf_get_bool(conf_block, "use_pin_caching", p15card->opts.use_pin_cache);
 1359|      0|		p15card->opts.pin_cache_counter = scconf_get_int(conf_block, "pin_cache_counter", p15card->opts.pin_cache_counter);
 1360|      0|		p15card->opts.pin_cache_ignore_user_consent = scconf_get_bool(conf_block, "pin_cache_ignore_user_consent",
 1361|      0|				p15card->opts.pin_cache_ignore_user_consent);
 1362|      0|		pin_protected_certificate = scconf_get_str(conf_block, "pin_protected_certificate", pin_protected_certificate);
 1363|       |		/* read also the old value to keep backward compatibility */
 1364|      0|		private_certificate = scconf_get_str(conf_block, "private_certificate", private_certificate);
 1365|      0|	}
 1366|       |
 1367|  16.4k|	if (0 == strcmp(use_file_cache, "yes")) {
  ------------------
  |  Branch (1367:6): [True: 0, False: 16.4k]
  ------------------
 1368|      0|		p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_ALL_FILES;
  ------------------
  |  |  606|      0|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
 1369|  16.4k|	} else if (0 == strcmp(use_file_cache, "public")) {
  ------------------
  |  Branch (1369:13): [True: 5.93k, False: 10.4k]
  ------------------
 1370|  5.93k|		p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_PUBLIC_FILES;
  ------------------
  |  |  605|  5.93k|#define SC_PKCS15_OPTS_CACHE_PUBLIC_FILES		1
  ------------------
 1371|  10.4k|	} else if (0 == strcmp(use_file_cache, "no")) {
  ------------------
  |  Branch (1371:13): [True: 10.4k, False: 0]
  ------------------
 1372|  10.4k|		p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_NO_FILES;
  ------------------
  |  |  604|  10.4k|#define SC_PKCS15_OPTS_CACHE_NO_FILES			0
  ------------------
 1373|  10.4k|	}
 1374|       |
 1375|  16.4k|	if (0 == strcmp(pin_protected_certificate, "protect")) {
  ------------------
  |  Branch (1375:6): [True: 16.4k, False: 0]
  ------------------
 1376|  16.4k|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT;
  ------------------
  |  |  609|  16.4k|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT		0
  ------------------
 1377|  16.4k|	} else if (0 == strcmp(pin_protected_certificate, "ignore")) {
  ------------------
  |  Branch (1377:13): [True: 0, False: 0]
  ------------------
 1378|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE;
  ------------------
  |  |  610|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE		1
  ------------------
 1379|      0|	} else if (0 == strcmp(pin_protected_certificate, "declassify")) {
  ------------------
  |  Branch (1379:13): [True: 0, False: 0]
  ------------------
 1380|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY;
  ------------------
  |  |  611|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY	2
  ------------------
 1381|      0|	}
 1382|       |	/* overwrite pin_protected_certificate when private_certificate set */
 1383|  16.4k|	if (0 == strcmp(private_certificate, "protect")) {
  ------------------
  |  Branch (1383:6): [True: 0, False: 16.4k]
  ------------------
 1384|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT;
  ------------------
  |  |  609|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT		0
  ------------------
 1385|  16.4k|	} else if (0 == strcmp(private_certificate, "ignore")) {
  ------------------
  |  Branch (1385:13): [True: 0, False: 16.4k]
  ------------------
 1386|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE;
  ------------------
  |  |  610|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE		1
  ------------------
 1387|  16.4k|	} else if (0 == strcmp(private_certificate, "declassify")) {
  ------------------
  |  Branch (1387:13): [True: 0, False: 16.4k]
  ------------------
 1388|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY;
  ------------------
  |  |  611|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY	2
  ------------------
 1389|      0|	}
 1390|  16.4k|	sc_log(ctx, "PKCS#15 options: use_file_cache=%d use_pin_cache=%d pin_cache_counter=%d pin_cache_ignore_user_consent=%d pin_protected_certificate=%d",
  ------------------
  |  |   71|  16.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1391|  16.4k|			p15card->opts.use_file_cache, p15card->opts.use_pin_cache, p15card->opts.pin_cache_counter,
 1392|  16.4k|			p15card->opts.pin_cache_ignore_user_consent, p15card->opts.pin_protected_certificate);
 1393|       |
 1394|  16.4k|	r = sc_lock(card);
 1395|  16.4k|	if (r) {
  ------------------
  |  Branch (1395:6): [True: 0, False: 16.4k]
  ------------------
 1396|      0|		sc_log(ctx, "sc_lock() failed: %s", sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1397|      0|		sc_pkcs15_card_free(p15card);
 1398|      0|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1399|      0|	}
 1400|       |
 1401|  16.4k|	enable_emu = scconf_get_bool(conf_block, "enable_pkcs15_emulation", 1);
 1402|  16.4k|	if (enable_emu) {
  ------------------
  |  Branch (1402:6): [True: 16.4k, False: 0]
  ------------------
 1403|  16.4k|		sc_log(ctx, "PKCS#15 emulation enabled");
  ------------------
  |  |   71|  16.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1404|  16.4k|		emu_first = scconf_get_bool(conf_block, "try_emulation_first", 0);
 1405|  16.4k|		if (emu_first || sc_pkcs15_is_emulation_only(card)) {
  ------------------
  |  Branch (1405:7): [True: 0, False: 16.4k]
  |  Branch (1405:20): [True: 3.20k, False: 13.2k]
  ------------------
 1406|  3.20k|			r = sc_pkcs15_bind_synthetic(p15card, aid);
 1407|  3.20k|			if (r == SC_SUCCESS)
  ------------------
  |  |   28|  3.20k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1407:8): [True: 951, False: 2.25k]
  ------------------
 1408|    951|				goto done;
 1409|  2.25k|			r = sc_pkcs15_bind_internal(p15card, aid);
 1410|  2.25k|			if (r < 0)
  ------------------
  |  Branch (1410:8): [True: 2.19k, False: 62]
  ------------------
 1411|  2.19k|				goto error;
 1412|  13.2k|		} else {
 1413|  13.2k|			r = sc_pkcs15_bind_internal(p15card, aid);
 1414|  13.2k|			if (r == SC_SUCCESS)
  ------------------
  |  |   28|  13.2k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1414:8): [True: 479, False: 12.7k]
  ------------------
 1415|    479|				goto done;
 1416|  12.7k|			r = sc_pkcs15_bind_synthetic(p15card, aid);
 1417|  12.7k|			if (r < 0)
  ------------------
  |  Branch (1417:8): [True: 7.74k, False: 4.97k]
  ------------------
 1418|  7.74k|				goto error;
 1419|  12.7k|		}
 1420|  16.4k|	}
 1421|      0|	else {
 1422|      0|		r = sc_pkcs15_bind_internal(p15card, aid);
 1423|      0|		if (r < 0)
  ------------------
  |  Branch (1423:7): [True: 0, False: 0]
  ------------------
 1424|      0|			goto error;
 1425|      0|	}
 1426|  6.47k|done:
 1427|  6.47k|	*p15card_out = p15card;
 1428|  6.47k|	sc_unlock(card);
 1429|  6.47k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  6.47k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.47k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.47k|	int _ret = r; \
  |  |  |  |  155|  6.47k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6.47k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  6.47k|		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: 6.47k]
  |  |  |  |  ------------------
  |  |  |  |  157|  6.47k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.47k|	} 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|  6.47k|	return _ret; \
  |  |  |  |  163|  6.47k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1430|  9.93k|error:
 1431|  9.93k|	sc_unlock(card);
 1432|  9.93k|	sc_pkcs15_card_free(p15card);
 1433|  9.93k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  9.93k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  9.93k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  9.93k|	int _ret = r; \
  |  |  |  |  155|  9.93k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9.93k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  9.93k|		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|  9.93k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9.93k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  9.93k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  9.93k|	} 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|  9.93k|	return _ret; \
  |  |  |  |  163|  9.93k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1434|  9.93k|}
sc_pkcs15_unbind:
 1439|  6.47k|{
 1440|  6.47k|	if (p15card == NULL || p15card->magic != SC_PKCS15_CARD_MAGIC) {
  ------------------
  |  |  519|  6.47k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  |  Branch (1440:6): [True: 0, False: 6.47k]
  |  Branch (1440:25): [True: 0, False: 6.47k]
  ------------------
 1441|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1442|      0|	}
 1443|       |
 1444|  6.47k|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|  6.47k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.47k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.47k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.47k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1445|  6.47k|	if (p15card->dll_handle)
  ------------------
  |  Branch (1445:6): [True: 0, False: 6.47k]
  ------------------
 1446|      0|		sc_dlclose(p15card->dll_handle);
 1447|  6.47k|	sc_pkcs15_pincache_clear(p15card);
 1448|  6.47k|	sc_pkcs15_card_free(p15card);
 1449|  6.47k|	return 0;
 1450|  6.47k|}
sc_pkcs15_get_objects:
 1538|   107k|{
 1539|   107k|	return sc_pkcs15_get_objects_cond(p15card, type, NULL, NULL, ret, ret_size);
 1540|   107k|}
sc_pkcs15_search_objects:
 1722|     55|{
 1723|     55|	return __sc_pkcs15_search_objects(p15card,
 1724|     55|			sk->class_mask, sk->type,
 1725|     55|			compare_obj_key, sk,
 1726|     55|			ret, ret_size);
 1727|     55|}
sc_pkcs15_get_objects_cond:
 1734|   108k|{
 1735|   108k|	return __sc_pkcs15_search_objects(p15card, 0, type,
 1736|   108k|			func, func_arg, ret, ret_size);
 1737|   108k|}
sc_pkcs15_find_object_by_id:
 1743|  1.36k|{
 1744|  1.36k|	struct sc_pkcs15_search_key sk;
 1745|  1.36k|	int	r;
 1746|       |
 1747|  1.36k|	memset(&sk, 0, sizeof(sk));
 1748|  1.36k|	sk.id = id;
 1749|       |
 1750|  1.36k|	r = __sc_pkcs15_search_objects(p15card, 0, type, compare_obj_key, &sk, out, 1);
 1751|  1.36k|	if (r < 0)
  ------------------
  |  Branch (1751:6): [True: 0, False: 1.36k]
  ------------------
 1752|      0|		return r;
 1753|  1.36k|	if (r == 0)
  ------------------
  |  Branch (1753:6): [True: 1.19k, False: 174]
  ------------------
 1754|  1.19k|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|  1.19k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1755|    174|	return 0;
 1756|  1.36k|}
sc_pkcs15_find_cert_by_id:
 1762|  1.34k|{
 1763|  1.34k|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_CERT, id, out);
  ------------------
  |  |  438|  1.34k|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
 1764|  1.34k|}
sc_pkcs15_find_pin_by_auth_id:
 1794|     16|{
 1795|     16|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_AUTH, id, out);
  ------------------
  |  |  444|     16|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
 1796|     16|}
sc_pkcs15_find_so_pin:
 1853|  1.02k|{
 1854|  1.02k|	struct sc_pkcs15_search_key sk;
 1855|       |
 1856|  1.02k|	memset(&sk, 0, sizeof(sk));
 1857|  1.02k|	sk.flags_mask = sk.flags_value = SC_PKCS15_PIN_FLAG_SO_PIN;
  ------------------
  |  |   61|  1.02k|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
 1858|       |
 1859|  1.02k|	return find_by_key(p15card, SC_PKCS15_TYPE_AUTH_PIN, &sk, out);
  ------------------
  |  |  445|  1.02k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 1860|  1.02k|}
sc_pkcs15_find_pin_by_flags:
 1867|  9.98k|{
 1868|  9.98k|	struct sc_context *ctx = p15card->card->ctx;
 1869|  9.98k|	struct sc_pkcs15_object *auths[SC_PKCS15_MAX_PINS];
 1870|  9.98k|	int r, i, num, idx = 0;
 1871|       |
 1872|  9.98k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  9.98k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  9.98k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  9.98k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  9.98k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 9.98k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1873|  9.98k|	sc_log(ctx, "Find PIN flags:0x%X, mask:0x%X, index:%i", flags, mask, index ? *index : -1);
  ------------------
  |  |   71|  19.9k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 0, False: 9.98k]
  |  |  ------------------
  ------------------
 1874|  9.98k|	if (index)
  ------------------
  |  Branch (1874:6): [True: 0, False: 9.98k]
  ------------------
 1875|      0|		idx = *index;
 1876|       |	/* Get authentication PKCS#15 objects that are present in the given application */
 1877|  9.98k|	r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, auths, SC_PKCS15_MAX_PINS);
  ------------------
  |  |  445|  9.98k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
              	r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, auths, SC_PKCS15_MAX_PINS);
  ------------------
  |  |   34|  9.98k|#define SC_PKCS15_MAX_PINS		8
  ------------------
 1878|  9.98k|	if (r < 0)
  ------------------
  |  Branch (1878:6): [True: 0, False: 9.98k]
  ------------------
 1879|      0|		return r;
 1880|  9.98k|	num = r;
 1881|       |
 1882|  12.7k|	for (i=idx; i<num; i++)   {
  ------------------
  |  Branch (1882:14): [True: 6.95k, False: 5.81k]
  ------------------
 1883|  6.95k|		struct sc_pkcs15_auth_info *pin_info = (struct sc_pkcs15_auth_info *)(*(auths + i))->data;
 1884|       |
 1885|  6.95k|		if (!pin_info || pin_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  6.95k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1885:7): [True: 0, False: 6.95k]
  |  Branch (1885:20): [True: 0, False: 6.95k]
  ------------------
 1886|      0|			continue;
 1887|       |
 1888|  6.95k|		if ((pin_info->attrs.pin.flags & mask) != flags)
  ------------------
  |  Branch (1888:7): [True: 2.78k, False: 4.17k]
  ------------------
 1889|  2.78k|			continue;
 1890|       |
 1891|  4.17k|		if (out)
  ------------------
  |  Branch (1891:7): [True: 4.17k, False: 0]
  ------------------
 1892|  4.17k|			*out = *(auths + i);
 1893|  4.17k|		if (index)
  ------------------
  |  Branch (1893:7): [True: 0, False: 4.17k]
  ------------------
 1894|      0|			*index = i;
 1895|       |
 1896|  4.17k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  4.17k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.17k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.17k|	int _ret = r; \
  |  |  |  |  155|  4.17k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.17k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.17k|		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: 4.17k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.17k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.17k|	} 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|  4.17k|	return _ret; \
  |  |  |  |  163|  4.17k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1897|  4.17k|	}
 1898|       |
 1899|  5.81k|	LOG_FUNC_RETURN(ctx, SC_ERROR_OBJECT_NOT_FOUND);
  ------------------
  |  |  164|  5.81k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.81k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.81k|	int _ret = r; \
  |  |  |  |  155|  5.81k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5.81k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  5.81k|		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|  5.81k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5.81k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  5.81k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  5.81k|	} 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|  5.81k|	return _ret; \
  |  |  |  |  163|  5.81k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1900|  5.81k|}
sc_pkcs15_add_object:
 1986|  40.0k|{
 1987|  40.0k|	struct sc_pkcs15_object *p = p15card->obj_list;
 1988|       |
 1989|  40.0k|	if (!obj)
  ------------------
  |  Branch (1989:6): [True: 0, False: 40.0k]
  ------------------
 1990|      0|		return 0;
 1991|  40.0k|	obj->next = obj->prev = NULL;
 1992|  40.0k|	if (p15card->obj_list == NULL) {
  ------------------
  |  Branch (1992:6): [True: 5.24k, False: 34.8k]
  ------------------
 1993|  5.24k|		p15card->obj_list = obj;
 1994|  5.24k|		return 0;
 1995|  5.24k|	}
 1996|   440k|	while (p->next != NULL)
  ------------------
  |  Branch (1996:9): [True: 405k, False: 34.8k]
  ------------------
 1997|   405k|		p = p->next;
 1998|  34.8k|	p->next = obj;
 1999|  34.8k|	obj->prev = p;
 2000|       |
 2001|  34.8k|	return 0;
 2002|  40.0k|}
sc_pkcs15_free_object:
 2037|  40.0k|{
 2038|  40.0k|	if (!obj)
  ------------------
  |  Branch (2038:6): [True: 0, False: 40.0k]
  ------------------
 2039|      0|		return;
 2040|  40.0k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  40.0k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 2041|  3.87k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  3.87k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2041:2): [True: 3.87k, False: 36.1k]
  ------------------
 2042|  3.87k|		sc_pkcs15_free_prkey_info((sc_pkcs15_prkey_info_t *)obj->data);
 2043|  3.87k|		break;
 2044|  1.27k|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|  1.27k|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (2044:2): [True: 1.27k, False: 38.7k]
  ------------------
 2045|       |		/* This is normally passed to framework-pkcs15,
 2046|       |		 * but if something fails on the way, it would not get freed */
 2047|  1.27k|		if (obj->emulated) {
  ------------------
  |  Branch (2047:7): [True: 1.12k, False: 146]
  ------------------
 2048|  1.12k|			sc_pkcs15_free_pubkey(obj->emulated);
 2049|  1.12k|		}
 2050|  1.27k|		sc_pkcs15_free_pubkey_info((sc_pkcs15_pubkey_info_t *)obj->data);
 2051|  1.27k|		break;
 2052|  2.64k|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|  2.64k|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (2052:2): [True: 2.64k, False: 37.4k]
  ------------------
 2053|  2.64k|		sc_pkcs15_free_cert_info((sc_pkcs15_cert_info_t *)obj->data);
 2054|  2.64k|		break;
 2055|      0|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (2055:2): [True: 0, False: 40.0k]
  ------------------
 2056|      0|		sc_pkcs15_free_skey_info((sc_pkcs15_skey_info_t *)obj->data);
 2057|      0|		break;
 2058|  25.5k|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|  25.5k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (2058:2): [True: 25.5k, False: 14.4k]
  ------------------
 2059|  25.5k|		sc_pkcs15_free_data_info((sc_pkcs15_data_info_t *)obj->data);
 2060|  25.5k|		break;
 2061|  6.68k|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|  6.68k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (2061:2): [True: 6.68k, False: 33.3k]
  ------------------
 2062|  6.68k|		sc_pkcs15_free_auth_info((sc_pkcs15_auth_info_t *)obj->data);
 2063|  6.68k|		break;
 2064|      0|	default:
  ------------------
  |  Branch (2064:2): [True: 0, False: 40.0k]
  ------------------
 2065|      0|		free(obj->data);
 2066|  40.0k|	}
 2067|       |
 2068|  40.0k|	sc_pkcs15_free_object_content(obj);
 2069|       |
 2070|  40.0k|	free(obj);
 2071|  40.0k|}
sc_pkcs15_add_df:
 2076|  12.2k|{
 2077|  12.2k|	struct sc_pkcs15_df *p, *newdf;
 2078|       |
 2079|  12.2k|	newdf = calloc(1, sizeof(struct sc_pkcs15_df));
 2080|  12.2k|	if (newdf == NULL)
  ------------------
  |  Branch (2080:6): [True: 0, False: 12.2k]
  ------------------
 2081|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2082|  12.2k|	newdf->path = *path;
 2083|  12.2k|	newdf->type = type;
 2084|       |
 2085|  12.2k|	if (p15card->df_list == NULL) {
  ------------------
  |  Branch (2085:6): [True: 5.48k, False: 6.73k]
  ------------------
 2086|  5.48k|		p15card->df_list = newdf;
 2087|  5.48k|		return 0;
 2088|  5.48k|	}
 2089|       |
 2090|  6.73k|	p = p15card->df_list;
 2091|  60.2k|	while (p->next != NULL)
  ------------------
  |  Branch (2091:9): [True: 53.5k, False: 6.73k]
  ------------------
 2092|  53.5k|		p = p->next;
 2093|  6.73k|	p->next = newdf;
 2094|  6.73k|	newdf->prev = p;
 2095|       |
 2096|  6.73k|	return 0;
 2097|  12.2k|}
sc_pkcs15_parse_df:
 2192|  11.6k|{
 2193|  11.6k|	struct sc_context *ctx = p15card->card->ctx;
 2194|  11.6k|	unsigned char *buf;
 2195|  11.6k|	const unsigned char *p;
 2196|  11.6k|	size_t bufsize;
 2197|  11.6k|	int r;
 2198|  11.6k|	struct sc_pkcs15_object *obj = NULL;
 2199|  11.6k|	int (* func)(struct sc_pkcs15_card *, struct sc_pkcs15_object *,
 2200|  11.6k|		     const u8 **nbuf, size_t *nbufsize) = NULL;
 2201|       |
 2202|  11.6k|	sc_log(ctx, "called; path=%s, type=%d, enum=%d", sc_print_path(&df->path), df->type, df->enumerated);
  ------------------
  |  |   71|  11.6k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2203|       |
 2204|  11.6k|	if (df->enumerated)
  ------------------
  |  Branch (2204:6): [True: 0, False: 11.6k]
  ------------------
 2205|  11.6k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2206|       |
 2207|  11.6k|	switch (df->type) {
  ------------------
  |  Branch (2207:10): [True: 11.6k, False: 15]
  ------------------
 2208|    633|	case SC_PKCS15_PRKDF:
  ------------------
  |  |  488|    633|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (2208:2): [True: 633, False: 11.0k]
  ------------------
 2209|    633|		func = sc_pkcs15_decode_prkdf_entry;
 2210|    633|		break;
 2211|  10.5k|	case SC_PKCS15_PUKDF:
  ------------------
  |  |  489|  10.5k|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (2211:2): [True: 10.5k, False: 1.16k]
  ------------------
 2212|  10.5k|		func = sc_pkcs15_decode_pukdf_entry;
 2213|  10.5k|		break;
 2214|     21|	case SC_PKCS15_SKDF:
  ------------------
  |  |  491|     21|#define SC_PKCS15_SKDF			3
  ------------------
  |  Branch (2214:2): [True: 21, False: 11.6k]
  ------------------
 2215|     21|		func = sc_pkcs15_decode_skdf_entry;
 2216|     21|		break;
 2217|     24|	case SC_PKCS15_CDF:
  ------------------
  |  |  492|     24|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (2217:2): [True: 24, False: 11.6k]
  ------------------
 2218|     55|	case SC_PKCS15_CDF_TRUSTED:
  ------------------
  |  |  493|     55|#define SC_PKCS15_CDF_TRUSTED		5
  ------------------
  |  Branch (2218:2): [True: 31, False: 11.6k]
  ------------------
 2219|     67|	case SC_PKCS15_CDF_USEFUL:
  ------------------
  |  |  494|     67|#define SC_PKCS15_CDF_USEFUL		6
  ------------------
  |  Branch (2219:2): [True: 12, False: 11.6k]
  ------------------
 2220|     67|		func = sc_pkcs15_decode_cdf_entry;
 2221|     67|		break;
 2222|      7|	case SC_PKCS15_DODF:
  ------------------
  |  |  495|      7|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (2222:2): [True: 7, False: 11.6k]
  ------------------
 2223|      7|		func = sc_pkcs15_decode_dodf_entry;
 2224|      7|		break;
 2225|    425|	case SC_PKCS15_AODF:
  ------------------
  |  |  496|    425|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (2225:2): [True: 425, False: 11.2k]
  ------------------
 2226|    425|		func = sc_pkcs15_decode_aodf_entry;
 2227|    425|		break;
 2228|  11.6k|	}
 2229|  11.6k|	if (func == NULL) {
  ------------------
  |  Branch (2229:6): [True: 15, False: 11.6k]
  ------------------
 2230|     15|		sc_log(ctx, "unknown DF type: %d", df->type);
  ------------------
  |  |   71|     15|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2231|     15|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		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|     15|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     15|	} 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|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2232|     15|	}
 2233|  11.6k|	r = sc_pkcs15_read_file(p15card, &df->path, &buf, &bufsize, 0);
 2234|  11.6k|	LOG_TEST_RET(ctx, r, "pkcs15 read file failed");
  ------------------
  |  |  174|  11.6k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  11.6k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  11.6k|	int _ret = (r); \
  |  |  |  |  168|  11.6k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11.4k, False: 201]
  |  |  |  |  ------------------
  |  |  |  |  169|  11.4k|		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|  11.4k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  11.4k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  11.4k|		return _ret; \
  |  |  |  |  172|  11.4k|	} \
  |  |  |  |  173|  11.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 201]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2235|       |
 2236|    201|	p = buf;
 2237|    201|	while (bufsize && *p != 0x00) {
  ------------------
  |  Branch (2237:9): [True: 185, False: 16]
  |  Branch (2237:20): [True: 182, False: 3]
  ------------------
 2238|       |
 2239|    182|		obj = calloc(1, sizeof(struct sc_pkcs15_object));
 2240|    182|		if (obj == NULL) {
  ------------------
  |  Branch (2240:7): [True: 0, False: 182]
  ------------------
 2241|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2242|      0|			goto ret;
 2243|      0|		}
 2244|    182|		r = func(p15card, obj, &p, &bufsize);
 2245|    182|		if (r) {
  ------------------
  |  Branch (2245:7): [True: 182, False: 0]
  ------------------
 2246|    182|			free(obj);
 2247|    182|			if (r == SC_ERROR_ASN1_END_OF_CONTENTS) {
  ------------------
  |  |   84|    182|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (2247:8): [True: 17, False: 165]
  ------------------
 2248|     17|				r = 0;
 2249|     17|				break;
 2250|     17|			}
 2251|    165|			sc_log(ctx, "%s: Error decoding DF entry", sc_strerror(r));
  ------------------
  |  |   71|    165|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2252|    165|			goto ret;
 2253|    182|		}
 2254|       |
 2255|      0|		obj->df = df;
 2256|      0|		r = sc_pkcs15_add_object(p15card, obj);
 2257|      0|		if (r) {
  ------------------
  |  Branch (2257:7): [True: 0, False: 0]
  ------------------
 2258|      0|			if (obj->data)
  ------------------
  |  Branch (2258:8): [True: 0, False: 0]
  ------------------
 2259|      0|				free(obj->data);
 2260|      0|			free(obj);
 2261|      0|			sc_log(ctx, "%s: Error adding object", sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2262|      0|			goto ret;
 2263|      0|		}
 2264|      0|		while (bufsize > 0 && *p == 00) {
  ------------------
  |  Branch (2264:10): [True: 0, False: 0]
  |  Branch (2264:25): [True: 0, False: 0]
  ------------------
 2265|      0|			bufsize--;
 2266|      0|			p++;
 2267|      0|		}
 2268|     36|	};
 2269|       |
 2270|     36|	if (r > 0)
  ------------------
  |  Branch (2270:6): [True: 0, False: 36]
  ------------------
 2271|      0|		r = 0;
 2272|    201|ret:
 2273|    201|	df->enumerated = 1;
 2274|    201|	free(buf);
 2275|    201|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    201|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    201|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    201|	int _ret = r; \
  |  |  |  |  155|    201|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 201, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    201|		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|    165|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 165, False: 36]
  |  |  |  |  ------------------
  |  |  |  |  157|    201|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    201|	} 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|    201|	return _ret; \
  |  |  |  |  163|    201|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2276|    201|}
sc_pkcs15_read_file:
 2528|  25.1k|{
 2529|  25.1k|	struct sc_context *ctx;
 2530|  25.1k|	struct sc_file *file = NULL;
 2531|  25.1k|	unsigned char *data = NULL;
 2532|  25.1k|	size_t	len = 0, offset = 0;
 2533|  25.1k|	int	r;
 2534|       |
 2535|  25.1k|	if (p15card == NULL || p15card->card == NULL || in_path == NULL || buf == NULL) {
  ------------------
  |  Branch (2535:6): [True: 0, False: 25.1k]
  |  Branch (2535:25): [True: 0, False: 25.1k]
  |  Branch (2535:50): [True: 0, False: 25.1k]
  |  Branch (2535:69): [True: 0, False: 25.1k]
  ------------------
 2536|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2537|      0|	}
 2538|  25.1k|	ctx = p15card->card->ctx;
 2539|       |
 2540|  25.1k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  25.1k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  25.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  25.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  25.1k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 25.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2541|  25.1k|	sc_log(ctx, "path=%s, index=%u, count=%d", sc_print_path(in_path), in_path->index, in_path->count);
  ------------------
  |  |   71|  25.1k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2542|       |
 2543|  25.1k|	r = -1; /* file state: not in cache */
 2544|  25.1k|	if (p15card->opts.use_file_cache
  ------------------
  |  Branch (2544:6): [True: 15.1k, False: 10.0k]
  ------------------
 2545|  15.1k|	    && ((p15card->opts.use_file_cache & SC_PKCS15_OPTS_CACHE_ALL_FILES) || !private_data)) {
  ------------------
  |  |  606|  15.1k|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
  |  Branch (2545:10): [True: 0, False: 15.1k]
  |  Branch (2545:77): [True: 15.1k, False: 0]
  ------------------
 2546|  15.1k|		r = sc_pkcs15_read_cached_file(p15card, in_path, &data, &len);
 2547|       |
 2548|  15.1k|		if (!r && in_path->aid.len > 0 && in_path->len >= 2)   {
  ------------------
  |  Branch (2548:7): [True: 0, False: 15.1k]
  |  Branch (2548:13): [True: 0, False: 0]
  |  Branch (2548:37): [True: 0, False: 0]
  ------------------
 2549|      0|			struct sc_path parent = *in_path;
 2550|       |
 2551|      0|			parent.len -= 2;
 2552|      0|			parent.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
 2553|      0|			r = sc_select_file(p15card->card, &parent, NULL);
 2554|      0|		}
 2555|  15.1k|	}
 2556|       |
 2557|  25.1k|	if (r) {
  ------------------
  |  Branch (2557:6): [True: 25.1k, False: 0]
  ------------------
 2558|  25.1k|		r = sc_lock(p15card->card);
 2559|  25.1k|		if (r)
  ------------------
  |  Branch (2559:7): [True: 0, False: 25.1k]
  ------------------
 2560|      0|			goto fail;
 2561|  25.1k|		r = sc_select_file(p15card->card, in_path, &file);
 2562|  25.1k|		if (r)
  ------------------
  |  Branch (2562:7): [True: 21.3k, False: 3.83k]
  ------------------
 2563|  21.3k|			goto fail_unlock;
 2564|       |
 2565|       |		/* Handle the case where the ASN.1 Path object specified
 2566|       |		 * index and length values */
 2567|       |
 2568|  3.83k|		if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|  3.83k|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2568:7): [True: 37, False: 3.79k]
  ------------------
 2569|       |
 2570|       |			// in_path->index: record_no
 2571|       |			// in_path->count: ignored!
 2572|       |
 2573|     37|			if(file->record_length > 0) {
  ------------------
  |  Branch (2573:7): [True: 22, False: 15]
  ------------------
 2574|     22|				if(file->record_length > MAX_FILE_SIZE) {
  ------------------
  |  |  220|     22|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (2574:8): [True: 0, False: 22]
  ------------------
 2575|      0|					len = MAX_FILE_SIZE;
  ------------------
  |  |  220|      0|#define MAX_FILE_SIZE 65535
  ------------------
 2576|      0|					sc_log(ctx, "  record size truncated, encoded length: %zu", file->record_length);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2577|     22|				} else {
 2578|     22|					len = file->record_length;
 2579|     22|				}
 2580|     22|			} else {
 2581|     15|				len = MAX_FILE_SIZE;
  ------------------
  |  |  220|     15|#define MAX_FILE_SIZE 65535
  ------------------
 2582|     15|			}
 2583|       |
 2584|     37|			if ((in_path->index <= 0) || (in_path->index > (int)(file->record_count))) {
  ------------------
  |  Branch (2584:8): [True: 33, False: 4]
  |  Branch (2584:33): [True: 1, False: 3]
  ------------------
 2585|     34|				sc_log(ctx, "  record number out of bounds: %d", in_path->index);
  ------------------
  |  |   71|     34|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2586|     34|				r = SC_ERROR_RECORD_NOT_FOUND;
  ------------------
  |  |   52|     34|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
 2587|     34|				goto fail_unlock;
 2588|     34|			}
 2589|       |
 2590|  3.79k|		} else {
 2591|       |
 2592|  3.79k|			if (in_path->count < 0) {
  ------------------
  |  Branch (2592:8): [True: 2.61k, False: 1.18k]
  ------------------
 2593|  2.61k|				if (file->size)
  ------------------
  |  Branch (2593:9): [True: 2.32k, False: 291]
  ------------------
 2594|  2.32k|					len = (file->size > MAX_FILE_SIZE)? MAX_FILE_SIZE:file->size;
  ------------------
  |  |  220|  2.32k|#define MAX_FILE_SIZE 65535
  ------------------
              					len = (file->size > MAX_FILE_SIZE)? MAX_FILE_SIZE:file->size;
  ------------------
  |  |  220|      5|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (2594:12): [True: 5, False: 2.31k]
  ------------------
 2595|    291|				else
 2596|    291|					len = 1024;
 2597|  2.61k|				offset = 0;
 2598|  2.61k|			}
 2599|  1.18k|			else {
 2600|  1.18k|				offset = in_path->index;
 2601|  1.18k|				len = in_path->count;
 2602|       |				/* Make sure we're within proper bounds */
 2603|  1.18k|				if (offset >= file->size || offset + len > file->size) {
  ------------------
  |  Branch (2603:9): [True: 25, False: 1.15k]
  |  Branch (2603:33): [True: 16, False: 1.14k]
  ------------------
 2604|     41|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     41|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2605|     41|					goto fail_unlock;
 2606|     41|				}
 2607|  1.18k|			}
 2608|  3.79k|		}
 2609|       |
 2610|  3.76k|		free(data);
 2611|  3.76k|		data = malloc(len);
 2612|  3.76k|		if (data == NULL) {
  ------------------
  |  Branch (2612:7): [True: 0, False: 3.76k]
  ------------------
 2613|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2614|      0|			goto fail_unlock;
 2615|      0|		}
 2616|       |
 2617|  3.76k|		if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE_TLV) {
  ------------------
  |  |  225|  3.76k|#define SC_FILE_EF_LINEAR_VARIABLE_TLV	0x05
  ------------------
  |  Branch (2617:7): [True: 104, False: 3.65k]
  ------------------
 2618|    104|			unsigned int i;
 2619|    104|			size_t l, record_len;
 2620|    104|			unsigned char *head = data;
 2621|       |
 2622|    491|			for (i=1; ; i++) {
 2623|    491|				l = len - (head - data);
 2624|    491|				if (l > 256) {
  ------------------
  |  Branch (2624:9): [True: 149, False: 342]
  ------------------
 2625|    149|					l = 256;
 2626|    149|				}
 2627|    491|				r = sc_read_record(p15card->card, i, 0, head, l, SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1298|    491|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
 2628|    491|				if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|    491|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (2628:9): [True: 1, False: 490]
  ------------------
 2629|      1|					break;
 2630|    490|				if (r < 0) {
  ------------------
  |  Branch (2630:9): [True: 70, False: 420]
  ------------------
 2631|     70|					goto fail_unlock;
 2632|     70|				}
 2633|    420|				if (r < 2)
  ------------------
  |  Branch (2633:9): [True: 32, False: 388]
  ------------------
 2634|     32|					break;
 2635|    388|				record_len = head[1];
 2636|    388|				if (record_len != 0xff) {
  ------------------
  |  Branch (2636:9): [True: 363, False: 25]
  ------------------
 2637|    363|					memmove(head, head+2, r-2);
 2638|    363|					head += (r-2);
 2639|    363|				}
 2640|     25|				else {
 2641|     25|					if (r < 4)
  ------------------
  |  Branch (2641:10): [True: 1, False: 24]
  ------------------
 2642|      1|						break;
 2643|     24|					memmove(head, head+4, r-4);
 2644|     24|					head += (r-4);
 2645|     24|				}
 2646|    388|			}
 2647|     34|			len = head-data;
 2648|     34|		}
 2649|  3.65k|		else if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|  3.65k|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2649:12): [True: 3, False: 3.65k]
  ------------------
 2650|      3|			r = sc_read_record(p15card->card, in_path->index, (unsigned)offset, data, len, SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1298|      3|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
 2651|      3|			if (r < 0) {
  ------------------
  |  Branch (2651:8): [True: 2, False: 1]
  ------------------
 2652|      2|				goto fail_unlock;
 2653|      2|			}
 2654|       |			/* sc_read_record may return less than requested */
 2655|      1|			len = r;
 2656|      1|		}
 2657|  3.65k|		else {
 2658|  3.65k|			unsigned long flags = 0;
 2659|  3.65k|			r = sc_read_binary(p15card->card, (unsigned)offset, data, len, &flags);
 2660|  3.65k|			if (r < 0) {
  ------------------
  |  Branch (2660:8): [True: 768, False: 2.88k]
  ------------------
 2661|    768|				goto fail_unlock;
 2662|    768|			}
 2663|       |			/* sc_read_binary may return less than requested */
 2664|  2.88k|			len = r;
 2665|       |
 2666|  2.88k|			if (flags & SC_FILE_FLAG_COMPRESSED_AUTO
  ------------------
  |  |  230|  5.77k|#define SC_FILE_FLAG_COMPRESSED_AUTO		0x01
  ------------------
  |  Branch (2666:8): [True: 195, False: 2.69k]
  ------------------
 2667|  2.69k|			    || flags & SC_FILE_FLAG_COMPRESSED_ZLIB
  ------------------
  |  |  231|  5.57k|#define SC_FILE_FLAG_COMPRESSED_ZLIB		0x02
  ------------------
  |  Branch (2667:11): [True: 0, False: 2.69k]
  ------------------
 2668|  2.69k|			    || flags & SC_FILE_FLAG_COMPRESSED_GZIP) {
  ------------------
  |  |  232|  2.69k|#define SC_FILE_FLAG_COMPRESSED_GZIP		0x04
  ------------------
  |  Branch (2668:11): [True: 0, False: 2.69k]
  ------------------
 2669|    195|				unsigned char *decompressed_buf = NULL;
 2670|    195|				size_t decompressed_len = 0;
 2671|    195|				r = decompress_file(p15card->card, data, len, &decompressed_buf, &decompressed_len, flags);
 2672|    195|				if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    195|#define SC_SUCCESS				0
  ------------------
  |  Branch (2672:9): [True: 195, False: 0]
  ------------------
 2673|    195|					goto fail_unlock;
 2674|    195|				}
 2675|      0|				free(data);
 2676|      0|				data = decompressed_buf;
 2677|      0|				len = decompressed_len;
 2678|      0|			}
 2679|  2.88k|		}
 2680|  2.72k|		sc_unlock(p15card->card);
 2681|       |
 2682|  2.72k|		sc_file_free(file);
 2683|       |
 2684|  2.72k|		if (p15card->opts.use_file_cache && ((p15card->opts.use_file_cache & SC_PKCS15_OPTS_CACHE_ALL_FILES) || !private_data)) {
  ------------------
  |  |  606|    895|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
  |  Branch (2684:7): [True: 895, False: 1.83k]
  |  Branch (2684:40): [True: 0, False: 895]
  |  Branch (2684:107): [True: 895, False: 0]
  ------------------
 2685|    895|			sc_pkcs15_cache_file(p15card, in_path, data, len);
 2686|    895|		}
 2687|  2.72k|		if (len == 0) {
  ------------------
  |  Branch (2687:7): [True: 259, False: 2.46k]
  ------------------
 2688|    259|			free(data);
 2689|    259|			data = NULL;
 2690|    259|		}
 2691|  2.72k|	}
 2692|  2.72k|	*buf = data;
 2693|  2.72k|	*buflen = len;
 2694|  2.72k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  2.72k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.72k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.72k|	int _ret = r; \
  |  |  |  |  155|  2.72k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.72k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.72k|		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: 2.72k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.72k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.72k|	} 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|  2.72k|	return _ret; \
  |  |  |  |  163|  2.72k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2695|       |
 2696|  22.4k|fail_unlock:
 2697|  22.4k|	sc_unlock(p15card->card);
 2698|  22.4k|fail:
 2699|  22.4k|	free(data);
 2700|  22.4k|	sc_file_free(file);
 2701|  22.4k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  22.4k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  22.4k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  22.4k|	int _ret = r; \
  |  |  |  |  155|  22.4k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 22.4k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  22.4k|		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|  22.4k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 22.4k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  22.4k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  22.4k|	} 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|  22.4k|	return _ret; \
  |  |  |  |  163|  22.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2702|  22.4k|}
sc_pkcs15_compare_id:
 2707|  49.0k|{
 2708|  49.0k|	if (id1 == NULL || id2 == NULL)
  ------------------
  |  Branch (2708:6): [True: 0, False: 49.0k]
  |  Branch (2708:21): [True: 0, False: 49.0k]
  ------------------
 2709|      0|		return 0;
 2710|  49.0k|	if (id1->len != id2->len)
  ------------------
  |  Branch (2710:6): [True: 4.23k, False: 44.8k]
  ------------------
 2711|  4.23k|		return 0;
 2712|  44.8k|	return memcmp(id1->value, id2->value, id1->len) == 0;
 2713|  49.0k|}
sc_pkcs15_format_id:
 2718|   123k|{
 2719|   123k|	size_t len;
 2720|       |
 2721|   123k|	if (!id)
  ------------------
  |  Branch (2721:6): [True: 0, False: 123k]
  ------------------
 2722|      0|		return;
 2723|   123k|	len = sizeof(id->value);
 2724|       |
 2725|   123k|	if (sc_hex_to_bin(str, id->value, &len) != SC_SUCCESS)
  ------------------
  |  |   28|   123k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2725:6): [True: 164, False: 123k]
  ------------------
 2726|    164|		id->len = 0;
 2727|   123k|	else
 2728|   123k|		id->len = len;
 2729|   123k|}
sc_pkcs15_print_id:
 2734|  18.1k|{
 2735|  18.1k|	static char buffer[256];
 2736|       |
 2737|  18.1k|	sc_bin_to_hex(id->value, id->len, buffer, sizeof(buffer), '\0');
 2738|  18.1k|	return buffer;
 2739|  18.1k|}
sc_pkcs15_make_absolute_path:
 2752|  17.5k|{
 2753|       |	/* nothing to do if child has valid 'aid' */
 2754|  17.5k|	if (child->aid.len)
  ------------------
  |  Branch (2754:6): [True: 0, False: 17.5k]
  ------------------
 2755|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2756|       |
 2757|  17.5k|	if (parent->aid.len)   {
  ------------------
  |  Branch (2757:6): [True: 0, False: 17.5k]
  ------------------
 2758|      0|		sc_path_t ppath;
 2759|       |
 2760|       |		/* child inherits parent's 'aid' */
 2761|      0|		child->aid = parent->aid;
 2762|      0|		if (!parent->len)
  ------------------
  |  Branch (2762:7): [True: 0, False: 0]
  ------------------
 2763|      0|			return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2764|       |
 2765|       |		/* parent has valid 'path' -- concatenate it with the child's one */
 2766|      0|		memcpy(&ppath, parent, sizeof(sc_path_t));
 2767|      0|		ppath.aid.len = 0;
 2768|      0|		ppath.type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|      0|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
 2769|      0|		return sc_concatenate_path(child, &ppath, child);
 2770|       |
 2771|      0|	}
 2772|  17.5k|	else if (parent->type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  17.5k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (2772:11): [True: 1.40k, False: 16.1k]
  ------------------
 2773|       |		/* child inherits parent's 'DF NAME' as 'aid' */
 2774|  1.40k|		if (parent->len > sizeof(child->aid.value))
  ------------------
  |  Branch (2774:7): [True: 0, False: 1.40k]
  ------------------
 2775|      0|			return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 2776|       |
 2777|  1.40k|		memcpy(child->aid.value, parent->value, parent->len);
 2778|  1.40k|		child->aid.len = parent->len;
 2779|       |
 2780|  1.40k|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.40k|#define SC_SUCCESS				0
  ------------------
 2781|  1.40k|	}
 2782|       |
 2783|       |	/* a 0 length path stays a 0 length path */
 2784|  16.1k|	if (child->len == 0)
  ------------------
  |  Branch (2784:6): [True: 219, False: 15.8k]
  ------------------
 2785|    219|		return SC_SUCCESS;
  ------------------
  |  |   28|    219|#define SC_SUCCESS				0
  ------------------
 2786|       |
 2787|  15.8k|	if (sc_compare_path_prefix(sc_get_mf_path(), child))
  ------------------
  |  Branch (2787:6): [True: 1.01k, False: 14.8k]
  ------------------
 2788|  1.01k|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.01k|#define SC_SUCCESS				0
  ------------------
 2789|       |
 2790|  14.8k|	return sc_concatenate_path(child, parent, child);
 2791|  15.8k|}
sc_pkcs15_free_object_content:
 2795|  47.4k|{
 2796|  47.4k|	if (obj->content.value && obj->content.len) {
  ------------------
  |  Branch (2796:6): [True: 179, False: 47.2k]
  |  Branch (2796:28): [True: 179, False: 0]
  ------------------
 2797|    179|		if (obj->content_free) {
  ------------------
  |  Branch (2797:7): [True: 179, False: 0]
  ------------------
 2798|    179|			obj->content_free(obj->content.value, obj->content.len);
 2799|    179|		} else {
 2800|      0|			free(obj->content.value);
 2801|      0|		}
 2802|    179|	}
 2803|       |	obj->content.value = NULL;
 2804|  47.4k|	obj->content.len = 0;
 2805|  47.4k|}
sc_pkcs15_allocate_object_content:
 2811|    179|{
 2812|    179|	unsigned char *tmp_buf;
 2813|       |
 2814|    179|	if (!obj)
  ------------------
  |  Branch (2814:6): [True: 0, False: 179]
  ------------------
 2815|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2816|       |
 2817|    179|	if (!value || !len)   {
  ------------------
  |  Branch (2817:6): [True: 0, False: 179]
  |  Branch (2817:16): [True: 0, False: 179]
  ------------------
 2818|      0|		sc_pkcs15_free_object_content(obj);
 2819|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2820|      0|	}
 2821|       |
 2822|       |	/* Need to pass by temporary variable,
 2823|       |	 * because 'value' and 'content.value' pointers can be the sames.
 2824|       |	 */
 2825|    179|	if (SC_PKCS15_TYPE_AUTH & obj->type
  ------------------
  |  |  444|    179|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (2825:6): [True: 179, False: 0]
  ------------------
 2826|      0|			|| SC_PKCS15_TYPE_SKEY & obj->type
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (2826:7): [True: 0, False: 0]
  ------------------
 2827|    179|			|| SC_PKCS15_TYPE_PRKEY & obj->type) {
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2827:7): [True: 0, False: 0]
  ------------------
 2828|    179|		tmp_buf = sc_mem_secure_alloc(len);
 2829|    179|		obj->content_free = sc_mem_secure_free;
 2830|    179|	} else {
 2831|      0|		tmp_buf = malloc(len);
 2832|      0|	}
 2833|    179|	if (!tmp_buf)
  ------------------
  |  Branch (2833:6): [True: 0, False: 179]
  ------------------
 2834|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2835|       |
 2836|    179|	memcpy(tmp_buf, value, len);
 2837|       |
 2838|    179|	sc_pkcs15_free_object_content(obj);
 2839|       |
 2840|    179|	obj->content.value = tmp_buf;
 2841|    179|	obj->content.len = len;
 2842|       |
 2843|    179|	return SC_SUCCESS;
  ------------------
  |  |   28|    179|#define SC_SUCCESS				0
  ------------------
 2844|    179|}
sc_pkcs15_free_key_params:
 3137|  5.30k|{
 3138|  5.30k|	if (!params)
  ------------------
  |  Branch (3138:6): [True: 0, False: 5.30k]
  ------------------
 3139|      0|		return;
 3140|  5.30k|	if (params->data && params->free_params)
  ------------------
  |  Branch (3140:6): [True: 0, False: 5.30k]
  |  Branch (3140:22): [True: 0, False: 0]
  ------------------
 3141|      0|		params->free_params(params->data);
 3142|  5.30k|	else if (params->data)
  ------------------
  |  Branch (3142:11): [True: 0, False: 5.30k]
  ------------------
 3143|      0|		free(params->data);
 3144|       |
 3145|       |	params->data = NULL;
 3146|  5.30k|}
pkcs15.c:sc_pkcs15_clear_tokeninfo:
  753|  29.4k|{
  754|  29.4k|	if (!tokeninfo)
  ------------------
  |  Branch (754:6): [True: 0, False: 29.4k]
  ------------------
  755|      0|		return;
  756|       |
  757|  29.4k|	free(tokeninfo->label);
  758|  29.4k|	tokeninfo->label = NULL;
  759|  29.4k|	free(tokeninfo->serial_number);
  760|  29.4k|	tokeninfo->serial_number = NULL;
  761|  29.4k|	free(tokeninfo->manufacturer_id);
  762|  29.4k|	tokeninfo->manufacturer_id = NULL;
  763|  29.4k|	free(tokeninfo->last_update.gtime);
  764|  29.4k|	tokeninfo->last_update.gtime = NULL;
  765|  29.4k|	free(tokeninfo->preferred_language);
  766|  29.4k|	tokeninfo->preferred_language = NULL;
  767|  29.4k|	free(tokeninfo->profile_indication.name);
  768|  29.4k|	tokeninfo->profile_indication.name = NULL;
  769|  29.4k|	if (tokeninfo->seInfo != NULL) {
  ------------------
  |  Branch (769:6): [True: 4, False: 29.4k]
  ------------------
  770|      4|		unsigned i;
  771|      4|		for (i = 0; i < tokeninfo->num_seInfo; i++)
  ------------------
  |  Branch (771:15): [True: 0, False: 4]
  ------------------
  772|      0|			free(tokeninfo->seInfo[i]);
  773|      4|		free(tokeninfo->seInfo);
  774|       |		tokeninfo->seInfo = NULL;
  775|      4|	}
  776|  29.4k|}
pkcs15.c:parse_odf:
  620|    282|{
  621|    282|	const unsigned char *p = buf;
  622|    282|	size_t left = buflen;
  623|    282|	int r, i, type;
  624|    282|	struct sc_path path;
  625|    282|	struct sc_asn1_entry asn1_obj_or_path[] = {
  626|    282|		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  174|    282|#define SC_ASN1_PATH			256
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  141|    282|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  162|    282|#define SC_ASN1_SEQUENCE                16
  ------------------
  627|    282|		{ NULL, 0, 0, 0, NULL, NULL }
  628|    282|	};
  629|    282|	struct sc_asn1_entry asn1_odf[10];
  630|       |
  631|    282|	sc_copy_asn1_entry(c_asn1_odf, asn1_odf);
  632|  2.82k|	for (i = 0; asn1_odf[i].name != NULL; i++)
  ------------------
  |  Branch (632:14): [True: 2.53k, False: 282]
  ------------------
  633|  2.53k|		sc_format_asn1_entry(asn1_odf + i, asn1_obj_or_path, NULL, 0);
  634|  2.80k|	while (left > 0) {
  ------------------
  |  Branch (634:9): [True: 2.61k, False: 189]
  ------------------
  635|  2.61k|		r = sc_asn1_decode_choice(p15card->card->ctx, asn1_odf, p, left, &p, &left);
  636|  2.61k|		if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|  2.61k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (636:7): [True: 49, False: 2.56k]
  ------------------
  637|     49|			break;
  638|  2.56k|		if (r < 0)
  ------------------
  |  Branch (638:7): [True: 44, False: 2.52k]
  ------------------
  639|     44|			return r;
  640|  2.52k|		type = r;
  641|  2.52k|		if (p15card->file_app) {
  ------------------
  |  Branch (641:7): [True: 2.52k, False: 0]
  ------------------
  642|  2.52k|			r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &path);
  643|  2.52k|			if (r < 0)
  ------------------
  |  Branch (643:8): [True: 0, False: 2.52k]
  ------------------
  644|      0|				return r;
  645|  2.52k|			r = sc_pkcs15_add_df(p15card, odf_indexes[type], &path);
  646|  2.52k|			if (r)
  ------------------
  |  Branch (646:8): [True: 0, False: 2.52k]
  ------------------
  647|      0|				return r;
  648|  2.52k|		}
  649|  2.52k|	}
  650|    238|	return 0;
  651|    282|}
pkcs15.c:sc_dup_app_info:
  907|  4.87k|{
  908|  4.87k|	struct sc_app_info *out = calloc(1, sizeof(struct sc_app_info));
  909|       |
  910|  4.87k|	if (!out)
  ------------------
  |  Branch (910:6): [True: 0, False: 4.87k]
  ------------------
  911|      0|		return NULL;
  912|       |
  913|  4.87k|	memcpy(out, info, sizeof(struct sc_app_info));
  914|       |
  915|  4.87k|	if (info->label) {
  ------------------
  |  Branch (915:6): [True: 135, False: 4.73k]
  ------------------
  916|    135|		out->label = strdup(info->label);
  917|    135|		if (!out->label) {
  ------------------
  |  Branch (917:7): [True: 0, False: 135]
  ------------------
  918|      0|			free(out);
  919|      0|			return NULL;
  920|      0|		}
  921|    135|	} else
  922|  4.73k|		out->label = NULL;
  923|       |
  924|  4.87k|	out->ddo.value = malloc(info->ddo.len);
  925|  4.87k|	if (!out->ddo.value) {
  ------------------
  |  Branch (925:6): [True: 0, False: 4.87k]
  ------------------
  926|      0|		free(out->label);
  927|      0|		free(out);
  928|      0|		return NULL;
  929|      0|	}
  930|  4.87k|	memcpy(out->ddo.value, info->ddo.value, info->ddo.len);
  931|  4.87k|	out->ddo.len = info->ddo.len;
  932|       |
  933|  4.87k|	return out;
  934|  4.87k|}
pkcs15.c:parse_ddo:
  472|    861|{
  473|    861|	struct sc_context *ctx = p15card->card->ctx;
  474|    861|	struct sc_asn1_entry asn1_ddo[7];
  475|    861|	sc_path_t odf_path, ti_path, us_path;
  476|    861|	struct sc_iid iid;
  477|    861|	struct sc_aid aid;
  478|    861|	int r;
  479|       |
  480|    861|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    861|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    861|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    861|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    861|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 861]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|       |
  482|    861|	iid.len = sizeof(iid.value);
  483|    861|	aid.len = sizeof(aid.value);
  484|       |
  485|    861|	sc_copy_asn1_entry(c_asn1_ddo, asn1_ddo);
  486|    861|	sc_format_asn1_entry(asn1_ddo + 1, &odf_path, NULL, 0);
  487|    861|	sc_format_asn1_entry(asn1_ddo + 2, &ti_path, NULL, 0);
  488|    861|	sc_format_asn1_entry(asn1_ddo + 3, &us_path, NULL, 0);
  489|    861|	sc_format_asn1_entry(asn1_ddo + 4, iid.value, &iid.len, 0);
  490|    861|	sc_format_asn1_entry(asn1_ddo + 5, aid.value, &aid.len, 0);
  491|       |
  492|    861|	r = sc_asn1_decode(ctx, asn1_ddo, buf, buflen, NULL, NULL);
  493|    861|	LOG_TEST_RET(ctx, r, "DDO parsing failed");
  ------------------
  |  |  174|    861|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    861|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    861|	int _ret = (r); \
  |  |  |  |  168|    861|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 152, False: 709]
  |  |  |  |  ------------------
  |  |  |  |  169|    152|		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|    152|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    152|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    152|		return _ret; \
  |  |  |  |  172|    152|	} \
  |  |  |  |  173|    861|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 709]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|       |
  495|    709|	if (asn1_ddo[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    709|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (495:6): [True: 169, False: 540]
  ------------------
  496|    169|		sc_file_free(p15card->file_odf);
  497|    169|		p15card->file_odf = sc_file_new();
  498|    169|		if (p15card->file_odf == NULL)
  ------------------
  |  Branch (498:7): [True: 0, False: 169]
  ------------------
  499|      0|			goto mem_err;
  500|    169|		p15card->file_odf->path = odf_path;
  501|    169|	}
  502|    709|	if (asn1_ddo[2].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    709|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (502:6): [True: 165, False: 544]
  ------------------
  503|    165|		sc_file_free(p15card->file_tokeninfo);
  504|    165|		p15card->file_tokeninfo = sc_file_new();
  505|    165|		if (p15card->file_tokeninfo == NULL)
  ------------------
  |  Branch (505:7): [True: 0, False: 165]
  ------------------
  506|      0|			goto mem_err;
  507|    165|		p15card->file_tokeninfo->path = ti_path;
  508|    165|	}
  509|    709|	if (asn1_ddo[3].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    709|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (509:6): [True: 18, False: 691]
  ------------------
  510|     18|		sc_file_free(p15card->file_unusedspace);
  511|     18|		p15card->file_unusedspace = sc_file_new();
  512|     18|		if (p15card->file_unusedspace == NULL)
  ------------------
  |  Branch (512:7): [True: 0, False: 18]
  ------------------
  513|      0|			goto mem_err;
  514|     18|		p15card->file_unusedspace->path = us_path;
  515|     18|	}
  516|    709|	if (asn1_ddo[4].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    709|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (516:6): [True: 41, False: 668]
  ------------------
  517|     41|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "DDO.IID '%s'", sc_dump_hex(iid.value, iid.len));
  ------------------
  |  |   70|     41|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  518|     41|		memcpy(&p15card->app->ddo.iid, &iid, sizeof(struct sc_iid));
  519|     41|	}
  520|    709|	if (asn1_ddo[5].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    709|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (520:6): [True: 45, False: 664]
  ------------------
  521|     45|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "DDO.AID '%s'", sc_dump_hex(aid.value, aid.len));
  ------------------
  |  |   70|     45|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  522|     45|		memcpy(&p15card->app->ddo.aid, &aid, sizeof(struct sc_aid));
  523|     45|	}
  524|       |
  525|    709|	fix_authentic_ddo(p15card);
  526|    709|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    709|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    709|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    709|	int _ret = r; \
  |  |  |  |  155|    709|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 709, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    709|		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: 709]
  |  |  |  |  ------------------
  |  |  |  |  157|    709|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    709|	} 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|    709|	return _ret; \
  |  |  |  |  163|    709|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  527|      0|mem_err:
  528|      0|	sc_file_free(p15card->file_odf);
  529|      0|	p15card->file_odf = NULL;
  530|      0|	sc_file_free(p15card->file_tokeninfo);
  531|      0|	p15card->file_tokeninfo = NULL;
  532|      0|	sc_file_free(p15card->file_unusedspace);
  533|      0|	p15card->file_unusedspace = NULL;
  534|      0|	LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  535|      0|}
pkcs15.c:fix_authentic_ddo:
  458|    709|{
  459|       |	/* AuthentIC v3.2 card has invalid ODF and tokenInfo paths encoded into DDO.
  460|       |	 * Cleanup this attributes -- default values must be OK.
  461|       |	 */
  462|    709|	if (p15card->card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2)   {
  ------------------
  |  Branch (462:6): [True: 11, False: 698]
  ------------------
  463|     11|		sc_file_free(p15card->file_odf);
  464|     11|		p15card->file_odf = NULL;
  465|     11|		sc_file_free(p15card->file_tokeninfo);
  466|       |		p15card->file_tokeninfo = NULL;
  467|     11|	}
  468|    709|}
pkcs15.c:__sc_pkcs15_search_objects:
 1457|   109k|{
 1458|   109k|	struct sc_pkcs15_object *obj = NULL;
 1459|   109k|	struct sc_pkcs15_df	*df = NULL;
 1460|   109k|	unsigned int	df_mask = 0;
 1461|   109k|	size_t		match_count = 0;
 1462|   109k|	int r;
 1463|       |
 1464|   109k|	if (type)
  ------------------
  |  Branch (1464:6): [True: 109k, False: 55]
  ------------------
 1465|   109k|		class_mask |= SC_PKCS15_TYPE_TO_CLASS(type);
  ------------------
  |  |  449|   109k|#define SC_PKCS15_TYPE_TO_CLASS(t)		(1 << ((t) >> 8))
  ------------------
 1466|       |
 1467|       |	/* Make sure the class mask we have makes sense */
 1468|   109k|	if (class_mask == 0
  ------------------
  |  Branch (1468:6): [True: 0, False: 109k]
  ------------------
 1469|   109k|			|| (class_mask & ~(
  ------------------
  |  Branch (1469:7): [True: 0, False: 109k]
  ------------------
 1470|   109k|					SC_PKCS15_SEARCH_CLASS_PRKEY |
  ------------------
  |  |  450|   109k|#define SC_PKCS15_SEARCH_CLASS_PRKEY		0x0002U
  ------------------
 1471|   109k|					SC_PKCS15_SEARCH_CLASS_PUBKEY |
  ------------------
  |  |  451|   109k|#define SC_PKCS15_SEARCH_CLASS_PUBKEY		0x0004U
  ------------------
 1472|   109k|					SC_PKCS15_SEARCH_CLASS_SKEY |
  ------------------
  |  |  452|   109k|#define SC_PKCS15_SEARCH_CLASS_SKEY		0x0008U
  ------------------
 1473|   109k|					SC_PKCS15_SEARCH_CLASS_CERT |
  ------------------
  |  |  453|   109k|#define SC_PKCS15_SEARCH_CLASS_CERT		0x0010U
  ------------------
 1474|   109k|					SC_PKCS15_SEARCH_CLASS_DATA |
  ------------------
  |  |  454|   109k|#define SC_PKCS15_SEARCH_CLASS_DATA		0x0020U
  ------------------
 1475|   109k|					SC_PKCS15_SEARCH_CLASS_AUTH))) {
  ------------------
  |  |  455|   109k|#define SC_PKCS15_SEARCH_CLASS_AUTH		0x0040U
  ------------------
 1476|      0|		LOG_FUNC_RETURN(p15card->card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1477|      0|	}
 1478|       |
 1479|   109k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_PRKEY)
  ------------------
  |  |  450|   109k|#define SC_PKCS15_SEARCH_CLASS_PRKEY		0x0002U
  ------------------
  |  Branch (1479:6): [True: 32.0k, False: 77.5k]
  ------------------
 1480|  32.0k|		df_mask |= (1 << SC_PKCS15_PRKDF);
  ------------------
  |  |  488|  32.0k|#define SC_PKCS15_PRKDF			0
  ------------------
 1481|   109k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_PUBKEY)
  ------------------
  |  |  451|   109k|#define SC_PKCS15_SEARCH_CLASS_PUBKEY		0x0004U
  ------------------
  |  Branch (1481:6): [True: 32.0k, False: 77.5k]
  ------------------
 1482|  32.0k|		df_mask |= (1 << SC_PKCS15_PUKDF) | (1 << SC_PKCS15_PUKDF_TRUSTED);
  ------------------
  |  |  489|  32.0k|#define SC_PKCS15_PUKDF			1
  ------------------
              		df_mask |= (1 << SC_PKCS15_PUKDF) | (1 << SC_PKCS15_PUKDF_TRUSTED);
  ------------------
  |  |  490|  32.0k|#define SC_PKCS15_PUKDF_TRUSTED		2
  ------------------
 1483|   109k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_CERT)
  ------------------
  |  |  453|   109k|#define SC_PKCS15_SEARCH_CLASS_CERT		0x0010U
  ------------------
  |  Branch (1483:6): [True: 7.79k, False: 101k]
  ------------------
 1484|  7.79k|		df_mask |= (1 << SC_PKCS15_CDF) | (1 << SC_PKCS15_CDF_TRUSTED) | (1 << SC_PKCS15_CDF_USEFUL);
  ------------------
  |  |  492|  7.79k|#define SC_PKCS15_CDF			4
  ------------------
              		df_mask |= (1 << SC_PKCS15_CDF) | (1 << SC_PKCS15_CDF_TRUSTED) | (1 << SC_PKCS15_CDF_USEFUL);
  ------------------
  |  |  493|  7.79k|#define SC_PKCS15_CDF_TRUSTED		5
  ------------------
              		df_mask |= (1 << SC_PKCS15_CDF) | (1 << SC_PKCS15_CDF_TRUSTED) | (1 << SC_PKCS15_CDF_USEFUL);
  ------------------
  |  |  494|  7.79k|#define SC_PKCS15_CDF_USEFUL		6
  ------------------
 1485|   109k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_DATA)
  ------------------
  |  |  454|   109k|#define SC_PKCS15_SEARCH_CLASS_DATA		0x0020U
  ------------------
  |  Branch (1485:6): [True: 6.70k, False: 102k]
  ------------------
 1486|  6.70k|		df_mask |= (1 << SC_PKCS15_DODF);
  ------------------
  |  |  495|  6.70k|#define SC_PKCS15_DODF			7
  ------------------
 1487|   109k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_AUTH)
  ------------------
  |  |  455|   109k|#define SC_PKCS15_SEARCH_CLASS_AUTH		0x0040U
  ------------------
  |  Branch (1487:6): [True: 24.7k, False: 84.8k]
  ------------------
 1488|  24.7k|		df_mask |= (1 << SC_PKCS15_AODF);
  ------------------
  |  |  496|  24.7k|#define SC_PKCS15_AODF			8
  ------------------
 1489|   109k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_SKEY)
  ------------------
  |  |  452|   109k|#define SC_PKCS15_SEARCH_CLASS_SKEY		0x0008U
  ------------------
  |  Branch (1489:6): [True: 6.39k, False: 103k]
  ------------------
 1490|  6.39k|		df_mask |= (1 << SC_PKCS15_SKDF);
  ------------------
  |  |  491|  6.39k|#define SC_PKCS15_SKDF			3
  ------------------
 1491|       |
 1492|       |	/* Make sure all the DFs we want to search have been
 1493|       |	 * enumerated. */
 1494|   302k|	for (df = p15card->df_list; df != NULL; df = df->next) {
  ------------------
  |  Branch (1494:30): [True: 192k, False: 109k]
  ------------------
 1495|   192k|		if (!(df_mask & (1 << df->type)))   {
  ------------------
  |  Branch (1495:7): [True: 152k, False: 40.0k]
  ------------------
 1496|   152k|			continue;
 1497|   152k|		}
 1498|  40.0k|		if (df->enumerated)
  ------------------
  |  Branch (1498:7): [True: 28.4k, False: 11.6k]
  ------------------
 1499|  28.4k|			continue;
 1500|       |		/* Enumerate the DF's, so p15card->obj_list is populated. */
 1501|  11.6k|		if (p15card->ops.parse_df)
  ------------------
  |  Branch (1501:7): [True: 6, False: 11.6k]
  ------------------
 1502|      6|			r = p15card->ops.parse_df(p15card, df);
 1503|  11.6k|		else
 1504|  11.6k|			r = sc_pkcs15_parse_df(p15card, df);
 1505|  11.6k|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|  11.6k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1505:7): [True: 11.6k, False: 31]
  ------------------
 1506|  11.6k|			continue;
 1507|  11.6k|	}
 1508|       |
 1509|       |	/* And now loop over all objects */
 1510|   730k|	for (obj = p15card->obj_list; obj != NULL; obj = obj->next) {
  ------------------
  |  Branch (1510:32): [True: 620k, False: 109k]
  ------------------
 1511|       |		/* Check object type */
 1512|   620k|		if (!(class_mask & SC_PKCS15_TYPE_TO_CLASS(obj->type)))
  ------------------
  |  |  449|   620k|#define SC_PKCS15_TYPE_TO_CLASS(t)		(1 << ((t) >> 8))
  ------------------
  |  Branch (1512:7): [True: 543k, False: 77.0k]
  ------------------
 1513|   543k|			continue;
 1514|  77.0k|		if (type != 0
  ------------------
  |  Branch (1514:7): [True: 76.6k, False: 468]
  ------------------
 1515|  76.6k|		 && obj->type != type
  ------------------
  |  Branch (1515:7): [True: 20.7k, False: 55.8k]
  ------------------
 1516|  20.7k|		 && (obj->type & SC_PKCS15_TYPE_CLASS_MASK) != type)
  ------------------
  |  |  416|  20.7k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (1516:7): [True: 19.3k, False: 1.46k]
  ------------------
 1517|  19.3k|			continue;
 1518|       |
 1519|       |		/* Potential candidate, apply search function */
 1520|  57.7k|		if (func != NULL && func(obj, func_arg) <= 0)
  ------------------
  |  Branch (1520:7): [True: 3.19k, False: 54.5k]
  |  Branch (1520:23): [True: 2.43k, False: 754]
  ------------------
 1521|  2.43k|			continue;
 1522|       |		/* Okay, we have a match. */
 1523|  55.3k|		match_count++;
 1524|  55.3k|		if (!ret || ret_size <= 0)
  ------------------
  |  Branch (1524:7): [True: 468, False: 54.8k]
  |  Branch (1524:15): [True: 0, False: 54.8k]
  ------------------
 1525|    468|			continue;
 1526|  54.8k|		ret[match_count-1] = obj;
 1527|  54.8k|		if (ret_size <= match_count)
  ------------------
  |  Branch (1527:7): [True: 286, False: 54.5k]
  ------------------
 1528|    286|			break;
 1529|  54.8k|	}
 1530|       |
 1531|   109k|	return (int)match_count;
 1532|   109k|}
pkcs15.c:compare_obj_key:
 1677|  3.19k|{
 1678|  3.19k|	struct sc_pkcs15_search_key *sk = (struct sc_pkcs15_search_key *) arg;
 1679|       |
 1680|  3.19k|	if (sk->id && !compare_obj_id(obj, sk->id))
  ------------------
  |  Branch (1680:6): [True: 1.46k, False: 1.72k]
  |  Branch (1680:16): [True: 1.29k, False: 174]
  ------------------
 1681|  1.29k|		return 0;
 1682|  1.89k|	if (sk->app_oid && !sc_obj_app_oid(obj, sk->app_oid))
  ------------------
  |  Branch (1682:6): [True: 0, False: 1.89k]
  |  Branch (1682:21): [True: 0, False: 0]
  ------------------
 1683|      0|		return 0;
 1684|  1.89k|	if (sk->usage_mask && !compare_obj_usage(obj, sk->usage_mask, sk->usage_value))
  ------------------
  |  Branch (1684:6): [True: 0, False: 1.89k]
  |  Branch (1684:24): [True: 0, False: 0]
  ------------------
 1685|      0|		return 0;
 1686|  1.89k|	if (sk->flags_mask && !compare_obj_flags(obj, sk->flags_mask, sk->flags_value))
  ------------------
  |  Branch (1686:6): [True: 1.25k, False: 642]
  |  Branch (1686:24): [True: 1.14k, False: 112]
  ------------------
 1687|  1.14k|		return 0;
 1688|    754|	if (sk->match_reference && !compare_obj_reference(obj, sk->reference))
  ------------------
  |  Branch (1688:6): [True: 0, False: 754]
  |  Branch (1688:29): [True: 0, False: 0]
  ------------------
 1689|      0|		return 0;
 1690|    754|	if (sk->path && !compare_obj_path(obj, sk->path))
  ------------------
  |  Branch (1690:6): [True: 0, False: 754]
  |  Branch (1690:18): [True: 0, False: 0]
  ------------------
 1691|      0|		return 0;
 1692|    754|	if (sk->app_label) {
  ------------------
  |  Branch (1692:6): [True: 0, False: 754]
  ------------------
 1693|      0|		if (sk->label && !compare_obj_data_name(obj, sk->app_label, sk->label))
  ------------------
  |  Branch (1693:7): [True: 0, False: 0]
  |  Branch (1693:20): [True: 0, False: 0]
  ------------------
 1694|      0|			return 0;
 1695|    754|	} else {
 1696|    754|		if (sk->label && strncmp(sk->label, obj->label, sizeof(obj->label)) != 0)
  ------------------
  |  Branch (1696:7): [True: 0, False: 754]
  |  Branch (1696:20): [True: 0, False: 0]
  ------------------
 1697|      0|			return 0;
 1698|    754|	}
 1699|       |
 1700|    754|	return 1;
 1701|    754|}
pkcs15.c:compare_obj_id:
 1545|  1.46k|{
 1546|  1.46k|	void *data = obj->data;
 1547|       |
 1548|  1.46k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  1.46k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (1548:10): [True: 1.46k, False: 0]
  ------------------
 1549|  1.44k|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|  1.44k|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1549:2): [True: 1.44k, False: 17]
  ------------------
 1550|  1.44k|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_cert_info *) data)->id, id);
 1551|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1551:2): [True: 0, False: 1.46k]
  ------------------
 1552|      0|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_prkey_info *) data)->id, id);
 1553|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1553:2): [True: 0, False: 1.46k]
  ------------------
 1554|      0|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_pubkey_info *) data)->id, id);
 1555|      0|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (1555:2): [True: 0, False: 1.46k]
  ------------------
 1556|      0|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_skey_info *) data)->id, id);
 1557|     17|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|     17|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (1557:2): [True: 17, False: 1.44k]
  ------------------
 1558|     17|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_auth_info *) data)->auth_id, id);
 1559|      0|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (1559:2): [True: 0, False: 1.46k]
  ------------------
 1560|      0|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_data_info *) data)->id, id);
 1561|  1.46k|	}
 1562|      0|	return 0;
 1563|  1.46k|}
pkcs15.c:compare_obj_flags:
 1597|  1.25k|{
 1598|  1.25k|	struct sc_pkcs15_auth_info *auth_info;
 1599|  1.25k|	unsigned int	flags;
 1600|       |
 1601|  1.25k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  1.25k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 1602|  1.25k|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|  1.25k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (1602:2): [True: 1.25k, False: 0]
  ------------------
 1603|  1.25k|		auth_info = (struct sc_pkcs15_auth_info *) obj->data;
 1604|  1.25k|		if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.25k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1604:7): [True: 0, False: 1.25k]
  ------------------
 1605|      0|			return 0;
 1606|  1.25k|		flags = auth_info->attrs.pin.flags;
 1607|  1.25k|		break;
 1608|      0|	default:
  ------------------
  |  Branch (1608:2): [True: 0, False: 1.25k]
  ------------------
 1609|      0|		return 0;
 1610|  1.25k|	}
 1611|  1.25k|	return !((flags ^ value) & mask);
 1612|  1.25k|}
pkcs15.c:find_by_key:
 1707|  1.02k|{
 1708|  1.02k|	int r;
 1709|       |
 1710|  1.02k|	r = sc_pkcs15_get_objects_cond(p15card, type, compare_obj_key, sk, out, 1);
 1711|  1.02k|	if (r < 0)
  ------------------
  |  Branch (1711:6): [True: 0, False: 1.02k]
  ------------------
 1712|      0|		return r;
 1713|  1.02k|	if (r == 0)
  ------------------
  |  Branch (1713:6): [True: 916, False: 112]
  ------------------
 1714|    916|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    916|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1715|    112|	return 0;
 1716|  1.02k|}
pkcs15.c:sc_pkcs15_remove_objects:
 2021|  36.6k|{
 2022|  36.6k|	struct sc_pkcs15_object *cur = NULL, *next = NULL;
 2023|       |
 2024|  36.6k|	if (!p15card || !p15card->obj_list)
  ------------------
  |  Branch (2024:6): [True: 0, False: 36.6k]
  |  Branch (2024:18): [True: 31.4k, False: 5.24k]
  ------------------
 2025|  31.4k|		return;
 2026|  45.3k|	for (cur = p15card->obj_list; cur; cur = next)   {
  ------------------
  |  Branch (2026:32): [True: 40.0k, False: 5.24k]
  ------------------
 2027|  40.0k|		next = cur->next;
 2028|  40.0k|		sc_pkcs15_free_object(cur);
 2029|  40.0k|	}
 2030|       |
 2031|       |	p15card->obj_list = NULL;
 2032|  5.24k|}
pkcs15.c:sc_pkcs15_remove_dfs:
 2102|  36.6k|{
 2103|  36.6k|	struct sc_pkcs15_df *cur = NULL, *next = NULL;
 2104|       |
 2105|  36.6k|	if (!p15card || !p15card->df_list)
  ------------------
  |  Branch (2105:6): [True: 0, False: 36.6k]
  |  Branch (2105:18): [True: 31.1k, False: 5.48k]
  ------------------
 2106|  31.1k|		return;
 2107|       |
 2108|  17.7k|	for (cur = p15card->df_list; cur; cur = next)   {
  ------------------
  |  Branch (2108:31): [True: 12.2k, False: 5.48k]
  ------------------
 2109|  12.2k|		next = cur->next;
 2110|  12.2k|		free(cur);
 2111|  12.2k|	}
 2112|       |
 2113|       |	p15card->df_list = NULL;
 2114|  5.48k|}
pkcs15.c:sc_pkcs15_free_unusedspace:
 2337|  16.6k|{
 2338|  16.6k|	struct sc_pkcs15_unusedspace *cur = NULL, *next = NULL;
 2339|       |
 2340|  16.6k|	if (!p15card || !p15card->unusedspace_list)
  ------------------
  |  Branch (2340:6): [True: 0, False: 16.6k]
  |  Branch (2340:18): [True: 16.6k, False: 0]
  ------------------
 2341|  16.6k|		return;
 2342|      0|	for (cur = p15card->unusedspace_list; cur; cur = next)   {
  ------------------
  |  Branch (2342:40): [True: 0, False: 0]
  ------------------
 2343|      0|		next = cur->next;
 2344|      0|		free(cur);
 2345|      0|	}
 2346|       |
 2347|       |	p15card->unusedspace_list = NULL;
 2348|      0|}
pkcs15.c:decompress_file:
 2477|    195|{
 2478|    195|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    195|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    195|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    195|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    195|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 195]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2479|    195|#ifdef ENABLE_ZLIB
 2480|    195|	int rv = SC_SUCCESS;
  ------------------
  |  |   28|    195|#define SC_SUCCESS				0
  ------------------
 2481|    195|	int method = 0;
 2482|       |
 2483|    195|	if (flags & SC_FILE_FLAG_COMPRESSED_GZIP) {
  ------------------
  |  |  232|    195|#define SC_FILE_FLAG_COMPRESSED_GZIP		0x04
  ------------------
  |  Branch (2483:6): [True: 0, False: 195]
  ------------------
 2484|      0|		method = COMPRESSION_GZIP;
  ------------------
  |  |   28|      0|#define COMPRESSION_GZIP	2
  ------------------
 2485|    195|	} else if (flags & SC_FILE_FLAG_COMPRESSED_ZLIB) {
  ------------------
  |  |  231|    195|#define SC_FILE_FLAG_COMPRESSED_ZLIB		0x02
  ------------------
  |  Branch (2485:13): [True: 0, False: 195]
  ------------------
 2486|      0|		method = COMPRESSION_ZLIB;
  ------------------
  |  |   27|      0|#define COMPRESSION_ZLIB	1
  ------------------
 2487|    195|	} else {
 2488|    195|		method = COMPRESSION_AUTO;
  ------------------
  |  |   26|    195|#define COMPRESSION_AUTO	0
  ------------------
 2489|    195|	}
 2490|       |
 2491|    195|	rv = sc_decompress_alloc(out, outlen, buf, buflen, method);
 2492|    195|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    195|#define SC_SUCCESS				0
  ------------------
  |  Branch (2492:6): [True: 195, False: 0]
  ------------------
 2493|    195|		sc_log(card->ctx,  "Decompression failed: %d", rv);
  ------------------
  |  |   71|    195|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2494|    195|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_DATA);
  ------------------
  |  |  164|    195|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    195|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    195|	int _ret = r; \
  |  |  |  |  155|    195|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 195, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    195|		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|    195|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 195, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    195|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    195|	} 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|    195|	return _ret; \
  |  |  |  |  163|    195|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2495|    195|	}
 2496|      0|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2497|       |#else
 2498|       |	sc_log(card->ctx, "Compression not supported, no zlib");
 2499|       |	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
 2500|       |#endif
 2501|      0|}

sc_get_ctapi_driver:
  557|  17.0k|{
  558|  17.0k|	ctapi_ops.init = ctapi_init;
  559|  17.0k|	ctapi_ops.finish = ctapi_finish;
  560|  17.0k|	ctapi_ops.detect_readers = NULL;
  561|  17.0k|	ctapi_ops.transmit = ctapi_transmit;
  562|  17.0k|	ctapi_ops.detect_card_presence = ctapi_detect_card_presence;
  563|  17.0k|	ctapi_ops.lock = ctapi_lock;
  564|  17.0k|	ctapi_ops.unlock = ctapi_unlock;
  565|  17.0k|	ctapi_ops.release = ctapi_release;
  566|  17.0k|	ctapi_ops.connect = ctapi_connect;
  567|  17.0k|	ctapi_ops.disconnect = ctapi_disconnect;
  568|  17.0k|	ctapi_ops.perform_verify = ctbcs_pin_cmd;
  569|  17.0k|	ctapi_ops.perform_pace = NULL;
  570|  17.0k|	ctapi_ops.use_reader = NULL;
  571|       |
  572|  17.0k|	return &ctapi_drv;
  573|  17.0k|}
reader-ctapi.c:ctapi_init:
  514|  17.0k|{
  515|  17.0k|	int i;
  516|  17.0k|	struct ctapi_global_private_data *gpriv;
  517|  17.0k|	scconf_block **blocks = NULL, *conf_block = NULL;
  518|       |
  519|  17.0k|	gpriv = calloc(1, sizeof(struct ctapi_global_private_data));
  520|  17.0k|	if (gpriv == NULL)
  ------------------
  |  Branch (520:6): [True: 0, False: 17.0k]
  ------------------
  521|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  522|  17.0k|	ctx->reader_drv_data = gpriv;
  523|       |
  524|  17.0k|	conf_block = sc_get_conf_block(ctx, "reader_driver", "ctapi", 1);
  525|  17.0k|	if (conf_block)   {
  ------------------
  |  Branch (525:6): [True: 0, False: 17.0k]
  ------------------
  526|      0|		blocks = scconf_find_blocks(ctx->conf, conf_block, "module", NULL);
  527|      0|		for (i = 0; blocks != NULL && blocks[i] != NULL; i++)
  ------------------
  |  Branch (527:15): [True: 0, False: 0]
  |  Branch (527:33): [True: 0, False: 0]
  ------------------
  528|      0|			ctapi_load_module(ctx, gpriv, blocks[i]);
  529|      0|		free(blocks);
  530|      0|	}
  531|       |
  532|  17.0k|	return 0;
  533|  17.0k|}
reader-ctapi.c:ctapi_finish:
  536|  17.0k|{
  537|  17.0k|	struct ctapi_global_private_data *priv = (struct ctapi_global_private_data *) ctx->reader_drv_data;
  538|       |
  539|  17.0k|	if (priv) {
  ------------------
  |  Branch (539:6): [True: 17.0k, False: 0]
  ------------------
  540|  17.0k|		int i;
  541|       |
  542|  17.0k|		for (i = 0; i < priv->module_count; i++) {
  ------------------
  |  Branch (542:15): [True: 0, False: 17.0k]
  ------------------
  543|      0|			struct ctapi_module *mod = &priv->modules[i];
  544|       |
  545|      0|			free(mod->name);
  546|      0|			sc_dlclose(mod->dlhandle);
  547|      0|		}
  548|  17.0k|		if (priv->module_count)
  ------------------
  |  Branch (548:7): [True: 0, False: 17.0k]
  ------------------
  549|      0|			free(priv->modules);
  550|  17.0k|		free(priv);
  551|  17.0k|	}
  552|       |
  553|  17.0k|	return 0;
  554|  17.0k|}

openssl.c:sc_evp_md:
  118|  42.0k|{
  119|  42.0k|	return (EVP_MD *)EVP_get_digestbyname(algorithm);
  120|  42.0k|}
openssl.c:sc_evp_md_free:
  123|  84.1k|{
  124|  84.1k|	return;
  125|  84.1k|}
openssl.c:sc_evp_pkey_ctx_new:
  128|     18|{
  129|       |	return EVP_PKEY_CTX_new(pkey, NULL);
  130|     18|}
card-epass2003.c:sc_evp_cipher:
  133|  2.32k|{
  134|  2.32k|	return (EVP_CIPHER *)EVP_get_cipherbyname(algorithm);
  135|  2.32k|}
card-epass2003.c:sc_evp_cipher_free:
  138|  2.32k|{
  139|  2.32k|	return;
  140|  2.32k|}

sc_get_version:
   58|  17.0k|{
   59|  17.0k|    return sc_version;
   60|  17.0k|}
sc_hex_to_bin:
   63|   424k|{
   64|   424k|	const char *sc_hex_to_bin_separators = " :";
   65|   424k|	if (in == NULL || out == NULL || outlen == NULL) {
  ------------------
  |  Branch (65:6): [True: 164, False: 423k]
  |  Branch (65:20): [True: 0, False: 423k]
  |  Branch (65:35): [True: 0, False: 423k]
  ------------------
   66|    164|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    164|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   67|    164|	}
   68|       |
   69|   423k|	int byte_needs_nibble = 0;
   70|   423k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|   423k|#define SC_SUCCESS				0
  ------------------
   71|   423k|	size_t left = *outlen;
   72|   423k|	u8 byte = 0;
   73|  6.43M|	while (*in != '\0' && 0 != left) {
  ------------------
  |  Branch (73:9): [True: 6.01M, False: 423k]
  |  Branch (73:24): [True: 6.01M, False: 0]
  ------------------
   74|  6.01M|		char c = *in++;
   75|  6.01M|		u8 nibble;
   76|  6.01M|		if      ('0' <= c && c <= '9')
  ------------------
  |  Branch (76:12): [True: 6.01M, False: 0]
  |  Branch (76:24): [True: 3.24M, False: 2.76M]
  ------------------
   77|  3.24M|			nibble = c - '0';
   78|  2.76M|		else if ('a' <= c && c <= 'f')
  ------------------
  |  Branch (78:12): [True: 538k, False: 2.22M]
  |  Branch (78:24): [True: 538k, False: 0]
  ------------------
   79|   538k|			nibble = c - 'a' + 10;
   80|  2.22M|		else if ('A' <= c && c <= 'F')
  ------------------
  |  Branch (80:12): [True: 778k, False: 1.44M]
  |  Branch (80:24): [True: 778k, False: 0]
  ------------------
   81|   778k|			nibble = c - 'A' + 10;
   82|  1.44M|		else {
   83|  1.44M|			if (strchr(sc_hex_to_bin_separators, (int) c)) {
  ------------------
  |  Branch (83:8): [True: 1.44M, False: 0]
  ------------------
   84|  1.44M|				if (byte_needs_nibble) {
  ------------------
  |  Branch (84:9): [True: 0, False: 1.44M]
  ------------------
   85|      0|					r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   86|      0|					goto err;
   87|      0|				}
   88|  1.44M|				continue;
   89|  1.44M|			}
   90|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   91|      0|			goto err;
   92|  1.44M|		}
   93|       |
   94|  4.56M|		if (byte_needs_nibble) {
  ------------------
  |  Branch (94:7): [True: 2.27M, False: 2.28M]
  ------------------
   95|  2.27M|			byte |= nibble;
   96|  2.27M|			*out++ = (u8) byte;
   97|  2.27M|			left--;
   98|  2.27M|			byte_needs_nibble = 0;
   99|  2.28M|		} else {
  100|  2.28M|			byte  = nibble << 4;
  101|  2.28M|			byte_needs_nibble = 1;
  102|  2.28M|		}
  103|  4.56M|	}
  104|       |
  105|   423k|	if (left == *outlen && 1 == byte_needs_nibble && 0 != left) {
  ------------------
  |  Branch (105:6): [True: 12.6k, False: 411k]
  |  Branch (105:25): [True: 6.72k, False: 5.89k]
  |  Branch (105:51): [True: 6.72k, False: 0]
  ------------------
  106|       |		/* no output written so far, but we have a valid nibble in the upper
  107|       |		 * bits. Allow this special case. */
  108|  6.72k|		*out = (u8) byte>>4;
  109|  6.72k|		left--;
  110|  6.72k|		byte_needs_nibble = 0;
  111|  6.72k|	}
  112|       |
  113|       |	/* for ease of implementation we only accept completely hexed bytes. */
  114|   423k|	if (byte_needs_nibble) {
  ------------------
  |  Branch (114:6): [True: 0, False: 423k]
  ------------------
  115|      0|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  116|      0|		goto err;
  117|      0|	}
  118|       |
  119|       |	/* skip all trailing separators to see if we missed something */
  120|   423k|	while (*in != '\0') {
  ------------------
  |  Branch (120:9): [True: 0, False: 423k]
  ------------------
  121|      0|		if (NULL == strchr(sc_hex_to_bin_separators, (int) *in))
  ------------------
  |  Branch (121:7): [True: 0, False: 0]
  ------------------
  122|      0|			break;
  123|      0|		in++;
  124|      0|	}
  125|   423k|	if (*in != '\0') {
  ------------------
  |  Branch (125:6): [True: 0, False: 423k]
  ------------------
  126|      0|		r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  127|      0|		goto err;
  128|      0|	}
  129|       |
  130|   423k|err:
  131|   423k|	*outlen -= left;
  132|   423k|	return r;
  133|   423k|}
sc_bin_to_hex:
  137|   399k|{
  138|   399k|	if (in == NULL || out == NULL) {
  ------------------
  |  Branch (138:6): [True: 0, False: 399k]
  |  Branch (138:20): [True: 0, False: 399k]
  ------------------
  139|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  140|      0|	}
  141|       |
  142|   399k|	if (in_sep > 0) {
  ------------------
  |  Branch (142:6): [True: 377k, False: 21.4k]
  ------------------
  143|   377k|		if (out_len < in_len*3 || out_len < 1)
  ------------------
  |  Branch (143:7): [True: 0, False: 377k]
  |  Branch (143:29): [True: 0, False: 377k]
  ------------------
  144|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  145|   377k|	} else {
  146|  21.4k|		if (out_len < in_len*2 + 1)
  ------------------
  |  Branch (146:7): [True: 11, False: 21.4k]
  ------------------
  147|     11|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|     11|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  148|  21.4k|	}
  149|       |
  150|   399k|	const char hex[] = "0123456789abcdef";
  151|  3.88M|	while (in_len) {
  ------------------
  |  Branch (151:9): [True: 3.48M, False: 399k]
  ------------------
  152|  3.48M|		unsigned char value = *in++;
  153|  3.48M|		*out++ = hex[(value >> 4) & 0xF];
  154|  3.48M|		*out++ = hex[ value       & 0xF];
  155|  3.48M|		in_len--;
  156|  3.48M|		if (in_len && in_sep > 0)
  ------------------
  |  Branch (156:7): [True: 3.24M, False: 240k]
  |  Branch (156:17): [True: 3.22M, False: 18.0k]
  ------------------
  157|  3.22M|			*out++ = (char)in_sep;
  158|  3.48M|	}
  159|   399k|	*out = '\0';
  160|       |
  161|   399k|	return SC_SUCCESS;
  ------------------
  |  |   28|   399k|#define SC_SUCCESS				0
  ------------------
  162|   399k|}
ulong2bebytes:
  188|  67.2k|{
  189|  67.2k|	if (buf != NULL) {
  ------------------
  |  Branch (189:6): [True: 67.2k, False: 0]
  ------------------
  190|  67.2k|		buf[3] = (u8) (x & 0xff);
  191|  67.2k|		buf[2] = (u8) ((x >> 8) & 0xff);
  192|  67.2k|		buf[1] = (u8) ((x >> 16) & 0xff);
  193|  67.2k|		buf[0] = (u8) ((x >> 24) & 0xff);
  194|  67.2k|	}
  195|  67.2k|	return buf;
  196|  67.2k|}
ushort2bebytes:
  199|     68|{
  200|     68|	if (buf != NULL) {
  ------------------
  |  Branch (200:6): [True: 68, False: 0]
  ------------------
  201|     68|		buf[1] = (u8) (x & 0xff);
  202|     68|		buf[0] = (u8) ((x >> 8) & 0xff);
  203|     68|	}
  204|     68|	return buf;
  205|     68|}
bebytes2ulong:
  208|   122k|{
  209|   122k|	if (buf == NULL)
  ------------------
  |  Branch (209:6): [True: 0, False: 122k]
  ------------------
  210|      0|		return 0UL;
  211|   122k|	return (unsigned long)buf[0] << 24
  212|   122k|		| (unsigned long)buf[1] << 16
  213|   122k|		| (unsigned long)buf[2] << 8
  214|   122k|		| (unsigned long)buf[3];
  215|   122k|}
bebytes2ushort:
  218|   145k|{
  219|   145k|	if (buf == NULL)
  ------------------
  |  Branch (219:6): [True: 0, False: 145k]
  ------------------
  220|      0|		return 0U;
  221|   145k|	return (unsigned short)buf[0] << 8
  222|   145k|		| (unsigned short)buf[1];
  223|   145k|}
lebytes2ushort:
  226|  3.93k|{
  227|  3.93k|	if (buf == NULL)
  ------------------
  |  Branch (227:6): [True: 0, False: 3.93k]
  ------------------
  228|      0|		return 0U;
  229|  3.93k|	return (unsigned short)buf[1] << 8
  230|  3.93k|		| (unsigned short)buf[0];
  231|  3.93k|}
lebytes2ulong:
  234|    866|{
  235|    866|	if (buf == NULL)
  ------------------
  |  Branch (235:6): [True: 0, False: 866]
  ------------------
  236|      0|		return 0UL;
  237|    866|	return (unsigned long)buf[3] << 24
  238|    866|		| (unsigned long)buf[2] << 16
  239|    866|		| (unsigned long)buf[1] << 8
  240|    866|		| (unsigned long)buf[0];
  241|    866|}
set_string:
  244|  16.5k|{
  245|  16.5k|	if (strp == NULL) {
  ------------------
  |  Branch (245:6): [True: 0, False: 16.5k]
  ------------------
  246|      0|		return;
  247|      0|	}
  248|       |
  249|  16.5k|	free(*strp);
  250|  16.5k|	*strp = value ? strdup(value) : NULL;
  ------------------
  |  Branch (250:10): [True: 16.5k, False: 0]
  ------------------
  251|  16.5k|}
sc_init_oid:
  254|  73.9k|{
  255|  73.9k|	int ii;
  256|       |
  257|  73.9k|	if (!oid)
  ------------------
  |  Branch (257:6): [True: 0, False: 73.9k]
  ------------------
  258|      0|		return;
  259|  1.25M|	for (ii=0; ii<SC_MAX_OBJECT_ID_OCTETS; ii++)
  ------------------
  |  |   46|  1.25M|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (259:13): [True: 1.18M, False: 73.9k]
  ------------------
  260|  1.18M|		oid->value[ii] = -1;
  261|  73.9k|}
sc_format_oid:
  264|  29.7k|{
  265|  29.7k|	int        ii, ret = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  29.7k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  266|  29.7k|	const char *p;
  267|  29.7k|	char       *q;
  268|       |
  269|  29.7k|	if (oid == NULL || in == NULL)
  ------------------
  |  Branch (269:6): [True: 0, False: 29.7k]
  |  Branch (269:21): [True: 0, False: 29.7k]
  ------------------
  270|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  271|       |
  272|  29.7k|	sc_init_oid(oid);
  273|       |
  274|  29.7k|	p = in;
  275|   269k|	for (ii=0; ii < SC_MAX_OBJECT_ID_OCTETS; ii++)   {
  ------------------
  |  |   46|   269k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (275:13): [True: 269k, False: 0]
  ------------------
  276|   269k|		oid->value[ii] = (int)strtol(p, &q, 10);
  277|   269k|		if (!*q)
  ------------------
  |  Branch (277:7): [True: 29.7k, False: 239k]
  ------------------
  278|  29.7k|			break;
  279|       |
  280|   239k|		if (!(q[0] == '.' && isdigit((unsigned char)q[1])))
  ------------------
  |  Branch (280:9): [True: 239k, False: 0]
  |  Branch (280:24): [True: 239k, False: 0]
  ------------------
  281|      0|			goto out;
  282|       |
  283|   239k|		p = q + 1;
  284|   239k|	}
  285|       |
  286|  29.7k|	if (!sc_valid_oid(oid))
  ------------------
  |  Branch (286:6): [True: 0, False: 29.7k]
  ------------------
  287|      0|		goto out;
  288|       |
  289|  29.7k|	ret = SC_SUCCESS;
  ------------------
  |  |   28|  29.7k|#define SC_SUCCESS				0
  ------------------
  290|  29.7k|out:
  291|  29.7k|	if (ret)
  ------------------
  |  Branch (291:6): [True: 0, False: 29.7k]
  ------------------
  292|      0|		sc_init_oid(oid);
  293|       |
  294|  29.7k|	return ret;
  295|  29.7k|}
sc_compare_oid:
  298|   130k|{
  299|   130k|	int i;
  300|       |
  301|   130k|	if (oid1 == NULL || oid2 == NULL) {
  ------------------
  |  Branch (301:6): [True: 0, False: 130k]
  |  Branch (301:22): [True: 0, False: 130k]
  ------------------
  302|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  303|      0|	}
  304|       |
  305|   385k|	for (i = 0; i < SC_MAX_OBJECT_ID_OCTETS; i++)   {
  ------------------
  |  |   46|   385k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (305:14): [True: 385k, False: 0]
  ------------------
  306|   385k|		if (oid1->value[i] != oid2->value[i])
  ------------------
  |  Branch (306:7): [True: 125k, False: 259k]
  ------------------
  307|   125k|			return 0;
  308|   259k|		if (oid1->value[i] == -1)
  ------------------
  |  Branch (308:7): [True: 4.89k, False: 255k]
  ------------------
  309|  4.89k|			break;
  310|   259k|	}
  311|       |
  312|  4.89k|	return 1;
  313|   130k|}
sc_valid_oid:
  317|  33.1k|{
  318|  33.1k|	int ii;
  319|       |
  320|  33.1k|	if (!oid)
  ------------------
  |  Branch (320:6): [True: 0, False: 33.1k]
  ------------------
  321|      0|		return 0;
  322|  33.1k|	if (oid->value[0] == -1 || oid->value[1] == -1)
  ------------------
  |  Branch (322:6): [True: 2, False: 33.1k]
  |  Branch (322:29): [True: 0, False: 33.1k]
  ------------------
  323|      2|		return 0;
  324|  33.1k|	if (oid->value[0] > 2 || oid->value[1] > 39)
  ------------------
  |  Branch (324:6): [True: 0, False: 33.1k]
  |  Branch (324:27): [True: 0, False: 33.1k]
  ------------------
  325|      0|		return 0;
  326|  33.1k|	for (ii=0;ii<SC_MAX_OBJECT_ID_OCTETS;ii++)
  ------------------
  |  |   46|  33.1k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (326:12): [True: 33.1k, False: 0]
  ------------------
  327|  33.1k|		if (oid->value[ii])
  ------------------
  |  Branch (327:7): [True: 33.1k, False: 0]
  ------------------
  328|  33.1k|			break;
  329|  33.1k|	if (ii==SC_MAX_OBJECT_ID_OCTETS)
  ------------------
  |  |   46|  33.1k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (329:6): [True: 0, False: 33.1k]
  ------------------
  330|      0|		return 0;
  331|  33.1k|	return 1;
  332|  33.1k|}
sc_detect_card_presence:
  336|  1.30k|{
  337|  1.30k|	int r;
  338|  1.30k|	LOG_FUNC_CALLED(reader->ctx);
  ------------------
  |  |  151|  1.30k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.30k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.30k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.30k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  339|  1.30k|	if (reader->ops->detect_card_presence == NULL)
  ------------------
  |  Branch (339:6): [True: 1.30k, False: 0]
  ------------------
  340|  1.30k|		LOG_FUNC_RETURN(reader->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|  1.30k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.30k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.30k|	int _ret = r; \
  |  |  |  |  155|  1.30k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.30k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.30k|		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|  1.30k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.30k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.30k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.30k|	} 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|  1.30k|	return _ret; \
  |  |  |  |  163|  1.30k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|       |
  342|      0|	r = reader->ops->detect_card_presence(reader);
  343|       |
  344|       |	// Check that we get sane return value from backend
  345|       |	// detect_card_presence should return 0 if no card is present.
  346|      0|	if (r && !(r & SC_READER_CARD_PRESENT))
  ------------------
  |  |  366|      0|#define SC_READER_CARD_PRESENT		0x00000001
  ------------------
  |  Branch (346:6): [True: 0, False: 0]
  |  Branch (346:11): [True: 0, False: 0]
  ------------------
  347|      0|		LOG_FUNC_RETURN(reader->ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  348|       |
  349|      0|	LOG_FUNC_RETURN(reader->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|      0|}
sc_path_set:
  354|  26.7k|{
  355|  26.7k|	if (path == NULL || id == NULL || id_len == 0 || id_len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  26.7k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (355:6): [True: 0, False: 26.7k]
  |  Branch (355:22): [True: 0, False: 26.7k]
  |  Branch (355:36): [True: 0, False: 26.7k]
  |  Branch (355:51): [True: 0, False: 26.7k]
  ------------------
  356|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  357|       |
  358|  26.7k|	memset(path, 0, sizeof(*path));
  359|  26.7k|	memcpy(path->value, id, id_len);
  360|  26.7k|	path->len   = id_len;
  361|  26.7k|	path->type  = type;
  362|  26.7k|	path->index = idx;
  363|  26.7k|	path->count = count;
  364|       |
  365|  26.7k|	return SC_SUCCESS;
  ------------------
  |  |   28|  26.7k|#define SC_SUCCESS				0
  ------------------
  366|  26.7k|}
sc_format_path:
  369|   190k|{
  370|   190k|	int type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|   190k|#define SC_PATH_TYPE_PATH		2
  ------------------
  371|       |
  372|   190k|	if (path) {
  ------------------
  |  Branch (372:6): [True: 190k, False: 0]
  ------------------
  373|   190k|		memset(path, 0, sizeof(*path));
  374|   190k|		if (*str == 'i' || *str == 'I') {
  ------------------
  |  Branch (374:7): [True: 90, False: 190k]
  |  Branch (374:22): [True: 0, False: 190k]
  ------------------
  375|     90|			type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     90|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  376|     90|			str++;
  377|     90|		}
  378|   190k|		path->len = sizeof(path->value);
  379|   190k|		if (sc_hex_to_bin(str, path->value, &path->len) >= 0) {
  ------------------
  |  Branch (379:7): [True: 190k, False: 0]
  ------------------
  380|   190k|			path->type = type;
  381|   190k|		}
  382|   190k|		path->count = -1;
  383|   190k|	}
  384|   190k|}
sc_append_path_id:
  392|  36.9k|{
  393|  36.9k|	if (dest->len + idlen > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  36.9k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (393:6): [True: 0, False: 36.9k]
  ------------------
  394|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  395|  36.9k|	memcpy(dest->value + dest->len, id, idlen);
  396|  36.9k|	dest->len += idlen;
  397|  36.9k|	return SC_SUCCESS;
  ------------------
  |  |   28|  36.9k|#define SC_SUCCESS				0
  ------------------
  398|  36.9k|}
sc_append_file_id:
  401|  36.9k|{
  402|  36.9k|	u8 id[2] = { fid >> 8, fid & 0xff };
  403|       |
  404|  36.9k|	return sc_append_path_id(dest, id, 2);
  405|  36.9k|}
sc_concatenate_path:
  408|  19.7k|{
  409|  19.7k|	sc_path_t tpath;
  410|       |
  411|  19.7k|	if (d == NULL || p1 == NULL || p2 == NULL)
  ------------------
  |  Branch (411:6): [True: 0, False: 19.7k]
  |  Branch (411:19): [True: 0, False: 19.7k]
  |  Branch (411:33): [True: 0, False: 19.7k]
  ------------------
  412|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  413|       |
  414|  19.7k|	if (p1->type == SC_PATH_TYPE_DF_NAME || p2->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  39.5k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
              	if (p1->type == SC_PATH_TYPE_DF_NAME || p2->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  19.7k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (414:6): [True: 0, False: 19.7k]
  |  Branch (414:42): [True: 0, False: 19.7k]
  ------------------
  415|       |		/* we do not support concatenation of AIDs at the moment */
  416|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  417|       |
  418|  19.7k|	if (p1->len + p2->len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  19.7k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (418:6): [True: 10, False: 19.7k]
  ------------------
  419|     10|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     10|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  420|       |
  421|  19.7k|	memset(&tpath, 0, sizeof(sc_path_t));
  422|  19.7k|	memcpy(tpath.value, p1->value, p1->len);
  423|  19.7k|	memcpy(tpath.value + p1->len, p2->value, p2->len);
  424|  19.7k|	tpath.len  = p1->len + p2->len;
  425|  19.7k|	tpath.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  19.7k|#define SC_PATH_TYPE_PATH		2
  ------------------
  426|       |	/* use 'index' and 'count' entry of the second path object */
  427|  19.7k|	tpath.index = p2->index;
  428|  19.7k|	tpath.count = p2->count;
  429|       |	/* the result is currently always as path */
  430|  19.7k|	tpath.type  = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  19.7k|#define SC_PATH_TYPE_PATH		2
  ------------------
  431|       |
  432|  19.7k|	*d = tpath;
  433|       |
  434|  19.7k|	return SC_SUCCESS;
  ------------------
  |  |   28|  19.7k|#define SC_SUCCESS				0
  ------------------
  435|  19.7k|}
sc_print_path:
  438|   265k|{
  439|   265k|	static char buffer[SC_MAX_PATH_STRING_SIZE + SC_MAX_AID_STRING_SIZE];
  440|       |
  441|   265k|	if (sc_path_print(buffer, sizeof(buffer), path) != SC_SUCCESS)
  ------------------
  |  |   28|   265k|#define SC_SUCCESS				0
  ------------------
  |  Branch (441:6): [True: 0, False: 265k]
  ------------------
  442|      0|		buffer[0] = '\0';
  443|       |
  444|   265k|	return buffer;
  445|   265k|}
sc_path_print:
  448|   384k|{
  449|   384k|	size_t i;
  450|       |
  451|   384k|	if (buf == NULL || path == NULL)
  ------------------
  |  Branch (451:6): [True: 0, False: 384k]
  |  Branch (451:21): [True: 0, False: 384k]
  ------------------
  452|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  453|       |
  454|   384k|	if (buflen < path->len * 2 + path->aid.len * 2 + 3)
  ------------------
  |  Branch (454:6): [True: 1.61k, False: 382k]
  ------------------
  455|  1.61k|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|  1.61k|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  456|       |
  457|   382k|	buf[0] = '\0';
  458|   382k|	if (path->aid.len)   {
  ------------------
  |  Branch (458:6): [True: 137k, False: 244k]
  ------------------
  459|  1.12M|		for (i = 0; i < path->aid.len; i++)
  ------------------
  |  Branch (459:15): [True: 983k, False: 137k]
  ------------------
  460|   983k|			snprintf(buf + strlen(buf), buflen - strlen(buf), "%02x", path->aid.value[i]);
  461|   137k|		snprintf(buf + strlen(buf), buflen - strlen(buf), "::");
  462|   137k|	}
  463|       |
  464|  1.59M|	for (i = 0; i < path->len; i++)
  ------------------
  |  Branch (464:14): [True: 1.21M, False: 382k]
  ------------------
  465|  1.21M|		snprintf(buf + strlen(buf), buflen - strlen(buf), "%02x", path->value[i]);
  466|   382k|	if (!path->aid.len && path->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|   244k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (466:6): [True: 244k, False: 137k]
  |  Branch (466:24): [True: 36.9k, False: 207k]
  ------------------
  467|  36.9k|		snprintf(buf + strlen(buf), buflen - strlen(buf), "::");
  468|       |
  469|   382k|	return SC_SUCCESS;
  ------------------
  |  |   28|   382k|#define SC_SUCCESS				0
  ------------------
  470|   384k|}
sc_compare_path:
  473|  18.6k|{
  474|  18.6k|	return path1->len == path2->len
  ------------------
  |  Branch (474:9): [True: 17.8k, False: 784]
  ------------------
  475|  17.8k|		&& !memcmp(path1->value, path2->value, path1->len);
  ------------------
  |  Branch (475:6): [True: 1.01k, False: 16.8k]
  ------------------
  476|  18.6k|}
sc_compare_path_prefix:
  479|  15.8k|{
  480|  15.8k|	sc_path_t tpath;
  481|       |
  482|  15.8k|	if (prefix->len > path->len)
  ------------------
  |  Branch (482:6): [True: 11, False: 15.8k]
  ------------------
  483|     11|		return 0;
  484|       |
  485|  15.8k|	tpath     = *path;
  486|  15.8k|	tpath.len = prefix->len;
  487|       |
  488|  15.8k|	return sc_compare_path(&tpath, prefix);
  489|  15.8k|}
sc_get_mf_path:
  492|  19.9k|{
  493|  19.9k|	static const sc_path_t mf_path = {
  494|  19.9k|		{0x3f, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 2,
  495|  19.9k|		0,
  496|  19.9k|		0,
  497|  19.9k|		SC_PATH_TYPE_PATH,
  ------------------
  |  |  119|  19.9k|#define SC_PATH_TYPE_PATH		2
  ------------------
  498|  19.9k|		{{0},0}
  499|  19.9k|	};
  500|  19.9k|	return &mf_path;
  501|  19.9k|}
sc_file_add_acl_entry:
  505|   171k|{
  506|   171k|	sc_acl_entry_t *p, *_new;
  507|       |
  508|   171k|	if (file == NULL || operation >= SC_MAX_AC_OPS) {
  ------------------
  |  |  198|   171k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (508:6): [True: 0, False: 171k]
  |  Branch (508:22): [True: 0, False: 171k]
  ------------------
  509|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  510|      0|	}
  511|       |
  512|   171k|	switch (method) {
  513|  48.4k|	case SC_AC_NEVER:
  ------------------
  |  |  163|  48.4k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (513:2): [True: 48.4k, False: 123k]
  ------------------
  514|  48.4k|		sc_file_clear_acl_entries(file, operation);
  515|  48.4k|		file->acl[operation] = (sc_acl_entry_t *) 1;
  516|  48.4k|		return SC_SUCCESS;
  ------------------
  |  |   28|  48.4k|#define SC_SUCCESS				0
  ------------------
  517|  31.5k|	case SC_AC_NONE:
  ------------------
  |  |  150|  31.5k|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (517:2): [True: 31.5k, False: 139k]
  ------------------
  518|  31.5k|		sc_file_clear_acl_entries(file, operation);
  519|  31.5k|		file->acl[operation] = (sc_acl_entry_t *) 2;
  520|  31.5k|		return SC_SUCCESS;
  ------------------
  |  |   28|  31.5k|#define SC_SUCCESS				0
  ------------------
  521|  1.55k|	case SC_AC_UNKNOWN:
  ------------------
  |  |  162|  1.55k|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  |  Branch (521:2): [True: 1.55k, False: 169k]
  ------------------
  522|  1.55k|		sc_file_clear_acl_entries(file, operation);
  523|  1.55k|		file->acl[operation] = (sc_acl_entry_t *) 3;
  524|  1.55k|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.55k|#define SC_SUCCESS				0
  ------------------
  525|  89.8k|	default:
  ------------------
  |  Branch (525:2): [True: 89.8k, False: 81.6k]
  ------------------
  526|       |		/* NONE and UNKNOWN get zapped when a new AC is added.
  527|       |		 * If the ACL is NEVER, additional entries will be
  528|       |		 * dropped silently. */
  529|  89.8k|		if (file->acl[operation] == (sc_acl_entry_t *) 1)
  ------------------
  |  Branch (529:7): [True: 13, False: 89.8k]
  ------------------
  530|     13|			return SC_SUCCESS;
  ------------------
  |  |   28|     13|#define SC_SUCCESS				0
  ------------------
  531|  89.8k|		if (file->acl[operation] == (sc_acl_entry_t *) 2
  ------------------
  |  Branch (531:7): [True: 1.25k, False: 88.6k]
  ------------------
  532|  88.6k|		 || file->acl[operation] == (sc_acl_entry_t *) 3)
  ------------------
  |  Branch (532:7): [True: 13, False: 88.5k]
  ------------------
  533|  1.26k|			file->acl[operation] = NULL;
  534|   171k|	}
  535|       |
  536|       |	/* If the entry is already present (e.g. due to the mapping)
  537|       |	 * of the card's AC with OpenSC's), don't add it again. */
  538|   124k|	for (p = file->acl[operation]; p != NULL; p = p->next) {
  ------------------
  |  Branch (538:33): [True: 37.9k, False: 86.8k]
  ------------------
  539|  37.9k|		if ((p->method == method) && (p->key_ref == key_ref))
  ------------------
  |  Branch (539:7): [True: 34.6k, False: 3.33k]
  |  Branch (539:32): [True: 3.02k, False: 31.6k]
  ------------------
  540|  3.02k|			return SC_SUCCESS;
  ------------------
  |  |   28|  3.02k|#define SC_SUCCESS				0
  ------------------
  541|  37.9k|	}
  542|       |
  543|  86.8k|	_new = malloc(sizeof(sc_acl_entry_t));
  544|  86.8k|	if (_new == NULL)
  ------------------
  |  Branch (544:6): [True: 0, False: 86.8k]
  ------------------
  545|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  546|  86.8k|	_new->method = method;
  547|  86.8k|	_new->key_ref = (unsigned)key_ref;
  548|  86.8k|	_new->next = NULL;
  549|       |
  550|  86.8k|	p = file->acl[operation];
  551|  86.8k|	if (p == NULL) {
  ------------------
  |  Branch (551:6): [True: 79.4k, False: 7.36k]
  ------------------
  552|  79.4k|		file->acl[operation] = _new;
  553|  79.4k|		return SC_SUCCESS;
  ------------------
  |  |   28|  79.4k|#define SC_SUCCESS				0
  ------------------
  554|  79.4k|	}
  555|  32.6k|	while (p->next != NULL)
  ------------------
  |  Branch (555:9): [True: 25.2k, False: 7.36k]
  ------------------
  556|  25.2k|		p = p->next;
  557|  7.36k|	p->next = _new;
  558|       |
  559|  7.36k|	return SC_SUCCESS;
  ------------------
  |  |   28|  7.36k|#define SC_SUCCESS				0
  ------------------
  560|  86.8k|}
sc_file_get_acl_entry:
  564|   403k|{
  565|   403k|	sc_acl_entry_t *p;
  566|   403k|	static const sc_acl_entry_t e_never = {
  567|   403k|		SC_AC_NEVER, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  163|   403k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		SC_AC_NEVER, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  204|   403k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  568|   403k|	};
  569|   403k|	static const sc_acl_entry_t e_none = {
  570|   403k|		SC_AC_NONE, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  150|   403k|#define SC_AC_NONE			0x00000000
  ------------------
              		SC_AC_NONE, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  204|   403k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  571|   403k|	};
  572|   403k|	static const sc_acl_entry_t e_unknown = {
  573|   403k|		SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  162|   403k|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  204|   403k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  574|   403k|	};
  575|       |
  576|   403k|	if (file == NULL || operation >= SC_MAX_AC_OPS) {
  ------------------
  |  |  198|   403k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (576:6): [True: 0, False: 403k]
  |  Branch (576:22): [True: 0, False: 403k]
  ------------------
  577|      0|		return NULL;
  578|      0|	}
  579|       |
  580|   403k|	p = file->acl[operation];
  581|   403k|	if (p == (sc_acl_entry_t *) 1)
  ------------------
  |  Branch (581:6): [True: 708, False: 402k]
  ------------------
  582|    708|		return &e_never;
  583|   402k|	if (p == (sc_acl_entry_t *) 2)
  ------------------
  |  Branch (583:6): [True: 587, False: 402k]
  ------------------
  584|    587|		return &e_none;
  585|   402k|	if (p == (sc_acl_entry_t *) 3)
  ------------------
  |  Branch (585:6): [True: 472, False: 401k]
  ------------------
  586|    472|		return &e_unknown;
  587|       |
  588|   401k|	return file->acl[operation];
  589|   402k|}
sc_file_clear_acl_entries:
  592|  3.34M|{
  593|  3.34M|	sc_acl_entry_t *e;
  594|       |
  595|  3.34M|	if (file == NULL || operation >= SC_MAX_AC_OPS) {
  ------------------
  |  |  198|  3.34M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (595:6): [True: 0, False: 3.34M]
  |  Branch (595:22): [True: 0, False: 3.34M]
  ------------------
  596|      0|		return;
  597|      0|	}
  598|       |
  599|  3.34M|	e = file->acl[operation];
  600|  3.34M|	if (e == (sc_acl_entry_t *) 1 ||
  ------------------
  |  Branch (600:6): [True: 48.4k, False: 3.29M]
  ------------------
  601|  3.29M|	    e == (sc_acl_entry_t *) 2 ||
  ------------------
  |  Branch (601:6): [True: 30.3k, False: 3.26M]
  ------------------
  602|  3.26M|	    e == (sc_acl_entry_t *) 3) {
  ------------------
  |  Branch (602:6): [True: 1.53k, False: 3.26M]
  ------------------
  603|  80.3k|		file->acl[operation] = NULL;
  604|  80.3k|		return;
  605|  80.3k|	}
  606|       |
  607|  3.35M|	while (e != NULL) {
  ------------------
  |  Branch (607:9): [True: 86.8k, False: 3.26M]
  ------------------
  608|  86.8k|		sc_acl_entry_t *tmp = e->next;
  609|  86.8k|		free(e);
  610|  86.8k|		e = tmp;
  611|  86.8k|	}
  612|       |	file->acl[operation] = NULL;
  613|  3.26M|}
sc_file_new:
  616|   105k|{
  617|   105k|	sc_file_t *file = (sc_file_t *)calloc(1, sizeof(sc_file_t));
  618|   105k|	if (file == NULL)
  ------------------
  |  Branch (618:6): [True: 0, False: 105k]
  ------------------
  619|      0|		return NULL;
  620|       |
  621|   105k|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   56|   105k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  622|   105k|	return file;
  623|   105k|}
sc_file_free:
  626|   324k|{
  627|   324k|	unsigned int i;
  628|   324k|	if (file == NULL || !sc_file_valid(file))
  ------------------
  |  Branch (628:6): [True: 219k, False: 105k]
  |  Branch (628:22): [True: 0, False: 105k]
  ------------------
  629|   219k|		return;
  630|   105k|	file->magic = 0;
  631|  3.37M|	for (i = 0; i < SC_MAX_AC_OPS; i++)
  ------------------
  |  |  198|  3.37M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (631:14): [True: 3.26M, False: 105k]
  ------------------
  632|  3.26M|		sc_file_clear_acl_entries(file, i);
  633|   105k|	if (file->sec_attr)
  ------------------
  |  Branch (633:6): [True: 1.52k, False: 103k]
  ------------------
  634|  1.52k|		free(file->sec_attr);
  635|   105k|	if (file->prop_attr)
  ------------------
  |  Branch (635:6): [True: 827, False: 104k]
  ------------------
  636|    827|		free(file->prop_attr);
  637|   105k|	if (file->type_attr)
  ------------------
  |  Branch (637:6): [True: 3.26k, False: 102k]
  ------------------
  638|  3.26k|		free(file->type_attr);
  639|   105k|	if (file->encoded_content)
  ------------------
  |  Branch (639:6): [True: 0, False: 105k]
  ------------------
  640|      0|		free(file->encoded_content);
  641|   105k|	free(file);
  642|   105k|}
sc_file_dup:
  645|  13.0k|{
  646|  13.0k|	sc_file_t *newf;
  647|  13.0k|	const sc_acl_entry_t *e;
  648|  13.0k|	unsigned int op;
  649|       |
  650|  13.0k|	if (!dest)
  ------------------
  |  Branch (650:6): [True: 0, False: 13.0k]
  ------------------
  651|      0|		return;
  652|  13.0k|	*dest = NULL;
  653|  13.0k|	if (!sc_file_valid(src))
  ------------------
  |  Branch (653:6): [True: 0, False: 13.0k]
  ------------------
  654|      0|		return;
  655|  13.0k|	newf = sc_file_new();
  656|  13.0k|	if (newf == NULL)
  ------------------
  |  Branch (656:6): [True: 0, False: 13.0k]
  ------------------
  657|      0|		return;
  658|  13.0k|	*dest = newf;
  659|       |
  660|  13.0k|	memcpy(&newf->path, &src->path, sizeof(struct sc_path));
  661|  13.0k|	memcpy(&newf->name, &src->name, sizeof(src->name));
  662|  13.0k|	newf->namelen = src->namelen;
  663|  13.0k|	newf->type    = src->type;
  664|  13.0k|	newf->shareable    = src->shareable;
  665|  13.0k|	newf->ef_structure = src->ef_structure;
  666|  13.0k|	newf->size    = src->size;
  667|  13.0k|	newf->id      = src->id;
  668|  13.0k|	newf->status  = src->status;
  669|   416k|	for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|   416k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (669:15): [True: 403k, False: 13.0k]
  ------------------
  670|   403k|		newf->acl[op] = NULL;
  671|   403k|		e = sc_file_get_acl_entry(src, op);
  672|   403k|		if (e != NULL) {
  ------------------
  |  Branch (672:7): [True: 3.63k, False: 399k]
  ------------------
  673|  3.63k|			if (sc_file_add_acl_entry(newf, op, e->method, e->key_ref) < 0)
  ------------------
  |  Branch (673:8): [True: 0, False: 3.63k]
  ------------------
  674|      0|				goto err;
  675|  3.63k|		}
  676|   403k|	}
  677|  13.0k|	newf->record_length = src->record_length;
  678|  13.0k|	newf->record_count  = src->record_count;
  679|       |
  680|  13.0k|	if (sc_file_set_sec_attr(newf, src->sec_attr, src->sec_attr_len) < 0)
  ------------------
  |  Branch (680:6): [True: 0, False: 13.0k]
  ------------------
  681|      0|		goto err;
  682|  13.0k|	if (sc_file_set_prop_attr(newf, src->prop_attr, src->prop_attr_len) < 0)
  ------------------
  |  Branch (682:6): [True: 0, False: 13.0k]
  ------------------
  683|      0|		goto err;
  684|  13.0k|	if (sc_file_set_type_attr(newf, src->type_attr, src->type_attr_len) < 0)
  ------------------
  |  Branch (684:6): [True: 0, False: 13.0k]
  ------------------
  685|      0|		goto err;
  686|  13.0k|	if (sc_file_set_content(newf, src->encoded_content, src->encoded_content_len) < 0)
  ------------------
  |  Branch (686:6): [True: 0, False: 13.0k]
  ------------------
  687|      0|		goto err;
  688|  13.0k|	return;
  689|  13.0k|err:
  690|      0|	sc_file_free(newf);
  691|       |	*dest = NULL;
  692|      0|}
sc_file_set_sec_attr:
  696|  14.7k|{
  697|  14.7k|	u8 *tmp;
  698|  14.7k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (698:6): [True: 0, False: 14.7k]
  ------------------
  699|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  700|      0|	}
  701|       |
  702|  14.7k|	if (sec_attr == NULL || sec_attr_len == 0) {
  ------------------
  |  Branch (702:6): [True: 12.9k, False: 1.75k]
  |  Branch (702:26): [True: 149, False: 1.60k]
  ------------------
  703|  13.1k|		if (file->sec_attr != NULL)
  ------------------
  |  Branch (703:7): [True: 66, False: 13.0k]
  ------------------
  704|     66|			free(file->sec_attr);
  705|  13.1k|		file->sec_attr = NULL;
  706|  13.1k|		file->sec_attr_len = 0;
  707|  13.1k|		return 0;
  708|  13.1k|	 }
  709|  1.60k|	tmp = (u8 *) realloc(file->sec_attr, sec_attr_len);
  710|  1.60k|	if (!tmp) {
  ------------------
  |  Branch (710:6): [True: 0, False: 1.60k]
  ------------------
  711|      0|		if (file->sec_attr)
  ------------------
  |  Branch (711:7): [True: 0, False: 0]
  ------------------
  712|      0|			free(file->sec_attr);
  713|      0|		file->sec_attr     = NULL;
  714|      0|		file->sec_attr_len = 0;
  715|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  716|      0|	}
  717|  1.60k|	file->sec_attr = tmp;
  718|  1.60k|	memcpy(file->sec_attr, sec_attr, sec_attr_len);
  719|  1.60k|	file->sec_attr_len = sec_attr_len;
  720|       |
  721|  1.60k|	return 0;
  722|  1.60k|}
sc_file_set_prop_attr:
  726|  14.0k|{
  727|  14.0k|	u8 *tmp;
  728|  14.0k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (728:6): [True: 0, False: 14.0k]
  ------------------
  729|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  730|      0|	}
  731|       |
  732|  14.0k|	if (prop_attr == NULL || prop_attr_len == 0) {
  ------------------
  |  Branch (732:6): [True: 12.9k, False: 1.09k]
  |  Branch (732:27): [True: 144, False: 952]
  ------------------
  733|  13.0k|		if (file->prop_attr != NULL)
  ------------------
  |  Branch (733:7): [True: 66, False: 13.0k]
  ------------------
  734|     66|			free(file->prop_attr);
  735|  13.0k|		file->prop_attr = NULL;
  736|  13.0k|		file->prop_attr_len = 0;
  737|  13.0k|		return SC_SUCCESS;
  ------------------
  |  |   28|  13.0k|#define SC_SUCCESS				0
  ------------------
  738|  13.0k|	 }
  739|    952|	tmp = (u8 *) realloc(file->prop_attr, prop_attr_len);
  740|    952|	if (!tmp) {
  ------------------
  |  Branch (740:6): [True: 0, False: 952]
  ------------------
  741|      0|		if (file->prop_attr)
  ------------------
  |  Branch (741:7): [True: 0, False: 0]
  ------------------
  742|      0|			free(file->prop_attr);
  743|      0|		file->prop_attr = NULL;
  744|      0|		file->prop_attr_len = 0;
  745|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  746|      0|	}
  747|    952|	file->prop_attr = tmp;
  748|    952|	memcpy(file->prop_attr, prop_attr, prop_attr_len);
  749|    952|	file->prop_attr_len = prop_attr_len;
  750|       |
  751|    952|	return SC_SUCCESS;
  ------------------
  |  |   28|    952|#define SC_SUCCESS				0
  ------------------
  752|    952|}
sc_file_set_type_attr:
  756|  16.0k|{
  757|  16.0k|	u8 *tmp;
  758|  16.0k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (758:6): [True: 0, False: 16.0k]
  ------------------
  759|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  760|      0|	}
  761|       |
  762|  16.0k|	if (type_attr == NULL || type_attr_len == 0) {
  ------------------
  |  Branch (762:6): [True: 12.3k, False: 3.73k]
  |  Branch (762:27): [True: 0, False: 3.73k]
  ------------------
  763|  12.3k|		if (file->type_attr != NULL)
  ------------------
  |  Branch (763:7): [True: 0, False: 12.3k]
  ------------------
  764|      0|			free(file->type_attr);
  765|  12.3k|		file->type_attr = NULL;
  766|  12.3k|		file->type_attr_len = 0;
  767|  12.3k|		return SC_SUCCESS;
  ------------------
  |  |   28|  12.3k|#define SC_SUCCESS				0
  ------------------
  768|  12.3k|	 }
  769|  3.73k|	tmp = (u8 *) realloc(file->type_attr, type_attr_len);
  770|  3.73k|	if (!tmp) {
  ------------------
  |  Branch (770:6): [True: 0, False: 3.73k]
  ------------------
  771|      0|		if (file->type_attr)
  ------------------
  |  Branch (771:7): [True: 0, False: 0]
  ------------------
  772|      0|			free(file->type_attr);
  773|      0|		file->type_attr = NULL;
  774|      0|		file->type_attr_len = 0;
  775|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  776|      0|	}
  777|  3.73k|	file->type_attr = tmp;
  778|  3.73k|	memcpy(file->type_attr, type_attr, type_attr_len);
  779|  3.73k|	file->type_attr_len = type_attr_len;
  780|       |
  781|  3.73k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.73k|#define SC_SUCCESS				0
  ------------------
  782|  3.73k|}
sc_file_set_content:
  787|  13.0k|{
  788|  13.0k|	u8 *tmp;
  789|  13.0k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (789:6): [True: 0, False: 13.0k]
  ------------------
  790|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  791|      0|	}
  792|       |
  793|  13.0k|	if (content == NULL || content_len == 0) {
  ------------------
  |  Branch (793:6): [True: 13.0k, False: 0]
  |  Branch (793:25): [True: 0, False: 0]
  ------------------
  794|  13.0k|		if (file->encoded_content != NULL)
  ------------------
  |  Branch (794:7): [True: 0, False: 13.0k]
  ------------------
  795|      0|			free(file->encoded_content);
  796|  13.0k|		file->encoded_content = NULL;
  797|  13.0k|		file->encoded_content_len = 0;
  798|  13.0k|		return SC_SUCCESS;
  ------------------
  |  |   28|  13.0k|#define SC_SUCCESS				0
  ------------------
  799|  13.0k|	}
  800|       |
  801|      0|	tmp = (u8 *) realloc(file->encoded_content, content_len);
  802|      0|	if (!tmp) {
  ------------------
  |  Branch (802:6): [True: 0, False: 0]
  ------------------
  803|      0|		if (file->encoded_content)
  ------------------
  |  Branch (803:7): [True: 0, False: 0]
  ------------------
  804|      0|			free(file->encoded_content);
  805|      0|		file->encoded_content = NULL;
  806|      0|		file->encoded_content_len = 0;
  807|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  808|      0|	}
  809|       |
  810|      0|	file->encoded_content = tmp;
  811|      0|	memcpy(file->encoded_content, content, content_len);
  812|      0|	file->encoded_content_len = content_len;
  813|       |
  814|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  815|      0|}
sc_file_valid:
  818|   176k|int sc_file_valid(const sc_file_t *file) {
  819|   176k|	if (file == NULL)
  ------------------
  |  Branch (819:6): [True: 0, False: 176k]
  ------------------
  820|      0|		return 0;
  821|   176k|	return file->magic == SC_FILE_MAGIC;
  ------------------
  |  |   56|   176k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  822|   176k|}
_sc_parse_atr:
  825|  17.0k|{
  826|  17.0k|	u8 *p = reader->atr.value;
  827|  17.0k|	int atr_len = (int) reader->atr.len;
  828|  17.0k|	int n_hist, x;
  829|  17.0k|	int tx[4] = {-1, -1, -1, -1};
  830|  17.0k|	int i, FI, DI;
  831|  17.0k|	const int Fi_table[] = {
  832|  17.0k|		372, 372, 558, 744, 1116, 1488, 1860, -1,
  833|  17.0k|		-1, 512, 768, 1024, 1536, 2048, -1, -1 };
  834|  17.0k|	const int f_table[] = {
  835|  17.0k|		40, 50, 60, 80, 120, 160, 200, -1,
  836|  17.0k|		-1, 50, 75, 100, 150, 200, -1, -1 };
  837|  17.0k|	const int Di_table[] = {
  838|  17.0k|		-1, 1, 2, 4, 8, 16, 32, -1,
  839|  17.0k|		12, 20, -1, -1, -1, -1, -1, -1 };
  840|       |
  841|  17.0k|	reader->atr_info.hist_bytes_len = 0;
  842|  17.0k|	reader->atr_info.hist_bytes = NULL;
  843|       |
  844|  17.0k|	if (atr_len == 0) {
  ------------------
  |  Branch (844:6): [True: 4.97k, False: 12.0k]
  ------------------
  845|  4.97k|		sc_log(reader->ctx, "empty ATR - card not present?\n");
  ------------------
  |  |   71|  4.97k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  846|  4.97k|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  4.97k|#define SC_ERROR_INTERNAL			-1400
  ------------------
  847|  4.97k|	}
  848|       |
  849|  12.0k|	if (p[0] != 0x3B && p[0] != 0x3F) {
  ------------------
  |  Branch (849:6): [True: 1.24k, False: 10.8k]
  |  Branch (849:22): [True: 1.08k, False: 154]
  ------------------
  850|  1.08k|		sc_log(reader->ctx, "invalid sync byte in ATR: 0x%02X\n", p[0]);
  ------------------
  |  |   71|  1.08k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  851|  1.08k|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  1.08k|#define SC_ERROR_INTERNAL			-1400
  ------------------
  852|  1.08k|	}
  853|  10.9k|	n_hist = p[1] & 0x0F;
  854|  10.9k|	x = p[1] >> 4;
  855|  10.9k|	p += 2;
  856|  10.9k|	atr_len -= 2;
  857|  54.8k|	for (i = 0; i < 4 && atr_len > 0; i++) {
  ------------------
  |  Branch (857:14): [True: 43.8k, False: 10.9k]
  |  Branch (857:23): [True: 43.8k, False: 8]
  ------------------
  858|  43.8k|                if (x & (1 << i)) {
  ------------------
  |  Branch (858:21): [True: 28.8k, False: 15.0k]
  ------------------
  859|  28.8k|                        tx[i] = *p;
  860|  28.8k|                        p++;
  861|  28.8k|                        atr_len--;
  862|  28.8k|                } else
  863|  15.0k|                        tx[i] = -1;
  864|  43.8k|        }
  865|  10.9k|	if (tx[0] >= 0) {
  ------------------
  |  Branch (865:6): [True: 9.58k, False: 1.38k]
  ------------------
  866|  9.58k|		reader->atr_info.FI = FI = tx[0] >> 4;
  867|  9.58k|		reader->atr_info.DI = DI = tx[0] & 0x0F;
  868|  9.58k|		reader->atr_info.Fi = Fi_table[FI];
  869|  9.58k|		reader->atr_info.f = f_table[FI];
  870|  9.58k|		reader->atr_info.Di = Di_table[DI];
  871|  9.58k|	} else {
  872|  1.38k|		reader->atr_info.Fi = -1;
  873|  1.38k|		reader->atr_info.f = -1;
  874|  1.38k|		reader->atr_info.Di = -1;
  875|  1.38k|	}
  876|  10.9k|	if (tx[2] >= 0)
  ------------------
  |  Branch (876:6): [True: 6.75k, False: 4.21k]
  ------------------
  877|  6.75k|		reader->atr_info.N = tx[3];
  878|  4.21k|	else
  879|  4.21k|		reader->atr_info.N = -1;
  880|  23.8k|	while (tx[3] > 0 && tx[3] & 0xF0 && atr_len > 0) {
  ------------------
  |  Branch (880:9): [True: 13.4k, False: 10.4k]
  |  Branch (880:22): [True: 12.9k, False: 500]
  |  Branch (880:38): [True: 12.9k, False: 43]
  ------------------
  881|  12.9k|		x = tx[3] >> 4;
  882|  64.6k|		for (i = 0; i < 4 && atr_len > 0; i++) {
  ------------------
  |  Branch (882:15): [True: 51.7k, False: 12.9k]
  |  Branch (882:24): [True: 51.6k, False: 34]
  ------------------
  883|  51.6k|	                if (x & (1 << i)) {
  ------------------
  |  Branch (883:22): [True: 19.5k, False: 32.1k]
  ------------------
  884|  19.5k|	                        tx[i] = *p;
  885|  19.5k|	                        p++;
  886|  19.5k|	                        atr_len--;
  887|  19.5k|	                } else
  888|  32.1k|	                        tx[i] = -1;
  889|  51.6k|		}
  890|  12.9k|	}
  891|  10.9k|	if (atr_len <= 0)
  ------------------
  |  Branch (891:6): [True: 54, False: 10.9k]
  ------------------
  892|     54|		return SC_SUCCESS;
  ------------------
  |  |   28|     54|#define SC_SUCCESS				0
  ------------------
  893|  10.9k|	if (n_hist > atr_len)
  ------------------
  |  Branch (893:6): [True: 1.36k, False: 9.54k]
  ------------------
  894|  1.36k|		n_hist = atr_len;
  895|  10.9k|	reader->atr_info.hist_bytes_len = n_hist;
  896|  10.9k|	reader->atr_info.hist_bytes = p;
  897|  10.9k|	return SC_SUCCESS;
  ------------------
  |  |   28|  10.9k|#define SC_SUCCESS				0
  ------------------
  898|  10.9k|}
sc_mem_secure_alloc:
  901|    699|{
  902|    699|	void *p;
  903|       |
  904|       |#ifdef _WIN32
  905|       |	p = VirtualAlloc(NULL, len, MEM_COMMIT, PAGE_READWRITE);
  906|       |	if (p != NULL) {
  907|       |		VirtualLock(p, len);
  908|       |	}
  909|       |#else
  910|    699|	p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  911|    699|	if (p != NULL) {
  ------------------
  |  Branch (911:6): [True: 699, False: 0]
  ------------------
  912|    699|		mlock(p, len);
  913|    699|	}
  914|    699|#endif
  915|       |
  916|    699|	return p;
  917|    699|}
sc_mem_secure_free:
  920|  2.10k|{
  921|       |#ifdef _WIN32
  922|       |	VirtualUnlock(ptr, len);
  923|       |	VirtualFree(ptr, 0, MEM_RELEASE);
  924|       |#else
  925|  2.10k|	munlock(ptr, len);
  926|  2.10k|	munmap(ptr, len);
  927|  2.10k|#endif
  928|  2.10k|}
sc_mem_clear:
  931|  82.0k|{
  932|  82.0k|	if (len > 0)   {
  ------------------
  |  Branch (932:6): [True: 80.6k, False: 1.40k]
  ------------------
  933|       |#ifdef HAVE_MEMSET_S
  934|       |		memset_s(ptr, len, 0, len);
  935|       |#elif _WIN32
  936|       |		SecureZeroMemory(ptr, len);
  937|       |#elif HAVE_EXPLICIT_BZERO
  938|       |		explicit_bzero(ptr, len);
  939|       |#elif ENABLE_OPENSSL
  940|       |		OPENSSL_cleanse(ptr, len);
  941|       |#else
  942|       |		memset(ptr, 0, len);
  943|       |#endif
  944|  80.6k|	}
  945|  82.0k|}
sc_compacttlv_find_tag:
 1059|    949|{
 1060|    949|	if (buf != NULL) {
  ------------------
  |  Branch (1060:6): [True: 949, False: 0]
  ------------------
 1061|    949|		size_t idx;
 1062|    949|		u8 plain_tag = tag & 0xF0;
 1063|    949|		size_t expected_len = tag & 0x0F;
 1064|       |
 1065|  15.0k|		for (idx = 0; idx < len; idx++) {
  ------------------
  |  Branch (1065:17): [True: 14.4k, False: 644]
  ------------------
 1066|  14.4k|			u8 ctag = buf[idx] & 0xF0;
 1067|  14.4k|			size_t ctag_len = buf[idx] & 0x0F;
 1068|  14.4k|			if (ctag == plain_tag && idx + ctag_len < len &&
  ------------------
  |  Branch (1068:8): [True: 1.76k, False: 12.6k]
  |  Branch (1068:29): [True: 1.74k, False: 17]
  ------------------
 1069|  1.74k|					(expected_len == 0 || expected_len == ctag_len)) {
  ------------------
  |  Branch (1069:7): [True: 268, False: 1.47k]
  |  Branch (1069:28): [True: 37, False: 1.43k]
  ------------------
 1070|    305|				if (outlen != NULL)
  ------------------
  |  Branch (1070:9): [True: 268, False: 37]
  ------------------
 1071|    268|					*outlen = ctag_len;
 1072|    305|				return buf + (idx + 1);
 1073|    305|			}
 1074|  14.1k|			idx += ctag_len;
 1075|  14.1k|		}
 1076|    949|	}
 1077|    644|	return NULL;
 1078|    949|}
sc_mutex_create:
 1083|  34.0k|{
 1084|  34.0k|	if (ctx == NULL)
  ------------------
  |  Branch (1084:6): [True: 0, False: 34.0k]
  ------------------
 1085|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1086|  34.0k|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->create_mutex != NULL)
  ------------------
  |  Branch (1086:6): [True: 34.0k, False: 0]
  |  Branch (1086:33): [True: 34.0k, False: 0]
  ------------------
 1087|  34.0k|		return ctx->thread_ctx->create_mutex(mutex);
 1088|      0|	else
 1089|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1090|  34.0k|}
sc_mutex_lock:
 1093|  1.46M|{
 1094|  1.46M|	if (ctx == NULL)
  ------------------
  |  Branch (1094:6): [True: 0, False: 1.46M]
  ------------------
 1095|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1096|  1.46M|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->lock_mutex != NULL)
  ------------------
  |  Branch (1096:6): [True: 1.46M, False: 0]
  |  Branch (1096:33): [True: 1.46M, False: 0]
  ------------------
 1097|  1.46M|		return ctx->thread_ctx->lock_mutex(mutex);
 1098|      0|	else
 1099|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1100|  1.46M|}
sc_mutex_unlock:
 1103|  1.46M|{
 1104|  1.46M|	if (ctx == NULL)
  ------------------
  |  Branch (1104:6): [True: 0, False: 1.46M]
  ------------------
 1105|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1106|  1.46M|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->unlock_mutex != NULL)
  ------------------
  |  Branch (1106:6): [True: 1.46M, False: 0]
  |  Branch (1106:33): [True: 1.46M, False: 0]
  ------------------
 1107|  1.46M|		return ctx->thread_ctx->unlock_mutex(mutex);
 1108|      0|	else
 1109|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1110|  1.46M|}

sc_decipher:
   36|    166|{
   37|    166|	int r;
   38|       |
   39|    166|	if (card == NULL) {
  ------------------
  |  Branch (39:6): [True: 0, False: 166]
  ------------------
   40|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   41|      0|	}
   42|    166|	if (crgram == NULL || out == NULL) {
  ------------------
  |  Branch (42:6): [True: 0, False: 166]
  |  Branch (42:24): [True: 0, False: 166]
  ------------------
   43|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   44|      0|	}
   45|    166|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    166|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    166|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    166|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    166|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 166]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   46|    166|	if (card->ops->decipher == NULL)
  ------------------
  |  Branch (46:6): [True: 0, False: 166]
  ------------------
   47|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   48|    166|	r = card->ops->decipher(card, crgram, crgram_len, out, outlen);
   49|    166|        SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    166|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    166|	int _ret = r; \
  |  |  155|    166|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 80, False: 86]
  |  |  ------------------
  |  |  156|     80|		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|     75|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 75, False: 5]
  |  |  ------------------
  |  |  157|     80|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|     86|	} else { \
  |  |  159|     86|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|     86|			"returning with: %d\n", _ret); \
  |  |  161|     86|	} \
  |  |  162|    166|	return _ret; \
  |  |  163|    166|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
   50|    166|}
sc_compute_signature:
   55|    169|{
   56|    169|	int r;
   57|       |
   58|    169|	if (card == NULL) {
  ------------------
  |  Branch (58:6): [True: 0, False: 169]
  ------------------
   59|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   60|      0|	}
   61|    169|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    169|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    169|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    169|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    169|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 169]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   62|    169|	if (card->ops->compute_signature == NULL)
  ------------------
  |  Branch (62:6): [True: 0, False: 169]
  ------------------
   63|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   64|    169|	r = card->ops->compute_signature(card, data, datalen, out, outlen);
   65|    169|        SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    169|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    169|	int _ret = r; \
  |  |  155|    169|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 148, False: 21]
  |  |  ------------------
  |  |  156|    148|		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|    136|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 136, False: 12]
  |  |  ------------------
  |  |  157|    148|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    148|	} else { \
  |  |  159|     21|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|     21|			"returning with: %d\n", _ret); \
  |  |  161|     21|	} \
  |  |  162|    169|	return _ret; \
  |  |  163|    169|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
   66|    169|}
sc_set_security_env:
  101|    424|{
  102|    424|	int r;
  103|       |
  104|    424|	if (card == NULL) {
  ------------------
  |  Branch (104:6): [True: 0, False: 424]
  ------------------
  105|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  106|      0|	}
  107|    424|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    424|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    424|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    424|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    424|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 424]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  108|    424|	if (card->ops->set_security_env == NULL)
  ------------------
  |  Branch (108:6): [True: 0, False: 424]
  ------------------
  109|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  110|    424|	r = card->ops->set_security_env(card, env, se_num);
  111|    424|        SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    424|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    424|	int _ret = r; \
  |  |  155|    424|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 424, False: 0]
  |  |  ------------------
  |  |  156|    424|		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|     89|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 89, False: 335]
  |  |  ------------------
  |  |  157|    424|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    424|	} 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|    424|	return _ret; \
  |  |  163|    424|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  112|    424|}
sc_restore_security_env:
  115|      7|{
  116|      7|	int r;
  117|       |
  118|      7|	if (card == NULL) {
  ------------------
  |  Branch (118:6): [True: 0, False: 7]
  ------------------
  119|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  120|      0|	}
  121|      7|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      7|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      7|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      7|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      7|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|      7|	if (card->ops->restore_security_env == NULL)
  ------------------
  |  Branch (122:6): [True: 0, False: 7]
  ------------------
  123|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  124|      7|	r = card->ops->restore_security_env(card, se_num);
  125|      7|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|      7|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      7|	int _ret = r; \
  |  |  155|      7|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 7, False: 0]
  |  |  ------------------
  |  |  156|      7|		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|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 2, False: 5]
  |  |  ------------------
  |  |  157|      7|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      7|	} 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|      7|	return _ret; \
  |  |  163|      7|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  126|      7|}
sc_verify:
  130|    974|{
  131|    974|	struct sc_pin_cmd_data data;
  132|       |
  133|    974|	memset(&data, 0, sizeof(data));
  134|    974|	data.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  415|    974|#define SC_PIN_CMD_VERIFY	0
  ------------------
  135|    974|	data.pin_type = type;
  136|    974|	data.pin_reference = ref;
  137|    974|	data.pin1.data = pin;
  138|    974|	data.pin1.len = pinlen;
  139|       |
  140|    974|	int r = sc_pin_cmd(card, &data);
  141|    974|	if (tries_left)
  ------------------
  |  Branch (141:6): [True: 974, False: 0]
  ------------------
  142|    974|		*tries_left = data.pin1.tries_left;
  143|       |
  144|    974|	return r;
  145|    974|}
sc_pin_cmd:
  203|  4.15k|{
  204|  4.15k|	int r, debug;
  205|       |
  206|  4.15k|	if (card == NULL) {
  ------------------
  |  Branch (206:6): [True: 0, False: 4.15k]
  ------------------
  207|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  208|      0|	}
  209|  4.15k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  4.15k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.15k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.15k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.15k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|       |
  211|  4.15k|	debug = card->ctx->debug;
  212|  4.15k|	if (data->cmd != SC_PIN_CMD_GET_INFO
  ------------------
  |  |  418|  8.30k|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (212:6): [True: 1.34k, False: 2.81k]
  ------------------
  213|  1.34k|			&& card->ctx->debug < SC_LOG_DEBUG_PIN) {
  ------------------
  |  Branch (213:7): [True: 1.34k, False: 0]
  ------------------
  214|  1.34k|		card->ctx->debug = 0;
  215|  1.34k|	}
  216|       |
  217|  4.15k|	if (card->ops->pin_cmd) {
  ------------------
  |  Branch (217:6): [True: 4.15k, False: 0]
  ------------------
  218|  4.15k|		r = card->ops->pin_cmd(card, data);
  219|  4.15k|	} else if (!(data->flags & SC_PIN_CMD_USE_PINPAD)) {
  ------------------
  |  |  421|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (219:13): [True: 0, False: 0]
  ------------------
  220|       |		/* Card driver doesn't support new style pin_cmd, fall
  221|       |		 * back to old interface */
  222|       |
  223|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  224|      0|		switch (data->cmd) {
  ------------------
  |  Branch (224:11): [True: 0, False: 0]
  ------------------
  225|      0|		case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  415|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (225:3): [True: 0, False: 0]
  ------------------
  226|      0|			if (card->ops->verify != NULL)
  ------------------
  |  Branch (226:8): [True: 0, False: 0]
  ------------------
  227|      0|				r = card->ops->verify(card,
  228|      0|					data->pin_type,
  229|      0|					data->pin_reference,
  230|      0|					data->pin1.data,
  231|      0|					(size_t) data->pin1.len,
  232|      0|					&data->pin1.tries_left);
  233|      0|			break;
  234|      0|		case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  416|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (234:3): [True: 0, False: 0]
  ------------------
  235|      0|			if (card->ops->change_reference_data != NULL)
  ------------------
  |  Branch (235:8): [True: 0, False: 0]
  ------------------
  236|      0|				r = card->ops->change_reference_data(card,
  237|      0|					data->pin_type,
  238|      0|					data->pin_reference,
  239|      0|					data->pin1.data,
  240|      0|					(size_t) data->pin1.len,
  241|      0|					data->pin2.data,
  242|      0|					(size_t) data->pin2.len,
  243|      0|					&data->pin1.tries_left);
  244|      0|			break;
  245|      0|		case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  417|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (245:3): [True: 0, False: 0]
  ------------------
  246|      0|			if (card->ops->reset_retry_counter != NULL)
  ------------------
  |  Branch (246:8): [True: 0, False: 0]
  ------------------
  247|      0|				r = card->ops->reset_retry_counter(card,
  248|      0|					data->pin_type,
  249|      0|					data->pin_reference,
  250|      0|					data->pin1.data,
  251|      0|					(size_t) data->pin1.len,
  252|      0|					data->pin2.data,
  253|      0|					(size_t) data->pin2.len);
  254|      0|			break;
  255|      0|		}
  256|      0|		if (r == SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (256:7): [True: 0, False: 0]
  ------------------
  257|      0|			sc_log(card->ctx,  "unsupported PIN operation (%d)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  258|      0|					data->cmd);
  259|      0|	} else {
  260|      0|		sc_log(card->ctx,  "Use of pin pad not supported by card driver");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  261|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  262|      0|	}
  263|  4.15k|	card->ctx->debug = debug;
  264|       |
  265|  4.15k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  4.15k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  4.15k|	int _ret = r; \
  |  |  155|  4.15k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 4.15k, False: 0]
  |  |  ------------------
  |  |  156|  4.15k|		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|  2.36k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 2.36k, False: 1.78k]
  |  |  ------------------
  |  |  157|  4.15k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  4.15k|	} 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|  4.15k|	return _ret; \
  |  |  163|  4.15k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  266|  4.15k|}
sc_build_pin:
  280|    387|{
  281|    387|	size_t i = 0, j, pin_len = pin->len;
  282|       |
  283|    387|	if (pin->max_length && pin_len > pin->max_length)
  ------------------
  |  Branch (283:6): [True: 387, False: 0]
  |  Branch (283:25): [True: 0, False: 387]
  ------------------
  284|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  285|       |
  286|    387|	if (pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  427|    387|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (286:6): [True: 36, False: 351]
  ------------------
  287|    102|		while (pin_len > 0 && pin->data[pin_len - 1] == 0xFF)
  ------------------
  |  Branch (287:10): [True: 95, False: 7]
  |  Branch (287:25): [True: 66, False: 29]
  ------------------
  288|     66|			pin_len--;
  289|     36|		if (pin_len > 12)
  ------------------
  |  Branch (289:7): [True: 3, False: 33]
  ------------------
  290|      3|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      3|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  291|    125|		for (i = 0; i < pin_len; i++) {
  ------------------
  |  Branch (291:15): [True: 104, False: 21]
  ------------------
  292|    104|			if (pin->data[i] < '0' || pin->data[i] > '9')
  ------------------
  |  Branch (292:8): [True: 5, False: 99]
  |  Branch (292:30): [True: 7, False: 92]
  ------------------
  293|     12|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     12|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  294|    104|		}
  295|     21|		buf[0] = 0x20 | (u8) pin_len;
  296|     21|		buf++;
  297|     21|		buflen--;
  298|     21|	}
  299|       |
  300|       |	/* PIN given by application, encode if required */
  301|    372|	if (pin->encoding == SC_PIN_ENCODING_ASCII) {
  ------------------
  |  |  425|    372|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  |  Branch (301:6): [True: 349, False: 23]
  ------------------
  302|    349|		if (pin_len > buflen)
  ------------------
  |  Branch (302:7): [True: 0, False: 349]
  ------------------
  303|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  304|    349|		memcpy(buf, pin->data, pin_len);
  305|    349|		i = pin_len;
  306|    349|	} else if (pin->encoding == SC_PIN_ENCODING_BCD || pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  426|     46|#define SC_PIN_ENCODING_BCD	1
  ------------------
              	} else if (pin->encoding == SC_PIN_ENCODING_BCD || pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  427|     21|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (306:13): [True: 2, False: 21]
  |  Branch (306:53): [True: 21, False: 0]
  ------------------
  307|     23|		if (pin_len > 2 * buflen)
  ------------------
  |  Branch (307:7): [True: 0, False: 23]
  ------------------
  308|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  309|    112|		for (i = j = 0; j < pin_len; j++) {
  ------------------
  |  Branch (309:19): [True: 90, False: 22]
  ------------------
  310|     90|			if (!isdigit(pin->data[j])) {
  ------------------
  |  Branch (310:8): [True: 1, False: 89]
  ------------------
  311|      1|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  312|      1|			}
  313|     89|			buf[i] <<= 4;
  314|     89|			buf[i] |= pin->data[j] & 0xf;
  315|     89|			if (j & 1)
  ------------------
  |  Branch (315:8): [True: 41, False: 48]
  ------------------
  316|     41|				i++;
  317|     89|		}
  318|     22|		if (j & 1) {
  ------------------
  |  Branch (318:7): [True: 6, False: 16]
  ------------------
  319|      6|			buf[i] <<= 4;
  320|      6|			buf[i] |= pin->pad_char & 0xf;
  321|      6|			i++;
  322|      6|		}
  323|     22|	}
  324|       |
  325|       |	/* Pad to maximum PIN length if requested */
  326|    371|	if (pad || pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  427|     82|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (326:6): [True: 289, False: 82]
  |  Branch (326:13): [True: 0, False: 82]
  ------------------
  327|    289|		size_t pad_length = pin->pad_length;
  328|    289|		u8     pad_char   = pin->encoding == SC_PIN_ENCODING_GLP ? 0xFF : pin->pad_char;
  ------------------
  |  |  427|    289|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (328:23): [True: 21, False: 268]
  ------------------
  329|       |
  330|    289|		if (pin->encoding == SC_PIN_ENCODING_BCD)
  ------------------
  |  |  426|    289|#define SC_PIN_ENCODING_BCD	1
  ------------------
  |  Branch (330:7): [True: 1, False: 288]
  ------------------
  331|      1|			pad_length >>= 1;
  332|    289|		if (pin->encoding == SC_PIN_ENCODING_GLP)
  ------------------
  |  |  427|    289|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (332:7): [True: 21, False: 268]
  ------------------
  333|     21|			pad_length = 8;
  334|       |
  335|    289|		if (pad_length > buflen)
  ------------------
  |  Branch (335:7): [True: 0, False: 289]
  ------------------
  336|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  337|       |
  338|    289|		if (pad_length && i < pad_length) {
  ------------------
  |  Branch (338:7): [True: 288, False: 1]
  |  Branch (338:21): [True: 270, False: 18]
  ------------------
  339|    270|			memset(buf + i, pad_char, pad_length - i);
  340|    270|			i = pad_length;
  341|    270|		}
  342|    289|	}
  343|       |
  344|    371|	return (int)i;
  345|    371|}

sc_simpletlv_put_tag:
   42|  4.30k|{
   43|  4.30k|	u8 *p = out;
   44|       |
   45|  4.30k|	if (outlen < 2 || (outlen < 4 && datalen >= 0xff))
  ------------------
  |  Branch (45:6): [True: 0, False: 4.30k]
  |  Branch (45:21): [True: 38, False: 4.26k]
  |  Branch (45:35): [True: 0, False: 38]
  ------------------
   46|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   47|       |
   48|       |	/* tag is just number between 0x01 and 0xFE */
   49|  4.30k|	if (tag == 0x00 || tag == 0xff)
  ------------------
  |  Branch (49:6): [True: 1.10k, False: 3.19k]
  |  Branch (49:21): [True: 265, False: 2.93k]
  ------------------
   50|  1.36k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  1.36k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   51|  2.93k|	if (datalen > 0xffff) {
  ------------------
  |  Branch (51:6): [True: 0, False: 2.93k]
  ------------------
   52|       |		/* we can't store more than two bytes in Simple TLV */
   53|      0|		return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
   54|      0|	}
   55|       |
   56|  2.93k|	*p++ = tag; /* tag is single byte */
   57|  2.93k|	if (datalen < 0xff) {
  ------------------
  |  Branch (57:6): [True: 2.76k, False: 172]
  ------------------
   58|       |		/* short value up to 255 */
   59|  2.76k|		*p++ = (u8)datalen; /* is in the second byte */
   60|  2.76k|	} else {
   61|       |		/* longer values up to 65535 */
   62|    172|		*p++ = (u8)0xff; /* first byte is 0xff */
   63|    172|		*p++ = (u8)datalen & 0xff;
   64|    172|		*p++ = (u8)(datalen >> 8) & 0xff; /* LE */
   65|    172|	}
   66|  2.93k|	if (ptr != NULL)
  ------------------
  |  Branch (66:6): [True: 2.93k, False: 0]
  ------------------
   67|  2.93k|		*ptr = p;
   68|  2.93k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.93k|#define SC_SUCCESS				0
  ------------------
   69|  2.93k|}
sc_simpletlv_read_tag:
   76|  57.9k|{
   77|  57.9k|	u8 tag;
   78|  57.9k|	size_t left = buflen, len;
   79|  57.9k|	const u8 *p = *buf;
   80|       |
   81|  57.9k|	*buf = NULL;
   82|       |
   83|  57.9k|	if (left < 2) {
  ------------------
  |  Branch (83:6): [True: 695, False: 57.2k]
  ------------------
   84|    695|		return SC_ERROR_INVALID_TLV_OBJECT;
  ------------------
  |  |   98|    695|#define SC_ERROR_INVALID_TLV_OBJECT		-1417
  ------------------
   85|    695|	}
   86|  57.2k|	tag = *p;
   87|  57.2k|	p++;
   88|  57.2k|	len = *p;
   89|  57.2k|	p++;
   90|  57.2k|	left -= 2;
   91|       |
   92|  57.2k|	if (len == 0xff) {
  ------------------
  |  Branch (92:6): [True: 1.87k, False: 55.4k]
  ------------------
   93|       |		/* don't crash on bad data */
   94|  1.87k|		if (left < 2) {
  ------------------
  |  Branch (94:7): [True: 459, False: 1.42k]
  ------------------
   95|    459|			return SC_ERROR_INVALID_TLV_OBJECT;
  ------------------
  |  |   98|    459|#define SC_ERROR_INVALID_TLV_OBJECT		-1417
  ------------------
   96|    459|		}
   97|       |		/* skip two bytes (the size) */
   98|  1.42k|		len = lebytes2ushort(p);
   99|  1.42k|		p += 2;
  100|  1.42k|		left -= 2;
  101|  1.42k|	}
  102|       |
  103|  56.8k|	*tag_out = tag;
  104|  56.8k|	*taglen = len;
  105|  56.8k|	*buf = p;
  106|       |
  107|  56.8k|	if (len > left)
  ------------------
  |  Branch (107:6): [True: 4.19k, False: 52.6k]
  ------------------
  108|  4.19k|		return SC_ERROR_TLV_END_OF_CONTENTS;
  ------------------
  |  |   99|  4.19k|#define SC_ERROR_TLV_END_OF_CONTENTS	-1418
  ------------------
  109|       |
  110|  52.6k|	return SC_SUCCESS;
  ------------------
  |  |   28|  52.6k|#define SC_SUCCESS				0
  ------------------
  111|  56.8k|}

sc_sm_parse_answer:
   44|  3.99k|{
   45|  3.99k|	struct sc_asn1_entry asn1_sm_response[4];
   46|  3.99k|	unsigned char data[SC_MAX_APDU_BUFFER_SIZE];
   47|  3.99k|	size_t data_len = sizeof(data);
   48|  3.99k|	unsigned char status[2] = {0, 0};
   49|  3.99k|	size_t status_len = sizeof(status);
   50|  3.99k|	unsigned char mac[8];
   51|  3.99k|	size_t mac_len = sizeof(mac);
   52|  3.99k|	int rv;
   53|       |
   54|  3.99k|	if (!resp_data || !resp_len || !out)
  ------------------
  |  Branch (54:6): [True: 0, False: 3.99k]
  |  Branch (54:20): [True: 0, False: 3.99k]
  |  Branch (54:33): [True: 0, False: 3.99k]
  ------------------
   55|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   56|       |
   57|  3.99k|	sc_copy_asn1_entry(c_asn1_sm_response, asn1_sm_response);
   58|       |
   59|  3.99k|	sc_format_asn1_entry(asn1_sm_response + 0, data, &data_len, 0);
   60|  3.99k|	sc_format_asn1_entry(asn1_sm_response + 1, status, &status_len, 0);
   61|  3.99k|	sc_format_asn1_entry(asn1_sm_response + 2, mac, &mac_len, 0);
   62|       |
   63|  3.99k|	rv = sc_asn1_decode(card->ctx, asn1_sm_response, resp_data, resp_len, NULL, NULL);
   64|  3.99k|	if (rv)
  ------------------
  |  Branch (64:6): [True: 3.82k, False: 172]
  ------------------
   65|  3.82k|		return rv;
   66|       |
   67|    172|	if (asn1_sm_response[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|    172|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (67:6): [True: 35, False: 137]
  ------------------
   68|     35|		if (data_len > sizeof(out->data))
  ------------------
  |  Branch (68:7): [True: 0, False: 35]
  ------------------
   69|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
   70|     35|		memcpy(out->data, data, data_len);
   71|     35|		out->data_len = data_len;
   72|     35|	}
   73|    172|	if (asn1_sm_response[1].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|    172|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (73:6): [True: 172, False: 0]
  ------------------
   74|    172|		if (!status[0])
  ------------------
  |  Branch (74:7): [True: 65, False: 107]
  ------------------
   75|     65|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     65|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
   76|    107|		out->sw1 = status[0];
   77|    107|		out->sw2 = status[1];
   78|    107|	}
   79|    107|	if (asn1_sm_response[2].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|    107|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (79:6): [True: 107, False: 0]
  ------------------
   80|    107|		memcpy(out->mac, mac, mac_len);
   81|    107|		out->mac_len = mac_len;
   82|    107|	}
   83|       |
   84|    107|	return SC_SUCCESS;
  ------------------
  |  |   28|    107|#define SC_SUCCESS				0
  ------------------
   85|    172|}
sc_sm_update_apdu_response:
   98|  3.99k|{
   99|  3.99k|	struct sm_card_response sm_resp;
  100|  3.99k|	int r;
  101|       |
  102|  3.99k|	if (!apdu)
  ------------------
  |  Branch (102:6): [True: 0, False: 3.99k]
  ------------------
  103|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  104|  3.99k|	else if (!resp_data || !resp_len)
  ------------------
  |  Branch (104:11): [True: 0, False: 3.99k]
  |  Branch (104:25): [True: 0, False: 3.99k]
  ------------------
  105|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  106|       |
  107|  3.99k|	memset(&sm_resp, 0, sizeof(sm_resp));
  108|  3.99k|	r = sc_sm_parse_answer(card, resp_data, resp_len, &sm_resp);
  109|  3.99k|	if (r)
  ------------------
  |  Branch (109:6): [True: 3.89k, False: 107]
  ------------------
  110|  3.89k|		return r;
  111|       |
  112|    107|	if (sm_resp.mac_len)   {
  ------------------
  |  Branch (112:6): [True: 52, False: 55]
  ------------------
  113|     52|		if (sm_resp.mac_len > sizeof(apdu->mac))
  ------------------
  |  Branch (113:7): [True: 0, False: 52]
  ------------------
  114|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  115|     52|		memcpy(apdu->mac, sm_resp.mac, sm_resp.mac_len);
  116|     52|		apdu->mac_len = sm_resp.mac_len;
  117|     52|	}
  118|       |
  119|    107|	apdu->sw1 = sm_resp.sw1;
  120|    107|	apdu->sw2 = sm_resp.sw2;
  121|       |
  122|    107|	return SC_SUCCESS;
  ------------------
  |  |   28|    107|#define SC_SUCCESS				0
  ------------------
  123|    107|}
sc_sm_single_transmit:
  127|  3.85k|{
  128|  3.85k|	struct sc_context *ctx  = card->ctx;
  129|  3.85k|	struct sc_apdu *sm_apdu = NULL;
  130|  3.85k|	int rv;
  131|       |
  132|  3.85k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.85k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.85k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.85k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.85k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|  3.85k|	sc_log(ctx, "SM_MODE:%X", card->sm_ctx.sm_mode);
  ------------------
  |  |   71|  3.85k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  134|  3.85k|	if (!card->sm_ctx.ops.get_sm_apdu || !card->sm_ctx.ops.free_sm_apdu)
  ------------------
  |  Branch (134:6): [True: 0, False: 3.85k]
  |  Branch (134:39): [True: 0, False: 3.85k]
  ------------------
  135|  3.85k|		LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  136|       |
  137|       |	/* get SM encoded APDU */
  138|  3.85k|	rv = card->sm_ctx.ops.get_sm_apdu(card, apdu, &sm_apdu);
  139|  3.85k|	if (rv == SC_ERROR_SM_NOT_APPLIED)   {
  ------------------
  |  |  125|  3.85k|#define SC_ERROR_SM_NOT_APPLIED			-1610
  ------------------
  |  Branch (139:6): [True: 0, False: 3.85k]
  ------------------
  140|       |		/* SM wrap of this APDU is ignored by card driver.
  141|       |		 * Send plain APDU to the reader driver */
  142|      0|		rv = card->reader->ops->transmit(card->reader, apdu);
  143|      0|		LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|  3.85k|	} else {
  145|  3.85k|		if (rv < 0)
  ------------------
  |  Branch (145:7): [True: 0, False: 3.85k]
  ------------------
  146|      0|			sc_sm_stop(card);
  147|  3.85k|	}
  148|  3.85k|	LOG_TEST_RET(ctx, rv, "get SM APDU error");
  ------------------
  |  |  174|  3.85k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.85k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.85k|	int _ret = (r); \
  |  |  |  |  168|  3.85k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.85k]
  |  |  |  |  ------------------
  |  |  |  |  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|  3.85k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.85k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  149|       |
  150|       |	/* check if SM APDU is still valid */
  151|  3.85k|	rv = sc_check_apdu(card, sm_apdu);
  152|  3.85k|	if (rv < 0)   {
  ------------------
  |  Branch (152:6): [True: 0, False: 3.85k]
  ------------------
  153|      0|		card->sm_ctx.ops.free_sm_apdu(card, apdu, &sm_apdu);
  154|      0|		sc_sm_stop(card);
  155|      0|		LOG_TEST_RET(ctx, rv, "cannot validate SM encoded APDU");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  156|      0|	}
  157|       |
  158|       |	/* send APDU flagged as NO_SM */
  159|  3.85k|	sm_apdu->flags |= SC_APDU_FLAGS_NO_SM | SC_APDU_FLAGS_NO_RETRY_WL;
  ------------------
  |  |  314|  3.85k|#define SC_APDU_FLAGS_NO_SM		0x00000008UL
  ------------------
              	sm_apdu->flags |= SC_APDU_FLAGS_NO_SM | SC_APDU_FLAGS_NO_RETRY_WL;
  ------------------
  |  |  312|  3.85k|#define SC_APDU_FLAGS_NO_RETRY_WL	0x00000004UL
  ------------------
  160|  3.85k|	rv = sc_transmit_apdu(card, sm_apdu);
  161|  3.85k|	if (rv < 0) {
  ------------------
  |  Branch (161:6): [True: 41, False: 3.81k]
  ------------------
  162|     41|		card->sm_ctx.ops.free_sm_apdu(card, apdu, &sm_apdu);
  163|     41|		sc_sm_stop(card);
  164|     41|		LOG_TEST_RET(ctx, rv, "unable to transmit APDU");
  ------------------
  |  |  174|     41|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     41|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     41|	int _ret = (r); \
  |  |  |  |  168|     41|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 41, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     41|		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|     41|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     41|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     41|		return _ret; \
  |  |  |  |  172|     41|	} \
  |  |  |  |  173|     41|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|     41|	}
  166|       |
  167|       |	/* decode SM answer and free temporary SM related data */
  168|  3.81k|	rv = card->sm_ctx.ops.free_sm_apdu(card, apdu, &sm_apdu);
  169|  3.81k|	if (rv < 0)
  ------------------
  |  Branch (169:6): [True: 563, False: 3.25k]
  ------------------
  170|    563|		sc_sm_stop(card);
  171|       |
  172|  3.81k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  3.81k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.81k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.81k|	int _ret = r; \
  |  |  |  |  155|  3.81k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.81k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.81k|		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|    563|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 563, False: 3.25k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.81k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.81k|	} 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|  3.81k|	return _ret; \
  |  |  |  |  163|  3.81k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  173|  3.81k|}
sc_sm_stop:
  177|    890|{
  178|    890|    int r = SC_SUCCESS;
  ------------------
  |  |   28|    890|#define SC_SUCCESS				0
  ------------------
  179|       |
  180|    890|    if (card) {
  ------------------
  |  Branch (180:9): [True: 890, False: 0]
  ------------------
  181|    890|        if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT
  ------------------
  |  |   47|  1.78k|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (181:13): [True: 604, False: 286]
  ------------------
  182|    604|                && card->sm_ctx.ops.close)
  ------------------
  |  Branch (182:20): [True: 0, False: 604]
  ------------------
  183|      0|            r = card->sm_ctx.ops.close(card);
  184|    890|        card->sm_ctx.sm_mode = SM_MODE_NONE;
  ------------------
  |  |   43|    890|#define SM_MODE_NONE		0x0
  ------------------
  185|    890|    }
  186|       |
  187|    890|    return r;
  188|    890|}

sc_pkcs11_print_attrs:
  180|  2.35k|{
  181|  2.35k|	if (ulCount == 0) {
  ------------------
  |  Branch (181:6): [True: 0, False: 2.35k]
  ------------------
  182|      0|		sc_do_log(context, level,
  183|      0|			file, line, function,
  184|      0|			"%s: empty template\n",
  185|      0|			info);
  186|      0|		return;
  187|      0|	}
  188|       |
  189|  7.71k|	while (ulCount--)
  ------------------
  |  Branch (189:9): [True: 5.35k, False: 2.35k]
  ------------------
  190|  5.35k|		sc_pkcs11_print_attr(level, file, line, function,
  191|  5.35k|				info, pTemplate++);
  192|       |
  193|  2.35k|}
debug.c:sc_pkcs11_print_attr:
  198|  5.35k|{
  199|  5.35k|	struct fmap	*fm;
  200|  5.35k|	const char *	value;
  201|       |
  202|  5.35k|	fm = sc_pkcs11_map_ulong(level, p11_attr_names, attr->type);
  203|       |
  204|  5.35k|	if (attr->pValue == NULL) {
  ------------------
  |  Branch (204:6): [True: 0, False: 5.35k]
  ------------------
  205|      0|		value = "<size inquiry>";
  206|  5.35k|	} else {
  207|  5.35k|		value = sc_pkcs11_print_value(level, fm,
  208|  5.35k|			attr->pValue, attr->ulValueLen);
  209|  5.35k|	}
  210|       |
  211|  5.35k|	if (fm == NULL) {
  ------------------
  |  Branch (211:6): [True: 8, False: 5.34k]
  ------------------
  212|      8|		sc_do_log(context, level,
  213|      8|			  file, line, function,
  214|      8|			  "%s: Attribute 0x%lx = %s\n",
  215|      8|			  info, attr->type, value);
  216|  5.34k|	} else {
  217|  5.34k|		sc_do_log(context, level,
  218|  5.34k|			  file, line, function,
  219|  5.34k|			  "%s: %s = %s\n",
  220|  5.34k|			  info, fm->name, value);
  221|  5.34k|	}
  222|  5.35k|}
debug.c:sc_pkcs11_map_ulong:
  292|  7.88k|{
  293|  57.3k|	for (; fm && fm->name; fm++) {
  ------------------
  |  Branch (293:9): [True: 57.3k, False: 0]
  |  Branch (293:15): [True: 57.1k, False: 127]
  ------------------
  294|  57.1k|		if (fm->value == value)
  ------------------
  |  Branch (294:7): [True: 7.76k, False: 49.4k]
  ------------------
  295|  7.76k|			return fm;
  296|  57.1k|	}
  297|    127|	return NULL;
  298|  7.88k|}
debug.c:sc_pkcs11_print_ulong:
  249|  2.64k|{
  250|  2.64k|	static char	buffer[64];
  251|  2.64k|	CK_ULONG	value;
  252|       |
  253|  2.64k|	if (count == sizeof(CK_ULONG)) {
  ------------------
  |  Branch (253:6): [True: 2.53k, False: 112]
  ------------------
  254|  2.53k|		memcpy(&value, ptr, count);
  255|  2.53k|		if ((fm = sc_pkcs11_map_ulong(level, fm->map, value)) != NULL)
  ------------------
  |  Branch (255:7): [True: 2.41k, False: 119]
  ------------------
  256|  2.41k|			return fm->name;
  257|    119|		sprintf(buffer, "0x%lx", (unsigned long) value);
  258|    119|		return buffer;
  259|  2.53k|	}
  260|       |
  261|    112|	return sc_pkcs11_print_value(level, NULL, ptr, count);
  262|  2.64k|}
debug.c:sc_pkcs11_print_bool:
  266|  2.05k|{
  267|  2.05k|	CK_BBOOL	value;
  268|       |
  269|  2.05k|	if (count == sizeof(CK_BBOOL)) {
  ------------------
  |  Branch (269:6): [True: 2.05k, False: 0]
  ------------------
  270|  2.05k|		memcpy(&value, ptr, count);
  271|  2.05k|		if (value)
  ------------------
  |  Branch (271:7): [True: 1.43k, False: 615]
  ------------------
  272|  1.43k|			return "TRUE";
  273|    615|		return "FALSE";
  274|  2.05k|	}
  275|       |
  276|      0|	return sc_pkcs11_print_value(level, NULL, ptr, count);
  277|  2.05k|}
debug.c:sc_pkcs11_print_string:
  281|     21|{
  282|     21|	static char	buffer[128];
  283|       |
  284|     21|	if (count >= sizeof(buffer))
  ------------------
  |  Branch (284:6): [True: 0, False: 21]
  ------------------
  285|      0|		count = sizeof(buffer)-1;
  286|     21|	memcpy(buffer, ptr, count);
  287|     21|	buffer[count] = 0;
  288|     21|	return buffer;
  289|     21|}
debug.c:sc_pkcs11_print_value:
  226|  5.46k|{
  227|  5.46k|	static char buffer[4 * DUMP_TEMPLATE_MAX + 1] = "";
  228|       |
  229|  5.46k|	if (count == (CK_ULONG)-1)
  ------------------
  |  Branch (229:6): [True: 0, False: 5.46k]
  ------------------
  230|      0|		return "<error>";
  231|       |
  232|  5.46k|	if (!fm || !fm->print) {
  ------------------
  |  Branch (232:6): [True: 120, False: 5.34k]
  |  Branch (232:13): [True: 629, False: 4.71k]
  ------------------
  233|    749|		unsigned char *value = (unsigned char*) ptr;
  234|    749|		char	*p;
  235|       |
  236|    749|		if (count > DUMP_TEMPLATE_MAX)
  ------------------
  |  |   28|    749|#define DUMP_TEMPLATE_MAX	32
  ------------------
  |  Branch (236:7): [True: 38, False: 711]
  ------------------
  237|     38|			count = DUMP_TEMPLATE_MAX;
  ------------------
  |  |   28|     38|#define DUMP_TEMPLATE_MAX	32
  ------------------
  238|       |
  239|  3.33k|		for (p = buffer; count--; value++)
  ------------------
  |  Branch (239:20): [True: 2.58k, False: 749]
  ------------------
  240|  2.58k|			p += sprintf(p, "%02X", *value);
  241|    749|		return buffer;
  242|    749|	}
  243|       |
  244|  4.71k|	return fm->print(level, fm, ptr, count);
  245|  5.46k|}

C_GetTokenInfo:
  498|  1.55k|{
  499|  1.55k|	struct sc_pkcs11_slot *slot;
  500|  1.55k|	struct pkcs15_fw_data *fw_data = NULL;
  501|  1.55k|	struct sc_pkcs15_object *auth;
  502|  1.55k|	const char *name;
  503|  1.55k|	CK_RV rv;
  504|       |
  505|  1.55k|	if (pInfo == NULL_PTR)
  ------------------
  |  |   27|  1.55k|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (505:6): [True: 0, False: 1.55k]
  ------------------
  506|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  507|       |
  508|  1.55k|	rv = sc_pkcs11_lock();
  509|  1.55k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.55k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (509:6): [True: 0, False: 1.55k]
  ------------------
  510|      0|		return rv;
  511|  1.55k|	sc_log(context, "C_GetTokenInfo(%lx)", slotID);
  ------------------
  |  |   71|  1.55k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  512|       |
  513|  1.55k|	rv = slot_get_token(slotID, &slot);
  514|  1.55k|	if (rv != CKR_OK)   {
  ------------------
  |  | 1086|  1.55k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (514:6): [True: 0, False: 1.55k]
  ------------------
  515|      0|		sc_log(context, "C_GetTokenInfo() get token: rv 0x%lX", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  516|      0|		goto out;
  517|      0|	}
  518|       |
  519|  1.55k|	if (slot->p11card == NULL) {
  ------------------
  |  Branch (519:6): [True: 0, False: 1.55k]
  ------------------
  520|      0|		if (slot->slot_info.flags & CKF_TOKEN_PRESENT) {
  ------------------
  |  |  407|      0|#define CKF_TOKEN_PRESENT 0x00000001UL
  ------------------
  |  Branch (520:7): [True: 0, False: 0]
  ------------------
  521|      0|			rv = CKR_TOKEN_NOT_RECOGNIZED;
  ------------------
  |  | 1145|      0|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
  522|      0|		} else {
  523|      0|			rv = CKR_TOKEN_NOT_PRESENT;
  ------------------
  |  | 1144|      0|#define CKR_TOKEN_NOT_PRESENT 0x000000E0UL
  ------------------
  524|      0|		}
  525|      0|		goto out;
  526|      0|	}
  527|       |
  528|  1.55k|	fw_data = (struct pkcs15_fw_data *) slot->p11card->fws_data[slot->fw_data_idx];
  529|  1.55k|	if (!fw_data) {
  ------------------
  |  Branch (529:6): [True: 0, False: 1.55k]
  ------------------
  530|      0|		rv = sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetTokenInfo");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  531|      0|		goto out;
  532|      0|	}
  533|       |	/* User PIN flags are cleared before re-calculation */
  534|  1.55k|	slot->token_info.flags &= ~(CKF_USER_PIN_COUNT_LOW | CKF_USER_PIN_FINAL_TRY | CKF_USER_PIN_LOCKED | CKF_USER_PIN_TO_BE_CHANGED);
  ------------------
  |  |  422|  1.55k|#define CKF_USER_PIN_COUNT_LOW 0x00010000UL
  ------------------
              	slot->token_info.flags &= ~(CKF_USER_PIN_COUNT_LOW | CKF_USER_PIN_FINAL_TRY | CKF_USER_PIN_LOCKED | CKF_USER_PIN_TO_BE_CHANGED);
  ------------------
  |  |  423|  1.55k|#define CKF_USER_PIN_FINAL_TRY 0x00020000UL
  ------------------
              	slot->token_info.flags &= ~(CKF_USER_PIN_COUNT_LOW | CKF_USER_PIN_FINAL_TRY | CKF_USER_PIN_LOCKED | CKF_USER_PIN_TO_BE_CHANGED);
  ------------------
  |  |  424|  1.55k|#define CKF_USER_PIN_LOCKED 0x00040000UL
  ------------------
              	slot->token_info.flags &= ~(CKF_USER_PIN_COUNT_LOW | CKF_USER_PIN_FINAL_TRY | CKF_USER_PIN_LOCKED | CKF_USER_PIN_TO_BE_CHANGED);
  ------------------
  |  |  425|  1.55k|#define CKF_USER_PIN_TO_BE_CHANGED 0x00080000UL
  ------------------
  535|  1.55k|	auth = slot_data_auth(slot->fw_data);
  ------------------
  |  |   51|  1.55k|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|  1.24k|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (50:23): [True: 1.24k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|  1.24k|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  ------------------
  |  |  |  Branch (51:29): [True: 1.24k, False: 317]
  |  |  ------------------
  ------------------
  536|  1.55k|	sc_log(context,
  ------------------
  |  |   71|  1.55k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  537|  1.55k|		"C_GetTokenInfo() auth. object %p, token-info flags 0x%lX", auth,
  538|  1.55k|		slot->token_info.flags);
  539|  1.55k|	if (auth) {
  ------------------
  |  Branch (539:6): [True: 977, False: 581]
  ------------------
  540|    977|		struct sc_pkcs15_card *p15card = NULL;
  541|    977|		struct sc_pkcs15_auth_info *pin_info = NULL;
  542|       |
  543|    977|		pin_info = (struct sc_pkcs15_auth_info*) auth->data;
  544|       |
  545|    977|		p15card = fw_data->p15_card;
  546|    977|		if (!p15card) {
  ------------------
  |  Branch (546:7): [True: 0, False: 977]
  ------------------
  547|      0|			rv = sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GetTokenInfo");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  548|      0|			goto out;
  549|      0|		}
  550|       |
  551|    977|		sc_pkcs15_get_pin_info(p15card, auth);
  552|       |
  553|    977|		if (pin_info->tries_left >= 0) {
  ------------------
  |  Branch (553:7): [True: 269, False: 708]
  ------------------
  554|    269|			if (pin_info->tries_left == 1 || pin_info->max_tries == 1)
  ------------------
  |  Branch (554:8): [True: 5, False: 264]
  |  Branch (554:37): [True: 0, False: 264]
  ------------------
  555|      5|				slot->token_info.flags |= CKF_USER_PIN_FINAL_TRY;
  ------------------
  |  |  423|      5|#define CKF_USER_PIN_FINAL_TRY 0x00020000UL
  ------------------
  556|    264|			else if (pin_info->tries_left == 0)
  ------------------
  |  Branch (556:13): [True: 25, False: 239]
  ------------------
  557|     25|				slot->token_info.flags |= CKF_USER_PIN_LOCKED;
  ------------------
  |  |  424|     25|#define CKF_USER_PIN_LOCKED 0x00040000UL
  ------------------
  558|    239|			else if (pin_info->max_tries > 1 && pin_info->tries_left < pin_info->max_tries)
  ------------------
  |  Branch (558:13): [True: 32, False: 207]
  |  Branch (558:40): [True: 6, False: 26]
  ------------------
  559|      6|				slot->token_info.flags |= CKF_USER_PIN_COUNT_LOW;
  ------------------
  |  |  422|      6|#define CKF_USER_PIN_COUNT_LOW 0x00010000UL
  ------------------
  560|    269|		}
  561|    977|		if (pin_info->logged_in & SC_PIN_STATE_NEEDS_CHANGE) {
  ------------------
  |  |  433|    977|#define SC_PIN_STATE_NEEDS_CHANGE 4
  ------------------
  |  Branch (561:7): [True: 0, False: 977]
  ------------------
  562|      0|			slot->token_info.flags |= CKF_USER_PIN_TO_BE_CHANGED;
  ------------------
  |  |  425|      0|#define CKF_USER_PIN_TO_BE_CHANGED 0x00080000UL
  ------------------
  563|      0|		}
  564|    977|	}
  565|  1.55k|	memcpy(pInfo, &slot->token_info, sizeof(CK_TOKEN_INFO));
  566|       |
  567|  1.55k|out:
  568|  1.55k|	name = lookup_enum(RV_T, rv);
  569|  1.55k|	if (name)
  ------------------
  |  Branch (569:6): [True: 1.55k, False: 0]
  ------------------
  570|  1.55k|		sc_log(context, "C_GetTokenInfo(%lx) returns %s", slotID, name);
  ------------------
  |  |   71|  1.55k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  571|      0|	else
  572|      0|		sc_log(context, "C_GetTokenInfo(%lx) returns 0x%08lX", slotID, rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  573|  1.55k|	sc_pkcs11_unlock();
  574|       |
  575|  1.55k|	return rv;
  576|  1.55k|}
_is_slot_auth_object:
 1313|  12.1k|{
 1314|       |
 1315|       |	/* Ignore all but PIN authentication objects */
 1316|  12.1k|	if (pin_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  12.1k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1316:6): [True: 0, False: 12.1k]
  ------------------
 1317|      0|		return 0;
 1318|       |
 1319|       |	/* Ignore any non-authentication PINs */
 1320|  12.1k|	if ((pin_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) != 0)
  ------------------
  |  |   61|  12.1k|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (1320:6): [True: 2.53k, False: 9.57k]
  ------------------
 1321|  2.53k|		return 0;
 1322|       |
 1323|       |	/* Ignore unblocking pins */
 1324|  9.57k|	if (!sc_pkcs11_conf.create_puk_slot)
  ------------------
  |  Branch (1324:6): [True: 9.57k, False: 0]
  ------------------
 1325|  9.57k|		if (pin_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|  9.57k|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (1325:7): [True: 1.03k, False: 8.54k]
  ------------------
 1326|  1.03k|			return 0;
 1327|       |
 1328|  8.54k|	return 1;
 1329|  9.57k|}
_get_auth_object_by_name:
 1393|  6.39k|{
 1394|  6.39k|	struct sc_pkcs15_object *out = NULL;
 1395|  6.39k|	int rv = SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|  6.39k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1396|       |
 1397|       |	/* please keep me in sync with md_get_pin_by_role() in minidriver */
 1398|       |
 1399|       |	/* If 'label' is set, then search for PIN with that label */
 1400|  6.39k|	if (label) {
  ------------------
  |  Branch (1400:6): [True: 0, False: 6.39k]
  ------------------
 1401|      0|		struct sc_pkcs15_id id;
 1402|      0|		strncpy((char*)id.value, label, sizeof(id.value) - 1);
 1403|      0|		id.len = strlen(label);
 1404|      0|		if (id.len > sizeof(id.value))
  ------------------
  |  Branch (1404:7): [True: 0, False: 0]
  ------------------
 1405|      0|			id.len = sizeof(id.value);
 1406|      0|		rv = sc_pkcs15_find_pin_by_auth_id(p15card, &id, &out);
 1407|      0|	}
 1408|  6.39k|	else if (!strcmp(name, "UserPIN"))   {
  ------------------
  |  Branch (1408:11): [True: 6.39k, False: 0]
  ------------------
 1409|       |		/* Try to get 'global' PIN; if no, get the 'local' one */
 1410|  6.39k|		rv = sc_pkcs15_find_pin_by_flags(p15card, SC_PKCS15_PIN_TYPE_FLAGS_PIN_GLOBAL,
  ------------------
  |  |   75|  6.39k|	( SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  ------------------
  |  |  |  |   58|  6.39k|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  ------------------
 1411|  6.39k|				SC_PKCS15_PIN_TYPE_FLAGS_MASK, NULL, &out);
  ------------------
  |  |   68|  6.39k|	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   55|  6.39k|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   58|  6.39k|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   69|  6.39k|	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   60|  6.39k|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |               	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   61|  6.39k|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  ------------------
 1412|  6.39k|		if (rv)
  ------------------
  |  Branch (1412:7): [True: 3.58k, False: 2.80k]
  ------------------
 1413|  3.58k|			rv = sc_pkcs15_find_pin_by_flags(p15card, SC_PKCS15_PIN_TYPE_FLAGS_PIN_LOCAL,
  ------------------
  |  |   78|  3.58k|	( SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   58|  3.58k|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   55|  3.58k|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  ------------------
 1414|  3.58k|					SC_PKCS15_PIN_TYPE_FLAGS_MASK, NULL, &out);
  ------------------
  |  |   68|  3.58k|	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   55|  3.58k|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   58|  3.58k|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   69|  3.58k|	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   60|  3.58k|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |               	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   61|  3.58k|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  ------------------
 1415|  6.39k|	}
 1416|      0|	else if (!strcmp(name, "SignPIN"))   {
  ------------------
  |  Branch (1416:11): [True: 0, False: 0]
  ------------------
 1417|      0|		int idx = 0;
 1418|       |
 1419|       |		/* Get the 'global' user PIN */
 1420|      0|		rv = sc_pkcs15_find_pin_by_flags(p15card, SC_PKCS15_PIN_TYPE_FLAGS_PIN_GLOBAL,
  ------------------
  |  |   75|      0|	( SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  ------------------
 1421|      0|				SC_PKCS15_PIN_TYPE_FLAGS_MASK, NULL, &out);
  ------------------
  |  |   68|      0|	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   69|      0|	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |               	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  ------------------
 1422|      0|		if (!rv)   {
  ------------------
  |  Branch (1422:7): [True: 0, False: 0]
  ------------------
 1423|       |			/* Global (user) PIN exists, get the local one -- sign PIN */
 1424|      0|			rv = sc_pkcs15_find_pin_by_flags(p15card, SC_PKCS15_PIN_TYPE_FLAGS_PIN_LOCAL,
  ------------------
  |  |   78|      0|	( SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  ------------------
 1425|      0|					SC_PKCS15_PIN_TYPE_FLAGS_MASK, NULL, &out);
  ------------------
  |  |   68|      0|	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   69|      0|	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |               	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  ------------------
 1426|      0|		}
 1427|      0|		else   {
 1428|       |			/* No global PIN, try to get first local one -- user PIN */
 1429|      0|			rv = sc_pkcs15_find_pin_by_flags(p15card, SC_PKCS15_PIN_TYPE_FLAGS_PIN_LOCAL,
  ------------------
  |  |   78|      0|	( SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  ------------------
 1430|      0|					SC_PKCS15_PIN_TYPE_FLAGS_MASK, &idx, &out);
  ------------------
  |  |   68|      0|	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   69|      0|	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |               	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  ------------------
 1431|      0|			if (!rv)   {
  ------------------
  |  Branch (1431:8): [True: 0, False: 0]
  ------------------
 1432|       |				/* User PIN is local, try to get the second local -- sign PIN */
 1433|      0|				idx++;
 1434|      0|				rv = sc_pkcs15_find_pin_by_flags(p15card, SC_PKCS15_PIN_TYPE_FLAGS_PIN_LOCAL,
  ------------------
  |  |   78|      0|	( SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  ------------------
 1435|      0|						SC_PKCS15_PIN_TYPE_FLAGS_MASK, &idx, &out);
  ------------------
  |  |   68|      0|	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   69|      0|	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |               	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  ------------------
 1436|      0|			}
 1437|      0|		}
 1438|      0|	}
 1439|      0|	else if (!strcmp(name, "UserPUK"))   {
  ------------------
  |  Branch (1439:11): [True: 0, False: 0]
  ------------------
 1440|       |		/* Get the 'global' PUK; if no, get the 'local' one */
 1441|      0|		rv = sc_pkcs15_find_pin_by_flags(p15card, SC_PKCS15_PIN_TYPE_FLAGS_PUK_GLOBAL,
  ------------------
  |  |   81|      0|	( SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN				\
  |  |  ------------------
  |  |  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |   82|      0|	| SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  ------------------
 1442|      0|				SC_PKCS15_PIN_TYPE_FLAGS_MASK, NULL, &out);
  ------------------
  |  |   68|      0|	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   69|      0|	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |               	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  ------------------
 1443|      0|		if (rv)
  ------------------
  |  Branch (1443:7): [True: 0, False: 0]
  ------------------
 1444|      0|			rv = sc_pkcs15_find_pin_by_flags(p15card, SC_PKCS15_PIN_TYPE_FLAGS_PUK_LOCAL,
  ------------------
  |  |   85|      0|	( SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN				\
  |  |  ------------------
  |  |  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |   86|      0|	| SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |               	| SC_PKCS15_PIN_FLAG_INITIALIZED | SC_PKCS15_PIN_FLAG_LOCAL)
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  ------------------
 1445|      0|					SC_PKCS15_PIN_TYPE_FLAGS_MASK, NULL, &out);
  ------------------
  |  |   68|      0|	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   55|      0|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_LOCAL | SC_PKCS15_PIN_FLAG_INITIALIZED 	\
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   69|      0|	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  |  |  ------------------
  |  |               	| SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN | SC_PKCS15_PIN_FLAG_SO_PIN )
  |  |  ------------------
  |  |  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  ------------------
 1446|      0|	}
 1447|      0|	else if (!strcmp(name, "SignPUK"))   {
  ------------------
  |  Branch (1447:11): [True: 0, False: 0]
  ------------------
 1448|       |		/* TODO: Sign PUK to be defined */
 1449|      0|	}
 1450|      0|	else if (!strcmp(name, "SoPIN"))   {
  ------------------
  |  Branch (1450:11): [True: 0, False: 0]
  ------------------
 1451|      0|		rv = sc_pkcs15_find_pin_by_flags(p15card, SC_PKCS15_PIN_TYPE_FLAGS_SOPIN,
  ------------------
  |  |   72|      0|	( SC_PKCS15_PIN_FLAG_SO_PIN | SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  ------------------
  |  |  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_SO_PIN | SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  ------------------
 1452|      0|				SC_PKCS15_PIN_TYPE_FLAGS_SOPIN, NULL, &out);
  ------------------
  |  |   72|      0|	( SC_PKCS15_PIN_FLAG_SO_PIN | SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  ------------------
  |  |  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  |  |  ------------------
  |  |               	( SC_PKCS15_PIN_FLAG_SO_PIN | SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  ------------------
  |  |  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  ------------------
 1453|      0|	}
 1454|       |
 1455|  6.39k|	return rv ? NULL : out;
  ------------------
  |  Branch (1455:9): [True: 2.22k, False: 4.17k]
  ------------------
 1456|  6.39k|}
framework-pkcs15.c:pkcs15_bind:
  281|  16.5k|{
  282|  16.5k|	struct pkcs15_fw_data *fw_data = NULL;
  283|  16.5k|	struct sc_aid *aid = app_info ? &app_info->aid : NULL;
  ------------------
  |  Branch (283:23): [True: 4.33k, False: 12.2k]
  ------------------
  284|  16.5k|	int rc, idx;
  285|  16.5k|	CK_RV ck_rv;
  286|       |
  287|  16.5k|	sc_log(context, "Bind PKCS#15 '%s' application", app_info ? app_info->label : "<anonymous>");
  ------------------
  |  |   71|  33.1k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 4.33k, False: 12.2k]
  |  |  ------------------
  ------------------
  288|  16.5k|	if (!p11card)
  ------------------
  |  Branch (288:6): [True: 0, False: 16.5k]
  ------------------
  289|      0|		return CKR_TOKEN_NOT_RECOGNIZED;
  ------------------
  |  | 1145|      0|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
  290|  21.4k|	for (idx=0; idx<SC_PKCS11_FRAMEWORK_DATA_MAX_NUM; idx++)
  ------------------
  |  |  194|  21.4k|#define SC_PKCS11_FRAMEWORK_DATA_MAX_NUM	4
  ------------------
  |  Branch (290:14): [True: 21.3k, False: 146]
  ------------------
  291|  21.3k|		if (!p11card->fws_data[idx])
  ------------------
  |  Branch (291:7): [True: 16.4k, False: 4.90k]
  ------------------
  292|  16.4k|			break;
  293|  16.5k|	if (idx == SC_PKCS11_FRAMEWORK_DATA_MAX_NUM)
  ------------------
  |  |  194|  16.5k|#define SC_PKCS11_FRAMEWORK_DATA_MAX_NUM	4
  ------------------
  |  Branch (293:6): [True: 146, False: 16.4k]
  ------------------
  294|    146|		return CKR_USER_TOO_MANY_TYPES;
  ------------------
  |  | 1155|    146|#define CKR_USER_TOO_MANY_TYPES 0x00000105UL
  ------------------
  295|       |
  296|  16.4k|	if (!(fw_data = calloc(1, sizeof(*fw_data))))
  ------------------
  |  Branch (296:6): [True: 0, False: 16.4k]
  ------------------
  297|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  298|  16.4k|	p11card->fws_data[idx] = fw_data;
  299|       |
  300|  16.4k|	rc = sc_pkcs15_bind(p11card->card, aid, &fw_data->p15_card);
  301|  16.4k|	if (rc != SC_SUCCESS) {
  ------------------
  |  |   28|  16.4k|#define SC_SUCCESS				0
  ------------------
  |  Branch (301:6): [True: 9.93k, False: 6.47k]
  ------------------
  302|  9.93k|		sc_log(context, "sc_pkcs15_bind failed: %d", rc);
  ------------------
  |  |   71|  9.93k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  303|  9.93k|		return sc_to_cryptoki_error(rc, NULL);
  304|  9.93k|	}
  305|       |
  306|       |	/* Mechanisms are registered globally per card. Checking
  307|       |	 * p11card->nmechanisms avoids registering the same mechanisms twice for a
  308|       |	 * card with multiple slots. */
  309|  6.47k|	if (!p11card->nmechanisms) {
  ------------------
  |  Branch (309:6): [True: 6.01k, False: 457]
  ------------------
  310|  6.01k|		ck_rv = register_mechanisms(p11card);
  311|  6.01k|		if (ck_rv != CKR_OK) {
  ------------------
  |  | 1086|  6.01k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (311:7): [True: 0, False: 6.01k]
  ------------------
  312|      0|			sc_log(context, "cannot register mechanisms; CKR 0x%lX",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  313|      0|			       ck_rv);
  314|      0|			return ck_rv;
  315|      0|		}
  316|  6.01k|	}
  317|       |
  318|  6.47k|	return CKR_OK;
  ------------------
  |  | 1086|  6.47k|#define CKR_OK 0x00000000UL
  ------------------
  319|  6.47k|}
framework-pkcs15.c:register_mechanisms:
 6497|  6.01k|{
 6498|  6.01k|	sc_card_t *card = p11card->card;
 6499|  6.01k|	sc_algorithm_info_t *alg_info;
 6500|  6.01k|	CK_MECHANISM_INFO mech_info;
 6501|  6.01k|	CK_ULONG ec_min_key_size, ec_max_key_size,
 6502|  6.01k|		aes_min_key_size, aes_max_key_size;
 6503|  6.01k|	unsigned long ec_ext_flags;
 6504|  6.01k|	sc_pkcs11_mechanism_type_t *mt = NULL, *registered_mt = NULL;
 6505|  6.01k|	unsigned int num;
 6506|  6.01k|	int rsa_flags = 0, ec_flags = 0, eddsa_flags = 0, xeddsa_flags = 0;
 6507|  6.01k|	int ec_found = 0, gostr_flags = 0, aes_flags = 0;
 6508|  6.01k|	CK_RV rc;
 6509|       |
 6510|       |	/* Register generic mechanisms */
 6511|  6.01k|	sc_pkcs11_register_generic_mechanisms(p11card);
 6512|       |
 6513|  6.01k|	mech_info.flags = CKF_HW | CKF_SIGN | CKF_DECRYPT;
  ------------------
  |  |  352|  6.01k|#define CKF_HW 0x00000001UL
  ------------------
              	mech_info.flags = CKF_HW | CKF_SIGN | CKF_DECRYPT;
  ------------------
  |  |  363|  6.01k|#define CKF_SIGN 0x00000800UL
  ------------------
              	mech_info.flags = CKF_HW | CKF_SIGN | CKF_DECRYPT;
  ------------------
  |  |  361|  6.01k|#define CKF_DECRYPT 0x00000200UL
  ------------------
 6514|  6.01k|#ifdef ENABLE_OPENSSL
 6515|       |	/* That practise definitely conflicts with CKF_HW -- andre 2010-11-28 */
 6516|  6.01k|	mech_info.flags |= CKF_VERIFY;
  ------------------
  |  |  365|  6.01k|#define CKF_VERIFY 0x00002000UL
  ------------------
 6517|  6.01k|#endif
 6518|  6.01k|	if ((card->caps & SC_CARD_CAP_UNWRAP_KEY) == SC_CARD_CAP_UNWRAP_KEY)
  ------------------
  |  |  574|  6.01k|#define SC_CARD_CAP_UNWRAP_KEY			0x00001000
  ------------------
              	if ((card->caps & SC_CARD_CAP_UNWRAP_KEY) == SC_CARD_CAP_UNWRAP_KEY)
  ------------------
  |  |  574|  6.01k|#define SC_CARD_CAP_UNWRAP_KEY			0x00001000
  ------------------
  |  Branch (6518:6): [True: 26, False: 5.98k]
  ------------------
 6519|     26|		mech_info.flags |= CKF_UNWRAP;
  ------------------
  |  |  370|     26|#define CKF_UNWRAP 0x00040000UL
  ------------------
 6520|  6.01k|	if ((card->caps & SC_CARD_CAP_WRAP_KEY) == SC_CARD_CAP_WRAP_KEY)
  ------------------
  |  |  572|  6.01k|#define SC_CARD_CAP_WRAP_KEY			0x00000800
  ------------------
              	if ((card->caps & SC_CARD_CAP_WRAP_KEY) == SC_CARD_CAP_WRAP_KEY)
  ------------------
  |  |  572|  6.01k|#define SC_CARD_CAP_WRAP_KEY			0x00000800
  ------------------
  |  Branch (6520:6): [True: 26, False: 5.98k]
  ------------------
 6521|     26|		mech_info.flags |= CKF_WRAP;
  ------------------
  |  |  369|     26|#define CKF_WRAP 0x00020000UL
  ------------------
 6522|       |
 6523|  6.01k|	mech_info.ulMinKeySize = ~0;
 6524|  6.01k|	mech_info.ulMaxKeySize = 0;
 6525|  6.01k|	ec_min_key_size = ~0;
 6526|  6.01k|	ec_max_key_size = 0;
 6527|  6.01k|	aes_min_key_size = ~0;
 6528|  6.01k|	aes_max_key_size = 0;
 6529|       |
 6530|  6.01k|	ec_ext_flags = 0;
 6531|       |
 6532|       |	/* For now, we just OR all the algorithm specific
 6533|       |	 * flags, based on the assumption that cards don't
 6534|       |	 * support different modes for different key *sizes*. */
 6535|  6.01k|	num = card->algorithm_count;
 6536|  6.01k|	alg_info = card->algorithms;
 6537|  29.7k|	while (num--) {
  ------------------
  |  Branch (6537:9): [True: 23.7k, False: 6.01k]
  ------------------
 6538|  23.7k|		switch (alg_info->algorithm) {
  ------------------
  |  Branch (6538:11): [True: 23.7k, False: 12]
  ------------------
 6539|  17.4k|			case SC_ALGORITHM_RSA:
  ------------------
  |  |   69|  17.4k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (6539:4): [True: 17.4k, False: 6.29k]
  ------------------
 6540|  17.4k|				if (alg_info->key_length < mech_info.ulMinKeySize)
  ------------------
  |  Branch (6540:9): [True: 5.71k, False: 11.7k]
  ------------------
 6541|  5.71k|					mech_info.ulMinKeySize = alg_info->key_length;
 6542|  17.4k|				if (alg_info->key_length > mech_info.ulMaxKeySize)
  ------------------
  |  Branch (6542:9): [True: 16.9k, False: 466]
  ------------------
 6543|  16.9k|					mech_info.ulMaxKeySize = alg_info->key_length;
 6544|  17.4k|				rsa_flags |= alg_info->flags;
 6545|  17.4k|				break;
 6546|  6.07k|			case SC_ALGORITHM_EC:
  ------------------
  |  |   70|  6.07k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (6546:4): [True: 6.07k, False: 17.6k]
  ------------------
 6547|  6.07k|				if (alg_info->key_length < ec_min_key_size)
  ------------------
  |  Branch (6547:9): [True: 2.29k, False: 3.78k]
  ------------------
 6548|  2.29k|					ec_min_key_size = alg_info->key_length;
 6549|  6.07k|				if (alg_info->key_length > ec_max_key_size)
  ------------------
  |  Branch (6549:9): [True: 5.94k, False: 128]
  ------------------
 6550|  5.94k|					ec_max_key_size = alg_info->key_length;
 6551|  6.07k|				ec_flags |= alg_info->flags;
 6552|  6.07k|				ec_ext_flags |= alg_info->u._ec.ext_flags;
 6553|  6.07k|				ec_found = 1;
 6554|  6.07k|				break;
 6555|     96|			case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   72|     96|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (6555:4): [True: 96, False: 23.6k]
  ------------------
 6556|     96|				eddsa_flags |= alg_info->flags;
 6557|     96|				break;
 6558|     96|			case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   73|     96|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (6558:4): [True: 96, False: 23.6k]
  ------------------
 6559|     96|				xeddsa_flags |= alg_info->flags;
 6560|     96|				break;
 6561|      8|			case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   71|      8|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (6561:4): [True: 8, False: 23.7k]
  ------------------
 6562|      8|				gostr_flags |= alg_info->flags;
 6563|      8|				break;
 6564|      6|			case SC_ALGORITHM_AES:
  ------------------
  |  |   79|      6|#define SC_ALGORITHM_AES		67
  ------------------
  |  Branch (6564:4): [True: 6, False: 23.7k]
  ------------------
 6565|      6|				aes_flags |= alg_info->flags;
 6566|      6|				if (alg_info->key_length < aes_min_key_size)
  ------------------
  |  Branch (6566:9): [True: 4, False: 2]
  ------------------
 6567|      4|					aes_min_key_size = alg_info->key_length;
 6568|      6|				if (alg_info->key_length > aes_max_key_size)
  ------------------
  |  Branch (6568:9): [True: 6, False: 0]
  ------------------
 6569|      6|					aes_max_key_size = alg_info->key_length;
 6570|      6|				break;
 6571|  23.7k|		}
 6572|  23.7k|		alg_info++;
 6573|  23.7k|	}
 6574|       |
 6575|       |	/*
 6576|       |	 * TODO this looked like a bug:
 6577|       |	 * if (ec_flags & SC_ALGORITHM_ECDSA_RAW)
 6578|       |	 * Card driver driver should not have to specify SC_ALGORITHM_ECDSA_RAW
 6579|       |	 */
 6580|  6.01k|	if (ec_found) {
  ------------------
  |  Branch (6580:6): [True: 2.29k, False: 3.72k]
  ------------------
 6581|  2.29k|		rc = register_ec_mechanisms(p11card, ec_flags, ec_ext_flags, ec_min_key_size, ec_max_key_size);
 6582|  2.29k|		if (rc != CKR_OK)
  ------------------
  |  | 1086|  2.29k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6582:7): [True: 0, False: 2.29k]
  ------------------
 6583|      0|			return rc;
 6584|  2.29k|	}
 6585|       |
 6586|  6.01k|	if (eddsa_flags & SC_ALGORITHM_EDDSA_RAW) {
  ------------------
  |  |  188|  6.01k|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
  |  Branch (6586:6): [True: 94, False: 5.91k]
  ------------------
 6587|     94|		rc = register_eddsa_mechanisms(p11card, eddsa_flags, 255, 255);
 6588|     94|		if (rc != CKR_OK)
  ------------------
  |  | 1086|     94|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6588:7): [True: 0, False: 94]
  ------------------
 6589|      0|			return rc;
 6590|     94|	}
 6591|       |
 6592|  6.01k|	if (xeddsa_flags & (SC_ALGORITHM_XEDDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW)) {
  ------------------
  |  |  189|  6.01k|#define SC_ALGORITHM_XEDDSA_RAW		0x00800000
  ------------------
              	if (xeddsa_flags & (SC_ALGORITHM_XEDDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW)) {
  ------------------
  |  |  173|  6.01k|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  |  Branch (6592:6): [True: 94, False: 5.91k]
  ------------------
 6593|     94|		rc = register_xeddsa_mechanisms(p11card, xeddsa_flags, 255, 255);
 6594|     94|		if (rc != CKR_OK)
  ------------------
  |  | 1086|     94|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6594:7): [True: 0, False: 94]
  ------------------
 6595|      0|			return rc;
 6596|     94|	}
 6597|       |
 6598|  6.01k|	if (gostr_flags & (SC_ALGORITHM_GOSTR3410_RAW
  ------------------
  |  |  156|  6.01k|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  ------------------
  |  Branch (6598:6): [True: 8, False: 6.00k]
  ------------------
 6599|  6.01k|				| SC_ALGORITHM_GOSTR3410_HASH_NONE
  ------------------
  |  |  157|  6.01k|#define SC_ALGORITHM_GOSTR3410_HASH_NONE	SC_ALGORITHM_GOSTR3410_RAW /*XXX*/
  |  |  ------------------
  |  |  |  |  156|  6.01k|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  |  |  ------------------
  ------------------
 6600|  6.01k|				| SC_ALGORITHM_GOSTR3410_HASH_GOSTR3411)) {
  ------------------
  |  |  158|  6.01k|#define SC_ALGORITHM_GOSTR3410_HASH_GOSTR3411	0x00080000
  ------------------
 6601|      8|		if (gostr_flags & SC_ALGORITHM_GOSTR3410_RAW)
  ------------------
  |  |  156|      8|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  ------------------
  |  Branch (6601:7): [True: 8, False: 0]
  ------------------
 6602|      8|			gostr_flags |= SC_ALGORITHM_GOSTR3410_HASH_NONE;
  ------------------
  |  |  157|      8|#define SC_ALGORITHM_GOSTR3410_HASH_NONE	SC_ALGORITHM_GOSTR3410_RAW /*XXX*/
  |  |  ------------------
  |  |  |  |  156|      8|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  |  |  ------------------
  ------------------
 6603|      8|		rc = register_gost_mechanisms(p11card, gostr_flags);
 6604|      8|		if (rc != CKR_OK)
  ------------------
  |  | 1086|      8|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6604:7): [True: 0, False: 8]
  ------------------
 6605|      0|			return rc;
 6606|      8|	}
 6607|       |
 6608|       |	/* Check if we support raw RSA */
 6609|  6.01k|	if (rsa_flags & SC_ALGORITHM_RSA_RAW) {
  ------------------
  |  |  102|  6.01k|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  |  Branch (6609:6): [True: 4.12k, False: 1.89k]
  ------------------
 6610|  4.12k|		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_X_509, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  541|  4.12k|#define CKM_RSA_X_509 0x00000003UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_X_509, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  464|  4.12k|#define CKK_RSA 0x00000000UL
  ------------------
 6611|  4.12k|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6612|  4.12k|		sc_pkcs11_free_mechanism(&mt);
 6613|  4.12k|		if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.12k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6613:7): [True: 0, False: 4.12k]
  ------------------
 6614|      0|			return rc;
 6615|       |
 6616|       |		/* We support PKCS1 padding in software */
 6617|       |		/* either the card supports it or OpenSC does */
 6618|  4.12k|		rsa_flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|  4.12k|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|  4.12k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|  4.12k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
 6619|  4.12k|#ifdef ENABLE_OPENSSL
 6620|  4.12k|		rsa_flags |= SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  107|  4.12k|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
 6621|  4.12k|		rsa_flags |= SC_ALGORITHM_RSA_PAD_OAEP;
  ------------------
  |  |  108|  4.12k|#define SC_ALGORITHM_RSA_PAD_OAEP	0x00000020 /* PKCS#1 v2.0 OAEP */
  ------------------
 6622|  4.12k|#endif
 6623|  4.12k|	}
 6624|       |
 6625|  6.01k|	if (rsa_flags & SC_ALGORITHM_RSA_PAD_ISO9796) {
  ------------------
  |  |  106|  6.01k|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  |  Branch (6625:6): [True: 828, False: 5.18k]
  ------------------
 6626|       |		/* Supported in hardware only, if the card driver declares it. */
 6627|    828|		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_9796, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  540|    828|#define CKM_RSA_9796 0x00000002UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_9796, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  464|    828|#define CKK_RSA 0x00000000UL
  ------------------
 6628|    828|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6629|    828|		sc_pkcs11_free_mechanism(&mt);
 6630|    828|		if (rc != CKR_OK)
  ------------------
  |  | 1086|    828|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6630:7): [True: 0, False: 828]
  ------------------
 6631|      0|			return rc;
 6632|    828|	}
 6633|       |
 6634|  6.01k|#ifdef ENABLE_OPENSSL
 6635|       |	/* all our software hashes are in OpenSSL */
 6636|       |	/* Only if card did not list the hashes, will we
 6637|       |	 * help it a little, by adding all the OpenSSL hashes
 6638|       |	 * that have PKCS#11 mechanisms.
 6639|       |	 */
 6640|  6.01k|	if (!(rsa_flags & (SC_ALGORITHM_RSA_HASHES & ~SC_ALGORITHM_RSA_HASH_NONE))) {
  ------------------
  |  |  142|  6.01k|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
              	if (!(rsa_flags & (SC_ALGORITHM_RSA_HASHES & ~SC_ALGORITHM_RSA_HASH_NONE))) {
  ------------------
  |  |  133|  6.01k|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  |  Branch (6640:6): [True: 4.51k, False: 1.50k]
  ------------------
 6641|  4.51k|		rsa_flags |= SC_ALGORITHM_RSA_HASHES;
  ------------------
  |  |  142|  4.51k|#define SC_ALGORITHM_RSA_HASHES		0x0001FF00
  ------------------
 6642|  4.51k|	}
 6643|  6.01k|#endif
 6644|       |
 6645|       |	/* No need to Check for PKCS1  We support it in software and turned it on above so always added it */
 6646|  6.01k|	if (rsa_flags & SC_ALGORITHM_RSA_PAD_PKCS1) {
  ------------------
  |  |  111|  6.01k|#define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  109|  6.01k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  |  |  ------------------
  |  |               #define SC_ALGORITHM_RSA_PAD_PKCS1	(SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02) /* PKCS#1 v1.5 (type 1 or 2) */
  |  |  ------------------
  |  |  |  |  110|  6.01k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  |  Branch (6646:6): [True: 5.69k, False: 317]
  ------------------
 6647|  5.69k|		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_PKCS, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  539|  5.69k|#define CKM_RSA_PKCS 0x00000001UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_PKCS, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  464|  5.69k|#define CKK_RSA 0x00000000UL
  ------------------
 6648|  5.69k|		rc = sc_pkcs11_register_mechanism(p11card, mt, &registered_mt);
 6649|  5.69k|		sc_pkcs11_free_mechanism(&mt);
 6650|  5.69k|		if (rc != CKR_OK)
  ------------------
  |  | 1086|  5.69k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6650:7): [True: 0, False: 5.69k]
  ------------------
 6651|      0|			return rc;
 6652|       |
 6653|  5.69k|#ifdef ENABLE_OPENSSL
 6654|       |		/* sc_pkcs11_register_sign_and_hash_mechanism expects software hash */
 6655|       |		/* All hashes are in OpenSSL
 6656|       |		 * Either the card set the hashes or we helped it above */
 6657|       |
 6658|  5.69k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA1) {
  ------------------
  |  |  134|  5.69k|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  |  Branch (6658:7): [True: 5.32k, False: 374]
  ------------------
 6659|  5.32k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6660|  5.32k|				CKM_SHA1_RSA_PKCS, CKM_SHA_1, registered_mt);
  ------------------
  |  |  544|  5.32k|#define CKM_SHA1_RSA_PKCS 0x00000006UL
  ------------------
              				CKM_SHA1_RSA_PKCS, CKM_SHA_1, registered_mt);
  ------------------
  |  |  667|  5.32k|#define CKM_SHA_1 0x00000220UL
  ------------------
 6661|  5.32k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  5.32k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6661:8): [True: 0, False: 5.32k]
  ------------------
 6662|      0|				return rc;
 6663|  5.32k|		}
 6664|  5.69k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA224) {
  ------------------
  |  |  141|  5.69k|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  ------------------
  |  Branch (6664:7): [True: 4.34k, False: 1.35k]
  ------------------
 6665|  4.34k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6666|  4.34k|				CKM_SHA224_RSA_PKCS, CKM_SHA224, registered_mt);
  ------------------
  |  |  604|  4.34k|#define CKM_SHA224_RSA_PKCS 0x00000046UL
  ------------------
              				CKM_SHA224_RSA_PKCS, CKM_SHA224, registered_mt);
  ------------------
  |  |  679|  4.34k|#define CKM_SHA224 0x00000255UL
  ------------------
 6667|  4.34k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.34k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6667:8): [True: 0, False: 4.34k]
  ------------------
 6668|      0|				return rc;
 6669|  4.34k|		}
 6670|  5.69k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA256) {
  ------------------
  |  |  138|  5.69k|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  |  Branch (6670:7): [True: 5.47k, False: 222]
  ------------------
 6671|  5.47k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6672|  5.47k|				CKM_SHA256_RSA_PKCS, CKM_SHA256, registered_mt);
  ------------------
  |  |  598|  5.47k|#define CKM_SHA256_RSA_PKCS 0x00000040UL
  ------------------
              				CKM_SHA256_RSA_PKCS, CKM_SHA256, registered_mt);
  ------------------
  |  |  676|  5.47k|#define CKM_SHA256 0x00000250UL
  ------------------
 6673|  5.47k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  5.47k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6673:8): [True: 0, False: 5.47k]
  ------------------
 6674|      0|				return rc;
 6675|  5.47k|		}
 6676|  5.69k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA384) {
  ------------------
  |  |  139|  5.69k|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
  |  Branch (6676:7): [True: 4.77k, False: 922]
  ------------------
 6677|  4.77k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6678|  4.77k|				CKM_SHA384_RSA_PKCS, CKM_SHA384, registered_mt);
  ------------------
  |  |  599|  4.77k|#define CKM_SHA384_RSA_PKCS 0x00000041UL
  ------------------
              				CKM_SHA384_RSA_PKCS, CKM_SHA384, registered_mt);
  ------------------
  |  |  682|  4.77k|#define CKM_SHA384 0x00000260UL
  ------------------
 6679|  4.77k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.77k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6679:8): [True: 0, False: 4.77k]
  ------------------
 6680|      0|				return rc;
 6681|  4.77k|		}
 6682|  5.69k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA512) {
  ------------------
  |  |  140|  5.69k|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
  |  Branch (6682:7): [True: 4.77k, False: 922]
  ------------------
 6683|  4.77k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6684|  4.77k|				CKM_SHA512_RSA_PKCS, CKM_SHA512, registered_mt);
  ------------------
  |  |  600|  4.77k|#define CKM_SHA512_RSA_PKCS 0x00000042UL
  ------------------
              				CKM_SHA512_RSA_PKCS, CKM_SHA512, registered_mt);
  ------------------
  |  |  685|  4.77k|#define CKM_SHA512 0x00000270UL
  ------------------
 6685|  4.77k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.77k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6685:8): [True: 0, False: 4.77k]
  ------------------
 6686|      0|				return rc;
 6687|  4.77k|		}
 6688|  5.69k|		if (!FIPS_mode() && rsa_flags & SC_ALGORITHM_RSA_HASH_MD5) {
  ------------------
  |  |  135|  5.69k|#define SC_ALGORITHM_RSA_HASH_MD5	0x00000400
  ------------------
  |  Branch (6688:7): [True: 5.69k, False: 0]
  |  Branch (6688:23): [True: 4.76k, False: 930]
  ------------------
 6689|  4.76k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6690|  4.76k|				CKM_MD5_RSA_PKCS, CKM_MD5, registered_mt);
  ------------------
  |  |  543|  4.76k|#define CKM_MD5_RSA_PKCS 0x00000005UL
  ------------------
              				CKM_MD5_RSA_PKCS, CKM_MD5, registered_mt);
  ------------------
  |  |  664|  4.76k|#define CKM_MD5 0x00000210UL
  ------------------
 6691|  4.76k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.76k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6691:8): [True: 0, False: 4.76k]
  ------------------
 6692|      0|				return rc;
 6693|  4.76k|		}
 6694|  5.69k|		if (!FIPS_mode() && rsa_flags & SC_ALGORITHM_RSA_HASH_RIPEMD160) {
  ------------------
  |  |  137|  5.69k|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
  |  Branch (6694:7): [True: 5.69k, False: 0]
  |  Branch (6694:23): [True: 4.76k, False: 930]
  ------------------
 6695|  4.76k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6696|  4.76k|				CKM_RIPEMD160_RSA_PKCS, CKM_RIPEMD160, registered_mt);
  ------------------
  |  |  546|  4.76k|#define CKM_RIPEMD160_RSA_PKCS 0x00000008UL
  ------------------
              				CKM_RIPEMD160_RSA_PKCS, CKM_RIPEMD160, registered_mt);
  ------------------
  |  |  673|  4.76k|#define CKM_RIPEMD160 0x00000240UL
  ------------------
 6697|  4.76k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.76k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6697:8): [True: 0, False: 4.76k]
  ------------------
 6698|      0|				return rc;
 6699|  4.76k|		}
 6700|  5.69k|#endif /* ENABLE_OPENSSL */
 6701|  5.69k|	}
 6702|       |
 6703|  6.01k|	if (rsa_flags & SC_ALGORITHM_RSA_PAD_PSS) {
  ------------------
  |  |  107|  6.01k|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  |  Branch (6703:6): [True: 4.50k, False: 1.50k]
  ------------------
 6704|  4.50k|		CK_FLAGS old_flags = mech_info.flags;
 6705|  4.50k|		mech_info.flags &= ~(CKF_DECRYPT|CKF_ENCRYPT|CKF_WRAP|CKF_UNWRAP);
  ------------------
  |  |  361|  4.50k|#define CKF_DECRYPT 0x00000200UL
  ------------------
              		mech_info.flags &= ~(CKF_DECRYPT|CKF_ENCRYPT|CKF_WRAP|CKF_UNWRAP);
  ------------------
  |  |  360|  4.50k|#define CKF_ENCRYPT 0x00000100UL
  ------------------
              		mech_info.flags &= ~(CKF_DECRYPT|CKF_ENCRYPT|CKF_WRAP|CKF_UNWRAP);
  ------------------
  |  |  369|  4.50k|#define CKF_WRAP 0x00020000UL
  ------------------
              		mech_info.flags &= ~(CKF_DECRYPT|CKF_ENCRYPT|CKF_WRAP|CKF_UNWRAP);
  ------------------
  |  |  370|  4.50k|#define CKF_UNWRAP 0x00040000UL
  ------------------
 6706|  4.50k|		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_PKCS_PSS, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  551|  4.50k|#define CKM_RSA_PKCS_PSS 0x0000000DUL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_PKCS_PSS, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  464|  4.50k|#define CKK_RSA 0x00000000UL
  ------------------
 6707|  4.50k|		rc = sc_pkcs11_register_mechanism(p11card, mt, &registered_mt);
 6708|  4.50k|		sc_pkcs11_free_mechanism(&mt);
 6709|  4.50k|		if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.50k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6709:7): [True: 0, False: 4.50k]
  ------------------
 6710|      0|			return rc;
 6711|       |
 6712|  4.50k|#ifdef ENABLE_OPENSSL
 6713|       |		/* sc_pkcs11_register_sign_and_hash_mechanism expects software hash */
 6714|       |		/* All hashes are in OpenSSL
 6715|       |		 * Either the card set the hashes or we helped it above */
 6716|       |
 6717|  4.50k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA1) {
  ------------------
  |  |  134|  4.50k|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  |  Branch (6717:7): [True: 4.21k, False: 290]
  ------------------
 6718|  4.21k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6719|  4.21k|				CKM_SHA1_RSA_PKCS_PSS, CKM_SHA_1, registered_mt);
  ------------------
  |  |  552|  4.21k|#define CKM_SHA1_RSA_PKCS_PSS 0x0000000EUL
  ------------------
              				CKM_SHA1_RSA_PKCS_PSS, CKM_SHA_1, registered_mt);
  ------------------
  |  |  667|  4.21k|#define CKM_SHA_1 0x00000220UL
  ------------------
 6720|  4.21k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.21k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6720:8): [True: 0, False: 4.21k]
  ------------------
 6721|      0|				return rc;
 6722|  4.21k|		}
 6723|  4.50k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA224) {
  ------------------
  |  |  141|  4.50k|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  ------------------
  |  Branch (6723:7): [True: 3.98k, False: 519]
  ------------------
 6724|  3.98k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6725|  3.98k|				CKM_SHA224_RSA_PKCS_PSS, CKM_SHA224, registered_mt);
  ------------------
  |  |  605|  3.98k|#define CKM_SHA224_RSA_PKCS_PSS 0x00000047UL
  ------------------
              				CKM_SHA224_RSA_PKCS_PSS, CKM_SHA224, registered_mt);
  ------------------
  |  |  679|  3.98k|#define CKM_SHA224 0x00000255UL
  ------------------
 6726|  3.98k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  3.98k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6726:8): [True: 0, False: 3.98k]
  ------------------
 6727|      0|				return rc;
 6728|  3.98k|		}
 6729|  4.50k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA256) {
  ------------------
  |  |  138|  4.50k|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  |  Branch (6729:7): [True: 4.41k, False: 91]
  ------------------
 6730|  4.41k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6731|  4.41k|				CKM_SHA256_RSA_PKCS_PSS, CKM_SHA256, registered_mt);
  ------------------
  |  |  601|  4.41k|#define CKM_SHA256_RSA_PKCS_PSS 0x00000043UL
  ------------------
              				CKM_SHA256_RSA_PKCS_PSS, CKM_SHA256, registered_mt);
  ------------------
  |  |  676|  4.41k|#define CKM_SHA256 0x00000250UL
  ------------------
 6732|  4.41k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.41k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6732:8): [True: 0, False: 4.41k]
  ------------------
 6733|      0|				return rc;
 6734|  4.41k|		}
 6735|  4.50k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA384) {
  ------------------
  |  |  139|  4.50k|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
  |  Branch (6735:7): [True: 4.41k, False: 91]
  ------------------
 6736|  4.41k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6737|  4.41k|				CKM_SHA384_RSA_PKCS_PSS, CKM_SHA384, registered_mt);
  ------------------
  |  |  602|  4.41k|#define CKM_SHA384_RSA_PKCS_PSS 0x00000044UL
  ------------------
              				CKM_SHA384_RSA_PKCS_PSS, CKM_SHA384, registered_mt);
  ------------------
  |  |  682|  4.41k|#define CKM_SHA384 0x00000260UL
  ------------------
 6738|  4.41k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.41k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6738:8): [True: 0, False: 4.41k]
  ------------------
 6739|      0|				return rc;
 6740|  4.41k|		}
 6741|  4.50k|		if (rsa_flags & SC_ALGORITHM_RSA_HASH_SHA512) {
  ------------------
  |  |  140|  4.50k|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
  |  Branch (6741:7): [True: 4.41k, False: 91]
  ------------------
 6742|  4.41k|			rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6743|  4.41k|				CKM_SHA512_RSA_PKCS_PSS, CKM_SHA512, registered_mt);
  ------------------
  |  |  603|  4.41k|#define CKM_SHA512_RSA_PKCS_PSS 0x00000045UL
  ------------------
              				CKM_SHA512_RSA_PKCS_PSS, CKM_SHA512, registered_mt);
  ------------------
  |  |  685|  4.41k|#define CKM_SHA512 0x00000270UL
  ------------------
 6744|  4.41k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  4.41k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6744:8): [True: 0, False: 4.41k]
  ------------------
 6745|      0|				return rc;
 6746|  4.41k|		}
 6747|  4.50k|#endif /* ENABLE_OPENSSL */
 6748|  4.50k|		mech_info.flags = old_flags;
 6749|  4.50k|	}
 6750|       |
 6751|  6.01k|	if (rsa_flags & SC_ALGORITHM_RSA_PAD_OAEP) {
  ------------------
  |  |  108|  6.01k|#define SC_ALGORITHM_RSA_PAD_OAEP	0x00000020 /* PKCS#1 v2.0 OAEP */
  ------------------
  |  Branch (6751:6): [True: 4.41k, False: 1.60k]
  ------------------
 6752|  4.41k|		CK_FLAGS old_flags = mech_info.flags;
 6753|  4.41k|		mech_info.flags &= ~(CKF_SIGN|CKF_VERIFY|CKF_SIGN_RECOVER|CKF_VERIFY_RECOVER);
  ------------------
  |  |  363|  4.41k|#define CKF_SIGN 0x00000800UL
  ------------------
              		mech_info.flags &= ~(CKF_SIGN|CKF_VERIFY|CKF_SIGN_RECOVER|CKF_VERIFY_RECOVER);
  ------------------
  |  |  365|  4.41k|#define CKF_VERIFY 0x00002000UL
  ------------------
              		mech_info.flags &= ~(CKF_SIGN|CKF_VERIFY|CKF_SIGN_RECOVER|CKF_VERIFY_RECOVER);
  ------------------
  |  |  364|  4.41k|#define CKF_SIGN_RECOVER 0x00001000UL
  ------------------
              		mech_info.flags &= ~(CKF_SIGN|CKF_VERIFY|CKF_SIGN_RECOVER|CKF_VERIFY_RECOVER);
  ------------------
  |  |  366|  4.41k|#define CKF_VERIFY_RECOVER 0x00004000UL
  ------------------
 6754|  4.41k|		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_PKCS_OAEP, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  547|  4.41k|#define CKM_RSA_PKCS_OAEP 0x00000009UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_PKCS_OAEP, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  464|  4.41k|#define CKK_RSA 0x00000000UL
  ------------------
 6755|  4.41k|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6756|  4.41k|		sc_pkcs11_free_mechanism(&mt);
 6757|  4.41k|		if (rc != CKR_OK) {
  ------------------
  |  | 1086|  4.41k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6757:7): [True: 0, False: 4.41k]
  ------------------
 6758|      0|			return rc;
 6759|      0|		}
 6760|  4.41k|		mech_info.flags = old_flags;
 6761|  4.41k|	}
 6762|       |
 6763|  6.01k|	if (rsa_flags & SC_ALGORITHM_ONBOARD_KEY_GEN) {
  ------------------
  |  |   93|  6.01k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  |  Branch (6763:6): [True: 1.42k, False: 4.58k]
  ------------------
 6764|  1.42k|		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  352|  1.42k|#define CKF_HW 0x00000001UL
  ------------------
              		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  368|  1.42k|#define CKF_GENERATE_KEY_PAIR 0x00010000UL
  ------------------
 6765|  1.42k|		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_PKCS_KEY_PAIR_GEN, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  538|  1.42k|#define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_RSA_PKCS_KEY_PAIR_GEN, &mech_info, CKK_RSA, NULL, NULL, NULL);
  ------------------
  |  |  464|  1.42k|#define CKK_RSA 0x00000000UL
  ------------------
 6766|  1.42k|		if (!mt)
  ------------------
  |  Branch (6766:7): [True: 0, False: 1.42k]
  ------------------
 6767|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6768|  1.42k|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6769|  1.42k|		sc_pkcs11_free_mechanism(&mt);
 6770|  1.42k|		if (rc != CKR_OK)
  ------------------
  |  | 1086|  1.42k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6770:7): [True: 0, False: 1.42k]
  ------------------
 6771|      0|			return rc;
 6772|  1.42k|	}
 6773|       |
 6774|  6.01k|	if (aes_max_key_size > 0) {
  ------------------
  |  Branch (6774:6): [True: 4, False: 6.00k]
  ------------------
 6775|      4|		rc = sc_pkcs11_register_aes_mechanisms(p11card, aes_flags, aes_min_key_size, aes_max_key_size);
 6776|      4|		if (rc != CKR_OK)
  ------------------
  |  | 1086|      4|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6776:7): [True: 0, False: 4]
  ------------------
 6777|      0|			return rc;
 6778|      4|	}
 6779|       |
 6780|       |
 6781|  6.01k|	return CKR_OK;
  ------------------
  |  | 1086|  6.01k|#define CKR_OK 0x00000000UL
  ------------------
 6782|  6.01k|}
framework-pkcs15.c:register_ec_mechanisms:
 6180|  2.29k|{
 6181|  2.29k|	CK_MECHANISM_INFO mech_info;
 6182|  2.29k|	sc_pkcs11_mechanism_type_t *mt = NULL, *registered_mt = NULL;
 6183|  2.29k|	CK_FLAGS ec_flags = 0;
 6184|  2.29k|	CK_RV rc;
 6185|       |
 6186|  2.29k|	if (ext_flags & SC_ALGORITHM_EXT_EC_F_P)
  ------------------
  |  |  198|  2.29k|#define SC_ALGORITHM_EXT_EC_F_P          0x00000001
  ------------------
  |  Branch (6186:6): [True: 242, False: 2.04k]
  ------------------
 6187|    242|		ec_flags |= CKF_EC_F_P;
  ------------------
  |  |  372|    242|#define CKF_EC_F_P 0x00100000UL
  ------------------
 6188|  2.29k|	if (ext_flags & SC_ALGORITHM_EXT_EC_F_2M)
  ------------------
  |  |  199|  2.29k|#define SC_ALGORITHM_EXT_EC_F_2M         0x00000002
  ------------------
  |  Branch (6188:6): [True: 0, False: 2.29k]
  ------------------
 6189|      0|		ec_flags |= CKF_EC_F_2M;
  ------------------
  |  |  373|      0|#define CKF_EC_F_2M 0x00200000UL
  ------------------
 6190|  2.29k|	if (ext_flags & SC_ALGORITHM_EXT_EC_ECPARAMETERS)
  ------------------
  |  |  200|  2.29k|#define SC_ALGORITHM_EXT_EC_ECPARAMETERS 0x00000004
  ------------------
  |  Branch (6190:6): [True: 214, False: 2.07k]
  ------------------
 6191|    214|		ec_flags |= CKF_EC_ECPARAMETERS;
  ------------------
  |  |  374|    214|#define CKF_EC_ECPARAMETERS 0x00400000UL
  ------------------
 6192|  2.29k|	if (ext_flags & SC_ALGORITHM_EXT_EC_NAMEDCURVE)
  ------------------
  |  |  201|  2.29k|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  |  Branch (6192:6): [True: 2.18k, False: 102]
  ------------------
 6193|  2.18k|		ec_flags |= CKF_EC_NAMEDCURVE;
  ------------------
  |  |  384|  2.18k|#define CKF_EC_NAMEDCURVE 0x00800000U
  ------------------
 6194|  2.29k|	if (ext_flags & SC_ALGORITHM_EXT_EC_UNCOMPRESES)
  ------------------
  |  |  202|  2.29k|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  |  Branch (6194:6): [True: 2.18k, False: 104]
  ------------------
 6195|  2.18k|		ec_flags |= CKF_EC_UNCOMPRESS;
  ------------------
  |  |  376|  2.18k|#define CKF_EC_UNCOMPRESS 0x01000000UL
  ------------------
 6196|  2.29k|	if (ext_flags & SC_ALGORITHM_EXT_EC_COMPRESS)
  ------------------
  |  |  203|  2.29k|#define SC_ALGORITHM_EXT_EC_COMPRESS     0x00000020
  ------------------
  |  Branch (6196:6): [True: 0, False: 2.29k]
  ------------------
 6197|      0|		ec_flags |= CKF_EC_COMPRESS;
  ------------------
  |  |  377|      0|#define CKF_EC_COMPRESS 0x02000000UL
  ------------------
 6198|       |
 6199|  2.29k|	mech_info.flags = CKF_HW | CKF_SIGN | CKF_VERIFY;
  ------------------
  |  |  352|  2.29k|#define CKF_HW 0x00000001UL
  ------------------
              	mech_info.flags = CKF_HW | CKF_SIGN | CKF_VERIFY;
  ------------------
  |  |  363|  2.29k|#define CKF_SIGN 0x00000800UL
  ------------------
              	mech_info.flags = CKF_HW | CKF_SIGN | CKF_VERIFY;
  ------------------
  |  |  365|  2.29k|#define CKF_VERIFY 0x00002000UL
  ------------------
 6200|  2.29k|	mech_info.flags |= ec_flags;
 6201|  2.29k|	mech_info.ulMinKeySize = min_key_size;
 6202|  2.29k|	mech_info.ulMaxKeySize = max_key_size;
 6203|       |
 6204|       |	/* add mechs card or driver support */
 6205|  2.29k|	if (flags & SC_ALGORITHM_ECDSA_RAW) {
  ------------------
  |  |  174|  2.29k|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  |  Branch (6205:6): [True: 2.26k, False: 28]
  ------------------
 6206|  2.26k|		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  860|  2.26k|#define CKM_ECDSA 0x00001041UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  467|  2.26k|#define CKK_EC 0x00000003UL
  ------------------
 6207|  2.26k|		if (!mt)
  ------------------
  |  Branch (6207:7): [True: 0, False: 2.26k]
  ------------------
 6208|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6209|  2.26k|		if (flags & SC_ALGORITHM_ECDSA_HASH_NONE) {
  ------------------
  |  |  175|  2.26k|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|  2.26k|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  |  Branch (6209:7): [True: 2.26k, False: 0]
  ------------------
 6210|  2.26k|			rc = sc_pkcs11_register_mechanism(p11card, mt, &registered_mt);
 6211|  2.26k|			sc_pkcs11_free_mechanism(&mt);
 6212|  2.26k|			if (rc != CKR_OK)
  ------------------
  |  | 1086|  2.26k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6212:8): [True: 0, False: 2.26k]
  ------------------
 6213|      0|				return rc;
 6214|  2.26k|		}
 6215|       |
 6216|  2.26k|#ifdef ENABLE_OPENSSL
 6217|       |		/* if card supports RAW add sign_and_hash using RAW for mechs  card does not support */
 6218|  2.26k|		sc_pkcs11_mechanism_type_t *sign_type = mt ? mt : registered_mt;
  ------------------
  |  Branch (6218:43): [True: 0, False: 2.26k]
  ------------------
 6219|  2.26k|		if (flags & SC_ALGORITHM_ECDSA_RAW) {
  ------------------
  |  |  174|  2.26k|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  |  Branch (6219:7): [True: 2.26k, False: 0]
  ------------------
 6220|  2.26k|			if (!(flags & SC_ALGORITHM_ECDSA_HASH_SHA1)) {
  ------------------
  |  |  176|  2.26k|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|  2.26k|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
  |  Branch (6220:8): [True: 2.02k, False: 233]
  ------------------
 6221|  2.02k|				rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6222|  2.02k|					CKM_ECDSA_SHA1, CKM_SHA_1, sign_type);
  ------------------
  |  |  861|  2.02k|#define CKM_ECDSA_SHA1 0x00001042UL
  ------------------
              					CKM_ECDSA_SHA1, CKM_SHA_1, sign_type);
  ------------------
  |  |  667|  2.02k|#define CKM_SHA_1 0x00000220UL
  ------------------
 6223|  2.02k|				if (rc != CKR_OK) {
  ------------------
  |  | 1086|  2.02k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6223:9): [True: 0, False: 2.02k]
  ------------------
 6224|      0|					sc_pkcs11_free_mechanism(&mt);
 6225|      0|					return rc;
 6226|      0|				}
 6227|  2.02k|			}
 6228|       |
 6229|  2.26k|			if (!(flags & SC_ALGORITHM_ECDSA_HASH_SHA224)) {
  ------------------
  |  |  177|  2.26k|#define SC_ALGORITHM_ECDSA_HASH_SHA224		SC_ALGORITHM_RSA_HASH_SHA224
  |  |  ------------------
  |  |  |  |  141|  2.26k|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  |  |  ------------------
  ------------------
  |  Branch (6229:8): [True: 2.12k, False: 138]
  ------------------
 6230|  2.12k|				rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6231|  2.12k|					CKM_ECDSA_SHA224, CKM_SHA224, sign_type);
  ------------------
  |  |  862|  2.12k|#define CKM_ECDSA_SHA224 0x00001043UL
  ------------------
              					CKM_ECDSA_SHA224, CKM_SHA224, sign_type);
  ------------------
  |  |  679|  2.12k|#define CKM_SHA224 0x00000255UL
  ------------------
 6232|  2.12k|				if (rc != CKR_OK) {
  ------------------
  |  | 1086|  2.12k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6232:9): [True: 0, False: 2.12k]
  ------------------
 6233|      0|					sc_pkcs11_free_mechanism(&mt);
 6234|      0|					return rc;
 6235|      0|				}
 6236|  2.12k|			}
 6237|       |
 6238|  2.26k|			if (!(flags & SC_ALGORITHM_ECDSA_HASH_SHA256)) {
  ------------------
  |  |  178|  2.26k|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  138|  2.26k|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  |  Branch (6238:8): [True: 2.02k, False: 233]
  ------------------
 6239|  2.02k|				rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6240|  2.02k|					CKM_ECDSA_SHA256, CKM_SHA256, sign_type);
  ------------------
  |  |  863|  2.02k|#define CKM_ECDSA_SHA256 0x00001044UL
  ------------------
              					CKM_ECDSA_SHA256, CKM_SHA256, sign_type);
  ------------------
  |  |  676|  2.02k|#define CKM_SHA256 0x00000250UL
  ------------------
 6241|  2.02k|				if (rc != CKR_OK) {
  ------------------
  |  | 1086|  2.02k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6241:9): [True: 0, False: 2.02k]
  ------------------
 6242|      0|					sc_pkcs11_free_mechanism(&mt);
 6243|      0|					return rc;
 6244|      0|				}
 6245|  2.02k|			}
 6246|       |
 6247|  2.26k|			if (!(flags & SC_ALGORITHM_ECDSA_HASH_SHA384)) {
  ------------------
  |  |  179|  2.26k|#define SC_ALGORITHM_ECDSA_HASH_SHA384		SC_ALGORITHM_RSA_HASH_SHA384
  |  |  ------------------
  |  |  |  |  139|  2.26k|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  |  |  ------------------
  ------------------
  |  Branch (6247:8): [True: 2.12k, False: 138]
  ------------------
 6248|  2.12k|				rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6249|  2.12k|					CKM_ECDSA_SHA384, CKM_SHA384, sign_type);
  ------------------
  |  |  864|  2.12k|#define CKM_ECDSA_SHA384 0x00001045UL
  ------------------
              					CKM_ECDSA_SHA384, CKM_SHA384, sign_type);
  ------------------
  |  |  682|  2.12k|#define CKM_SHA384 0x00000260UL
  ------------------
 6250|  2.12k|				if (rc != CKR_OK) {
  ------------------
  |  | 1086|  2.12k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6250:9): [True: 0, False: 2.12k]
  ------------------
 6251|      0|					sc_pkcs11_free_mechanism(&mt);
 6252|      0|					return rc;
 6253|      0|				}
 6254|  2.12k|			}
 6255|       |
 6256|  2.26k|			if (!(flags & SC_ALGORITHM_ECDSA_HASH_SHA512)) {
  ------------------
  |  |  180|  2.26k|#define SC_ALGORITHM_ECDSA_HASH_SHA512		SC_ALGORITHM_RSA_HASH_SHA512
  |  |  ------------------
  |  |  |  |  140|  2.26k|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  |  |  ------------------
  ------------------
  |  Branch (6256:8): [True: 2.12k, False: 138]
  ------------------
 6257|  2.12k|				rc = sc_pkcs11_register_sign_and_hash_mechanism(p11card,
 6258|  2.12k|					CKM_ECDSA_SHA512, CKM_SHA512, sign_type);
  ------------------
  |  |  865|  2.12k|#define CKM_ECDSA_SHA512 0x00001046UL
  ------------------
              					CKM_ECDSA_SHA512, CKM_SHA512, sign_type);
  ------------------
  |  |  685|  2.12k|#define CKM_SHA512 0x00000270UL
  ------------------
 6259|  2.12k|				if (rc != CKR_OK) {
  ------------------
  |  | 1086|  2.12k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6259:9): [True: 0, False: 2.12k]
  ------------------
 6260|      0|					sc_pkcs11_free_mechanism(&mt);
 6261|      0|					return rc;
 6262|      0|				}
 6263|  2.12k|			}
 6264|  2.26k|		}
 6265|  2.26k|		sc_pkcs11_free_mechanism(&mt);
 6266|  2.26k|#endif
 6267|  2.26k|	}
 6268|       |
 6269|  2.29k|	if (flags & SC_ALGORITHM_ECDSA_HASH_SHA1) {
  ------------------
  |  |  176|  2.29k|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|  2.29k|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
  |  Branch (6269:6): [True: 261, False: 2.02k]
  ------------------
 6270|    261|		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA1, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  861|    261|#define CKM_ECDSA_SHA1 0x00001042UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA1, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  467|    261|#define CKK_EC 0x00000003UL
  ------------------
 6271|    261|		if (!mt)
  ------------------
  |  Branch (6271:7): [True: 0, False: 261]
  ------------------
 6272|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6273|    261|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6274|    261|		sc_pkcs11_free_mechanism(&mt);
 6275|    261|		if (rc != CKR_OK)
  ------------------
  |  | 1086|    261|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6275:7): [True: 0, False: 261]
  ------------------
 6276|      0|			return rc;
 6277|    261|	}
 6278|       |
 6279|  2.29k|	if (flags & SC_ALGORITHM_ECDSA_HASH_SHA224) {
  ------------------
  |  |  177|  2.29k|#define SC_ALGORITHM_ECDSA_HASH_SHA224		SC_ALGORITHM_RSA_HASH_SHA224
  |  |  ------------------
  |  |  |  |  141|  2.29k|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  |  |  ------------------
  ------------------
  |  Branch (6279:6): [True: 138, False: 2.15k]
  ------------------
 6280|    138|		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA224, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  862|    138|#define CKM_ECDSA_SHA224 0x00001043UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA224, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  467|    138|#define CKK_EC 0x00000003UL
  ------------------
 6281|    138|		if (!mt)
  ------------------
  |  Branch (6281:7): [True: 0, False: 138]
  ------------------
 6282|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6283|    138|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6284|    138|		sc_pkcs11_free_mechanism(&mt);
 6285|    138|		if (rc != CKR_OK)
  ------------------
  |  | 1086|    138|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6285:7): [True: 0, False: 138]
  ------------------
 6286|      0|			return rc;
 6287|    138|	}
 6288|       |
 6289|  2.29k|	if (flags & SC_ALGORITHM_ECDSA_HASH_SHA256) {
  ------------------
  |  |  178|  2.29k|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  138|  2.29k|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  |  Branch (6289:6): [True: 233, False: 2.05k]
  ------------------
 6290|    233|		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA256, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  863|    233|#define CKM_ECDSA_SHA256 0x00001044UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA256, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  467|    233|#define CKK_EC 0x00000003UL
  ------------------
 6291|    233|		if (!mt)
  ------------------
  |  Branch (6291:7): [True: 0, False: 233]
  ------------------
 6292|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6293|    233|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6294|    233|		sc_pkcs11_free_mechanism(&mt);
 6295|    233|		if (rc != CKR_OK)
  ------------------
  |  | 1086|    233|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6295:7): [True: 0, False: 233]
  ------------------
 6296|      0|			return rc;
 6297|    233|	}
 6298|       |
 6299|  2.29k|	if (flags & SC_ALGORITHM_ECDSA_HASH_SHA384) {
  ------------------
  |  |  179|  2.29k|#define SC_ALGORITHM_ECDSA_HASH_SHA384		SC_ALGORITHM_RSA_HASH_SHA384
  |  |  ------------------
  |  |  |  |  139|  2.29k|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  |  |  ------------------
  ------------------
  |  Branch (6299:6): [True: 138, False: 2.15k]
  ------------------
 6300|    138|		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA384, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  864|    138|#define CKM_ECDSA_SHA384 0x00001045UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA384, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  467|    138|#define CKK_EC 0x00000003UL
  ------------------
 6301|    138|		if (!mt)
  ------------------
  |  Branch (6301:7): [True: 0, False: 138]
  ------------------
 6302|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6303|    138|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6304|    138|		sc_pkcs11_free_mechanism(&mt);
 6305|    138|		if (rc != CKR_OK)
  ------------------
  |  | 1086|    138|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6305:7): [True: 0, False: 138]
  ------------------
 6306|      0|			return rc;
 6307|    138|	}
 6308|       |
 6309|  2.29k|	if (flags & SC_ALGORITHM_ECDSA_HASH_SHA512) {
  ------------------
  |  |  180|  2.29k|#define SC_ALGORITHM_ECDSA_HASH_SHA512		SC_ALGORITHM_RSA_HASH_SHA512
  |  |  ------------------
  |  |  |  |  140|  2.29k|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  |  |  ------------------
  ------------------
  |  Branch (6309:6): [True: 138, False: 2.15k]
  ------------------
 6310|    138|		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA512, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  865|    138|#define CKM_ECDSA_SHA512 0x00001046UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDSA_SHA512, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  467|    138|#define CKK_EC 0x00000003UL
  ------------------
 6311|    138|		if (!mt)
  ------------------
  |  Branch (6311:7): [True: 0, False: 138]
  ------------------
 6312|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6313|    138|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6314|    138|		sc_pkcs11_free_mechanism(&mt);
 6315|    138|		if (rc != CKR_OK)
  ------------------
  |  | 1086|    138|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6315:7): [True: 0, False: 138]
  ------------------
 6316|      0|			return rc;
 6317|    138|	}
 6318|       |
 6319|       |	/* ADD ECDH mechanisms */
 6320|       |	/* The PIV uses curves where CKM_ECDH1_DERIVE and CKM_ECDH1_COFACTOR_DERIVE produce the same results */
 6321|  2.29k|	if (flags & SC_ALGORITHM_ECDH_CDH_RAW) {
  ------------------
  |  |  173|  2.29k|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  |  Branch (6321:6): [True: 2.10k, False: 189]
  ------------------
 6322|  2.10k|		mech_info.flags &= ~(CKF_SIGN | CKF_VERIFY);
  ------------------
  |  |  363|  2.10k|#define CKF_SIGN 0x00000800UL
  ------------------
              		mech_info.flags &= ~(CKF_SIGN | CKF_VERIFY);
  ------------------
  |  |  365|  2.10k|#define CKF_VERIFY 0x00002000UL
  ------------------
 6323|  2.10k|		mech_info.flags |= CKF_DERIVE;
  ------------------
  |  |  371|  2.10k|#define CKF_DERIVE 0x00080000UL
  ------------------
 6324|       |
 6325|  2.10k|		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDH1_COFACTOR_DERIVE, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  868|  2.10k|#define CKM_ECDH1_COFACTOR_DERIVE 0x00001051UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDH1_COFACTOR_DERIVE, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  467|  2.10k|#define CKK_EC 0x00000003UL
  ------------------
 6326|  2.10k|		if (!mt)
  ------------------
  |  Branch (6326:7): [True: 0, False: 2.10k]
  ------------------
 6327|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6328|  2.10k|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6329|  2.10k|		sc_pkcs11_free_mechanism(&mt);
 6330|  2.10k|		if (rc != CKR_OK)
  ------------------
  |  | 1086|  2.10k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6330:7): [True: 0, False: 2.10k]
  ------------------
 6331|      0|			return rc;
 6332|       |
 6333|  2.10k|		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDH1_DERIVE, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  867|  2.10k|#define CKM_ECDH1_DERIVE 0x00001050UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDH1_DERIVE, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  467|  2.10k|#define CKK_EC 0x00000003UL
  ------------------
 6334|  2.10k|		if (!mt)
  ------------------
  |  Branch (6334:7): [True: 0, False: 2.10k]
  ------------------
 6335|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6336|  2.10k|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6337|  2.10k|		sc_pkcs11_free_mechanism(&mt);
 6338|  2.10k|		if (rc != CKR_OK)
  ------------------
  |  | 1086|  2.10k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6338:7): [True: 0, False: 2.10k]
  ------------------
 6339|      0|			return rc;
 6340|  2.10k|	}
 6341|       |
 6342|  2.29k|	if (flags & SC_ALGORITHM_ONBOARD_KEY_GEN) {
  ------------------
  |  |   93|  2.29k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  |  Branch (6342:6): [True: 289, False: 2.00k]
  ------------------
 6343|    289|		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  352|    289|#define CKF_HW 0x00000001UL
  ------------------
              		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  368|    289|#define CKF_GENERATE_KEY_PAIR 0x00010000UL
  ------------------
 6344|    289|		mech_info.flags |= ec_flags;
 6345|    289|		mt = sc_pkcs11_new_fw_mechanism(CKM_EC_KEY_PAIR_GEN, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  859|    289|#define CKM_EC_KEY_PAIR_GEN 0x00001040UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_EC_KEY_PAIR_GEN, &mech_info, CKK_EC, NULL, NULL, NULL);
  ------------------
  |  |  467|    289|#define CKK_EC 0x00000003UL
  ------------------
 6346|    289|		if (!mt)
  ------------------
  |  Branch (6346:7): [True: 0, False: 289]
  ------------------
 6347|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6348|    289|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6349|    289|		sc_pkcs11_free_mechanism(&mt);
 6350|    289|		if (rc != CKR_OK)
  ------------------
  |  | 1086|    289|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6350:7): [True: 0, False: 289]
  ------------------
 6351|      0|			return rc;
 6352|    289|	}
 6353|       |
 6354|  2.29k|	return CKR_OK;
  ------------------
  |  | 1086|  2.29k|#define CKR_OK 0x00000000UL
  ------------------
 6355|  2.29k|}
framework-pkcs15.c:register_eddsa_mechanisms:
 6359|     94|{
 6360|     94|	CK_MECHANISM_INFO mech_info;
 6361|     94|	sc_pkcs11_mechanism_type_t *mt;
 6362|     94|	CK_RV rc;
 6363|       |
 6364|     94|	mech_info.flags = CKF_HW | CKF_SIGN;
  ------------------
  |  |  352|     94|#define CKF_HW 0x00000001UL
  ------------------
              	mech_info.flags = CKF_HW | CKF_SIGN;
  ------------------
  |  |  363|     94|#define CKF_SIGN 0x00000800UL
  ------------------
 6365|     94|	mech_info.ulMinKeySize = min_key_size;
 6366|     94|	mech_info.ulMaxKeySize = max_key_size;
 6367|       |
 6368|     94|#ifdef ENABLE_OPENSSL
 6369|     94|	mech_info.flags |= CKF_VERIFY;
  ------------------
  |  |  365|     94|#define CKF_VERIFY 0x00002000UL
  ------------------
 6370|     94|#endif
 6371|     94|	if (flags & SC_ALGORITHM_EDDSA_RAW) {
  ------------------
  |  |  188|     94|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
  |  Branch (6371:6): [True: 94, False: 0]
  ------------------
 6372|     94|		mt = sc_pkcs11_new_fw_mechanism(CKM_EDDSA, &mech_info, CKK_EC_EDWARDS, NULL, NULL, NULL);
  ------------------
  |  |  990|     94|#define CKM_EDDSA 0x00001057UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_EDDSA, &mech_info, CKK_EC_EDWARDS, NULL, NULL, NULL);
  ------------------
  |  |  518|     94|#define CKK_EC_EDWARDS 0x00000040UL
  ------------------
 6373|     94|		if (!mt)
  ------------------
  |  Branch (6373:7): [True: 0, False: 94]
  ------------------
 6374|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6375|     94|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6376|     94|		sc_pkcs11_free_mechanism(&mt);
 6377|     94|		if (rc != CKR_OK)
  ------------------
  |  | 1086|     94|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6377:7): [True: 0, False: 94]
  ------------------
 6378|      0|			return rc;
 6379|     94|	}
 6380|       |
 6381|     94|	if (flags & SC_ALGORITHM_ONBOARD_KEY_GEN) {
  ------------------
  |  |   93|     94|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  |  Branch (6381:6): [True: 2, False: 92]
  ------------------
 6382|      2|		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  352|      2|#define CKF_HW 0x00000001UL
  ------------------
              		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  368|      2|#define CKF_GENERATE_KEY_PAIR 0x00010000UL
  ------------------
 6383|      2|		mt = sc_pkcs11_new_fw_mechanism(CKM_EC_EDWARDS_KEY_PAIR_GEN,
  ------------------
  |  |  988|      2|#define CKM_EC_EDWARDS_KEY_PAIR_GEN 0x00001055UL
  ------------------
 6384|      2|			&mech_info, CKK_EC_EDWARDS, NULL, NULL, NULL);
  ------------------
  |  |  518|      2|#define CKK_EC_EDWARDS 0x00000040UL
  ------------------
 6385|      2|		if (!mt)
  ------------------
  |  Branch (6385:7): [True: 0, False: 2]
  ------------------
 6386|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6387|      2|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6388|      2|		sc_pkcs11_free_mechanism(&mt);
 6389|      2|		if (rc != CKR_OK)
  ------------------
  |  | 1086|      2|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6389:7): [True: 0, False: 2]
  ------------------
 6390|      0|			return rc;
 6391|      2|	}
 6392|       |
 6393|     94|	return CKR_OK;
  ------------------
  |  | 1086|     94|#define CKR_OK 0x00000000UL
  ------------------
 6394|     94|}
framework-pkcs15.c:register_xeddsa_mechanisms:
 6398|     94|{
 6399|     94|	CK_MECHANISM_INFO mech_info;
 6400|     94|	sc_pkcs11_mechanism_type_t *mt;
 6401|     94|	CK_RV rc;
 6402|       |
 6403|     94|	mech_info.flags = CKF_HW | CKF_SIGN | CKF_DERIVE;
  ------------------
  |  |  352|     94|#define CKF_HW 0x00000001UL
  ------------------
              	mech_info.flags = CKF_HW | CKF_SIGN | CKF_DERIVE;
  ------------------
  |  |  363|     94|#define CKF_SIGN 0x00000800UL
  ------------------
              	mech_info.flags = CKF_HW | CKF_SIGN | CKF_DERIVE;
  ------------------
  |  |  371|     94|#define CKF_DERIVE 0x00080000UL
  ------------------
 6404|     94|	mech_info.ulMinKeySize = min_key_size;
 6405|     94|	mech_info.ulMaxKeySize = max_key_size;
 6406|       |
 6407|     94|	if (flags & SC_ALGORITHM_XEDDSA_RAW) {
  ------------------
  |  |  189|     94|#define SC_ALGORITHM_XEDDSA_RAW		0x00800000
  ------------------
  |  Branch (6407:6): [True: 92, False: 2]
  ------------------
 6408|     92|		mt = sc_pkcs11_new_fw_mechanism(CKM_XEDDSA, &mech_info, CKK_EC_MONTGOMERY, NULL, NULL, NULL);
  ------------------
  |  |  979|     92|#define CKM_XEDDSA 0x00004029UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_XEDDSA, &mech_info, CKK_EC_MONTGOMERY, NULL, NULL, NULL);
  ------------------
  |  |  519|     92|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
 6409|     92|		if (!mt)
  ------------------
  |  Branch (6409:7): [True: 0, False: 92]
  ------------------
 6410|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6411|     92|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6412|     92|		sc_pkcs11_free_mechanism(&mt);
 6413|     92|		if (rc != CKR_OK)
  ------------------
  |  | 1086|     92|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6413:7): [True: 0, False: 92]
  ------------------
 6414|      0|			return rc;
 6415|     92|	}
 6416|       |
 6417|       |	/* ADD ECDH mechanisms */
 6418|     94|	if (flags & SC_ALGORITHM_ECDH_CDH_RAW) {
  ------------------
  |  |  173|     94|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  |  Branch (6418:6): [True: 94, False: 0]
  ------------------
 6419|     94|		mech_info.flags &= ~CKF_SIGN;
  ------------------
  |  |  363|     94|#define CKF_SIGN 0x00000800UL
  ------------------
 6420|     94|		mech_info.flags |= CKF_DERIVE;
  ------------------
  |  |  371|     94|#define CKF_DERIVE 0x00080000UL
  ------------------
 6421|       |
 6422|       |		/* Montgomery curves derive function is defined only for CKM_ECDH1_DERIVE mechanism */
 6423|     94|		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDH1_DERIVE, &mech_info, CKK_EC_MONTGOMERY, NULL, NULL, NULL);
  ------------------
  |  |  867|     94|#define CKM_ECDH1_DERIVE 0x00001050UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_ECDH1_DERIVE, &mech_info, CKK_EC_MONTGOMERY, NULL, NULL, NULL);
  ------------------
  |  |  519|     94|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
 6424|     94|		if (!mt)
  ------------------
  |  Branch (6424:7): [True: 0, False: 94]
  ------------------
 6425|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6426|     94|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6427|     94|		sc_pkcs11_free_mechanism(&mt);
 6428|     94|		if (rc != CKR_OK)
  ------------------
  |  | 1086|     94|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6428:7): [True: 0, False: 94]
  ------------------
 6429|      0|			return rc;
 6430|     94|	}
 6431|       |
 6432|     94|	if (flags & SC_ALGORITHM_ONBOARD_KEY_GEN) {
  ------------------
  |  |   93|     94|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  |  Branch (6432:6): [True: 2, False: 92]
  ------------------
 6433|      2|		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  352|      2|#define CKF_HW 0x00000001UL
  ------------------
              		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  368|      2|#define CKF_GENERATE_KEY_PAIR 0x00010000UL
  ------------------
 6434|      2|		mt = sc_pkcs11_new_fw_mechanism(CKM_EC_MONTGOMERY_KEY_PAIR_GEN, &mech_info, CKK_EC_MONTGOMERY, NULL, NULL, NULL);
  ------------------
  |  |  989|      2|#define CKM_EC_MONTGOMERY_KEY_PAIR_GEN 0x00001056UL
  ------------------
              		mt = sc_pkcs11_new_fw_mechanism(CKM_EC_MONTGOMERY_KEY_PAIR_GEN, &mech_info, CKK_EC_MONTGOMERY, NULL, NULL, NULL);
  ------------------
  |  |  519|      2|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
 6435|      2|		if (!mt)
  ------------------
  |  Branch (6435:7): [True: 0, False: 2]
  ------------------
 6436|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6437|      2|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6438|      2|		sc_pkcs11_free_mechanism(&mt);
 6439|      2|		if (rc != CKR_OK)
  ------------------
  |  | 1086|      2|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6439:7): [True: 0, False: 2]
  ------------------
 6440|      0|			return rc;
 6441|      2|	}
 6442|       |
 6443|     94|	return CKR_OK;
  ------------------
  |  | 1086|     94|#define CKR_OK 0x00000000UL
  ------------------
 6444|     94|}
framework-pkcs15.c:register_gost_mechanisms:
 6129|      8|{
 6130|      8|	CK_MECHANISM_INFO mech_info;
 6131|      8|	sc_pkcs11_mechanism_type_t *mt;
 6132|      8|	CK_RV rc;
 6133|       |
 6134|      8|	mech_info.flags = CKF_HW | CKF_SIGN | CKF_DECRYPT;
  ------------------
  |  |  352|      8|#define CKF_HW 0x00000001UL
  ------------------
              	mech_info.flags = CKF_HW | CKF_SIGN | CKF_DECRYPT;
  ------------------
  |  |  363|      8|#define CKF_SIGN 0x00000800UL
  ------------------
              	mech_info.flags = CKF_HW | CKF_SIGN | CKF_DECRYPT;
  ------------------
  |  |  361|      8|#define CKF_DECRYPT 0x00000200UL
  ------------------
 6135|      8|#ifdef ENABLE_OPENSSL
 6136|       |	/* That practise definitely conflicts with CKF_HW -- andre 2010-11-28 */
 6137|      8|	mech_info.flags |= CKF_VERIFY;
  ------------------
  |  |  365|      8|#define CKF_VERIFY 0x00002000UL
  ------------------
 6138|      8|#endif
 6139|      8|	mech_info.ulMinKeySize = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      8|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
 6140|      8|	mech_info.ulMaxKeySize = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      8|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
 6141|       |
 6142|      8|	if (flags & SC_ALGORITHM_GOSTR3410_HASH_NONE) {
  ------------------
  |  |  157|      8|#define SC_ALGORITHM_GOSTR3410_HASH_NONE	SC_ALGORITHM_GOSTR3410_RAW /*XXX*/
  |  |  ------------------
  |  |  |  |  156|      8|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  |  |  ------------------
  ------------------
  |  Branch (6142:6): [True: 8, False: 0]
  ------------------
 6143|      8|		mt = sc_pkcs11_new_fw_mechanism(CKM_GOSTR3410,
  ------------------
  |  |  909|      8|#define CKM_GOSTR3410 0x00001201UL
  ------------------
 6144|      8|				&mech_info, CKK_GOSTR3410, NULL, NULL, NULL);
  ------------------
  |  |  502|      8|#define CKK_GOSTR3410 0x00000030UL
  ------------------
 6145|      8|		if (!mt)
  ------------------
  |  Branch (6145:7): [True: 0, False: 8]
  ------------------
 6146|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6147|      8|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6148|      8|		sc_pkcs11_free_mechanism(&mt);
 6149|      8|		if (rc != CKR_OK)
  ------------------
  |  | 1086|      8|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6149:7): [True: 0, False: 8]
  ------------------
 6150|      0|			return rc;
 6151|      8|	}
 6152|      8|	if (flags & SC_ALGORITHM_GOSTR3410_HASH_GOSTR3411) {
  ------------------
  |  |  158|      8|#define SC_ALGORITHM_GOSTR3410_HASH_GOSTR3411	0x00080000
  ------------------
  |  Branch (6152:6): [True: 0, False: 8]
  ------------------
 6153|      0|		mt = sc_pkcs11_new_fw_mechanism(CKM_GOSTR3410_WITH_GOSTR3411,
  ------------------
  |  |  910|      0|#define CKM_GOSTR3410_WITH_GOSTR3411 0x00001202UL
  ------------------
 6154|      0|				&mech_info, CKK_GOSTR3410, NULL, NULL, NULL);
  ------------------
  |  |  502|      0|#define CKK_GOSTR3410 0x00000030UL
  ------------------
 6155|      0|		if (!mt)
  ------------------
  |  Branch (6155:7): [True: 0, False: 0]
  ------------------
 6156|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6157|      0|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6158|      0|		sc_pkcs11_free_mechanism(&mt);
 6159|      0|		if (rc != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6159:7): [True: 0, False: 0]
  ------------------
 6160|      0|			return rc;
 6161|      0|	}
 6162|      8|	if (flags & SC_ALGORITHM_ONBOARD_KEY_GEN) {
  ------------------
  |  |   93|      8|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  |  Branch (6162:6): [True: 8, False: 0]
  ------------------
 6163|      8|		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  352|      8|#define CKF_HW 0x00000001UL
  ------------------
              		mech_info.flags = CKF_HW | CKF_GENERATE_KEY_PAIR;
  ------------------
  |  |  368|      8|#define CKF_GENERATE_KEY_PAIR 0x00010000UL
  ------------------
 6164|      8|		mt = sc_pkcs11_new_fw_mechanism(CKM_GOSTR3410_KEY_PAIR_GEN,
  ------------------
  |  |  908|      8|#define CKM_GOSTR3410_KEY_PAIR_GEN 0x00001200UL
  ------------------
 6165|      8|				&mech_info, CKK_GOSTR3410, NULL, NULL, NULL);
  ------------------
  |  |  502|      8|#define CKK_GOSTR3410 0x00000030UL
  ------------------
 6166|      8|		if (!mt)
  ------------------
  |  Branch (6166:7): [True: 0, False: 8]
  ------------------
 6167|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6168|      8|		rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6169|      8|		sc_pkcs11_free_mechanism(&mt);
 6170|      8|		if (rc != CKR_OK)
  ------------------
  |  | 1086|      8|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6170:7): [True: 0, False: 8]
  ------------------
 6171|      0|			return rc;
 6172|      8|	}
 6173|       |
 6174|      8|	return CKR_OK;
  ------------------
  |  | 1086|      8|#define CKR_OK 0x00000000UL
  ------------------
 6175|      8|}
framework-pkcs15.c:sc_pkcs11_register_aes_mechanisms:
 6448|      4|{
 6449|      4|	CK_RV rc;
 6450|      4|	CK_MECHANISM_INFO mech_info;
 6451|      4|	sc_pkcs11_mechanism_type_t *mt;
 6452|      4|	sc_card_t* card = p11card->card;
 6453|      4|	memset(&mech_info, 0, sizeof(mech_info));
 6454|      4|	mech_info.flags = CKF_ENCRYPT | CKF_DECRYPT;
  ------------------
  |  |  360|      4|#define CKF_ENCRYPT 0x00000100UL
  ------------------
              	mech_info.flags = CKF_ENCRYPT | CKF_DECRYPT;
  ------------------
  |  |  361|      4|#define CKF_DECRYPT 0x00000200UL
  ------------------
 6455|      4|	mech_info.ulMinKeySize = min_key_size;
 6456|      4|	mech_info.ulMaxKeySize = max_key_size;
 6457|       |
 6458|      4|	if ((card->caps & SC_CARD_CAP_UNWRAP_KEY) == SC_CARD_CAP_UNWRAP_KEY)
  ------------------
  |  |  574|      4|#define SC_CARD_CAP_UNWRAP_KEY			0x00001000
  ------------------
              	if ((card->caps & SC_CARD_CAP_UNWRAP_KEY) == SC_CARD_CAP_UNWRAP_KEY)
  ------------------
  |  |  574|      4|#define SC_CARD_CAP_UNWRAP_KEY			0x00001000
  ------------------
  |  Branch (6458:6): [True: 3, False: 1]
  ------------------
 6459|      3|		mech_info.flags |= CKF_UNWRAP;
  ------------------
  |  |  370|      3|#define CKF_UNWRAP 0x00040000UL
  ------------------
 6460|      4|	if ((card->caps & SC_CARD_CAP_WRAP_KEY) == SC_CARD_CAP_WRAP_KEY)
  ------------------
  |  |  572|      4|#define SC_CARD_CAP_WRAP_KEY			0x00000800
  ------------------
              	if ((card->caps & SC_CARD_CAP_WRAP_KEY) == SC_CARD_CAP_WRAP_KEY)
  ------------------
  |  |  572|      4|#define SC_CARD_CAP_WRAP_KEY			0x00000800
  ------------------
  |  Branch (6460:6): [True: 3, False: 1]
  ------------------
 6461|      3|		mech_info.flags |= CKF_WRAP;
  ------------------
  |  |  369|      3|#define CKF_WRAP 0x00020000UL
  ------------------
 6462|       |
 6463|      4|	mt = sc_pkcs11_new_fw_mechanism(CKM_AES_ECB, &mech_info, CKK_AES, NULL, NULL, NULL);
  ------------------
  |  |  882|      4|#define CKM_AES_ECB 0x00001081UL
  ------------------
              	mt = sc_pkcs11_new_fw_mechanism(CKM_AES_ECB, &mech_info, CKK_AES, NULL, NULL, NULL);
  ------------------
  |  |  485|      4|#define CKK_AES 0x0000001FUL
  ------------------
 6464|      4|	if (!mt)
  ------------------
  |  Branch (6464:6): [True: 0, False: 4]
  ------------------
 6465|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6466|      4|	rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6467|      4|	sc_pkcs11_free_mechanism(&mt);
 6468|      4|	if (rc != CKR_OK)
  ------------------
  |  | 1086|      4|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6468:6): [True: 0, False: 4]
  ------------------
 6469|      0|			return rc;
 6470|       |
 6471|      4|	mt = sc_pkcs11_new_fw_mechanism(CKM_AES_CBC, &mech_info, CKK_AES, NULL, NULL, NULL);
  ------------------
  |  |  883|      4|#define CKM_AES_CBC 0x00001082UL
  ------------------
              	mt = sc_pkcs11_new_fw_mechanism(CKM_AES_CBC, &mech_info, CKK_AES, NULL, NULL, NULL);
  ------------------
  |  |  485|      4|#define CKK_AES 0x0000001FUL
  ------------------
 6472|      4|	if (!mt)
  ------------------
  |  Branch (6472:6): [True: 0, False: 4]
  ------------------
 6473|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6474|      4|	rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6475|      4|	sc_pkcs11_free_mechanism(&mt);
 6476|      4|	if (rc != CKR_OK)
  ------------------
  |  | 1086|      4|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6476:6): [True: 0, False: 4]
  ------------------
 6477|      0|			return rc;
 6478|       |
 6479|      4|	mt = sc_pkcs11_new_fw_mechanism(CKM_AES_CBC_PAD, &mech_info, CKK_AES, NULL, NULL, NULL);
  ------------------
  |  |  886|      4|#define CKM_AES_CBC_PAD 0x00001085UL
  ------------------
              	mt = sc_pkcs11_new_fw_mechanism(CKM_AES_CBC_PAD, &mech_info, CKK_AES, NULL, NULL, NULL);
  ------------------
  |  |  485|      4|#define CKK_AES 0x0000001FUL
  ------------------
 6480|      4|	if (!mt)
  ------------------
  |  Branch (6480:6): [True: 0, False: 4]
  ------------------
 6481|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 6482|      4|	rc = sc_pkcs11_register_mechanism(p11card, mt, NULL);
 6483|      4|	sc_pkcs11_free_mechanism(&mt);
 6484|      4|	if (rc != CKR_OK)
  ------------------
  |  | 1086|      4|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (6484:6): [True: 0, False: 4]
  ------------------
 6485|      0|			return rc;
 6486|       |
 6487|      4|	return CKR_OK;
  ------------------
  |  | 1086|      4|#define CKR_OK 0x00000000UL
  ------------------
 6488|      4|}
framework-pkcs15.c:pkcs15_unbind:
  324|  13.8k|{
  325|  13.8k|	unsigned int i, idx;
  326|  13.8k|	int rv = SC_SUCCESS;
  ------------------
  |  |   28|  13.8k|#define SC_SUCCESS				0
  ------------------
  327|       |
  328|  13.8k|	if (!p11card)
  ------------------
  |  Branch (328:6): [True: 0, False: 13.8k]
  ------------------
  329|      0|		return CKR_TOKEN_NOT_RECOGNIZED;
  ------------------
  |  | 1145|      0|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
  330|  30.2k|	for (idx=0; p11card && idx<SC_PKCS11_FRAMEWORK_DATA_MAX_NUM; idx++)   {
  ------------------
  |  |  194|  30.2k|#define SC_PKCS11_FRAMEWORK_DATA_MAX_NUM	4
  ------------------
  |  Branch (330:14): [True: 30.2k, False: 0]
  |  Branch (330:25): [True: 29.7k, False: 486]
  ------------------
  331|  29.7k|		struct pkcs15_fw_data *fw_data = (struct pkcs15_fw_data *) p11card->fws_data[idx];
  332|       |
  333|  29.7k|		if (!fw_data)
  ------------------
  |  Branch (333:7): [True: 13.3k, False: 16.4k]
  ------------------
  334|  13.3k|			break;
  335|  50.7k|		for (i = 0; i < fw_data->num_objects; i++) {
  ------------------
  |  Branch (335:15): [True: 34.3k, False: 16.4k]
  ------------------
  336|  34.3k|			struct pkcs15_any_object *obj = fw_data->objects[i];
  337|       |
  338|       |			/* use object specific release method if existing */
  339|  34.3k|			if (obj->base.ops && obj->base.ops->release)
  ------------------
  |  Branch (339:8): [True: 34.3k, False: 0]
  |  Branch (339:25): [True: 34.3k, False: 0]
  ------------------
  340|  34.3k|				obj->base.ops->release(obj);
  341|      0|			else
  342|      0|				__pkcs15_release_object(obj);
  343|  34.3k|		}
  344|       |
  345|  16.4k|		unlock_card(fw_data);
  346|       |
  347|  16.4k|		if (fw_data->p15_card) {
  ------------------
  |  Branch (347:7): [True: 6.47k, False: 9.93k]
  ------------------
  348|  6.47k|			rv = sc_pkcs15_unbind(fw_data->p15_card);
  349|  6.47k|		}
  350|  16.4k|		fw_data->p15_card = NULL;
  351|       |
  352|  16.4k|		free(fw_data);
  353|  16.4k|		p11card->fws_data[idx] = NULL;
  354|  16.4k|	}
  355|       |
  356|       |	return sc_to_cryptoki_error(rv, NULL);
  357|  13.8k|}
framework-pkcs15.c:__pkcs15_release_object:
  466|  65.2k|{
  467|  65.2k|	if (--(obj->refcount) != 0)
  ------------------
  |  Branch (467:6): [True: 30.8k, False: 34.3k]
  ------------------
  468|  30.8k|		return obj->refcount;
  469|       |
  470|  34.3k|	sc_mem_clear(obj, obj->size);
  471|  34.3k|	free(obj);
  472|       |
  473|  34.3k|	return 0;
  474|  65.2k|}
framework-pkcs15.c:unlock_card:
 6801|  16.4k|{
 6802|  16.4k|	while (fw_data->locked) {
  ------------------
  |  Branch (6802:9): [True: 0, False: 16.4k]
  ------------------
 6803|      0|		sc_unlock(fw_data->p15_card->card);
 6804|      0|		fw_data->locked--;
 6805|      0|	}
 6806|  16.4k|	return 0;
 6807|  16.4k|}
framework-pkcs15.c:pkcs15_create_tokens:
 1593|  11.7k|{
 1594|  11.7k|	struct pkcs15_fw_data *fw_data = NULL;
 1595|  11.7k|	struct sc_pkcs15_object *auth_user_pin = NULL, *auth_sign_pin = NULL;
 1596|  11.7k|	struct sc_pkcs11_slot *slot = NULL, *sign_slot = NULL;
 1597|  11.7k|	unsigned int cs_flags = sc_pkcs11_conf.create_slots_flags;
 1598|  11.7k|	CK_RV rv;
 1599|  11.7k|	int rc, i, idx;
 1600|  11.7k|	scconf_block *conf_block = NULL;
 1601|  11.7k|	char *user_pin = NULL, *sign_pin = NULL;
 1602|       |
 1603|  11.7k|	if (p11card) {
  ------------------
  |  Branch (1603:6): [True: 11.7k, False: 0]
  ------------------
 1604|  11.7k|		sc_log(context, "create PKCS#15 tokens; fws:%p,%p,%p", p11card->fws_data[0], p11card->fws_data[1], p11card->fws_data[2]);
  ------------------
  |  |   71|  11.7k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1605|  11.7k|	}
 1606|  11.7k|	sc_log(context, "create slots flags 0x%X", cs_flags);
  ------------------
  |  |   71|  11.7k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1607|       |
 1608|  11.7k|	if (p11card) {
  ------------------
  |  Branch (1608:6): [True: 11.7k, False: 0]
  ------------------
 1609|  11.7k|		p11card->num_slots = 0;
 1610|  11.7k|	}
 1611|       |
 1612|       |	/* Find out framework data corresponding to the given application */
 1613|  11.7k|	fw_data = get_fw_data(p11card, app_info, &idx);
 1614|  11.7k|	if (!fw_data)   {
  ------------------
  |  Branch (1614:6): [True: 5.37k, False: 6.39k]
  ------------------
 1615|  5.37k|		if (p11card) {
  ------------------
  |  Branch (1615:7): [True: 5.37k, False: 0]
  ------------------
 1616|  5.37k|			sc_log(context, "Create slot for the non-binded card");
  ------------------
  |  |   71|  5.37k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1617|  5.37k|			pkcs15_create_slot(p11card, NULL, NULL, app_info, &slot);
 1618|  5.37k|		}
 1619|  5.37k|		return CKR_OK;
  ------------------
  |  | 1086|  5.37k|#define CKR_OK 0x00000000UL
  ------------------
 1620|  5.37k|	}
 1621|  6.39k|	sc_log(context, "Use FW data with index %i; fw_data->p15_card %p", idx, fw_data->p15_card);
  ------------------
  |  |   71|  6.39k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1622|       |
 1623|  6.39k|	conf_block = sc_get_conf_block(p11card->card->ctx, "framework", "pkcs15", 1);
 1624|  6.39k|	if (conf_block && app_info)   {
  ------------------
  |  Branch (1624:6): [True: 0, False: 6.39k]
  |  Branch (1624:20): [True: 0, False: 0]
  ------------------
 1625|      0|		scconf_block **blocks = NULL;
 1626|      0|		char str_path[SC_MAX_AID_STRING_SIZE];
 1627|       |
 1628|      0|		memset(str_path, 0, sizeof(str_path));
 1629|      0|		sc_bin_to_hex(app_info->path.value, app_info->path.len, str_path, sizeof(str_path), 0);
 1630|      0|		blocks = scconf_find_blocks(p11card->card->ctx->conf, conf_block, "application", str_path);
 1631|      0|		if (blocks)   {
  ------------------
  |  Branch (1631:7): [True: 0, False: 0]
  ------------------
 1632|      0|			if (blocks[0]) {
  ------------------
  |  Branch (1632:8): [True: 0, False: 0]
  ------------------
 1633|      0|				user_pin = (char *)scconf_get_str(blocks[0], "user_pin", NULL);
 1634|      0|				sign_pin = (char *)scconf_get_str(blocks[0], "sign_pin", NULL);
 1635|      0|			}
 1636|      0|			free(blocks);
 1637|      0|		}
 1638|      0|	}
 1639|       |
 1640|       |	/* Try to identify UserPIN and SignPIN by their symbolic name */
 1641|  6.39k|	auth_user_pin = _get_auth_object_by_name(fw_data->p15_card, "UserPIN", user_pin);
 1642|  6.39k|	if (cs_flags & SC_PKCS11_SLOT_FOR_PIN_SIGN)
  ------------------
  |  |   45|  6.39k|#define SC_PKCS11_SLOT_FOR_PIN_SIGN	2
  ------------------
  |  Branch (1642:6): [True: 0, False: 6.39k]
  ------------------
 1643|      0|		auth_sign_pin = _get_auth_object_by_name(fw_data->p15_card, "SignPIN", sign_pin);
 1644|  6.39k|	sc_log(context, "Flags:0x%X; Auth User/Sign PINs %p/%p", cs_flags, auth_user_pin, auth_sign_pin);
  ------------------
  |  |   71|  6.39k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1645|       |
 1646|       |	/* Add PKCS#15 objects of the known types to the framework data */
 1647|  6.39k|	rc = _pkcs15_create_typed_objects(fw_data);
 1648|  6.39k|	if (rc < 0)
  ------------------
  |  Branch (1648:6): [True: 0, False: 6.39k]
  ------------------
 1649|      0|		return sc_to_cryptoki_error(rc, NULL);
 1650|  6.39k|	sc_log(context, "Found %d FW objects objects", fw_data->num_objects);
  ------------------
  |  |   71|  6.39k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1651|       |
 1652|       |	/* Create slots for all non-unblock, non-so PINs if:
 1653|       |	 *  - 'UserPIN' cannot be identified (VT: for some cards with incomplete PIN flags);
 1654|       |	 *  - configuration impose to create slot for all PINs.
 1655|       |	 */
 1656|  6.39k|	if (!auth_user_pin || cs_flags & SC_PKCS11_SLOT_CREATE_ALL)   {
  ------------------
  |  |   46|  4.17k|#define SC_PKCS11_SLOT_CREATE_ALL	8
  ------------------
  |  Branch (1656:6): [True: 2.22k, False: 4.17k]
  |  Branch (1656:24): [True: 4.17k, False: 0]
  ------------------
 1657|  6.39k|		struct sc_pkcs15_object *auths[MAX_OBJECTS];
 1658|  6.39k|		int auth_count;
 1659|       |
 1660|  6.39k|		memset(auths, 0, sizeof(auths));
 1661|       |		/* Get authentication PKCS#15 objects present in the associated on-card application */
 1662|  6.39k|		rc = sc_pkcs15_get_objects(fw_data->p15_card, SC_PKCS15_TYPE_AUTH_PIN, auths, SC_PKCS15_MAX_PINS);
  ------------------
  |  |  445|  6.39k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
              		rc = sc_pkcs15_get_objects(fw_data->p15_card, SC_PKCS15_TYPE_AUTH_PIN, auths, SC_PKCS15_MAX_PINS);
  ------------------
  |  |   34|  6.39k|#define SC_PKCS15_MAX_PINS		8
  ------------------
 1663|  6.39k|		if (rc < 0)
  ------------------
  |  Branch (1663:7): [True: 0, False: 6.39k]
  ------------------
 1664|      0|			return sc_to_cryptoki_error(rc, NULL);
 1665|  6.39k|		auth_count = rc;
 1666|  6.39k|		sc_log(context, "Found %d authentication objects", auth_count);
  ------------------
  |  |   71|  6.39k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1667|       |
 1668|  12.4k|		for (i = 0; i < auth_count; i++) {
  ------------------
  |  Branch (1668:15): [True: 6.06k, False: 6.39k]
  ------------------
 1669|  6.06k|			struct sc_pkcs15_auth_info *pin_info = (struct sc_pkcs15_auth_info *)auths[i]->data;
 1670|  6.06k|			if (!_is_slot_auth_object(pin_info))
  ------------------
  |  Branch (1670:8): [True: 1.79k, False: 4.27k]
  ------------------
 1671|  1.79k|				continue;
 1672|  4.27k|			p11card->num_slots++;
 1673|  4.27k|		}
 1674|       |
 1675|  12.2k|		for (i = 0; i < auth_count; i++) {
  ------------------
  |  Branch (1675:15): [True: 6.03k, False: 6.25k]
  ------------------
 1676|  6.03k|			struct sc_pkcs15_auth_info *pin_info = (struct sc_pkcs15_auth_info*)auths[i]->data;
 1677|  6.03k|			struct sc_pkcs11_slot *islot = NULL;
 1678|       |
 1679|       |			/* Check if a slot could be created with this PIN */
 1680|  6.03k|			if (!_is_slot_auth_object(pin_info))
  ------------------
  |  Branch (1680:8): [True: 1.76k, False: 4.27k]
  ------------------
 1681|  1.76k|				continue;
 1682|  4.27k|			sc_log(context, "Found authentication object '%.*s'", (int) sizeof auths[i]->label, auths[i]->label);
  ------------------
  |  |   71|  4.27k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1683|       |
 1684|  4.27k|			rv = pkcs15_create_slot(p11card, fw_data, auths[i], app_info, &islot);
 1685|  4.27k|			if (rv != CKR_OK)
  ------------------
  |  | 1086|  4.27k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1685:8): [True: 140, False: 4.13k]
  ------------------
 1686|    140|				return CKR_OK; /* no more slots available for this card */
  ------------------
  |  | 1086|    140|#define CKR_OK 0x00000000UL
  ------------------
 1687|  4.13k|			islot->fw_data_idx = idx;
 1688|  4.13k|			_add_pin_related_objects(islot, auths[i], fw_data, NULL);
 1689|       |
 1690|       |			/* Get slot to which the public objects will be associated */
 1691|  4.13k|			if (!slot && !auth_user_pin)
  ------------------
  |  Branch (1691:8): [True: 4.13k, False: 0]
  |  Branch (1691:17): [True: 30, False: 4.10k]
  ------------------
 1692|     30|				slot = islot;
 1693|  4.10k|			else if (!slot && auth_user_pin && auth_user_pin == auths[i])
  ------------------
  |  Branch (1693:13): [True: 4.10k, False: 0]
  |  Branch (1693:22): [True: 4.10k, False: 0]
  |  Branch (1693:39): [True: 4.09k, False: 3]
  ------------------
 1694|  4.09k|				slot = islot;
 1695|  4.13k|		}
 1696|  6.39k|	}
 1697|      0|	else   {
 1698|      0|		if (auth_user_pin && (cs_flags & SC_PKCS11_SLOT_FOR_PIN_USER))
  ------------------
  |  |   44|      0|#define SC_PKCS11_SLOT_FOR_PIN_USER	1
  ------------------
  |  Branch (1698:7): [True: 0, False: 0]
  |  Branch (1698:24): [True: 0, False: 0]
  ------------------
 1699|      0|			p11card->num_slots++;
 1700|      0|		if (auth_sign_pin && (cs_flags & SC_PKCS11_SLOT_FOR_PIN_SIGN))
  ------------------
  |  |   45|      0|#define SC_PKCS11_SLOT_FOR_PIN_SIGN	2
  ------------------
  |  Branch (1700:7): [True: 0, False: 0]
  |  Branch (1700:24): [True: 0, False: 0]
  ------------------
 1701|      0|			p11card->num_slots++;
 1702|      0|		sc_log(context, "User/Sign PINs %p/%p", auth_user_pin, auth_sign_pin);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1703|      0|		if (auth_user_pin && (cs_flags & SC_PKCS11_SLOT_FOR_PIN_USER)) {
  ------------------
  |  |   44|      0|#define SC_PKCS11_SLOT_FOR_PIN_USER	1
  ------------------
  |  Branch (1703:7): [True: 0, False: 0]
  |  Branch (1703:24): [True: 0, False: 0]
  ------------------
 1704|       |			/* For the UserPIN of the first slot create slot */
 1705|      0|			sc_log(context, "Create slot for User PIN '%.*s'", (int) sizeof auth_user_pin->label, auth_user_pin->label);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1706|      0|			rv = pkcs15_create_slot(p11card, fw_data, auth_user_pin, app_info, &slot);
 1707|      0|			if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1707:8): [True: 0, False: 0]
  ------------------
 1708|      0|				return CKR_OK; /* no more slots available for this card */
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 1709|      0|			slot->fw_data_idx = idx;
 1710|      0|			_add_pin_related_objects(slot, auth_user_pin, fw_data, NULL);
 1711|      0|		}
 1712|       |
 1713|      0|		if (auth_sign_pin && (cs_flags & SC_PKCS11_SLOT_FOR_PIN_SIGN))   {
  ------------------
  |  |   45|      0|#define SC_PKCS11_SLOT_FOR_PIN_SIGN	2
  ------------------
  |  Branch (1713:7): [True: 0, False: 0]
  |  Branch (1713:24): [True: 0, False: 0]
  ------------------
 1714|       |			/* Only Sign PIN slot needs to be exposed */
 1715|      0|			sc_log(context, "Create slot for Sign PIN '%.*s'", (int) sizeof auth_sign_pin->label, auth_sign_pin->label);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1716|      0|			rv = pkcs15_create_slot(p11card, fw_data, auth_sign_pin, app_info, &sign_slot);
 1717|      0|			if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1717:8): [True: 0, False: 0]
  ------------------
 1718|      0|				return CKR_OK; /* no more slots available for this card */
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 1719|      0|			sign_slot->fw_data_idx = idx;
 1720|      0|			_add_pin_related_objects(sign_slot, auth_sign_pin, fw_data, NULL);
 1721|      0|		}
 1722|       |
 1723|      0|		if (!slot && sign_slot)
  ------------------
  |  Branch (1723:7): [True: 0, False: 0]
  |  Branch (1723:16): [True: 0, False: 0]
  ------------------
 1724|      0|			slot = sign_slot;
 1725|      0|	}
 1726|       |
 1727|  6.25k|	if (!slot && (cs_flags == SC_PKCS11_SLOT_CREATE_ALL))   {
  ------------------
  |  |   46|  2.19k|#define SC_PKCS11_SLOT_CREATE_ALL	8
  ------------------
  |  Branch (1727:6): [True: 2.19k, False: 4.06k]
  |  Branch (1727:15): [True: 2.19k, False: 0]
  ------------------
 1728|  2.19k|		sc_log(context, "Now create slot without AUTH object");
  ------------------
  |  |   71|  2.19k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1729|  2.19k|		pkcs15_create_slot(p11card, fw_data, NULL, app_info, &slot);
 1730|  2.19k|		sc_log(context, "Created slot without AUTH object: %p", slot);
  ------------------
  |  |   71|  2.19k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1731|  2.19k|	}
 1732|       |
 1733|  6.25k|	if (slot)   {
  ------------------
  |  Branch (1733:6): [True: 5.90k, False: 353]
  ------------------
 1734|  5.90k|		sc_log(context, "Add public objects to slot %p", slot);
  ------------------
  |  |   71|  5.90k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1735|  5.90k|		_add_public_objects(slot, fw_data);
 1736|  5.90k|	}
 1737|       |
 1738|  6.25k|	sc_log(context, "All tokens created");
  ------------------
  |  |   71|  6.25k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1739|  6.25k|	return CKR_OK;
  ------------------
  |  | 1086|  6.25k|#define CKR_OK 0x00000000UL
  ------------------
 1740|  6.39k|}
framework-pkcs15.c:get_fw_data:
  244|  11.7k|{
  245|  11.7k|	struct pkcs15_fw_data *out = NULL;
  246|  11.7k|	int idx;
  247|       |
  248|  11.7k|	if (!p11card)
  ------------------
  |  Branch (248:6): [True: 0, False: 11.7k]
  ------------------
  249|      0|		return NULL;
  250|  33.4k|	for (idx=0; p11card && idx < SC_PKCS11_FRAMEWORK_DATA_MAX_NUM; idx++)   {
  ------------------
  |  |  194|  33.4k|#define SC_PKCS11_FRAMEWORK_DATA_MAX_NUM	4
  ------------------
  |  Branch (250:14): [True: 33.4k, False: 0]
  |  Branch (250:25): [True: 28.0k, False: 5.37k]
  ------------------
  251|  28.0k|		struct pkcs15_fw_data *fw_data = (struct pkcs15_fw_data *) p11card->fws_data[idx];
  252|  28.0k|		struct sc_file *file_app = NULL;
  253|       |
  254|  28.0k|		if (!fw_data || !fw_data->p15_card)
  ------------------
  |  Branch (254:7): [True: 16.0k, False: 11.9k]
  |  Branch (254:19): [True: 5.40k, False: 6.56k]
  ------------------
  255|  21.4k|			continue;
  256|       |
  257|  6.56k|		file_app = fw_data->p15_card->file_app;
  258|  6.56k|		if (app_info && file_app)   {
  ------------------
  |  Branch (258:7): [True: 909, False: 5.65k]
  |  Branch (258:19): [True: 264, False: 645]
  ------------------
  259|    264|			if (file_app->path.len != app_info->path.len)
  ------------------
  |  Branch (259:8): [True: 93, False: 171]
  ------------------
  260|     93|				continue;
  261|    171|			if (file_app->path.aid.len != app_info->path.aid.len)
  ------------------
  |  Branch (261:8): [True: 0, False: 171]
  ------------------
  262|      0|				continue;
  263|    171|			if (memcmp(file_app->path.aid.value, app_info->path.aid.value, app_info->path.aid.len))
  ------------------
  |  Branch (263:8): [True: 0, False: 171]
  ------------------
  264|      0|				continue;
  265|    171|			if (memcmp(file_app->path.value, app_info->path.value, app_info->path.len))
  ------------------
  |  Branch (265:8): [True: 74, False: 97]
  ------------------
  266|     74|				continue;
  267|    171|		}
  268|       |
  269|  6.39k|		out = fw_data;
  270|  6.39k|		if (out_idx)
  ------------------
  |  Branch (270:7): [True: 6.39k, False: 0]
  ------------------
  271|  6.39k|			*out_idx = idx;
  272|  6.39k|		break;
  273|  6.56k|	}
  274|       |
  275|  11.7k|	return out;
  276|  11.7k|}
framework-pkcs15.c:pkcs15_create_slot:
 1208|  11.8k|{
 1209|  11.8k|	struct sc_pkcs11_slot *slot = NULL;
 1210|  11.8k|	CK_RV rv;
 1211|       |
 1212|  11.8k|	rv = slot_allocate(&slot, p11card);
 1213|  11.8k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  11.8k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1213:6): [True: 524, False: 11.3k]
  ------------------
 1214|    524|		return rv;
 1215|       |
 1216|       |	/* There's a token in this slot */
 1217|  11.3k|	slot->slot_info.flags |= CKF_TOKEN_PRESENT;
  ------------------
  |  |  407|  11.3k|#define CKF_TOKEN_PRESENT 0x00000001UL
  ------------------
 1218|       |
 1219|       |	/* Fill in the slot/token info from pkcs15 data */
 1220|  11.3k|	if (fw_data)
  ------------------
  |  Branch (1220:6): [True: 5.97k, False: 5.34k]
  ------------------
 1221|  5.97k|		pkcs15_init_slot(fw_data->p15_card, slot, auth, app_info);
 1222|  5.34k|	else {
 1223|       |		/* Token is not initialized, announce pinpad capability nevertheless */
 1224|  5.34k|		if (slot->reader->capabilities & SC_READER_CAP_PIN_PAD)
  ------------------
  |  |  376|  5.34k|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (1224:7): [True: 0, False: 5.34k]
  ------------------
 1225|      0|			slot->token_info.flags |= CKF_PROTECTED_AUTHENTICATION_PATH;
  ------------------
  |  |  418|      0|#define CKF_PROTECTED_AUTHENTICATION_PATH 0x00000100UL
  ------------------
 1226|  5.34k|	}
 1227|       |
 1228|  11.3k|	*out = slot;
 1229|  11.3k|	return CKR_OK;
  ------------------
  |  | 1086|  11.3k|#define CKR_OK 0x00000000UL
  ------------------
 1230|  11.8k|}
framework-pkcs15.c:pkcs15_init_slot:
 1096|  5.97k|{
 1097|  5.97k|	struct pkcs15_slot_data *fw_data;
 1098|  5.97k|	struct sc_pkcs15_auth_info *pin_info = NULL;
 1099|  5.97k|	int write_protected;
 1100|  5.97k|	scconf_block *atrblock;
 1101|       |
 1102|  5.97k|	sc_log(context, "Called");
  ------------------
  |  |   71|  5.97k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1103|  5.97k|	pkcs15_init_token_info(p15card, &slot->token_info);
 1104|  5.97k|	slot->token_info.flags |= CKF_TOKEN_INITIALIZED;
  ------------------
  |  |  420|  5.97k|#define CKF_TOKEN_INITIALIZED 0x00000400UL
  ------------------
 1105|  5.97k|	if (auth != NULL)
  ------------------
  |  Branch (1105:6): [True: 4.13k, False: 1.84k]
  ------------------
 1106|  4.13k|		slot->token_info.flags |= CKF_USER_PIN_INITIALIZED;
  ------------------
  |  |  415|  4.13k|#define CKF_USER_PIN_INITIALIZED 0x00000008UL
  ------------------
 1107|       |
 1108|  5.97k|	if ((p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD) || (p15card->card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH))
  ------------------
  |  |  376|  5.97k|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
              	if ((p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD) || (p15card->card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH))
  ------------------
  |  |  560|  5.97k|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (1108:6): [True: 0, False: 5.97k]
  |  Branch (1108:71): [True: 0, False: 5.97k]
  ------------------
 1109|      0|		slot->token_info.flags |= CKF_PROTECTED_AUTHENTICATION_PATH;
  ------------------
  |  |  418|      0|#define CKF_PROTECTED_AUTHENTICATION_PATH 0x00000100UL
  ------------------
 1110|       |
 1111|  5.97k|	if (p15card->card->caps & SC_CARD_CAP_RNG && p15card->card->ops->get_challenge != NULL)
  ------------------
  |  |  550|  11.9k|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  |  Branch (1111:6): [True: 4.11k, False: 1.85k]
  |  Branch (1111:47): [True: 4.11k, False: 0]
  ------------------
 1112|  4.11k|		slot->token_info.flags |= CKF_RNG;
  ------------------
  |  |  412|  4.11k|#define CKF_RNG 0x00000001UL
  ------------------
 1113|       |
 1114|  5.97k|	if (p15card->tokeninfo && p15card->tokeninfo->flags & SC_PKCS15_TOKEN_READONLY) {
  ------------------
  |  |  595|  5.97k|#define SC_PKCS15_TOKEN_READONLY			0x01
  ------------------
  |  Branch (1114:6): [True: 5.97k, False: 0]
  |  Branch (1114:28): [True: 169, False: 5.80k]
  ------------------
 1115|    169|		write_protected = 1;
 1116|  5.80k|	} else {
 1117|  5.80k|		write_protected = 0;
 1118|  5.80k|	}
 1119|  5.97k|	atrblock = _sc_match_atr_block(p15card->card->ctx, NULL, &p15card->card->atr);
 1120|  5.97k|	if (atrblock) {
  ------------------
  |  Branch (1120:6): [True: 0, False: 5.97k]
  ------------------
 1121|      0|		write_protected = scconf_get_bool(atrblock, "read_only", write_protected);
 1122|      0|	}
 1123|  5.97k|	if (write_protected) {
  ------------------
  |  Branch (1123:6): [True: 169, False: 5.80k]
  ------------------
 1124|    169|		slot->token_info.flags |= CKF_WRITE_PROTECTED;
  ------------------
  |  |  413|    169|#define CKF_WRITE_PROTECTED 0x00000002UL
  ------------------
 1125|    169|	}
 1126|       |
 1127|  5.97k|	slot->fw_data = fw_data = calloc(1, sizeof(*fw_data));
 1128|  5.97k|	if (!fw_data) {
  ------------------
  |  Branch (1128:6): [True: 0, False: 5.97k]
  ------------------
 1129|      0|		return;
 1130|      0|	}
 1131|  5.97k|	fw_data->auth_obj = auth;
 1132|       |
 1133|  5.97k|	if (auth != NULL) {
  ------------------
  |  Branch (1133:6): [True: 4.13k, False: 1.84k]
  ------------------
 1134|  4.13k|		pin_info = (struct sc_pkcs15_auth_info*) auth->data;
 1135|       |
 1136|  4.13k|		if (pin_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)   {
  ------------------
  |  |   94|  4.13k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1136:7): [True: 0, False: 4.13k]
  ------------------
 1137|      0|			pin_info = NULL;
 1138|      0|		}
 1139|  4.13k|		else   {
 1140|  4.13k|			size_t pin_len = 0;
 1141|  4.13k|			if (auth->label[0] && strncmp(auth->label, "PIN", 4) != 0)
  ------------------
  |  Branch (1141:8): [True: 4.13k, False: 0]
  |  Branch (1141:26): [True: 1.02k, False: 3.10k]
  ------------------
 1142|  1.02k|				pin_len = strlen(auth->label);
 1143|  4.13k|			if (pin_len && get_num_slots(p15card->card) > 1) {
  ------------------
  |  Branch (1143:8): [True: 1.02k, False: 3.10k]
  |  Branch (1143:19): [True: 48, False: 979]
  ------------------
 1144|     48|				size_t tokeninfo_len = 0;
 1145|     48|				if (p15card->tokeninfo && p15card->tokeninfo->label)
  ------------------
  |  Branch (1145:9): [True: 48, False: 0]
  |  Branch (1145:31): [True: 45, False: 3]
  ------------------
 1146|     45|					tokeninfo_len = strlen(p15card->tokeninfo->label);
 1147|       |				/* Print the possibly truncated token label with at least 4
 1148|       |				 * characters followed by the PIN label in parenthesis */
 1149|     48|				if (tokeninfo_len == 0
  ------------------
  |  Branch (1149:9): [True: 3, False: 45]
  ------------------
 1150|     45|						|| pin_len + strlen("L... ()") > 32) {
  ------------------
  |  Branch (1150:10): [True: 0, False: 45]
  ------------------
 1151|       |					/* There is no token label or it doesn't fit,
 1152|       |					 * print only PIN label */
 1153|      3|					strcpy_bp(slot->token_info.label, auth->label, 32);
 1154|     45|				} else {
 1155|     45|					size_t max_tokeninfo_len = MIN(tokeninfo_len,
  ------------------
  |  |   69|     45|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 45, False: 0]
  |  |  ------------------
  ------------------
 1156|     45|							32 - pin_len - strlen(" ()"));
 1157|     45|					strcpy_bp(slot->token_info.label,
 1158|     45|							p15card->tokeninfo->label,
 1159|     45|							max_tokeninfo_len);
 1160|     45|					slot->token_info.label[max_tokeninfo_len]           = ' ';
 1161|     45|					slot->token_info.label[max_tokeninfo_len+1]         = '(';
 1162|     45|					strcpy_bp(slot->token_info.label+max_tokeninfo_len+2,
 1163|     45|							auth->label, pin_len);
 1164|     45|					strcpy_bp(slot->token_info.label+max_tokeninfo_len+2+pin_len,
 1165|     45|							")", 32 - max_tokeninfo_len-2-pin_len);
 1166|     45|				}
 1167|  4.08k|			} else {
 1168|       |				/* PIN label is empty or just says useless "PIN",
 1169|       |				 * print only token label */
 1170|  4.08k|				strcpy_bp(slot->token_info.label,
 1171|  4.08k|						p15card->tokeninfo ? p15card->tokeninfo->label : "",
  ------------------
  |  Branch (1171:7): [True: 4.08k, False: 0]
  ------------------
 1172|  4.08k|						32);
 1173|  4.08k|			}
 1174|       |			/* Some applications (NSS) do not like the colons in the
 1175|       |			 * TOKEN_INFO label so replace them here */
 1176|   136k|			for (int i = 0; i < 32; i++) {
  ------------------
  |  Branch (1176:20): [True: 132k, False: 4.13k]
  ------------------
 1177|   132k|				if (slot->token_info.label[i] == ':') {
  ------------------
  |  Branch (1177:9): [True: 10, False: 132k]
  ------------------
 1178|     10|					slot->token_info.label[i] = '.';
 1179|     10|				}
 1180|   132k|			}
 1181|  4.13k|			slot->token_info.flags |= CKF_LOGIN_REQUIRED;
  ------------------
  |  |  414|  4.13k|#define CKF_LOGIN_REQUIRED 0x00000004UL
  ------------------
 1182|  4.13k|		}
 1183|  4.13k|	}
 1184|       |
 1185|  5.97k|	if (pin_info) {
  ------------------
  |  Branch (1185:6): [True: 4.13k, False: 1.84k]
  ------------------
 1186|  4.13k|		slot->token_info.ulMaxPinLen = pin_info->attrs.pin.max_length;
 1187|  4.13k|		slot->token_info.ulMinPinLen = pin_info->attrs.pin.min_length;
 1188|  4.13k|	}
 1189|  1.84k|	else {
 1190|       |		/* choose reasonable defaults */
 1191|  1.84k|		slot->token_info.ulMaxPinLen = 8;
 1192|  1.84k|		slot->token_info.ulMinPinLen = 4;
 1193|  1.84k|		strcpy_bp(slot->token_info.label,
 1194|  1.84k|				p15card->tokeninfo ? p15card->tokeninfo->label : "",
  ------------------
  |  Branch (1194:5): [True: 1.84k, False: 0]
  ------------------
 1195|  1.84k|				32);
 1196|  1.84k|	}
 1197|       |
 1198|  5.97k|	slot->app_info = app_info;
 1199|  5.97k|	sc_log(context, "Initialized slot 0x%lx with token %*s", slot->id,
  ------------------
  |  |   71|  5.97k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1200|  5.97k|			(int)sizeof(slot->token_info.label), slot->token_info.label);
 1201|  5.97k|}
framework-pkcs15.c:pkcs15_init_token_info:
  362|  5.97k|{
  363|  5.97k|	scconf_block *conf_block = NULL;
  364|  5.97k|	char *model = NULL;
  365|       |
  366|  5.97k|	conf_block = sc_get_conf_block(p15card->card->ctx, "framework", "pkcs15", 1);
  367|  5.97k|	if (conf_block && p15card->file_app)   {
  ------------------
  |  Branch (367:6): [True: 0, False: 5.97k]
  |  Branch (367:20): [True: 0, False: 0]
  ------------------
  368|      0|		scconf_block **blocks = NULL;
  369|      0|		char str_path[SC_MAX_AID_STRING_SIZE];
  370|       |
  371|      0|		memset(str_path, 0, sizeof(str_path));
  372|      0|		sc_bin_to_hex(p15card->file_app->path.value, p15card->file_app->path.len, str_path, sizeof(str_path), 0);
  373|      0|		blocks = scconf_find_blocks(p15card->card->ctx->conf, conf_block, "application", str_path);
  374|      0|		if (blocks)   {
  ------------------
  |  Branch (374:7): [True: 0, False: 0]
  ------------------
  375|      0|			if (blocks[0])
  ------------------
  |  Branch (375:8): [True: 0, False: 0]
  ------------------
  376|      0|				model = (char *)scconf_get_str(blocks[0], "model", NULL);
  377|      0|			free(blocks);
  378|      0|		}
  379|      0|	}
  380|       |
  381|  5.97k|	if (model)
  ------------------
  |  Branch (381:6): [True: 0, False: 5.97k]
  ------------------
  382|      0|		strcpy_bp(pToken->model, model, sizeof(pToken->model));
  383|  5.97k|	else if (sc_card_ctl(p15card->card, SC_CARDCTL_GET_MODEL, &model) == SC_SUCCESS)
  ------------------
  |  |   28|  5.97k|#define SC_SUCCESS				0
  ------------------
  |  Branch (383:11): [True: 4, False: 5.96k]
  ------------------
  384|      4|		strcpy_bp(pToken->model, model, sizeof(pToken->model));
  385|  5.96k|	else if (p15card->flags & SC_PKCS15_CARD_FLAG_EMULATED)
  ------------------
  |  |  601|  5.96k|#define SC_PKCS15_CARD_FLAG_EMULATED			0x02000000
  ------------------
  |  Branch (385:11): [True: 5.49k, False: 470]
  ------------------
  386|  5.49k|		strcpy_bp(pToken->model, "PKCS#15 emulated", sizeof(pToken->model));
  387|    470|	else
  388|    470|		strcpy_bp(pToken->model, "PKCS#15", sizeof(pToken->model));
  389|       |
  390|  5.97k|	if (p15card->tokeninfo) {
  ------------------
  |  Branch (390:6): [True: 5.97k, False: 0]
  ------------------
  391|  5.97k|		strcpy_bp(pToken->manufacturerID, p15card->tokeninfo->manufacturer_id, 32);
  392|       |
  393|       |		/* Take the last 16 chars of the serial number (if the are more than 16).
  394|       |		 * _Assuming_ that the serial number is a Big Endian counter, this
  395|       |		 * will assure that the serial within each type of card will be
  396|       |		 * unique in pkcs11 (at least for the first 8^16 cards :-) */
  397|  5.97k|		if (p15card->tokeninfo->serial_number != NULL) {
  ------------------
  |  Branch (397:7): [True: 3.98k, False: 1.98k]
  ------------------
  398|  3.98k|			size_t sn_start = strlen(p15card->tokeninfo->serial_number);
  399|       |
  400|  3.98k|			if (sn_start <= 16)
  ------------------
  |  Branch (400:8): [True: 3.03k, False: 952]
  ------------------
  401|  3.03k|				sn_start = 0;
  402|    952|			else
  403|    952|				sn_start -= 16;
  404|       |
  405|  3.98k|			strcpy_bp(pToken->serialNumber, p15card->tokeninfo->serial_number + sn_start, 16);
  406|  3.98k|		}
  407|  5.97k|	}
  408|       |
  409|  5.97k|	pToken->ulMaxSessionCount = CK_EFFECTIVELY_INFINITE;
  ------------------
  |  |   31|  5.97k|#define CK_EFFECTIVELY_INFINITE 0UL
  ------------------
  410|  5.97k|	pToken->ulSessionCount = 0; /* FIXME */
  411|  5.97k|	pToken->ulMaxRwSessionCount = CK_EFFECTIVELY_INFINITE;
  ------------------
  |  |   31|  5.97k|#define CK_EFFECTIVELY_INFINITE 0UL
  ------------------
  412|  5.97k|	pToken->ulRwSessionCount = 0; /* FIXME */
  413|  5.97k|	pToken->ulTotalPublicMemory = CK_UNAVAILABLE_INFORMATION;
  ------------------
  |  |   32|  5.97k|#define CK_UNAVAILABLE_INFORMATION ~0UL
  ------------------
  414|  5.97k|	pToken->ulFreePublicMemory = CK_UNAVAILABLE_INFORMATION;
  ------------------
  |  |   32|  5.97k|#define CK_UNAVAILABLE_INFORMATION ~0UL
  ------------------
  415|  5.97k|	pToken->ulTotalPrivateMemory = CK_UNAVAILABLE_INFORMATION;
  ------------------
  |  |   32|  5.97k|#define CK_UNAVAILABLE_INFORMATION ~0UL
  ------------------
  416|  5.97k|	pToken->ulFreePrivateMemory = CK_UNAVAILABLE_INFORMATION;
  ------------------
  |  |   32|  5.97k|#define CK_UNAVAILABLE_INFORMATION ~0UL
  ------------------
  417|  5.97k|	pToken->hardwareVersion.major = p15card->card->version.hw_major;
  418|  5.97k|	pToken->hardwareVersion.minor = p15card->card->version.hw_minor;
  419|  5.97k|	pToken->firmwareVersion.major = p15card->card->version.fw_major;
  420|  5.97k|	pToken->firmwareVersion.minor = p15card->card->version.fw_minor;
  421|  5.97k|}
framework-pkcs15.c:get_num_slots:
 1083|  1.02k|{
 1084|  1.02k|	unsigned int i;
 1085|  1.02k|	for (i = 0; i < list_size(&virtual_slots); i++) {
  ------------------
  |  Branch (1085:14): [True: 1.02k, False: 0]
  ------------------
 1086|  1.02k|		sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *)list_get_at(&virtual_slots, i);
 1087|  1.02k|		if (slot && slot->p11card && slot->p11card->card == card)
  ------------------
  |  Branch (1087:7): [True: 1.02k, False: 0]
  |  Branch (1087:15): [True: 1.02k, False: 0]
  |  Branch (1087:32): [True: 1.02k, False: 0]
  ------------------
 1088|  1.02k|			return slot->p11card->num_slots;
 1089|  1.02k|	}
 1090|      0|	return 0;
 1091|  1.02k|}
framework-pkcs15.c:_pkcs15_create_typed_objects:
 1235|  6.39k|{
 1236|  6.39k|	int rv;
 1237|       |
 1238|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PRKEY_RSA, "RSA private key",
  ------------------
  |  |  419|  6.39k|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
 1239|  6.39k|			__pkcs15_create_prkey_object);
 1240|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1240:6): [True: 0, False: 6.39k]
  ------------------
 1241|      0|		return rv;
 1242|       |
 1243|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PUBKEY_RSA, "RSA public key",
  ------------------
  |  |  426|  6.39k|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
 1244|  6.39k|			__pkcs15_create_pubkey_object);
 1245|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1245:6): [True: 0, False: 6.39k]
  ------------------
 1246|      0|		return rv;
 1247|       |
 1248|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PRKEY_EC, "EC private key",
  ------------------
  |  |  421|  6.39k|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
 1249|  6.39k|			__pkcs15_create_prkey_object);
 1250|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1250:6): [True: 0, False: 6.39k]
  ------------------
 1251|      0|		return rv;
 1252|       |
 1253|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PUBKEY_EC, "EC public key",
  ------------------
  |  |  428|  6.39k|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
 1254|  6.39k|			__pkcs15_create_pubkey_object);
 1255|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1255:6): [True: 0, False: 6.39k]
  ------------------
 1256|      0|		return rv;
 1257|       |
 1258|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PRKEY_EDDSA, "EdDSA private key",
  ------------------
  |  |  422|  6.39k|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
 1259|  6.39k|			__pkcs15_create_prkey_object);
 1260|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1260:6): [True: 0, False: 6.39k]
  ------------------
 1261|      0|		return rv;
 1262|       |
 1263|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PUBKEY_EDDSA, "EdDSA public key",
  ------------------
  |  |  429|  6.39k|#define SC_PKCS15_TYPE_PUBKEY_EDDSA		0x205
  ------------------
 1264|  6.39k|			__pkcs15_create_pubkey_object);
 1265|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1265:6): [True: 0, False: 6.39k]
  ------------------
 1266|      0|		return rv;
 1267|       |
 1268|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PRKEY_XEDDSA, "XEdDSA private key",
  ------------------
  |  |  423|  6.39k|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
 1269|  6.39k|			__pkcs15_create_prkey_object);
 1270|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1270:6): [True: 0, False: 6.39k]
  ------------------
 1271|      0|		return rv;
 1272|       |
 1273|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PUBKEY_XEDDSA, "XEdDSA public key",
  ------------------
  |  |  430|  6.39k|#define SC_PKCS15_TYPE_PUBKEY_XEDDSA		0x206
  ------------------
 1274|  6.39k|			__pkcs15_create_pubkey_object);
 1275|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1275:6): [True: 0, False: 6.39k]
  ------------------
 1276|      0|		return rv;
 1277|       |
 1278|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PRKEY_GOSTR3410, "GOSTR3410 private key",
  ------------------
  |  |  420|  6.39k|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
 1279|  6.39k|			__pkcs15_create_prkey_object);
 1280|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1280:6): [True: 0, False: 6.39k]
  ------------------
 1281|      0|		return rv;
 1282|       |
 1283|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_PUBKEY_GOSTR3410, "GOSTR3410 public key",
  ------------------
  |  |  427|  6.39k|#define SC_PKCS15_TYPE_PUBKEY_GOSTR3410		0x203
  ------------------
 1284|  6.39k|			__pkcs15_create_pubkey_object);
 1285|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1285:6): [True: 0, False: 6.39k]
  ------------------
 1286|      0|		return rv;
 1287|       |
 1288|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_CERT_X509, "certificate",
  ------------------
  |  |  439|  6.39k|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
 1289|  6.39k|			__pkcs15_create_cert_object);
 1290|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1290:6): [True: 0, False: 6.39k]
  ------------------
 1291|      0|		return rv;
 1292|       |
 1293|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_DATA_OBJECT, "data object",
  ------------------
  |  |  442|  6.39k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
 1294|  6.39k|			__pkcs15_create_data_object);
 1295|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1295:6): [True: 0, False: 6.39k]
  ------------------
 1296|      0|		return rv;
 1297|       |
 1298|  6.39k|	rv = pkcs15_create_pkcs11_objects(fw_data, SC_PKCS15_TYPE_SKEY_GENERIC, "Generic secret key",
  ------------------
  |  |  433|  6.39k|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
 1299|  6.39k|			__pkcs15_create_secret_key_object);
 1300|  6.39k|	if (rv < 0)
  ------------------
  |  Branch (1300:6): [True: 0, False: 6.39k]
  ------------------
 1301|      0|		return rv;
 1302|       |
 1303|       |	/* Match up related keys and certificates */
 1304|  6.39k|	pkcs15_bind_related_objects(fw_data);
 1305|  6.39k|	sc_log(context, "found %i FW objects", fw_data->num_objects);
  ------------------
  |  |   71|  6.39k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1306|       |
 1307|  6.39k|	return rv;
 1308|  6.39k|}
framework-pkcs15.c:pkcs15_create_pkcs11_objects:
  853|  83.1k|{
  854|  83.1k|	struct sc_pkcs15_object *p15_object[MAX_OBJECTS];
  855|  83.1k|	int i, count, rv;
  856|       |
  857|  83.1k|	rv = count = sc_pkcs15_get_objects(fw_data->p15_card, p15_type, p15_object, MAX_OBJECTS);
  ------------------
  |  |   66|  83.1k|#define MAX_OBJECTS	128
  ------------------
  858|  83.1k|	if (rv >= 0)
  ------------------
  |  Branch (858:6): [True: 83.1k, False: 0]
  ------------------
  859|  83.1k|		sc_log(context, "Found %d %s%s", count, name, (count == 1)? "" : "s");
  ------------------
  |  |   71|   166k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 1.82k, False: 81.3k]
  |  |  ------------------
  ------------------
  860|       |
  861|   112k|	for (i = 0; rv >= 0 && i < count; i++)
  ------------------
  |  Branch (861:14): [True: 111k, False: 831]
  |  Branch (861:25): [True: 28.9k, False: 82.3k]
  ------------------
  862|  28.9k|		rv = create(fw_data, p15_object[i], NULL);
  863|       |
  864|  83.1k|	return count;
  865|  83.1k|}
framework-pkcs15.c:__pkcs15_create_prkey_object:
  756|  3.63k|{
  757|  3.63k|	struct pkcs15_any_object *any_object = NULL;
  758|  3.63k|	struct pkcs15_prkey_object *object = NULL;
  759|  3.63k|	int rv;
  760|       |
  761|  3.63k|	rv = __pkcs15_create_object(fw_data, &any_object,
  762|  3.63k|			prkey, &pkcs15_prkey_ops, sizeof(struct pkcs15_prkey_object));
  763|  3.63k|	object = (struct pkcs15_prkey_object *) any_object;
  764|  3.63k|	if (rv >= 0)
  ------------------
  |  Branch (764:6): [True: 3.63k, False: 0]
  ------------------
  765|  3.63k|		object->prv_info = (struct sc_pkcs15_prkey_info *) prkey->data;
  766|       |
  767|  3.63k|	if (prkey_object != NULL)
  ------------------
  |  Branch (767:6): [True: 0, False: 3.63k]
  ------------------
  768|      0|		*prkey_object = any_object;
  769|       |
  770|  3.63k|	return rv;
  771|  3.63k|}
framework-pkcs15.c:__pkcs15_create_object:
  444|  34.3k|{
  445|  34.3k|	struct pkcs15_any_object *obj;
  446|       |
  447|  34.3k|	if (fw_data->num_objects >= MAX_OBJECTS)
  ------------------
  |  |   66|  34.3k|#define MAX_OBJECTS	128
  ------------------
  |  Branch (447:6): [True: 0, False: 34.3k]
  ------------------
  448|      0|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  449|       |
  450|  34.3k|	if (!(obj = calloc(1, size)))
  ------------------
  |  Branch (450:6): [True: 0, False: 34.3k]
  ------------------
  451|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  452|       |
  453|  34.3k|	fw_data->objects[fw_data->num_objects++] = obj;
  454|       |
  455|  34.3k|	obj->base.ops = ops;
  456|  34.3k|	obj->p15_object = p15_object;
  457|  34.3k|	obj->refcount = 1;
  458|  34.3k|	obj->size = size;
  459|       |
  460|  34.3k|	*result = obj;
  461|  34.3k|	return SC_SUCCESS;
  ------------------
  |  |   28|  34.3k|#define SC_SUCCESS				0
  ------------------
  462|  34.3k|}
framework-pkcs15.c:__pkcs15_create_pubkey_object:
  701|  1.20k|{
  702|  1.20k|	struct pkcs15_any_object *any_object = NULL;
  703|  1.20k|	struct pkcs15_pubkey_object *object = NULL;
  704|  1.20k|	struct sc_pkcs15_pubkey *p15_key = NULL;
  705|  1.20k|	int rv;
  706|       |
  707|       |	/* Read public key from card */
  708|       |	/* Attempt to read pubkey from card or file.
  709|       |	 * During initialization process, the key may have been created
  710|       |	 * and saved as a file before the certificate has been created.
  711|       |	 */
  712|  1.20k|	if (pubkey->flags & SC_PKCS15_CO_FLAG_PRIVATE)   {	/* is the key private? */
  ------------------
  |  |   50|  1.20k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (712:6): [True: 35, False: 1.16k]
  ------------------
  713|     35|		sc_log(context, "No pubkey");
  ------------------
  |  |   71|     35|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  714|     35|		p15_key = NULL;					/* will read key when needed */
  715|     35|	}
  716|  1.16k|	else {
  717|       |		/* if emulation already created pubkey use it */
  718|  1.16k|		if (pubkey->emulated && (fw_data->p15_card->flags & SC_PKCS15_CARD_FLAG_EMULATED)) {
  ------------------
  |  |  601|  1.10k|#define SC_PKCS15_CARD_FLAG_EMULATED			0x02000000
  ------------------
  |  Branch (718:7): [True: 1.10k, False: 61]
  |  Branch (718:27): [True: 1.10k, False: 0]
  ------------------
  719|  1.10k|			sc_log(context, "Use emulated pubkey");
  ------------------
  |  |   71|  1.10k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  720|  1.10k|			sc_pkcs15_dup_pubkey(context, (struct sc_pkcs15_pubkey *) pubkey->emulated, &p15_key);
  721|  1.10k|		}
  722|     61|		else {
  723|     61|			sc_log(context, "Get pubkey from PKCS#15 object");
  ------------------
  |  |   71|     61|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  724|     61|			rv = sc_pkcs15_read_pubkey(fw_data->p15_card, pubkey, &p15_key);
  725|     61|			if (rv < 0)
  ------------------
  |  Branch (725:8): [True: 60, False: 1]
  ------------------
  726|     60|				 p15_key = NULL;
  727|     61|		}
  728|  1.16k|	}
  729|       |
  730|       |	/* Public key object */
  731|  1.20k|	rv = __pkcs15_create_object(fw_data, &any_object,
  732|  1.20k|			pubkey, &pkcs15_pubkey_ops, sizeof(struct pkcs15_pubkey_object));
  733|  1.20k|	object = (struct pkcs15_pubkey_object *) any_object;
  734|  1.20k|	if (rv >= 0) {
  ------------------
  |  Branch (734:6): [True: 1.20k, False: 0]
  ------------------
  735|  1.20k|		object->pub_info = (struct sc_pkcs15_pubkey_info *) pubkey->data;
  736|  1.20k|		object->pub_data = p15_key;
  737|  1.20k|		if (p15_key && object->pub_info->modulus_length == 0 && p15_key->algorithm == SC_ALGORITHM_RSA)
  ------------------
  |  |   69|  1.01k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (737:7): [True: 1.10k, False: 99]
  |  Branch (737:18): [True: 1.01k, False: 88]
  |  Branch (737:59): [True: 1, False: 1.01k]
  ------------------
  738|      1|			object->pub_info->modulus_length = 8 * p15_key->u.rsa.modulus.len;
  739|  1.20k|	} else {
  740|      0|		sc_pkcs15_free_pubkey(p15_key);
  741|      0|	}
  742|  1.20k|	if (object && object->pub_data) {
  ------------------
  |  Branch (742:6): [True: 1.20k, False: 0]
  |  Branch (742:16): [True: 1.10k, False: 99]
  ------------------
  743|  1.10k|		if ((object->pub_data->alg_id)&&(object->pub_data->algorithm == SC_ALGORITHM_GOSTR3410))
  ------------------
  |  |   71|  1.10k|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (743:7): [True: 1.10k, False: 1]
  |  Branch (743:35): [True: 0, False: 1.10k]
  ------------------
  744|      0|			object->pub_data->alg_id->params = &((object->pub_data->u).gostr3410.params);
  745|  1.10k|	}
  746|  1.20k|	if (pubkey_object != NULL)
  ------------------
  |  Branch (746:6): [True: 0, False: 1.20k]
  ------------------
  747|      0|		*pubkey_object = any_object;
  748|       |
  749|  1.20k|	return rv;
  750|  1.20k|}
framework-pkcs15.c:__pkcs15_create_cert_object:
  635|  2.18k|{
  636|  2.18k|	struct sc_pkcs15_cert_info *p15_info = NULL;
  637|  2.18k|	struct sc_pkcs15_cert *p15_cert = NULL;
  638|  2.18k|	struct pkcs15_any_object *any_object = NULL;
  639|  2.18k|	struct pkcs15_cert_object *object = NULL;
  640|  2.18k|	struct pkcs15_pubkey_object *obj2 = NULL;
  641|  2.18k|	struct pkcs15_any_object *any_object2 = NULL;
  642|  2.18k|	int rv;
  643|       |
  644|  2.18k|	p15_info = (struct sc_pkcs15_cert_info *) cert->data;
  645|       |
  646|  2.18k|	if (cert->flags & SC_PKCS15_CO_FLAG_PRIVATE)  {	/* is the cert private? */
  ------------------
  |  |   50|  2.18k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (646:6): [True: 215, False: 1.96k]
  ------------------
  647|    215|		p15_cert = NULL;			/* will read cert when needed */
  648|    215|	}
  649|  1.96k|	else    {
  650|  1.96k|		rv = sc_pkcs15_read_certificate(fw_data->p15_card, p15_info, 0, &p15_cert);
  651|  1.96k|		if (rv < 0)
  ------------------
  |  Branch (651:7): [True: 831, False: 1.13k]
  ------------------
  652|    831|			return rv;
  653|  1.96k|	}
  654|       |
  655|       |	/* Certificate object */
  656|  1.34k|	rv = __pkcs15_create_object(fw_data, &any_object,
  657|  1.34k|			cert, &pkcs15_cert_ops, sizeof(struct pkcs15_cert_object));
  658|  1.34k|	object = (struct pkcs15_cert_object *) any_object;
  659|  1.34k|	if (rv < 0) {
  ------------------
  |  Branch (659:6): [True: 0, False: 1.34k]
  ------------------
  660|      0|		if (p15_cert != NULL)
  ------------------
  |  Branch (660:7): [True: 0, False: 0]
  ------------------
  661|      0|			sc_pkcs15_free_certificate(p15_cert);
  662|      0|		return rv;
  663|      0|	}
  664|       |
  665|  1.34k|	object->cert_info = p15_info;
  666|  1.34k|	object->cert_data = p15_cert;
  667|       |
  668|       |	/* Corresponding public key */
  669|  1.34k|	rv = public_key_created(fw_data, &p15_info->id, &any_object2);
  670|  1.34k|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|  1.34k|#define SC_SUCCESS				0
  ------------------
  |  Branch (670:6): [True: 246, False: 1.10k]
  ------------------
  671|    246|		rv = __pkcs15_create_object(fw_data, &any_object2,
  672|    246|				NULL, &pkcs15_pubkey_ops, sizeof(struct pkcs15_pubkey_object));
  673|  1.34k|	obj2 = (struct pkcs15_pubkey_object *) any_object2;
  674|  1.34k|	if (rv < 0)
  ------------------
  |  Branch (674:6): [True: 0, False: 1.34k]
  ------------------
  675|      0|		return rv;
  676|       |
  677|  1.34k|	if (p15_cert) {
  ------------------
  |  Branch (677:6): [True: 1.13k, False: 215]
  ------------------
  678|       |		 /* make a copy of public key from the cert */
  679|  1.13k|		if (!obj2->pub_data)
  ------------------
  |  Branch (679:7): [True: 35, False: 1.09k]
  ------------------
  680|     35|			rv = sc_pkcs15_pubkey_from_cert(context, &p15_cert->data, &obj2->pub_data);
  681|  1.13k|		if (rv < 0)
  ------------------
  |  Branch (681:7): [True: 0, False: 1.13k]
  ------------------
  682|      0|			return rv;
  683|  1.13k|	}
  684|       |
  685|  1.34k|	obj2->pub_genfrom = object;
  ------------------
  |  |  117|  1.34k|#define pub_genfrom		base.related_cert
  ------------------
  686|  1.34k|	object->cert_pubkey = obj2;
  ------------------
  |  |   94|  1.34k|#define cert_pubkey		base.related_pubkey
  ------------------
  687|       |
  688|       |	/* Find missing labels for certificate */
  689|  1.34k|	pkcs15_cert_extract_label(object);
  690|       |
  691|  1.34k|	if (cert_object != NULL)
  ------------------
  |  Branch (691:6): [True: 0, False: 1.34k]
  ------------------
  692|      0|		*cert_object = any_object;
  693|       |
  694|  1.34k|	return 0;
  695|  1.34k|}
framework-pkcs15.c:public_key_created:
  582|  1.34k|{
  583|  1.34k|	size_t ii;
  584|       |
  585|  20.7k|	for(ii=0; ii<fw_data->num_objects; ii++) {
  ------------------
  |  Branch (585:12): [True: 20.4k, False: 246]
  ------------------
  586|  20.4k|		struct pkcs15_any_object *any_object = fw_data->objects[ii];
  587|  20.4k|		struct sc_pkcs15_object *p15_object = any_object->p15_object;
  588|       |
  589|  20.4k|		if (!p15_object)
  ------------------
  |  Branch (589:7): [True: 364, False: 20.1k]
  ------------------
  590|    364|			continue;
  591|       |
  592|  20.1k|		if ((p15_object->type & SC_PKCS15_TYPE_CLASS_MASK) != SC_PKCS15_TYPE_PUBKEY)
  ------------------
  |  |  416|  20.1k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              		if ((p15_object->type & SC_PKCS15_TYPE_CLASS_MASK) != SC_PKCS15_TYPE_PUBKEY)
  ------------------
  |  |  425|  20.1k|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (592:7): [True: 13.4k, False: 6.65k]
  ------------------
  593|  13.4k|			continue;
  594|       |
  595|  6.65k|		if (sc_pkcs15_compare_id(id, &((struct sc_pkcs15_pubkey_info *)p15_object->data)->id))   {
  ------------------
  |  Branch (595:7): [True: 1.10k, False: 5.55k]
  ------------------
  596|  1.10k|			if (obj2)
  ------------------
  |  Branch (596:8): [True: 1.10k, False: 0]
  ------------------
  597|  1.10k|				*obj2 = any_object;
  598|  1.10k|			return SC_SUCCESS;
  ------------------
  |  |   28|  1.10k|#define SC_SUCCESS				0
  ------------------
  599|  1.10k|		}
  600|  6.65k|	}
  601|       |
  602|    246|	return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    246|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  603|  1.34k|}
framework-pkcs15.c:pkcs15_cert_extract_label:
  607|  1.34k|{
  608|  1.34k|	if (!cert || !cert->cert_p15obj || !cert->cert_data)
  ------------------
  |  |   93|  2.69k|#define cert_p15obj		base.p15_object
  ------------------
  |  Branch (608:6): [True: 0, False: 1.34k]
  |  Branch (608:15): [True: 0, False: 1.34k]
  |  Branch (608:37): [True: 215, False: 1.13k]
  ------------------
  609|    215|		return;
  610|       |
  611|  1.13k|	sc_log(context, "pkcs15_cert_extract_label() called. Current label: %s", cert->cert_p15obj->label);
  ------------------
  |  |   71|  1.13k|#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)
  |  |  ------------------
  |  |  |  |  611|  1.13k|	sc_log(context, "pkcs15_cert_extract_label() called. Current label: %s", cert->cert_p15obj->label);
  |  |  |  |  ------------------
  |  |  |  |  |  |   93|  1.13k|#define cert_p15obj		base.p15_object
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|       |
  613|       |	/* if we didn't get a label, set one based on the CN */
  614|  1.13k|	if (*cert->cert_p15obj->label == '\0') { /* can't be NULL -- static array */
  ------------------
  |  |   93|  1.13k|#define cert_p15obj		base.p15_object
  ------------------
  |  Branch (614:6): [True: 0, False: 1.13k]
  ------------------
  615|      0|		static const struct sc_object_id cn_oid = {{ 2, 5, 4, 3, -1 }};
  616|      0|		u8 *cn_name = NULL;
  617|      0|		size_t cn_len = 0;
  618|      0|		int rv = sc_pkcs15_get_name_from_dn(context,
  619|      0|			cert->cert_data->subject, cert->cert_data->subject_len,
  620|      0|			&cn_oid, &cn_name, &cn_len);
  621|      0|		if (rv == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (621:7): [True: 0, False: 0]
  ------------------
  622|      0|			sc_log(context, "pkcs15_cert_extract_label(): Name from DN is %.*s",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  623|      0|					(unsigned int) cn_len, cn_name);
  624|      0|			cn_len = MIN(cn_len, SC_PKCS15_MAX_LABEL_SIZE-1);
  ------------------
  |  |   69|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (69:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  625|      0|			memcpy(cert->cert_p15obj->label, cn_name, cn_len);
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
  626|      0|			cert->cert_p15obj->label[cn_len] = '\0';
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
  627|      0|		}
  628|      0|		free(cn_name);
  629|      0|	}
  630|  1.13k|}
framework-pkcs15.c:__pkcs15_create_data_object:
  777|  21.9k|{
  778|  21.9k|	struct pkcs15_any_object *any_object = NULL;
  779|  21.9k|	struct pkcs15_data_object *dobj = NULL;
  780|  21.9k|	int rv;
  781|       |
  782|  21.9k|	rv = __pkcs15_create_object(fw_data, &any_object,
  783|  21.9k|			object, &pkcs15_dobj_ops, sizeof(struct pkcs15_data_object));
  784|  21.9k|        dobj = (struct pkcs15_data_object *) any_object;
  785|  21.9k|	if (rv >= 0)   {
  ------------------
  |  Branch (785:6): [True: 21.9k, False: 0]
  ------------------
  786|  21.9k|		dobj->info = (struct sc_pkcs15_data_info *) object->data;
  787|  21.9k|		dobj->value = NULL;
  788|  21.9k|	}
  789|       |
  790|  21.9k|	if (data_object != NULL)
  ------------------
  |  Branch (790:6): [True: 0, False: 21.9k]
  ------------------
  791|      0|		*data_object = any_object;
  792|       |
  793|  21.9k|	return rv;
  794|  21.9k|}
framework-pkcs15.c:pkcs15_bind_related_objects:
  957|  6.39k|{
  958|  6.39k|	unsigned int i;
  959|       |
  960|       |	/* Loop over all private keys and attached related certificate
  961|       |	 * and/or public key
  962|       |	 */
  963|  35.4k|	for (i = 0; i < fw_data->num_objects; i++) {
  ------------------
  |  Branch (963:14): [True: 29.0k, False: 6.39k]
  ------------------
  964|  29.0k|		struct pkcs15_any_object *obj = fw_data->objects[i];
  965|       |
  966|  29.0k|		if (obj->base.flags & SC_PKCS11_OBJECT_HIDDEN)
  ------------------
  |  |  138|  29.0k|#define SC_PKCS11_OBJECT_HIDDEN	0x0002
  ------------------
  |  Branch (966:7): [True: 655, False: 28.3k]
  ------------------
  967|    655|			continue;
  968|       |
  969|  28.3k|		sc_log(context, "Looking for objects related to object %d", i);
  ------------------
  |  |   71|  28.3k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  970|  28.3k|		if (is_privkey(obj))
  ------------------
  |  |  120|  28.3k|#define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  119|  28.3k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 28.3k, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 28.1k, False: 246]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  416|  28.3k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  |  |  ------------------
  |  |               #define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  418|  28.3k|#define SC_PKCS15_TYPE_PRKEY			0x100
  |  |  ------------------
  |  |  |  Branch (120:26): [True: 3.04k, False: 25.3k]
  |  |  ------------------
  ------------------
  971|  3.04k|			__pkcs15_prkey_bind_related(fw_data, (struct pkcs15_prkey_object *) obj);
  972|  25.3k|		else if (is_cert(obj))
  ------------------
  |  |  122|  25.3k|#define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  119|  25.3k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 25.3k, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 25.0k, False: 246]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  439|  25.3k|#define SC_PKCS15_TYPE_CERT_X509		0x401
  |  |  ------------------
  |  |  |  Branch (122:23): [True: 1.34k, False: 23.9k]
  |  |  ------------------
  ------------------
  973|  1.34k|			__pkcs15_cert_bind_related(fw_data, (struct pkcs15_cert_object *) obj);
  974|  28.3k|	}
  975|  6.39k|}
framework-pkcs15.c:__pkcs15_prkey_bind_related:
  870|  3.04k|{
  871|  3.04k|	struct sc_pkcs15_id *id = &pk->prv_info->id;
  872|  3.04k|	unsigned int i;
  873|       |
  874|  3.04k|	sc_log(context, "Object is a private key and has id %s", sc_pkcs15_print_id(id));
  ------------------
  |  |   71|  3.04k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  875|       |
  876|  82.2k|	for (i = 0; i < fw_data->num_objects; i++) {
  ------------------
  |  Branch (876:14): [True: 79.2k, False: 3.04k]
  ------------------
  877|  79.2k|		struct pkcs15_any_object *obj = fw_data->objects[i];
  878|       |
  879|  79.2k|		if (obj->base.flags & SC_PKCS11_OBJECT_HIDDEN)
  ------------------
  |  |  138|  79.2k|#define SC_PKCS11_OBJECT_HIDDEN	0x0002
  ------------------
  |  Branch (879:7): [True: 1.08k, False: 78.1k]
  ------------------
  880|  1.08k|			continue;
  881|  78.1k|		if (is_privkey(obj) && obj != (struct pkcs15_any_object *) pk) {
  ------------------
  |  |  120|   156k|#define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  119|  78.1k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 78.1k, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 77.4k, False: 657]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  416|  78.1k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  |  |  ------------------
  |  |               #define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  418|  78.1k|#define SC_PKCS15_TYPE_PRKEY			0x100
  |  |  ------------------
  |  |  |  Branch (120:26): [True: 18.7k, False: 59.4k]
  |  |  ------------------
  ------------------
  |  Branch (881:26): [True: 15.6k, False: 3.04k]
  ------------------
  882|       |			/* merge private keys with the same ID and
  883|       |			 * different usage bits */
  884|  15.6k|			struct pkcs15_prkey_object *other, **pp;
  885|       |
  886|  15.6k|			other = (struct pkcs15_prkey_object *) obj;
  887|  15.6k|			if (sc_pkcs15_compare_id(&other->prv_info->id, id)) {
  ------------------
  |  Branch (887:8): [True: 630, False: 15.0k]
  ------------------
  888|    630|				obj->base.flags |= SC_PKCS11_OBJECT_HIDDEN;
  ------------------
  |  |  138|    630|#define SC_PKCS11_OBJECT_HIDDEN	0x0002
  ------------------
  889|  1.57k|				for (pp = &pk->prv_next; *pp; pp = &(*pp)->prv_next)
  ------------------
  |  |  107|    630|#define prv_next		base.related_privkey
  ------------------
              				for (pp = &pk->prv_next; *pp; pp = &(*pp)->prv_next)
  ------------------
  |  |  107|    949|#define prv_next		base.related_privkey
  ------------------
  |  Branch (889:30): [True: 949, False: 630]
  ------------------
  890|    949|					;
  891|    630|				*pp = (struct pkcs15_prkey_object *) obj;
  892|    630|			}
  893|  15.6k|		}
  894|  62.4k|		else if (is_pubkey(obj) && !pk->prv_pubkey) {
  ------------------
  |  |  121|   124k|#define is_pubkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY)
  |  |  ------------------
  |  |  |  |  119|  62.4k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 62.4k, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 61.8k, False: 657]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_pubkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY)
  |  |  ------------------
  |  |  |  |  416|  62.4k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  |  |  ------------------
  |  |               #define is_pubkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY)
  |  |  ------------------
  |  |  |  |  425|  62.4k|#define SC_PKCS15_TYPE_PUBKEY			0x200
  |  |  ------------------
  |  |  |  Branch (121:25): [True: 12.1k, False: 50.3k]
  |  |  ------------------
  ------------------
              		else if (is_pubkey(obj) && !pk->prv_pubkey) {
  ------------------
  |  |  106|  12.1k|#define prv_pubkey		base.related_pubkey
  ------------------
  |  Branch (894:30): [True: 6.66k, False: 5.49k]
  ------------------
  895|  6.66k|			struct pkcs15_pubkey_object *pubkey;
  896|       |
  897|  6.66k|			pubkey = (struct pkcs15_pubkey_object *) obj;
  898|  6.66k|			if (sc_pkcs15_compare_id(&pubkey->pub_info->id, id)) {
  ------------------
  |  Branch (898:8): [True: 1.17k, False: 5.49k]
  ------------------
  899|  1.17k|				sc_log(context, "Associating object %d as public key", i);
  ------------------
  |  |   71|  1.17k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  900|  1.17k|				pk->prv_pubkey = pubkey;
  ------------------
  |  |  106|  1.17k|#define prv_pubkey		base.related_pubkey
  ------------------
  901|  1.17k|				if (pubkey->pub_data) {
  ------------------
  |  Branch (901:9): [True: 1.10k, False: 70]
  ------------------
  902|  1.10k|					sc_pkcs15_dup_pubkey(context, pubkey->pub_data, &pk->pub_data);
  903|  1.10k|					if (pk->prv_info->modulus_length == 0)
  ------------------
  |  Branch (903:10): [True: 1.01k, False: 88]
  ------------------
  904|  1.01k|						pk->prv_info->modulus_length = pubkey->pub_info->modulus_length;
  905|  1.10k|				}
  906|  1.17k|			}
  907|  6.66k|		}
  908|  78.1k|	}
  909|  3.04k|}
framework-pkcs15.c:__pkcs15_cert_bind_related:
  914|  1.34k|{
  915|  1.34k|	struct sc_pkcs15_cert *c1 = cert->cert_data;
  916|  1.34k|	struct sc_pkcs15_id *id = &cert->cert_info->id;
  917|  1.34k|	unsigned int i;
  918|       |
  919|  1.34k|	sc_log(context, "Object is a certificate and has id %s", sc_pkcs15_print_id(id));
  ------------------
  |  |   71|  1.34k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  920|       |
  921|       |	/* Loop over all objects to see if we find the certificate of
  922|       |	 * the issuer and the associated private key */
  923|  69.0k|	for (i = 0; i < fw_data->num_objects; i++) {
  ------------------
  |  Branch (923:14): [True: 67.8k, False: 1.21k]
  ------------------
  924|  67.8k|		struct pkcs15_any_object *obj = fw_data->objects[i];
  925|       |
  926|  67.8k|		if (is_cert(obj) && obj != (struct pkcs15_any_object *) cert) {
  ------------------
  |  |  122|   135k|#define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  119|  67.8k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 67.8k, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 66.7k, False: 1.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  439|  67.8k|#define SC_PKCS15_TYPE_CERT_X509		0x401
  |  |  ------------------
  |  |  |  Branch (122:23): [True: 12.1k, False: 55.6k]
  |  |  ------------------
  ------------------
  |  Branch (926:23): [True: 10.9k, False: 1.26k]
  ------------------
  927|  10.9k|			struct pkcs15_cert_object *cert2;
  928|  10.9k|			struct sc_pkcs15_cert *c2;
  929|       |
  930|  10.9k|			cert2 = (struct pkcs15_cert_object *) obj;
  931|  10.9k|			c2 = cert2->cert_data;
  932|       |
  933|  10.9k|			if (!c1 || !c2 || !c1->issuer_len || !c2->subject_len)
  ------------------
  |  Branch (933:8): [True: 728, False: 10.1k]
  |  Branch (933:15): [True: 0, False: 10.1k]
  |  Branch (933:22): [True: 46, False: 10.1k]
  |  Branch (933:41): [True: 0, False: 10.1k]
  ------------------
  934|    774|				continue;
  935|  10.1k|			if (c1->issuer_len == c2->subject_len
  ------------------
  |  Branch (935:8): [True: 9.81k, False: 313]
  ------------------
  936|  9.81k|			 && !memcmp(c1->issuer, c2->subject, c1->issuer_len)) {
  ------------------
  |  Branch (936:8): [True: 132, False: 9.68k]
  ------------------
  937|    132|				sc_log(context, "Associating object %d (id %s) as issuer",
  ------------------
  |  |   71|    132|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  938|    132|						i, sc_pkcs15_print_id(&cert2->cert_info->id));
  939|    132|				cert->cert_issuer = (struct pkcs15_cert_object *) obj;
  ------------------
  |  |   95|    132|#define cert_issuer		base.related_cert
  ------------------
  940|    132|				return;
  941|    132|			}
  942|  10.1k|		} else
  943|  56.9k|		if (is_privkey(obj) && !cert->cert_prvkey) {
  ------------------
  |  |  120|   113k|#define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  119|  56.9k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 56.9k, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 55.8k, False: 1.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  416|  56.9k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  |  |  ------------------
  |  |               #define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  418|  56.9k|#define SC_PKCS15_TYPE_PRKEY			0x100
  |  |  ------------------
  |  |  |  Branch (120:26): [True: 12.8k, False: 44.0k]
  |  |  ------------------
  ------------------
              		if (is_privkey(obj) && !cert->cert_prvkey) {
  ------------------
  |  |   96|  12.8k|#define cert_prvkey		base.related_privkey
  ------------------
  |  Branch (943:26): [True: 7.24k, False: 5.60k]
  ------------------
  944|  7.24k|			struct pkcs15_prkey_object *pk;
  945|       |
  946|  7.24k|			pk = (struct pkcs15_prkey_object *) obj;
  947|  7.24k|			if (sc_pkcs15_compare_id(&pk->prv_info->id, id)) {
  ------------------
  |  Branch (947:8): [True: 1.18k, False: 6.06k]
  ------------------
  948|  1.18k|				sc_log(context, "Associating object %d as private key", i);
  ------------------
  |  |   71|  1.18k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  949|  1.18k|				cert->cert_prvkey = pk;
  ------------------
  |  |   96|  1.18k|#define cert_prvkey		base.related_privkey
  ------------------
  950|  1.18k|			}
  951|  7.24k|		}
  952|  67.8k|	}
  953|  1.34k|}
framework-pkcs15.c:_add_pin_related_objects:
 1487|  4.13k|{
 1488|  4.13k|	struct sc_pkcs15_auth_info *pin_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
 1489|  4.13k|	int public_certificates = 1;
 1490|  4.13k|	unsigned i;
 1491|       |
 1492|  4.13k|	sc_log(context, "Add objects related to PIN('%.*s',ID:%s)", (int) sizeof pin_obj->label, pin_obj->label, sc_pkcs15_print_id(&pin_info->auth_id));
  ------------------
  |  |   71|  4.13k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1493|  31.9k|	for (i=0; i < fw_data->num_objects; i++) {
  ------------------
  |  Branch (1493:12): [True: 27.8k, False: 4.13k]
  ------------------
 1494|  27.8k|		struct pkcs15_any_object *obj = fw_data->objects[i];
 1495|       |
 1496|       |		/* "Fake" objects we've generated */
 1497|  27.8k|		if (__p15_type(obj) == (unsigned int)-1)
  ------------------
  |  |  119|  27.8k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  ------------------
  |  |  |  Branch (119:28): [True: 27.8k, False: 0]
  |  |  |  Branch (119:37): [True: 27.5k, False: 246]
  |  |  ------------------
  ------------------
  |  Branch (1497:7): [True: 246, False: 27.5k]
  ------------------
 1498|    246|			continue;
 1499|       |		/* Some objects have an auth_id even though they are
 1500|       |		 * not private. Just ignore those... */
 1501|  27.5k|		if (!(obj->p15_object->flags & SC_PKCS15_CO_FLAG_PRIVATE))
  ------------------
  |  |   50|  27.5k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (1501:7): [True: 18.5k, False: 9.06k]
  ------------------
 1502|  18.5k|			continue;
 1503|  9.06k|		sc_log(context, "ObjID(%p,%.*s,%x):%s", obj, (int) sizeof obj->p15_object->label, obj->p15_object->label,
  ------------------
  |  |   71|  9.06k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1504|  9.06k|				obj->p15_object->type, sc_pkcs15_print_id(&obj->p15_object->auth_id));
 1505|  9.06k|		if (!sc_pkcs15_compare_id(&pin_info->auth_id, &obj->p15_object->auth_id))   {
  ------------------
  |  Branch (1505:7): [True: 2.55k, False: 6.50k]
  ------------------
 1506|  2.55k|			sc_log(context, "Ignoring object %d", i);
  ------------------
  |  |   71|  2.55k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1507|  2.55k|			continue;
 1508|  2.55k|		}
 1509|       |
 1510|  6.50k|		if (is_privkey(obj)) {
  ------------------
  |  |  120|  6.50k|#define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  119|  6.50k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 6.50k, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 6.50k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  416|  6.50k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  |  |  ------------------
  |  |               #define is_privkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY)
  |  |  ------------------
  |  |  |  |  418|  6.50k|#define SC_PKCS15_TYPE_PRKEY			0x100
  |  |  ------------------
  |  |  |  Branch (120:26): [True: 2.65k, False: 3.84k]
  |  |  ------------------
  ------------------
 1511|  2.65k|			sc_log(context, "Slot:%p, obj:%p  Adding private key %d to PIN '%.*s'", slot, obj, i, (int) sizeof pin_obj->label, pin_obj->label);
  ------------------
  |  |   71|  2.65k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1512|  2.65k|			pkcs15_add_object(slot, obj, NULL);
 1513|  2.65k|		}
 1514|  3.84k|		else if (is_data(obj)) {
  ------------------
  |  |  132|  3.84k|#define is_data(obj) (__p15_type(obj) == SC_PKCS15_TYPE_DATA_OBJECT)
  |  |  ------------------
  |  |  |  |  119|  3.84k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 3.84k, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 3.84k, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_data(obj) (__p15_type(obj) == SC_PKCS15_TYPE_DATA_OBJECT)
  |  |  ------------------
  |  |  |  |  442|  3.84k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  |  |  ------------------
  |  |  |  Branch (132:22): [True: 3.63k, False: 215]
  |  |  ------------------
  ------------------
 1515|  3.63k|			sc_log(context, "Slot:%p Adding data object %d to PIN '%.*s'", slot, i, (int) sizeof pin_obj->label, pin_obj->label);
  ------------------
  |  |   71|  3.63k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1516|  3.63k|			pkcs15_add_object(slot, obj, NULL);
 1517|  3.63k|		}
 1518|    215|		else if (is_cert(obj)) {
  ------------------
  |  |  122|    215|#define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  119|    215|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 215, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 215, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  439|    215|#define SC_PKCS15_TYPE_CERT_X509		0x401
  |  |  ------------------
  |  |  |  Branch (122:23): [True: 215, False: 0]
  |  |  ------------------
  ------------------
 1519|    215|			sc_log(context, "Slot:%p Adding cert object %d to PIN '%.*s'", slot, i, (int) sizeof pin_obj->label, pin_obj->label);
  ------------------
  |  |   71|    215|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1520|    215|			pkcs15_add_object(slot, obj, NULL);
 1521|    215|			public_certificates = 0;
 1522|    215|		}
 1523|      0|		else if (is_skey(obj)) {
  ------------------
  |  |  147|      0|#define is_skey(obj) ((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_SKEY)
  |  |  ------------------
  |  |  |  |  119|      0|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 0, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_skey(obj) ((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_SKEY)
  |  |  ------------------
  |  |  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  |  |  ------------------
  |  |               #define is_skey(obj) ((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_SKEY)
  |  |  ------------------
  |  |  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  |  |  ------------------
  |  |  |  Branch (147:22): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1524|      0|			sc_log(context, "Slot:%p Adding secret key object %d to PIN '%.*s'", slot, i, (int) sizeof pin_obj->label, pin_obj->label);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1525|      0|			pkcs15_add_object(slot, obj, NULL);
 1526|      0|		}
 1527|      0|		else   {
 1528|      0|			sc_log(context, "Slot:%p Object %d skipped", slot, i);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1529|      0|			continue;
 1530|      0|		}
 1531|       |
 1532|  6.50k|		if (move_to_fw && move_to_fw != fw_data && move_to_fw->num_objects < MAX_OBJECTS)   {
  ------------------
  |  |   66|      0|#define MAX_OBJECTS	128
  ------------------
  |  Branch (1532:7): [True: 0, False: 6.50k]
  |  Branch (1532:21): [True: 0, False: 0]
  |  Branch (1532:46): [True: 0, False: 0]
  ------------------
 1533|      0|			int tail = fw_data->num_objects - i - 1;
 1534|       |
 1535|      0|			move_to_fw->objects[move_to_fw->num_objects++] = obj;
 1536|      0|			if (tail)
  ------------------
  |  Branch (1536:8): [True: 0, False: 0]
  ------------------
 1537|      0|				memcpy(&fw_data->objects[i], &fw_data->objects[i + 1], sizeof(fw_data->objects[0]) * tail);
 1538|      0|			i--;
 1539|      0|			fw_data->num_objects--;
 1540|      0|		}
 1541|  6.50k|	}
 1542|  4.13k|	_add_profile_object(slot, fw_data, public_certificates);
 1543|  4.13k|}
framework-pkcs15.c:pkcs15_add_object:
 1015|  35.6k|{
 1016|  35.6k|	unsigned int i;
 1017|  35.6k|	struct pkcs15_fw_data *card_fw_data;
 1018|  35.6k|	CK_OBJECT_HANDLE handle =
 1019|  35.6k|		(CK_OBJECT_HANDLE)(uintptr_t)obj; /* cast pointer to long, will truncate on Win64 */
 1020|       |
 1021|  35.6k|	if (obj == NULL || slot == NULL)
  ------------------
  |  Branch (1021:6): [True: 2.91k, False: 32.7k]
  |  Branch (1021:21): [True: 0, False: 32.7k]
  ------------------
 1022|  2.91k|		return;
 1023|  32.7k|	if (obj->base.flags & (SC_PKCS11_OBJECT_HIDDEN | SC_PKCS11_OBJECT_RECURS))
  ------------------
  |  |  138|  32.7k|#define SC_PKCS11_OBJECT_HIDDEN	0x0002
  ------------------
              	if (obj->base.flags & (SC_PKCS11_OBJECT_HIDDEN | SC_PKCS11_OBJECT_RECURS))
  ------------------
  |  |  139|  32.7k|#define SC_PKCS11_OBJECT_RECURS	0x8000
  ------------------
  |  Branch (1023:6): [True: 592, False: 32.1k]
  ------------------
 1024|    592|		return;
 1025|       |
 1026|  32.1k|	if (list_contains(&slot->objects, obj))
  ------------------
  |  Branch (1026:6): [True: 1.31k, False: 30.8k]
  ------------------
 1027|  1.31k|		return;
 1028|       |
 1029|  30.8k|	if (pHandle != NULL)
  ------------------
  |  Branch (1029:6): [True: 0, False: 30.8k]
  ------------------
 1030|      0|		*pHandle = handle;
 1031|       |
 1032|  30.8k|	list_append(&slot->objects, obj);
 1033|  30.8k|	sc_log(context, "Slot:%lX Setting object handle of 0x%lx to 0x%lx",
  ------------------
  |  |   71|  30.8k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1034|  30.8k|		   slot->id, obj->base.handle, handle);
 1035|  30.8k|	obj->base.handle = handle;
 1036|  30.8k|	obj->base.flags |= SC_PKCS11_OBJECT_SEEN;
  ------------------
  |  |  137|  30.8k|#define SC_PKCS11_OBJECT_SEEN	0x0001
  ------------------
 1037|  30.8k|	obj->refcount++;
 1038|       |
 1039|       |	/* Add related objects
 1040|       |	 * XXX prevent infinite recursion when a card specifies two certificates
 1041|       |	 * referring to each other.
 1042|       |	 */
 1043|  30.8k|	obj->base.flags |= SC_PKCS11_OBJECT_RECURS;
  ------------------
  |  |  139|  30.8k|#define SC_PKCS11_OBJECT_RECURS	0x8000
  ------------------
 1044|       |
 1045|  30.8k|	switch (__p15_type(obj)) {
  ------------------
  |  |  119|  30.8k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  ------------------
  |  |  |  Branch (119:26): [True: 4.18k, False: 26.6k]
  |  |  |  Branch (119:28): [True: 30.8k, False: 0]
  |  |  |  Branch (119:37): [True: 30.6k, False: 246]
  |  |  ------------------
  ------------------
 1046|  1.81k|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|  1.81k|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (1046:2): [True: 1.81k, False: 29.0k]
  ------------------
 1047|  1.81k|	case SC_PKCS15_TYPE_PRKEY_GOSTR3410:
  ------------------
  |  |  420|  1.81k|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  |  Branch (1047:2): [True: 0, False: 30.8k]
  ------------------
 1048|  2.83k|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|  2.83k|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (1048:2): [True: 1.01k, False: 29.8k]
  ------------------
 1049|  2.83k|	case SC_PKCS15_TYPE_PRKEY_EDDSA:
  ------------------
  |  |  422|  2.83k|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
  |  Branch (1049:2): [True: 0, False: 30.8k]
  ------------------
 1050|  2.83k|	case SC_PKCS15_TYPE_PRKEY_XEDDSA:
  ------------------
  |  |  423|  2.83k|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
  |  Branch (1050:2): [True: 0, False: 30.8k]
  ------------------
 1051|  2.83k|		if (slot->p11card != NULL) {
  ------------------
  |  Branch (1051:7): [True: 2.83k, False: 0]
  ------------------
 1052|  2.83k|			pkcs15_add_object(slot, (struct pkcs15_any_object *) obj->related_pubkey, NULL);
 1053|  2.83k|			if (!slot->p11card)
  ------------------
  |  Branch (1053:8): [True: 0, False: 2.83k]
  ------------------
 1054|      0|				return;
 1055|  2.83k|			card_fw_data = (struct pkcs15_fw_data *) slot->p11card->fws_data[slot->fw_data_idx];
 1056|  81.6k|			for (i = 0; i < card_fw_data->num_objects; i++) {
  ------------------
  |  Branch (1056:16): [True: 78.8k, False: 2.83k]
  ------------------
 1057|  78.8k|				struct pkcs15_any_object *obj2 = card_fw_data->objects[i];
 1058|  78.8k|				struct pkcs15_cert_object *cert;
 1059|       |
 1060|  78.8k|				if (!is_cert(obj2))
  ------------------
  |  |  122|  78.8k|#define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  119|  78.8k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 78.8k, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 78.1k, False: 657]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  439|  78.8k|#define SC_PKCS15_TYPE_CERT_X509		0x401
  |  |  ------------------
  ------------------
  |  Branch (1060:9): [True: 66.1k, False: 12.6k]
  ------------------
 1061|  66.1k|					continue;
 1062|       |
 1063|  12.6k|				cert = (struct pkcs15_cert_object*) obj2;
 1064|       |
 1065|  12.6k|				if ((struct pkcs15_any_object*)(cert->cert_prvkey) != obj)
  ------------------
  |  |   96|  12.6k|#define cert_prvkey		base.related_privkey
  ------------------
  |  Branch (1065:9): [True: 11.4k, False: 1.18k]
  ------------------
 1066|  11.4k|					continue;
 1067|       |
 1068|  1.18k|				pkcs15_add_object(slot, obj2, NULL);
 1069|  1.18k|			}
 1070|  2.83k|		}
 1071|  2.83k|		break;
 1072|  2.83k|	case SC_PKCS15_TYPE_CERT_X509:
  ------------------
  |  |  439|  1.34k|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  |  Branch (1072:2): [True: 1.34k, False: 29.5k]
  ------------------
 1073|  1.34k|		pkcs15_add_object(slot, (struct pkcs15_any_object *) obj->related_pubkey, NULL);
 1074|  1.34k|		pkcs15_add_object(slot, (struct pkcs15_any_object *) obj->related_cert, NULL);
 1075|  1.34k|		break;
 1076|  30.8k|	}
 1077|       |
 1078|  30.8k|	obj->base.flags &= ~SC_PKCS11_OBJECT_RECURS;
  ------------------
  |  |  139|  30.8k|#define SC_PKCS11_OBJECT_RECURS	0x8000
  ------------------
 1079|  30.8k|}
framework-pkcs15.c:_add_profile_object:
 1462|  10.0k|{
 1463|       |	/* Public Certificates Token in PKCS #11 3.0 */
 1464|  10.0k|	struct pkcs15_any_object *any_pobj = NULL;
 1465|  10.0k|	int rv;
 1466|       |
 1467|  10.0k|	if (slot->profile) {
  ------------------
  |  Branch (1467:6): [True: 4.06k, False: 5.97k]
  ------------------
 1468|  4.06k|		struct pkcs15_profile_object *pobj = (struct pkcs15_profile_object *)slot->profile;
 1469|       |		/* already exists -- downgrade if we found some non-public certificates */
 1470|  4.06k|		if (pobj->profile_id == CKP_PUBLIC_CERTIFICATES_TOKEN && !public_certificates) {
  ------------------
  |  | 1046|  8.12k|#define CKP_PUBLIC_CERTIFICATES_TOKEN 0x00000004UL
  ------------------
  |  Branch (1470:7): [True: 3.97k, False: 92]
  |  Branch (1470:60): [True: 0, False: 3.97k]
  ------------------
 1471|      0|			pobj->profile_id = CKP_AUTHENTICATION_TOKEN;
  ------------------
  |  | 1045|      0|#define CKP_AUTHENTICATION_TOKEN 0x00000003UL
  ------------------
 1472|      0|		}
 1473|  4.06k|		return;
 1474|  4.06k|	}
 1475|       |
 1476|  5.97k|	rv = __pkcs15_create_profile_object(fw_data, public_certificates, &any_pobj);
 1477|  5.97k|	if (rv != CKR_OK || any_pobj == NULL) {
  ------------------
  |  | 1086|  11.9k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1477:6): [True: 0, False: 5.97k]
  |  Branch (1477:22): [True: 0, False: 5.97k]
  ------------------
 1478|      0|		return;
 1479|      0|	}
 1480|  5.97k|	pkcs15_add_object(slot, any_pobj, NULL);
 1481|  5.97k|	slot->profile = any_pobj;
 1482|  5.97k|}
framework-pkcs15.c:__pkcs15_create_profile_object:
  802|  5.97k|{
  803|  5.97k|	struct pkcs15_profile_object *pobj = NULL;
  804|  5.97k|	struct pkcs15_any_object *any_pobj = NULL;
  805|  5.97k|	struct sc_pkcs15_object *obj = NULL;
  806|  5.97k|	int rv;
  807|       |
  808|  5.97k|	obj = calloc(1, sizeof(struct sc_pkcs15_object));
  809|       |
  810|  5.97k|	rv = __pkcs15_create_object(fw_data, &any_pobj,
  811|  5.97k|			obj, &pkcs15_profile_ops, sizeof(struct pkcs15_profile_object));
  812|       |
  813|  5.97k|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|  5.97k|#define SC_SUCCESS				0
  ------------------
  |  Branch (813:6): [True: 0, False: 5.97k]
  ------------------
  814|      0|		free(obj);
  815|      0|		return rv;
  816|      0|	}
  817|  5.97k|	pobj = (struct pkcs15_profile_object *) any_pobj;
  818|  5.97k|	pobj->profile_id = public_certificates ? CKP_PUBLIC_CERTIFICATES_TOKEN : CKP_AUTHENTICATION_TOKEN;
  ------------------
  |  | 1046|  5.88k|#define CKP_PUBLIC_CERTIFICATES_TOKEN 0x00000004UL
  ------------------
              	pobj->profile_id = public_certificates ? CKP_PUBLIC_CERTIFICATES_TOKEN : CKP_AUTHENTICATION_TOKEN;
  ------------------
  |  | 1045|  6.06k|#define CKP_AUTHENTICATION_TOKEN 0x00000003UL
  ------------------
  |  Branch (818:21): [True: 5.88k, False: 92]
  ------------------
  819|       |
  820|  5.97k|	if (profile_object != NULL)
  ------------------
  |  Branch (820:6): [True: 5.97k, False: 0]
  ------------------
  821|  5.97k|		*profile_object = (struct pkcs15_any_object *) pobj;
  822|       |
  823|  5.97k|	return rv;
  824|  5.97k|}
framework-pkcs15.c:_add_public_objects:
 1548|  5.90k|{
 1549|  5.90k|	int public_certificates = 1;
 1550|  5.90k|	unsigned i;
 1551|       |
 1552|  5.90k|	if (slot == NULL || fw_data == NULL)
  ------------------
  |  Branch (1552:6): [True: 0, False: 5.90k]
  |  Branch (1552:22): [True: 0, False: 5.90k]
  ------------------
 1553|      0|		return;
 1554|       |
 1555|  5.90k|	sc_log(context, "%i public objects to process", fw_data->num_objects);
  ------------------
  |  |   71|  5.90k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1556|  38.0k|	for (i=0; i < fw_data->num_objects; i++) {
  ------------------
  |  Branch (1556:12): [True: 32.1k, False: 5.90k]
  ------------------
 1557|  32.1k|		struct pkcs15_any_object *obj = fw_data->objects[i];
 1558|       |
 1559|       |		/* "Fake" objects we've generated */
 1560|  32.1k|		if (__p15_type(obj) == (unsigned int)-1)
  ------------------
  |  |  119|  32.1k|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  ------------------
  |  |  |  Branch (119:28): [True: 32.1k, False: 0]
  |  |  |  Branch (119:37): [True: 31.8k, False: 246]
  |  |  ------------------
  ------------------
  |  Branch (1560:7): [True: 246, False: 31.8k]
  ------------------
 1561|    246|			continue;
 1562|       |		/* Ignore seen object */
 1563|  31.8k|		if (obj->base.flags & SC_PKCS11_OBJECT_SEEN)
  ------------------
  |  |  137|  31.8k|#define SC_PKCS11_OBJECT_SEEN	0x0001
  ------------------
  |  Branch (1563:7): [True: 12.3k, False: 19.5k]
  ------------------
 1564|  12.3k|			continue;
 1565|       |		/* Ignore 'private' object */
 1566|  19.5k|		if (obj->p15_object->flags & SC_PKCS15_CO_FLAG_PRIVATE) {
  ------------------
  |  |   50|  19.5k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (1566:7): [True: 3.01k, False: 16.5k]
  ------------------
 1567|       |			/* If we found some non-accessible public object,
 1568|       |			 * we can no longer claim Public Certificate Token conformance */
 1569|  3.01k|			if ((obj->p15_object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY ||
  ------------------
  |  |  416|  3.01k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              			if ((obj->p15_object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY ||
  ------------------
  |  |  425|  6.02k|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1569:8): [True: 0, False: 3.01k]
  ------------------
 1570|  3.01k|				(obj->p15_object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_CERT) {
  ------------------
  |  |  416|  3.01k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              				(obj->p15_object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_CERT) {
  ------------------
  |  |  438|  3.01k|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1570:5): [True: 0, False: 3.01k]
  ------------------
 1571|      0|				public_certificates = 0;
 1572|      0|			}
 1573|  3.01k|			continue;
 1574|  3.01k|		}
 1575|       |		/* PKCS#15 4.1.3 is a little vague, but implies if not PRIVATE it is readable
 1576|       |		 * even if there is an auth_id to allow writing for example.
 1577|       |		 * See bug issue #291
 1578|       |		 * treat pubkey and cert as readable.
 1579|       |		 */
 1580|  16.5k|		if (obj->p15_object->auth_id.len && !(is_pubkey(obj) || is_cert(obj)))
  ------------------
  |  |  121|      0|#define is_pubkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY)
  |  |  ------------------
  |  |  |  |  119|      0|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 0, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_pubkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY)
  |  |  ------------------
  |  |  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  |  |  ------------------
  |  |               #define is_pubkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY)
  |  |  ------------------
  |  |  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  |  |  ------------------
  |  |  |  Branch (121:25): [True: 0, False: 0]
  |  |  ------------------
  ------------------
              		if (obj->p15_object->auth_id.len && !(is_pubkey(obj) || is_cert(obj)))
  ------------------
  |  |  122|      0|#define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  119|      0|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 0, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  439|      0|#define SC_PKCS15_TYPE_CERT_X509		0x401
  |  |  ------------------
  |  |  |  Branch (122:23): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1580:7): [True: 0, False: 16.5k]
  ------------------
 1581|      0|			continue;
 1582|       |
 1583|  16.5k|		sc_log(context, "Add public object(%p,%.*s,%x)", obj,
  ------------------
  |  |   71|  16.5k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1584|  16.5k|			(int) sizeof obj->p15_object->label, obj->p15_object->label,
 1585|  16.5k|			obj->p15_object->type);
 1586|       |		pkcs15_add_object(slot, obj, NULL);
 1587|  16.5k|	}
 1588|  5.90k|	_add_profile_object(slot, fw_data, public_certificates);
 1589|  5.90k|}
framework-pkcs15.c:pkcs15_release_token:
 1745|  5.97k|{
 1746|  5.97k|	sc_log(context, "pkcs15_release_token() not implemented");
  ------------------
  |  |   71|  5.97k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1747|  5.97k|	free(fw_token);
 1748|  5.97k|	return CKR_FUNCTION_REJECTED;
  ------------------
  |  | 1180|  5.97k|#define CKR_FUNCTION_REJECTED 0x00000200UL
  ------------------
 1749|  5.97k|}
framework-pkcs15.c:pkcs15_login:
 1755|  1.77k|{
 1756|  1.77k|	struct sc_pkcs11_card *p11card;
 1757|  1.77k|	struct pkcs15_fw_data *fw_data = NULL;
 1758|  1.77k|	struct sc_pkcs15_card *p15card = NULL;
 1759|  1.77k|	struct sc_pkcs15_object *auth_object = NULL;
 1760|  1.77k|	struct sc_pkcs15_auth_info *pin_info = NULL;
 1761|  1.77k|	int rc;
 1762|       |
 1763|  1.77k|	if (slot->p11card == NULL)
  ------------------
  |  Branch (1763:6): [True: 0, False: 1.77k]
  ------------------
 1764|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_Login");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1765|  1.77k|	p11card = slot->p11card;
 1766|       |
 1767|  1.77k|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
 1768|  1.77k|	if (!fw_data)
  ------------------
  |  Branch (1768:6): [True: 0, False: 1.77k]
  ------------------
 1769|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_Login");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1770|  1.77k|	p15card = fw_data->p15_card;
 1771|  1.77k|	if (!p15card)
  ------------------
  |  Branch (1771:6): [True: 80, False: 1.69k]
  ------------------
 1772|     80|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_Login");
  ------------------
  |  |   60|     80|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1773|       |
 1774|  1.69k|	sc_log(context, "pkcs15-login: userType 0x%lX, PIN length %li", userType, ulPinLen);
  ------------------
  |  |   71|  1.69k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1775|  1.69k|	switch (userType) {
 1776|    316|	case CKU_USER:
  ------------------
  |  | 1211|    316|#define CKU_USER 1UL
  ------------------
  |  Branch (1776:2): [True: 316, False: 1.37k]
  ------------------
 1777|    316|		auth_object = slot_data_auth(slot->fw_data);
  ------------------
  |  |   51|    316|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|    316|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (50:23): [True: 316, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|    316|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  ------------------
  |  |  |  Branch (51:29): [True: 316, False: 0]
  |  |  ------------------
  ------------------
 1778|    316|		if (auth_object == NULL)
  ------------------
  |  Branch (1778:7): [True: 0, False: 316]
  ------------------
 1779|      0|			return CKR_USER_PIN_NOT_INITIALIZED;
  ------------------
  |  | 1152|      0|#define CKR_USER_PIN_NOT_INITIALIZED 0x00000102UL
  ------------------
 1780|    316|		break;
 1781|    947|	case CKU_SO:
  ------------------
  |  | 1210|    947|#define CKU_SO 0UL
  ------------------
  |  Branch (1781:2): [True: 947, False: 748]
  ------------------
 1782|       |		/* A card with no SO PIN is treated as if no SO login
 1783|       |		 * is required */
 1784|    947|		rc = sc_pkcs15_find_so_pin(p15card, &auth_object);
 1785|    947|		sc_log(context, "pkcs15-login: find SO PIN: rc %i", rc);
  ------------------
  |  |   71|    947|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1786|       |
 1787|       |		/* If there's no SO PIN on the card, silently
 1788|       |		 * accept any PIN, and lock the card if required */
 1789|    947|		if (rc == SC_ERROR_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   88|    947|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1789:7): [True: 836, False: 111]
  ------------------
 1790|    836|			rc = 0;
 1791|    836|			if (sc_pkcs11_conf.lock_login)
  ------------------
  |  Branch (1791:8): [True: 0, False: 836]
  ------------------
 1792|      0|				rc = lock_card(fw_data);
 1793|       |
 1794|    836|			if (sc_pkcs11_conf.pin_unblock_style == SC_PKCS11_PIN_UNBLOCK_SO_LOGGED_INITPIN)   {
  ------------------
  |  |   42|    836|#define SC_PKCS11_PIN_UNBLOCK_SO_LOGGED_INITPIN	3
  ------------------
  |  Branch (1794:8): [True: 0, False: 836]
  ------------------
 1795|      0|				if (ulPinLen)   {
  ------------------
  |  Branch (1795:9): [True: 0, False: 0]
  ------------------
 1796|      0|					unsigned char *user_puk = sc_mem_secure_alloc(ulPinLen);
 1797|      0|					if (user_puk) {
  ------------------
  |  Branch (1797:10): [True: 0, False: 0]
  ------------------
 1798|      0|						memcpy(user_puk, pPin, ulPinLen);
 1799|       |
 1800|      0|						sc_mem_secure_clear_free(fw_data->user_puk, fw_data->user_puk_len);
  ------------------
  |  | 1580|      0|#define sc_mem_secure_clear_free(ptr, len) do { \
  |  | 1581|      0|	sc_mem_clear(ptr, len); \
  |  | 1582|      0|	sc_mem_secure_free(ptr, len); \
  |  | 1583|      0|} while (0);
  |  |  ------------------
  |  |  |  Branch (1583:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1801|       |
 1802|      0|						fw_data->user_puk = user_puk;
 1803|      0|						fw_data->user_puk_len = (unsigned int) ulPinLen;
 1804|      0|					}
 1805|      0|				}
 1806|      0|			}
 1807|       |
 1808|    836|			sc_log(context, "No SOPIN found; returns %d", rc);
  ------------------
  |  |   71|    836|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1809|    836|			return sc_to_cryptoki_error(rc, "C_Login");
 1810|    836|		}
 1811|    111|		else if (rc < 0)   {
  ------------------
  |  Branch (1811:12): [True: 0, False: 111]
  ------------------
 1812|      0|			return sc_to_cryptoki_error(rc, "C_Login");
 1813|      0|		}
 1814|       |
 1815|    111|		break;
 1816|    432|	case CKU_CONTEXT_SPECIFIC:
  ------------------
  |  | 1212|    432|#define CKU_CONTEXT_SPECIFIC 2UL
  ------------------
  |  Branch (1816:2): [True: 432, False: 1.26k]
  ------------------
 1817|       |		/*
 1818|       |		 * A session should already be open for user or SO
 1819|       |		 * All we need to do is authenticate to the card
 1820|       |		 * using the correct auth_object.
 1821|       |		 * TODO: handle the CK_SO case
 1822|       |		 */
 1823|    432|		sc_log(context, "context specific login %d", slot->login_user);
  ------------------
  |  |   71|    432|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1824|    432|		if (slot->login_user == CKU_USER) {
  ------------------
  |  | 1211|    432|#define CKU_USER 1UL
  ------------------
  |  Branch (1824:7): [True: 29, False: 403]
  ------------------
 1825|     29|			auth_object = slot_data_auth(slot->fw_data);
  ------------------
  |  |   51|     29|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|     29|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (50:23): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|     29|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  ------------------
  |  |  |  Branch (51:29): [True: 29, False: 0]
  |  |  ------------------
  ------------------
 1826|     29|			if (auth_object == NULL)
  ------------------
  |  Branch (1826:8): [True: 0, False: 29]
  ------------------
 1827|      0|				return CKR_USER_PIN_NOT_INITIALIZED;
  ------------------
  |  | 1152|      0|#define CKR_USER_PIN_NOT_INITIALIZED 0x00000102UL
  ------------------
 1828|     29|			break;
 1829|     29|		}
 1830|       |		/* TODO looks like this was never executed,
 1831|       |		 * And even if it was, why the lock as a session
 1832|       |		 * should already be open and the card locked.
 1833|       |		 */
 1834|       |		/* For a while, used only to unblock User PIN. */
 1835|    403|		rc = 0;
 1836|    403|		if (sc_pkcs11_conf.lock_login)
  ------------------
  |  Branch (1836:7): [True: 0, False: 403]
  ------------------
 1837|      0|			rc = lock_card(fw_data);
 1838|    403|		sc_log(context, "context specific login returns %d", rc);
  ------------------
  |  |   71|    403|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1839|    403|		return sc_to_cryptoki_error(rc, "C_Login");
 1840|      0|	default:
  ------------------
  |  Branch (1840:2): [True: 0, False: 1.69k]
  ------------------
 1841|      0|		return CKR_USER_TYPE_INVALID;
  ------------------
  |  | 1153|      0|#define CKR_USER_TYPE_INVALID 0x00000103UL
  ------------------
 1842|  1.69k|	}
 1843|    456|	pin_info = (struct sc_pkcs15_auth_info *) auth_object->data;
 1844|    456|	if (pin_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    456|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1844:6): [True: 0, False: 456]
  ------------------
 1845|      0|		return CKR_FUNCTION_REJECTED;
  ------------------
  |  | 1180|      0|#define CKR_FUNCTION_REJECTED 0x00000200UL
  ------------------
 1846|       |
 1847|    456|	if (!p11card)
  ------------------
  |  Branch (1847:6): [True: 0, False: 456]
  ------------------
 1848|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_Login");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1849|       |
 1850|       |	/* By default, we make the reader resource manager keep other
 1851|       |	 * processes from accessing the card while we're logged in.
 1852|       |	 * Otherwise an attacker could perform some crypto operation
 1853|       |	 * after we've authenticated with the card */
 1854|       |
 1855|       |	/* Context specific login is not real login but only a
 1856|       |	 * reassertion of the PIN to the card.
 1857|       |	 * And we don't want to do any extra operations to the card
 1858|       |	 * that could invalidate the assertion of the pin
 1859|       |	 * before the crypto operation that requires the assertion
 1860|       |	 */
 1861|    456|	if (userType != CKU_CONTEXT_SPECIFIC) {
  ------------------
  |  | 1212|    456|#define CKU_CONTEXT_SPECIFIC 2UL
  ------------------
  |  Branch (1861:6): [True: 427, False: 29]
  ------------------
 1862|    427|		if (sc_pkcs11_conf.lock_login && (rc = lock_card(fw_data)) < 0)   {
  ------------------
  |  Branch (1862:7): [True: 0, False: 427]
  |  Branch (1862:36): [True: 0, False: 0]
  ------------------
 1863|      0|			return sc_to_cryptoki_error(rc, "C_Login");
 1864|      0|		}
 1865|    427|	}
 1866|       |
 1867|    456|	if (userType  == CKU_CONTEXT_SPECIFIC) {
  ------------------
  |  | 1212|    456|#define CKU_CONTEXT_SPECIFIC 2UL
  ------------------
  |  Branch (1867:6): [True: 29, False: 427]
  ------------------
 1868|     29|		int auth_meth_saved = pin_info->auth_method;
 1869|       |
 1870|     29|		sc_log(context, "Setting SC_AC_CONTEXT_SPECIFIC");
  ------------------
  |  |   71|     29|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1871|     29|		pin_info->auth_method = SC_AC_CONTEXT_SPECIFIC;
  ------------------
  |  |  160|     29|#define SC_AC_CONTEXT_SPECIFIC		0x00000200 /* Context specific login */
  ------------------
 1872|     29|		rc = sc_pkcs15_verify_pin(p15card, auth_object, pPin, ulPinLen);
 1873|     29|		pin_info->auth_method = auth_meth_saved;
 1874|     29|	} else
 1875|    427|		rc = sc_pkcs15_verify_pin(p15card, auth_object, pPin, ulPinLen);
 1876|       |
 1877|    456|	sc_log(context, "PKCS15 verify PIN returned %d", rc);
  ------------------
  |  |   71|    456|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1878|       |
 1879|    456|	if (rc != SC_SUCCESS)
  ------------------
  |  |   28|    456|#define SC_SUCCESS				0
  ------------------
  |  Branch (1879:6): [True: 369, False: 87]
  ------------------
 1880|    369|		return sc_to_cryptoki_error(rc, "C_Login");
 1881|       |
 1882|     87|	if (userType == CKU_USER)   {
  ------------------
  |  | 1211|     87|#define CKU_USER 1UL
  ------------------
  |  Branch (1882:6): [True: 51, False: 36]
  ------------------
 1883|     51|		sc_pkcs15_object_t *p15_obj = p15card->obj_list;
 1884|     51|		sc_pkcs15_search_key_t sk;
 1885|       |
 1886|     51|		sc_log(context, "Check if pkcs15 object list can be completed.");
  ------------------
  |  |   71|     51|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1887|       |
 1888|       |		/* Ensure non empty list */
 1889|     51|		if (p15_obj == NULL)
  ------------------
  |  Branch (1889:7): [True: 0, False: 51]
  ------------------
 1890|      0|			return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 1891|       |
 1892|       |		/* Select last object in list */
 1893|    552|		while(p15_obj->next)
  ------------------
  |  Branch (1893:9): [True: 501, False: 51]
  ------------------
 1894|    501|			p15_obj = p15_obj->next;
 1895|       |
 1896|       |		/* Trigger enumeration of EF.XXX files */
 1897|     51|		memset(&sk, 0, sizeof(sk));
 1898|     51|		sk.class_mask = SC_PKCS15_SEARCH_CLASS_PRKEY | SC_PKCS15_SEARCH_CLASS_PUBKEY |
  ------------------
  |  |  450|     51|#define SC_PKCS15_SEARCH_CLASS_PRKEY		0x0002U
  ------------------
              		sk.class_mask = SC_PKCS15_SEARCH_CLASS_PRKEY | SC_PKCS15_SEARCH_CLASS_PUBKEY |
  ------------------
  |  |  451|     51|#define SC_PKCS15_SEARCH_CLASS_PUBKEY		0x0004U
  ------------------
 1899|     51|				SC_PKCS15_SEARCH_CLASS_CERT  | SC_PKCS15_SEARCH_CLASS_DATA;
  ------------------
  |  |  453|     51|#define SC_PKCS15_SEARCH_CLASS_CERT		0x0010U
  ------------------
              				SC_PKCS15_SEARCH_CLASS_CERT  | SC_PKCS15_SEARCH_CLASS_DATA;
  ------------------
  |  |  454|     51|#define SC_PKCS15_SEARCH_CLASS_DATA		0x0020U
  ------------------
 1900|     51|		sc_pkcs15_search_objects(p15card, &sk, NULL, 0);
 1901|       |
 1902|       |		/* Iterate over newly discovered objects */
 1903|     51|		while(p15_obj->next) {
  ------------------
  |  Branch (1903:9): [True: 0, False: 51]
  ------------------
 1904|      0|			struct pkcs15_any_object *fw_obj;
 1905|       |
 1906|      0|			p15_obj = p15_obj->next;
 1907|       |
 1908|      0|			if (!sc_pkcs15_compare_id(&pin_info->auth_id, &p15_obj->auth_id))
  ------------------
  |  Branch (1908:8): [True: 0, False: 0]
  ------------------
 1909|      0|				continue;
 1910|       |
 1911|      0|			switch (p15_obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 1912|      0|			case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1912:4): [True: 0, False: 0]
  ------------------
 1913|      0|				__pkcs15_create_prkey_object(fw_data, p15_obj, &fw_obj); break;
 1914|      0|			case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1914:4): [True: 0, False: 0]
  ------------------
 1915|      0|				__pkcs15_create_pubkey_object(fw_data, p15_obj, &fw_obj); break;
 1916|      0|			case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1916:4): [True: 0, False: 0]
  ------------------
 1917|      0|				__pkcs15_create_cert_object(fw_data, p15_obj, &fw_obj); break;
 1918|      0|			case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (1918:4): [True: 0, False: 0]
  ------------------
 1919|      0|				__pkcs15_create_data_object(fw_data, p15_obj, &fw_obj); break;
 1920|      0|			default: continue;
  ------------------
  |  Branch (1920:4): [True: 0, False: 0]
  ------------------
 1921|      0|			}
 1922|       |
 1923|      0|			sc_log(context, "new object found: type=0x%03X", p15_obj->type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1924|      0|			pkcs15_add_object(slot, fw_obj, NULL);
 1925|      0|		}
 1926|     51|	}
 1927|       |
 1928|     87|	return CKR_OK;
  ------------------
  |  | 1086|     87|#define CKR_OK 0x00000000UL
  ------------------
 1929|     87|}
framework-pkcs15.c:pkcs15_logout:
 1945|    898|{
 1946|    898|	struct sc_pkcs11_card *p11card = slot->p11card;
 1947|    898|	struct pkcs15_fw_data *fw_data = NULL;
 1948|    898|	CK_RV ret = CKR_OK;
  ------------------
  |  | 1086|    898|#define CKR_OK 0x00000000UL
  ------------------
 1949|       |#if !(defined(SW_PIN_LOGOUT_ONLY) && SW_PIN_LOGOUT_ONLY == 1)
 1950|       |	int rc;
 1951|       |#endif
 1952|       |
 1953|    898|	if (!p11card)
  ------------------
  |  Branch (1953:6): [True: 0, False: 898]
  ------------------
 1954|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_Logout");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1955|    898|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
 1956|    898|	if (!fw_data)
  ------------------
  |  Branch (1956:6): [True: 0, False: 898]
  ------------------
 1957|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_Logout");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1958|    898|	if (!fw_data->p15_card)
  ------------------
  |  Branch (1958:6): [True: 0, False: 898]
  ------------------
 1959|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_Logout");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1960|       |
 1961|    898|	sc_mem_secure_clear_free(fw_data->user_puk, fw_data->user_puk_len);
  ------------------
  |  | 1580|    898|#define sc_mem_secure_clear_free(ptr, len) do { \
  |  | 1581|    898|	sc_mem_clear(ptr, len); \
  |  | 1582|    898|	sc_mem_secure_free(ptr, len); \
  |  | 1583|    898|} while (0);
  |  |  ------------------
  |  |  |  Branch (1583:10): [Folded, False: 898]
  |  |  ------------------
  ------------------
 1962|    898|	fw_data->user_puk = NULL;
 1963|    898|	fw_data->user_puk_len = 0;
 1964|       |
 1965|    898|	sc_pkcs15_pincache_clear(fw_data->p15_card);
 1966|       |
 1967|    898|#if defined(SW_PIN_LOGOUT_ONLY) && SW_PIN_LOGOUT_ONLY == 1
 1968|    898|	sc_log(context, "Clearing PIN state without calling sc_logout()");
  ------------------
  |  |   71|    898|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1969|       |#else
 1970|       |	rc = sc_logout(fw_data->p15_card->card);
 1971|       |
 1972|       |	/* Ignore missing card specific logout functions. #302 */
 1973|       |	if (rc == SC_ERROR_NOT_SUPPORTED)
 1974|       |		rc = SC_SUCCESS;
 1975|       |
 1976|       |	if (rc != SC_SUCCESS)
 1977|       |		ret = sc_to_cryptoki_error(rc, "C_Logout");
 1978|       |
 1979|       |	if (sc_pkcs11_conf.lock_login) {
 1980|       |		rc = unlock_card(fw_data);
 1981|       |		if (rc != SC_SUCCESS)
 1982|       |			ret = sc_to_cryptoki_error(rc, "C_Logout");
 1983|       |	}
 1984|       |#endif
 1985|       |
 1986|       |	/* TODO DEE free any session objects ? */
 1987|       |
 1988|    898|	return ret;
 1989|    898|}
framework-pkcs15.c:pkcs15_change_pin:
 1996|    764|{
 1997|    764|	struct sc_pkcs11_card *p11card = slot->p11card;
 1998|    764|	struct sc_pkcs15_card *p15card = NULL;
 1999|    764|	struct pkcs15_fw_data *fw_data = NULL;
 2000|    764|	struct sc_pkcs15_auth_info *auth_info = NULL;
 2001|    764|	struct sc_pkcs15_object *pin_obj = NULL;
 2002|    764|	int login_user = slot->login_user;
 2003|    764|	int rc;
 2004|       |
 2005|    764|	if (!p11card)
  ------------------
  |  Branch (2005:6): [True: 0, False: 764]
  ------------------
 2006|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_SetPin");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 2007|    764|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
 2008|    764|	if (!fw_data)
  ------------------
  |  Branch (2008:6): [True: 0, False: 764]
  ------------------
 2009|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_SetPin");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2010|    764|	p15card = fw_data->p15_card;
 2011|    764|	if (!p15card)
  ------------------
  |  Branch (2011:6): [True: 198, False: 566]
  ------------------
 2012|    198|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_SetPin");
  ------------------
  |  |   60|    198|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 2013|       |
 2014|    566|	if (login_user == CKU_SO) {
  ------------------
  |  | 1210|    566|#define CKU_SO 0UL
  ------------------
  |  Branch (2014:6): [True: 81, False: 485]
  ------------------
 2015|     81|		rc = sc_pkcs15_find_so_pin(p15card, &pin_obj);
 2016|     81|		sc_log(context, "pkcs15-login: find SO PIN: rc %i", rc);
  ------------------
  |  |   71|     81|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2017|    485|	} else {
 2018|    485|		pin_obj = slot_data_auth(slot->fw_data);
  ------------------
  |  |   51|    485|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|    481|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (50:23): [True: 481, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|    481|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  ------------------
  |  |  |  Branch (51:29): [True: 481, False: 4]
  |  |  ------------------
  ------------------
 2019|    485|	}
 2020|       |
 2021|    566|	if (!pin_obj)
  ------------------
  |  Branch (2021:6): [True: 123, False: 443]
  ------------------
 2022|    123|		return CKR_USER_PIN_NOT_INITIALIZED;
  ------------------
  |  | 1152|    123|#define CKR_USER_PIN_NOT_INITIALIZED 0x00000102UL
  ------------------
 2023|       |
 2024|    443|	auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
 2025|    443|	if (!auth_info)
  ------------------
  |  Branch (2025:6): [True: 0, False: 443]
  ------------------
 2026|      0|		return CKR_USER_PIN_NOT_INITIALIZED;
  ------------------
  |  | 1152|      0|#define CKR_USER_PIN_NOT_INITIALIZED 0x00000102UL
  ------------------
 2027|       |
 2028|    443|	sc_log(context, "Change '%.*s' (ref:%i,type:%i)", (int) sizeof pin_obj->label, pin_obj->label, auth_info->attrs.pin.reference, login_user);
  ------------------
  |  |   71|    443|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2029|    443|	if (pNewPin && (ulNewLen < auth_info->attrs.pin.min_length || ulNewLen > auth_info->attrs.pin.max_length)) {
  ------------------
  |  Branch (2029:6): [True: 443, False: 0]
  |  Branch (2029:18): [True: 313, False: 130]
  |  Branch (2029:64): [True: 28, False: 102]
  ------------------
 2030|    341|		return CKR_PIN_LEN_RANGE;
  ------------------
  |  | 1129|    341|#define CKR_PIN_LEN_RANGE 0x000000A2UL
  ------------------
 2031|    341|	}
 2032|       |
 2033|    102|	if (login_user < 0 && sc_pkcs11_conf.pin_unblock_style == SC_PKCS11_PIN_UNBLOCK_UNLOGGED_SETPIN) {
  ------------------
  |  |   40|     95|#define SC_PKCS11_PIN_UNBLOCK_UNLOGGED_SETPIN	1
  ------------------
  |  Branch (2033:6): [True: 95, False: 7]
  |  Branch (2033:24): [True: 0, False: 95]
  ------------------
 2034|      0|		rc = sc_pkcs15_unblock_pin(fw_data->p15_card, pin_obj, pOldPin, ulOldLen, pNewPin, ulNewLen);
 2035|      0|	}
 2036|    102|	else if (login_user == CKU_CONTEXT_SPECIFIC)   {
  ------------------
  |  | 1212|    102|#define CKU_CONTEXT_SPECIFIC 2UL
  ------------------
  |  Branch (2036:11): [True: 0, False: 102]
  ------------------
 2037|      0|		if (sc_pkcs11_conf.pin_unblock_style != SC_PKCS11_PIN_UNBLOCK_SCONTEXT_SETPIN) {
  ------------------
  |  |   41|      0|#define SC_PKCS11_PIN_UNBLOCK_SCONTEXT_SETPIN	2
  ------------------
  |  Branch (2037:7): [True: 0, False: 0]
  ------------------
 2038|      0|			sc_log(context, "PIN unlock is not allowed with CKU_CONTEXT_SPECIFIC login");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2039|      0|			return CKR_FUNCTION_NOT_SUPPORTED;
  ------------------
  |  | 1111|      0|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
 2040|      0|		}
 2041|      0|		rc = sc_pkcs15_unblock_pin(fw_data->p15_card, pin_obj, pOldPin, ulOldLen, pNewPin, ulNewLen);
 2042|      0|	}
 2043|    102|	else if (login_user < 0 || login_user == CKU_USER || login_user == CKU_SO) {
  ------------------
  |  | 1211|    109|#define CKU_USER 1UL
  ------------------
              	else if (login_user < 0 || login_user == CKU_USER || login_user == CKU_SO) {
  ------------------
  |  | 1210|      1|#define CKU_SO 0UL
  ------------------
  |  Branch (2043:11): [True: 95, False: 7]
  |  Branch (2043:29): [True: 6, False: 1]
  |  Branch (2043:55): [True: 1, False: 0]
  ------------------
 2044|    102|		rc = sc_pkcs15_change_pin(fw_data->p15_card, pin_obj, pOldPin, ulOldLen, pNewPin, ulNewLen);
 2045|    102|	}
 2046|      0|	else {
 2047|      0|		sc_log(context, "cannot change PIN: non supported login type: %i", login_user);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2048|      0|		return CKR_FUNCTION_NOT_SUPPORTED;
  ------------------
  |  | 1111|      0|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
 2049|      0|	}
 2050|       |
 2051|    102|	sc_log(context, "PIN change returns %d", rc);
  ------------------
  |  |   71|    102|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2052|    102|	return sc_to_cryptoki_error(rc, "C_SetPIN");
 2053|    102|}
framework-pkcs15.c:pkcs15_init_pin:
 2176|    160|{
 2177|    160|	struct sc_pkcs11_card *p11card = slot->p11card;
 2178|    160|	struct pkcs15_fw_data *fw_data = NULL;
 2179|    160|	struct sc_pkcs15init_pinargs args;
 2180|    160|	struct sc_profile	*profile = NULL;
 2181|    160|	struct sc_pkcs15_object	*auth_obj = NULL;
 2182|    160|	struct sc_pkcs15_auth_info *auth_info = NULL;
 2183|    160|	struct sc_cardctl_pkcs11_init_pin p11args;
 2184|    160|	int rc;
 2185|       |
 2186|    160|	memset(&p11args, 0, sizeof(p11args));
 2187|    160|	p11args.pin = pPin;
 2188|    160|	p11args.pin_len = ulPinLen;
 2189|       |
 2190|    160|	if (!p11card)
  ------------------
  |  Branch (2190:6): [True: 0, False: 160]
  ------------------
 2191|      0|		return CKR_TOKEN_NOT_RECOGNIZED;
  ------------------
  |  | 1145|      0|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
 2192|    160|	rc = sc_card_ctl(p11card->card, SC_CARDCTL_PKCS11_INIT_PIN, &p11args);
 2193|    160|	if (rc != SC_ERROR_NOT_SUPPORTED) {
  ------------------
  |  |   89|    160|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (2193:6): [True: 14, False: 146]
  ------------------
 2194|     14|		if (rc == SC_SUCCESS)
  ------------------
  |  |   28|     14|#define SC_SUCCESS				0
  ------------------
  |  Branch (2194:7): [True: 1, False: 13]
  ------------------
 2195|      1|			return CKR_OK;
  ------------------
  |  | 1086|      1|#define CKR_OK 0x00000000UL
  ------------------
 2196|     13|		return sc_to_cryptoki_error(rc, "C_InitPin");
 2197|     14|	}
 2198|       |
 2199|    146|	sc_log(context, "Init PIN: pin %p:%lu; unblock style %i", pPin,
  ------------------
  |  |   71|    146|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2200|    146|		ulPinLen, sc_pkcs11_conf.pin_unblock_style);
 2201|       |
 2202|    146|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
 2203|    146|	if (!fw_data)
  ------------------
  |  Branch (2203:6): [True: 0, False: 146]
  ------------------
 2204|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_InitPin");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2205|       |
 2206|    146|	auth_info = slot_data_auth_info(slot->fw_data);
  ------------------
  |  |   52|    146|#define slot_data_auth_info(p)	(((p) && slot_data_auth(p))? \
  |  |  ------------------
  |  |  |  |   51|    145|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|    145|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (50:23): [True: 145, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|    145|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (51:27): [True: 20, False: 125]
  |  |  |  |  |  Branch (51:29): [True: 145, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (52:34): [True: 145, False: 1]
  |  |  ------------------
  |  |   53|    146|		(struct sc_pkcs15_auth_info *) slot_data_auth(p)->data : NULL)
  |  |  ------------------
  |  |  |  |   51|     20|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     20|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (50:23): [True: 20, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     20|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (51:29): [True: 20, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2207|    146|	if (auth_info && sc_pkcs11_conf.pin_unblock_style == SC_PKCS11_PIN_UNBLOCK_SO_LOGGED_INITPIN)   {
  ------------------
  |  |   42|     20|#define SC_PKCS11_PIN_UNBLOCK_SO_LOGGED_INITPIN	3
  ------------------
  |  Branch (2207:6): [True: 20, False: 126]
  |  Branch (2207:19): [True: 0, False: 20]
  ------------------
 2208|      0|		if (!fw_data->p15_card)
  ------------------
  |  Branch (2208:7): [True: 0, False: 0]
  ------------------
 2209|      0|			return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_InitPin");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 2210|       |		/* C_InitPIN is used to unblock User PIN or set it in the SO session .*/
 2211|      0|		auth_obj = slot_data_auth(slot->fw_data);
  ------------------
  |  |   51|      0|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|      0|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (50:23): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  ------------------
  |  |  |  |   50|      0|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  ------------------
  |  |  |  Branch (51:29): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 2212|      0|		if (fw_data->user_puk_len)
  ------------------
  |  Branch (2212:7): [True: 0, False: 0]
  ------------------
 2213|      0|			rc = sc_pkcs15_unblock_pin(fw_data->p15_card, auth_obj,
 2214|      0|					fw_data->user_puk, fw_data->user_puk_len, pPin, ulPinLen);
 2215|      0|		else
 2216|       |			/* FIXME (VT): Actually sc_pkcs15_unblock_pin() do not accepts zero length PUK.
 2217|       |			 * Something like sc_pkcs15_set_pin() should be introduced.
 2218|       |			 * For a while, use the 'libopensc' API to set PIN. */
 2219|      0|			rc = sc_reset_retry_counter(fw_data->p15_card->card, SC_AC_CHV, auth_info->attrs.pin.reference,
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 2220|      0|					NULL, 0, pPin, ulPinLen);
 2221|       |
 2222|      0|		return sc_to_cryptoki_error(rc, "C_InitPIN");
 2223|      0|	}
 2224|       |
 2225|    146|	rc = sc_lock(p11card->card);
 2226|    146|	if (rc < 0)
  ------------------
  |  Branch (2226:6): [True: 0, False: 146]
  ------------------
 2227|      0|		return sc_to_cryptoki_error(rc, "C_InitPIN");
 2228|       |
 2229|    146|	rc = sc_pkcs15init_bind(p11card->card, "pkcs15", NULL, NULL, &profile);
 2230|    146|	if (rc < 0) {
  ------------------
  |  Branch (2230:6): [True: 146, False: 0]
  ------------------
 2231|    146|		sc_unlock(p11card->card);
 2232|    146|		return sc_to_cryptoki_error(rc, "C_InitPIN");
 2233|    146|	}
 2234|       |
 2235|      0|	rc = sc_pkcs15init_finalize_profile(p11card->card, profile, NULL);
 2236|      0|	if (rc != CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (2236:6): [True: 0, False: 0]
  ------------------
 2237|      0|		sc_log(context, "Cannot finalize profile: %i", rc);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2238|      0|		return sc_to_cryptoki_error(rc, "C_InitPIN");
 2239|      0|	}
 2240|       |
 2241|      0|	memset(&args, 0, sizeof(args));
 2242|      0|	args.label = "User PIN";
 2243|      0|	args.pin = pPin;
 2244|      0|	args.pin_len = ulPinLen;
 2245|      0|	rc = sc_pkcs15init_store_pin(fw_data->p15_card, profile, &args);
 2246|       |
 2247|      0|	sc_pkcs15init_unbind(profile);
 2248|      0|	sc_unlock(p11card->card);
 2249|      0|	if (rc < 0)
  ------------------
  |  Branch (2249:6): [True: 0, False: 0]
  ------------------
 2250|      0|		return sc_to_cryptoki_error(rc, "C_InitPIN");
 2251|       |
 2252|      0|	rc = sc_pkcs15_find_pin_by_auth_id(fw_data->p15_card, &args.auth_id, &auth_obj);
 2253|      0|	if (rc < 0)
  ------------------
  |  Branch (2253:6): [True: 0, False: 0]
  ------------------
 2254|      0|		return sc_to_cryptoki_error(rc, "C_InitPIN");
 2255|       |
 2256|       |	/* Re-initialize the slot */
 2257|      0|	free(slot->fw_data);
 2258|      0|	pkcs15_init_slot(fw_data->p15_card, slot, auth_obj, slot->app_info);
 2259|       |
 2260|      0|	return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 2261|      0|}
framework-pkcs15.c:pkcs15_create_object:
 3048|    319|{
 3049|    319|	struct sc_pkcs11_card *p11card = slot->p11card;
 3050|    319|	struct pkcs15_fw_data *fw_data = NULL;
 3051|    319|	struct sc_profile *profile = NULL;
 3052|    319|	CK_OBJECT_CLASS	_class;
 3053|    319|	CK_BBOOL _token = FALSE;
  ------------------
  |  |   48|    319|#define FALSE 0
  ------------------
 3054|    319|	CK_RV rv;
 3055|    319|	int rc;
 3056|    319|	CK_BBOOL p15init_create_object;
 3057|       |
 3058|    319|	if (!p11card)
  ------------------
  |  Branch (3058:6): [True: 0, False: 319]
  ------------------
 3059|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_CreateObject");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3060|    319|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
 3061|    319|	if (!fw_data)
  ------------------
  |  Branch (3061:6): [True: 0, False: 319]
  ------------------
 3062|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_CreateObject");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3063|    319|	if (!fw_data->p15_card)
  ------------------
  |  Branch (3063:6): [True: 167, False: 152]
  ------------------
 3064|    167|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_CreateObject");
  ------------------
  |  |   60|    167|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3065|       |
 3066|    152|	rv = attr_find(pTemplate, ulCount, CKA_CLASS, &_class, NULL);
  ------------------
  |  |  137|    152|#define CKA_CLASS 0x00000000UL
  ------------------
 3067|    152|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    152|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3067:6): [True: 0, False: 152]
  ------------------
 3068|      0|		return rv;
 3069|       |
 3070|    152|	rv = attr_find(pTemplate, ulCount, CKA_TOKEN, &_token, NULL);
  ------------------
  |  |  138|    152|#define CKA_TOKEN 0x00000001UL
  ------------------
 3071|    152|	if (rv != CKR_TEMPLATE_INCOMPLETE && rv != CKR_OK) {
  ------------------
  |  | 1142|    304|#define CKR_TEMPLATE_INCOMPLETE 0x000000D0UL
  ------------------
              	if (rv != CKR_TEMPLATE_INCOMPLETE && rv != CKR_OK) {
  ------------------
  |  | 1086|    152|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3071:6): [True: 152, False: 0]
  |  Branch (3071:39): [True: 0, False: 152]
  ------------------
 3072|      0|		return rv;
 3073|      0|	}
 3074|       |
 3075|       |	/* Dont need profile if creating session only objects,
 3076|       |	 * except when the card supports temporary on card session objects */
 3077|    152|	p15init_create_object = _token == TRUE || (p11card->card->caps & SC_CARD_CAP_ONCARD_SESSION_OBJECTS) == SC_CARD_CAP_ONCARD_SESSION_OBJECTS;
  ------------------
  |  |   51|    304|#define TRUE 1
  ------------------
              	p15init_create_object = _token == TRUE || (p11card->card->caps & SC_CARD_CAP_ONCARD_SESSION_OBJECTS) == SC_CARD_CAP_ONCARD_SESSION_OBJECTS;
  ------------------
  |  |  569|     37|#define SC_CARD_CAP_ONCARD_SESSION_OBJECTS	0x00000400
  ------------------
              	p15init_create_object = _token == TRUE || (p11card->card->caps & SC_CARD_CAP_ONCARD_SESSION_OBJECTS) == SC_CARD_CAP_ONCARD_SESSION_OBJECTS;
  ------------------
  |  |  569|    189|#define SC_CARD_CAP_ONCARD_SESSION_OBJECTS	0x00000400
  ------------------
  |  Branch (3077:26): [True: 115, False: 37]
  |  Branch (3077:44): [True: 0, False: 37]
  ------------------
 3078|       |
 3079|    152|	if (p15init_create_object) {
  ------------------
  |  Branch (3079:6): [True: 115, False: 37]
  ------------------
 3080|    115|		struct sc_aid *aid = NULL;
 3081|       |
 3082|    115|		rc = sc_lock(p11card->card);
 3083|    115|		if (rc < 0)
  ------------------
  |  Branch (3083:7): [True: 0, False: 115]
  ------------------
 3084|      0|			return sc_to_cryptoki_error(rc, "C_CreateObject");
 3085|       |
 3086|       |		/* Bind the profile */
 3087|    115|		rc = sc_pkcs15init_bind(p11card->card, "pkcs15", NULL, slot->app_info, &profile);
 3088|    115|		if (rc < 0) {
  ------------------
  |  Branch (3088:7): [True: 115, False: 0]
  ------------------
 3089|    115|			sc_unlock(p11card->card);
 3090|    115|			return sc_to_cryptoki_error(rc, "C_CreateObject");
 3091|    115|		}
 3092|       |
 3093|      0|		if (slot->app_info)
  ------------------
  |  Branch (3093:7): [True: 0, False: 0]
  ------------------
 3094|      0|			aid = &slot->app_info->aid;
 3095|       |
 3096|      0|		rc = sc_pkcs15init_finalize_profile(p11card->card, profile, aid);
 3097|      0|		if (rc != CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3097:7): [True: 0, False: 0]
  ------------------
 3098|      0|			sc_log(context, "Cannot finalize profile: %i", rc);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3099|      0|			sc_unlock(p11card->card);
 3100|      0|			return sc_to_cryptoki_error(rc, "C_CreateObject");
 3101|      0|		}
 3102|       |
 3103|      0|		sc_pkcs15init_set_p15card(profile, fw_data->p15_card);
 3104|      0|	}
 3105|     37|	switch (_class) {
 3106|      0|	case CKO_PRIVATE_KEY:
  ------------------
  |  | 1030|      0|#define CKO_PRIVATE_KEY 0x00000003UL
  ------------------
  |  Branch (3106:2): [True: 0, False: 37]
  ------------------
 3107|      0|		rv = pkcs15_create_private_key(slot, profile, pTemplate, ulCount, phObject);
 3108|      0|		break;
 3109|      0|	case CKO_PUBLIC_KEY:
  ------------------
  |  | 1029|      0|#define CKO_PUBLIC_KEY 0x00000002UL
  ------------------
  |  Branch (3109:2): [True: 0, False: 37]
  ------------------
 3110|      0|		rv = pkcs15_create_public_key(slot, profile, pTemplate, ulCount, phObject);
 3111|      0|		break;
 3112|      7|	case CKO_CERTIFICATE:
  ------------------
  |  | 1028|      7|#define CKO_CERTIFICATE 0x00000001UL
  ------------------
  |  Branch (3112:2): [True: 7, False: 30]
  ------------------
 3113|      7|		rv = pkcs15_create_certificate(slot, profile, pTemplate, ulCount, phObject);
 3114|      7|		break;
 3115|     30|	case CKO_DATA:
  ------------------
  |  | 1027|     30|#define CKO_DATA 0x00000000UL
  ------------------
  |  Branch (3115:2): [True: 30, False: 7]
  ------------------
 3116|     30|		rv = pkcs15_create_data(slot, profile, pTemplate, ulCount, phObject);
 3117|     30|		break;
 3118|      0|	case CKO_SECRET_KEY:
  ------------------
  |  | 1031|      0|#define CKO_SECRET_KEY 0x00000004UL
  ------------------
  |  Branch (3118:2): [True: 0, False: 37]
  ------------------
 3119|      0|		rv = pkcs15_create_secret_key(slot, profile, pTemplate, ulCount, phObject);
 3120|      0|		break;
 3121|      0|	default:
  ------------------
  |  Branch (3121:2): [True: 0, False: 37]
  ------------------
 3122|      0|		rv = CKR_FUNCTION_NOT_SUPPORTED;
  ------------------
  |  | 1111|      0|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
 3123|     37|	}
 3124|       |
 3125|     37|	if (p15init_create_object) {
  ------------------
  |  Branch (3125:6): [True: 0, False: 37]
  ------------------
 3126|       |		// TODO: after sc_pkcs15init_unbind, user may have to enter PIN on a pin pad reader even though authentication state
 3127|       |		// is supposed to remain open. Check why this happens.
 3128|      0|		sc_pkcs15init_unbind(profile);
 3129|      0|		sc_unlock(p11card->card);
 3130|      0|	}
 3131|       |
 3132|     37|	return rv;
 3133|     37|}
framework-pkcs15.c:pkcs15_create_certificate:
 2875|      7|{
 2876|      7|	struct sc_pkcs11_card *p11card = slot->p11card;
 2877|      7|	struct pkcs15_fw_data *fw_data = NULL;
 2878|      7|	struct sc_pkcs15init_certargs args;
 2879|      7|	struct pkcs15_any_object *cert_any_obj = NULL;
 2880|      7|	struct sc_pkcs15_object	*cert_obj = NULL;
 2881|      7|	CK_CERTIFICATE_TYPE	cert_type;
 2882|      7|	CK_BBOOL		bValue;
 2883|      7|	int			rc;
 2884|      7|	CK_RV rv;
 2885|      7|	char label[SC_PKCS15_MAX_LABEL_SIZE];
 2886|       |
 2887|      7|	memset(&args, 0, sizeof(args));
 2888|      7|	if (!p11card)
  ------------------
  |  Branch (2888:6): [True: 0, False: 7]
  ------------------
 2889|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_CreateObject");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 2890|      7|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
 2891|      7|	if (!fw_data)
  ------------------
  |  Branch (2891:6): [True: 0, False: 7]
  ------------------
 2892|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_CreateObject");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2893|      7|	if (!fw_data->p15_card)
  ------------------
  |  Branch (2893:6): [True: 0, False: 7]
  ------------------
 2894|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_CreateObject");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 2895|       |
 2896|       |	/* Get the key type */
 2897|      7|	rv = attr_find(pTemplate, ulCount, CKA_CERTIFICATE_TYPE,
  ------------------
  |  |  145|      7|#define CKA_CERTIFICATE_TYPE 0x00000080UL
  ------------------
 2898|      7|				&cert_type, NULL);
 2899|      7|	if (rv != CKR_OK)
  ------------------
  |  | 1086|      7|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (2899:6): [True: 0, False: 7]
  ------------------
 2900|      0|		return rv;
 2901|      7|	if (cert_type != CKC_X_509)
  ------------------
  |  |  303|      7|#define CKC_X_509 0x00000000UL
  ------------------
  |  Branch (2901:6): [True: 0, False: 7]
  ------------------
 2902|      0|		return CKR_ATTRIBUTE_VALUE_INVALID;
  ------------------
  |  | 1099|      0|#define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013UL
  ------------------
 2903|       |
 2904|     38|	while (ulCount--) {
  ------------------
  |  Branch (2904:9): [True: 35, False: 3]
  ------------------
 2905|     35|		CK_ATTRIBUTE_PTR attr = pTemplate++;
 2906|       |
 2907|     35|		switch (attr->type) {
 2908|       |		/* Skip attrs we already know or don't care for */
 2909|      7|		case CKA_CLASS:
  ------------------
  |  |  137|      7|#define CKA_CLASS 0x00000000UL
  ------------------
  |  Branch (2909:3): [True: 7, False: 28]
  ------------------
 2910|      7|			break;
 2911|      7|		case CKA_PRIVATE:
  ------------------
  |  |  139|      7|#define CKA_PRIVATE 0x00000002UL
  ------------------
  |  Branch (2911:3): [True: 7, False: 28]
  ------------------
 2912|      7|			attr_extract(attr, &bValue, NULL);
 2913|      7|			if (bValue) {
  ------------------
  |  Branch (2913:8): [True: 4, False: 3]
  ------------------
 2914|      4|				rv = CKR_TEMPLATE_INCONSISTENT;
  ------------------
  |  | 1143|      4|#define CKR_TEMPLATE_INCONSISTENT 0x000000D1UL
  ------------------
 2915|      4|				goto out;
 2916|      4|			}
 2917|      3|			break;
 2918|      3|		case CKA_LABEL:
  ------------------
  |  |  140|      0|#define CKA_LABEL 0x00000003UL
  ------------------
  |  Branch (2918:3): [True: 0, False: 35]
  ------------------
 2919|      0|			args.label = set_cka_label(attr, label);
 2920|      0|			break;
 2921|      0|		case CKA_ID:
  ------------------
  |  |  161|      0|#define CKA_ID 0x00000102UL
  ------------------
  |  Branch (2921:3): [True: 0, False: 35]
  ------------------
 2922|      0|			args.id.len = sizeof(args.id.value);
 2923|      0|			rv = attr_extract(attr, args.id.value, &args.id.len);
 2924|      0|			if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (2924:8): [True: 0, False: 0]
  ------------------
 2925|      0|				goto out;
 2926|      0|			break;
 2927|      7|		case CKA_VALUE:
  ------------------
  |  |  143|      7|#define CKA_VALUE 0x00000011UL
  ------------------
  |  Branch (2927:3): [True: 7, False: 28]
  ------------------
 2928|      7|			args.der_encoded.len = attr->ulValueLen;
 2929|      7|			args.der_encoded.value = (u8 *) attr->pValue;
 2930|      7|			break;
 2931|     14|		default:
  ------------------
  |  Branch (2931:3): [True: 14, False: 21]
  ------------------
 2932|       |			/* ignore unknown attrs, or flag error? */
 2933|     14|			continue;
 2934|     35|		}
 2935|     35|	}
 2936|       |
 2937|      3|	if (args.der_encoded.len == 0) {
  ------------------
  |  Branch (2937:6): [True: 0, False: 3]
  ------------------
 2938|      0|		rv = CKR_TEMPLATE_INCOMPLETE;
  ------------------
  |  | 1142|      0|#define CKR_TEMPLATE_INCOMPLETE 0x000000D0UL
  ------------------
 2939|      0|		goto out;
 2940|      0|	}
 2941|       |
 2942|      3|	rc = sc_pkcs15init_store_certificate(fw_data->p15_card, profile, &args, &cert_obj);
 2943|      3|	if (rc < 0) {
  ------------------
  |  Branch (2943:6): [True: 3, False: 0]
  ------------------
 2944|      3|		rv = sc_to_cryptoki_error(rc, "C_CreateObject");
 2945|      3|		goto out;
 2946|      3|	}
 2947|       |	/* Create a new pkcs11 object for it */
 2948|      0|	__pkcs15_create_cert_object(fw_data, cert_obj, &cert_any_obj);
 2949|      0|	pkcs15_add_object(slot, cert_any_obj, phObject);
 2950|       |
 2951|      0|	rv = CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 2952|       |
 2953|      7|out:	return rv;
 2954|      0|}
framework-pkcs15.c:pkcs15_create_data:
 2961|     30|{
 2962|     30|	struct sc_pkcs11_card *p11card = slot->p11card;
 2963|     30|	struct pkcs15_fw_data *fw_data = NULL;
 2964|     30|	struct sc_pkcs15init_dataargs args;
 2965|     30|	struct pkcs15_any_object *data_any_obj = NULL;
 2966|     30|	struct sc_pkcs15_object	*data_obj = NULL;
 2967|     30|	struct sc_pkcs15_auth_info *pin = NULL;
 2968|     30|	CK_BBOOL bValue;
 2969|     30|	int rc;
 2970|     30|	CK_RV rv;
 2971|     30|	char label[SC_PKCS15_MAX_LABEL_SIZE];
 2972|       |
 2973|     30|	memset(&args, 0, sizeof(args));
 2974|     30|	sc_init_oid(&args.app_oid);
 2975|       |
 2976|     30|	if (!p11card)
  ------------------
  |  Branch (2976:6): [True: 0, False: 30]
  ------------------
 2977|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_CreateObject");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 2978|     30|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
 2979|     30|	if (!fw_data)
  ------------------
  |  Branch (2979:6): [True: 0, False: 30]
  ------------------
 2980|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_CreateObject");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2981|     30|	if (!fw_data->p15_card)
  ------------------
  |  Branch (2981:6): [True: 0, False: 30]
  ------------------
 2982|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_CreateObject");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 2983|       |
 2984|    162|	while (ulCount--) {
  ------------------
  |  Branch (2984:9): [True: 141, False: 21]
  ------------------
 2985|    141|		CK_ATTRIBUTE_PTR attr = pTemplate++;
 2986|       |
 2987|    141|		switch (attr->type) {
 2988|       |		/* Skip attrs we already know or don't care for */
 2989|     30|		case CKA_CLASS:
  ------------------
  |  |  137|     30|#define CKA_CLASS 0x00000000UL
  ------------------
  |  Branch (2989:3): [True: 30, False: 111]
  ------------------
 2990|     30|			break;
 2991|     30|		case CKA_PRIVATE:
  ------------------
  |  |  139|     30|#define CKA_PRIVATE 0x00000002UL
  ------------------
  |  Branch (2991:3): [True: 30, False: 111]
  ------------------
 2992|     30|			attr_extract(attr, &bValue, NULL);
 2993|     30|			if (bValue) {
  ------------------
  |  Branch (2993:8): [True: 15, False: 15]
  ------------------
 2994|     15|				pin = slot_data_auth_info(slot->fw_data);
  ------------------
  |  |   52|     15|#define slot_data_auth_info(p)	(((p) && slot_data_auth(p))? \
  |  |  ------------------
  |  |  |  |   51|     15|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     15|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (50:23): [True: 15, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     15|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (51:27): [True: 14, False: 1]
  |  |  |  |  |  Branch (51:29): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (52:34): [True: 15, False: 0]
  |  |  ------------------
  |  |   53|     15|		(struct sc_pkcs15_auth_info *) slot_data_auth(p)->data : NULL)
  |  |  ------------------
  |  |  |  |   51|     14|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     14|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (50:23): [True: 14, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|     14|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (51:29): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2995|     15|				if (pin == NULL) {
  ------------------
  |  Branch (2995:9): [True: 1, False: 14]
  ------------------
 2996|      1|					rv = CKR_TEMPLATE_INCOMPLETE;
  ------------------
  |  | 1142|      1|#define CKR_TEMPLATE_INCOMPLETE 0x000000D0UL
  ------------------
 2997|      1|					goto out;
 2998|      1|				}
 2999|     14|				args.auth_id = pin->auth_id;
 3000|     14|			}
 3001|     29|			break;
 3002|     29|		case CKA_LABEL:
  ------------------
  |  |  140|      0|#define CKA_LABEL 0x00000003UL
  ------------------
  |  Branch (3002:3): [True: 0, False: 141]
  ------------------
 3003|      0|			args.label = set_cka_label(attr, label);
 3004|      0|			break;
 3005|      0|		case CKA_ID:
  ------------------
  |  |  161|      0|#define CKA_ID 0x00000102UL
  ------------------
  |  Branch (3005:3): [True: 0, False: 141]
  ------------------
 3006|      0|			args.id.len = sizeof(args.id.value);
 3007|      0|			rv = attr_extract(attr, args.id.value, &args.id.len);
 3008|      0|			if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3008:8): [True: 0, False: 0]
  ------------------
 3009|      0|				goto out;
 3010|      0|			break;
 3011|      0|		case CKA_APPLICATION:
  ------------------
  |  |  142|      0|#define CKA_APPLICATION 0x00000010UL
  ------------------
  |  Branch (3011:3): [True: 0, False: 141]
  ------------------
 3012|      0|			args.app_label = (char *) attr->pValue;
 3013|      0|			break;
 3014|     21|		case CKA_OBJECT_ID:
  ------------------
  |  |  144|     21|#define CKA_OBJECT_ID 0x00000012UL
  ------------------
  |  Branch (3014:3): [True: 21, False: 120]
  ------------------
 3015|     21|			if (sc_asn1_decode_object_id(attr->pValue, attr->ulValueLen, &args.app_oid)) {
  ------------------
  |  Branch (3015:8): [True: 8, False: 13]
  ------------------
 3016|      8|				rv = CKR_ATTRIBUTE_VALUE_INVALID;
  ------------------
  |  | 1099|      8|#define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013UL
  ------------------
 3017|      8|				goto out;
 3018|      8|			}
 3019|     13|			break;
 3020|     30|		case CKA_VALUE:
  ------------------
  |  |  143|     30|#define CKA_VALUE 0x00000011UL
  ------------------
  |  Branch (3020:3): [True: 30, False: 111]
  ------------------
 3021|     30|			args.der_encoded.len = attr->ulValueLen;
 3022|     30|			args.der_encoded.value = (u8 *) attr->pValue;
 3023|     30|			break;
 3024|     30|		default:
  ------------------
  |  Branch (3024:3): [True: 30, False: 111]
  ------------------
 3025|       |			/* ignore unknown attrs, or flag error? */
 3026|     30|			continue;
 3027|    141|		}
 3028|    141|	}
 3029|       |
 3030|     21|	rc = sc_pkcs15init_store_data_object(fw_data->p15_card, profile, &args, &data_obj);
 3031|     21|	if (rc < 0) {
  ------------------
  |  Branch (3031:6): [True: 21, False: 0]
  ------------------
 3032|     21|		rv = sc_to_cryptoki_error(rc, "C_CreateObject");
 3033|     21|		goto out;
 3034|     21|	}
 3035|       |	/* Create a new pkcs11 object for it */
 3036|      0|	__pkcs15_create_data_object(fw_data, data_obj, &data_any_obj);
 3037|      0|	pkcs15_add_object(slot, data_any_obj, phObject);
 3038|       |
 3039|      0|	rv = CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 3040|       |
 3041|     30|out:	return rv;
 3042|      0|}
framework-pkcs15.c:pkcs15_gen_keypair:
 3311|    251|{
 3312|    251|	struct sc_profile *profile = NULL;
 3313|    251|	struct sc_pkcs11_card *p11card = slot->p11card;
 3314|    251|	struct sc_pkcs15_auth_info *pin = NULL;
 3315|    251|	struct sc_aid *aid = NULL;
 3316|    251|	struct pkcs15_fw_data *fw_data = NULL;
 3317|    251|	struct sc_pkcs15init_keygen_args keygen_args;
 3318|    251|	struct sc_pkcs15_object	 *priv_key_obj = NULL, *pub_key_obj = NULL;
 3319|    251|	struct pkcs15_any_object *priv_any_obj = NULL, *pub_any_obj = NULL;
 3320|    251|	struct pkcs15_prkey_object *priv_prk_obj = NULL;
 3321|    251|	struct sc_pkcs15_id id;
 3322|    251|	size_t		len;
 3323|    251|	CK_KEY_TYPE	keytype;
 3324|    251|	CK_ULONG	keybits = 0;
 3325|    251|	char		pub_label[SC_PKCS15_MAX_LABEL_SIZE];
 3326|    251|	char		priv_label[SC_PKCS15_MAX_LABEL_SIZE];
 3327|    251|	int		rc;
 3328|    251|	CK_RV rv = CKR_OK;
  ------------------
  |  | 1086|    251|#define CKR_OK 0x00000000UL
  ------------------
 3329|    251|	CK_BBOOL always_auth = CK_FALSE;
  ------------------
  |  |   35|    251|#define CK_FALSE 0
  ------------------
 3330|    251|	CK_BBOOL sensitive = CK_FALSE;
  ------------------
  |  |   35|    251|#define CK_FALSE 0
  ------------------
 3331|    251|	CK_BBOOL extractable = CK_FALSE;
  ------------------
  |  |   35|    251|#define CK_FALSE 0
  ------------------
 3332|       |
 3333|    251|	sc_log(context, "Key pair generation, mech = 0x%0lx",
  ------------------
  |  |   71|    251|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3334|    251|		   pMechanism->mechanism);
 3335|       |
 3336|    251|	if (pMechanism->mechanism != CKM_RSA_PKCS_KEY_PAIR_GEN
  ------------------
  |  |  538|    502|#define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000UL
  ------------------
  |  Branch (3336:6): [True: 244, False: 7]
  ------------------
 3337|    244|			&& pMechanism->mechanism != CKM_GOSTR3410_KEY_PAIR_GEN
  ------------------
  |  |  908|    495|#define CKM_GOSTR3410_KEY_PAIR_GEN 0x00001200UL
  ------------------
  |  Branch (3337:7): [True: 243, False: 1]
  ------------------
 3338|    243|			&& pMechanism->mechanism != CKM_EC_KEY_PAIR_GEN
  ------------------
  |  |  859|    494|#define CKM_EC_KEY_PAIR_GEN 0x00001040UL
  ------------------
  |  Branch (3338:7): [True: 242, False: 1]
  ------------------
 3339|    242|			&& pMechanism->mechanism != CKM_EC_EDWARDS_KEY_PAIR_GEN
  ------------------
  |  |  988|    493|#define CKM_EC_EDWARDS_KEY_PAIR_GEN 0x00001055UL
  ------------------
  |  Branch (3339:7): [True: 240, False: 2]
  ------------------
 3340|    240|			&& pMechanism->mechanism != CKM_EC_MONTGOMERY_KEY_PAIR_GEN)
  ------------------
  |  |  989|    240|#define CKM_EC_MONTGOMERY_KEY_PAIR_GEN 0x00001056UL
  ------------------
  |  Branch (3340:7): [True: 239, False: 1]
  ------------------
 3341|    239|		return CKR_MECHANISM_INVALID;
  ------------------
  |  | 1122|    239|#define CKR_MECHANISM_INVALID 0x00000070UL
  ------------------
 3342|       |
 3343|     12|	if (!p11card)
  ------------------
  |  Branch (3343:6): [True: 0, False: 12]
  ------------------
 3344|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GenerateKeyPair");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3345|     12|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
 3346|     12|	if (!fw_data)
  ------------------
  |  Branch (3346:6): [True: 0, False: 12]
  ------------------
 3347|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GenerateKeyPair");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3348|     12|	if (!fw_data->p15_card)
  ------------------
  |  Branch (3348:6): [True: 5, False: 7]
  ------------------
 3349|      5|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GenerateKeyPair");
  ------------------
  |  |   60|      5|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3350|       |
 3351|      7|	rc = sc_lock(p11card->card);
 3352|      7|	if (rc < 0)
  ------------------
  |  Branch (3352:6): [True: 0, False: 7]
  ------------------
 3353|      0|		return sc_to_cryptoki_error(rc, "C_GenerateKeyPair");
 3354|       |
 3355|      7|	rc = sc_pkcs15init_bind(p11card->card, "pkcs15", NULL, slot->app_info, &profile);
 3356|      7|	if (rc < 0) {
  ------------------
  |  Branch (3356:6): [True: 7, False: 0]
  ------------------
 3357|      7|		sc_unlock(p11card->card);
 3358|      7|		return sc_to_cryptoki_error(rc, "C_GenerateKeyPair");
 3359|      7|	}
 3360|       |
 3361|      0|	if(slot->app_info)
  ------------------
  |  Branch (3361:5): [True: 0, False: 0]
  ------------------
 3362|      0|		aid = &slot->app_info->aid;
 3363|       |
 3364|      0|	rc = sc_pkcs15init_finalize_profile(p11card->card, profile, aid);
 3365|      0|	if (rc != CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3365:6): [True: 0, False: 0]
  ------------------
 3366|      0|		sc_log(context, "Cannot finalize profile: %i", rc);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3367|      0|		return sc_to_cryptoki_error(rc, "C_GenerateKeyPair");
 3368|      0|	}
 3369|       |
 3370|      0|	memset(&keygen_args, 0, sizeof(keygen_args));
 3371|       |
 3372|       |	/* 1. Convert the pkcs11 attributes to pkcs15init args */
 3373|       |
 3374|      0|	if ((pin = slot_data_auth_info(slot->fw_data)) != NULL)
  ------------------
  |  |   52|      0|#define slot_data_auth_info(p)	(((p) && slot_data_auth(p))? \
  |  |  ------------------
  |  |  |  |   51|      0|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (50:23): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (51:27): [True: 0, False: 0]
  |  |  |  |  |  Branch (51:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (52:34): [True: 0, False: 0]
  |  |  ------------------
  |  |   53|      0|		(struct sc_pkcs15_auth_info *) slot_data_auth(p)->data : NULL)
  |  |  ------------------
  |  |  |  |   51|      0|#define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  |  |  ------------------
  |  |  |  |  |  |  |  Branch (50:23): [True: 0, False: 0]
  |  |  |  |  |  |  ------------------
  |  |  |  |  ------------------
  |  |  |  |               #define slot_data_auth(p)	(((p) && slot_data(p)) ? slot_data(p)->auth_obj : NULL)
  |  |  |  |  ------------------
  |  |  |  |  |  |   50|      0|#define slot_data(p)		((struct pkcs15_slot_data *) (p))
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (51:29): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (3374:6): [True: 0, False: 0]
  ------------------
 3375|      0|		keygen_args.prkey_args.auth_id = pin->auth_id;
 3376|       |
 3377|      0|	rv = attr_find2(pPubTpl, ulPubCnt, pPrivTpl, ulPrivCnt, CKA_KEY_TYPE,
  ------------------
  |  |  159|      0|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
 3378|      0|		&keytype, NULL);
 3379|      0|	if (rv != CKR_OK && pMechanism->mechanism == CKM_RSA_PKCS_KEY_PAIR_GEN)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
              	if (rv != CKR_OK && pMechanism->mechanism == CKM_RSA_PKCS_KEY_PAIR_GEN)
  ------------------
  |  |  538|      0|#define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000UL
  ------------------
  |  Branch (3379:6): [True: 0, False: 0]
  |  Branch (3379:22): [True: 0, False: 0]
  ------------------
 3380|      0|		keytype = CKK_RSA;
  ------------------
  |  |  464|      0|#define CKK_RSA 0x00000000UL
  ------------------
 3381|      0|	else if (rv != CKR_OK && pMechanism->mechanism == CKM_EC_KEY_PAIR_GEN)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
              	else if (rv != CKR_OK && pMechanism->mechanism == CKM_EC_KEY_PAIR_GEN)
  ------------------
  |  |  859|      0|#define CKM_EC_KEY_PAIR_GEN 0x00001040UL
  ------------------
  |  Branch (3381:11): [True: 0, False: 0]
  |  Branch (3381:27): [True: 0, False: 0]
  ------------------
 3382|      0|		keytype = CKK_EC;
  ------------------
  |  |  467|      0|#define CKK_EC 0x00000003UL
  ------------------
 3383|      0|	else if (rv != CKR_OK && pMechanism->mechanism == CKM_EC_EDWARDS_KEY_PAIR_GEN)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
              	else if (rv != CKR_OK && pMechanism->mechanism == CKM_EC_EDWARDS_KEY_PAIR_GEN)
  ------------------
  |  |  988|      0|#define CKM_EC_EDWARDS_KEY_PAIR_GEN 0x00001055UL
  ------------------
  |  Branch (3383:11): [True: 0, False: 0]
  |  Branch (3383:27): [True: 0, False: 0]
  ------------------
 3384|      0|		keytype = CKK_EC_EDWARDS;
  ------------------
  |  |  518|      0|#define CKK_EC_EDWARDS 0x00000040UL
  ------------------
 3385|      0|	else if (rv != CKR_OK && pMechanism->mechanism == CKM_EC_MONTGOMERY_KEY_PAIR_GEN)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
              	else if (rv != CKR_OK && pMechanism->mechanism == CKM_EC_MONTGOMERY_KEY_PAIR_GEN)
  ------------------
  |  |  989|      0|#define CKM_EC_MONTGOMERY_KEY_PAIR_GEN 0x00001056UL
  ------------------
  |  Branch (3385:11): [True: 0, False: 0]
  |  Branch (3385:27): [True: 0, False: 0]
  ------------------
 3386|      0|		keytype = CKK_EC_MONTGOMERY;
  ------------------
  |  |  519|      0|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
 3387|      0|	else if (rv != CKR_OK && pMechanism->mechanism == CKM_GOSTR3410_KEY_PAIR_GEN)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
              	else if (rv != CKR_OK && pMechanism->mechanism == CKM_GOSTR3410_KEY_PAIR_GEN)
  ------------------
  |  |  908|      0|#define CKM_GOSTR3410_KEY_PAIR_GEN 0x00001200UL
  ------------------
  |  Branch (3387:11): [True: 0, False: 0]
  |  Branch (3387:27): [True: 0, False: 0]
  ------------------
 3388|      0|		keytype = CKK_GOSTR3410;
  ------------------
  |  |  502|      0|#define CKK_GOSTR3410 0x00000030UL
  ------------------
 3389|      0|	else if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3389:11): [True: 0, False: 0]
  ------------------
 3390|      0|		goto kpgen_done;
 3391|       |
 3392|      0|	if (keytype == CKK_GOSTR3410)   {
  ------------------
  |  |  502|      0|#define CKK_GOSTR3410 0x00000030UL
  ------------------
  |  Branch (3392:6): [True: 0, False: 0]
  ------------------
 3393|      0|		keygen_args.prkey_args.key.algorithm = SC_ALGORITHM_GOSTR3410;
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
 3394|      0|		rv = set_gost3410_params(&keygen_args.prkey_args, NULL,
 3395|      0|				pPubTpl, ulPubCnt, pPrivTpl, ulPrivCnt);
 3396|      0|		if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3396:7): [True: 0, False: 0]
  ------------------
 3397|      0|			goto kpgen_done;
 3398|      0|		keybits = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      0|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
 3399|      0|	}
 3400|      0|	else if (keytype == CKK_RSA)   {
  ------------------
  |  |  464|      0|#define CKK_RSA 0x00000000UL
  ------------------
  |  Branch (3400:11): [True: 0, False: 0]
  ------------------
 3401|       |		/* default value (CKA_KEY_TYPE isn't set) or CKK_RSA is set */
 3402|      0|		keygen_args.prkey_args.key.algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
 3403|       |
 3404|      0|		rv = attr_find2(pPubTpl, ulPubCnt, pPrivTpl, ulPrivCnt,	CKA_MODULUS_BITS, &keybits, NULL);
  ------------------
  |  |  175|      0|#define CKA_MODULUS_BITS 0x00000121UL
  ------------------
 3405|      0|		if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3405:7): [True: 0, False: 0]
  ------------------
 3406|      0|			keybits = 1024; /* Default key size */
 3407|       |		/* TODO: check allowed values of keybits */
 3408|      0|	} else if (keytype == CKK_EC || keytype == CKK_EC_EDWARDS || keytype == CKK_EC_MONTGOMERY) {
  ------------------
  |  |  467|      0|#define CKK_EC 0x00000003UL
  ------------------
              	} else if (keytype == CKK_EC || keytype == CKK_EC_EDWARDS || keytype == CKK_EC_MONTGOMERY) {
  ------------------
  |  |  518|      0|#define CKK_EC_EDWARDS 0x00000040UL
  ------------------
              	} else if (keytype == CKK_EC || keytype == CKK_EC_EDWARDS || keytype == CKK_EC_MONTGOMERY) {
  ------------------
  |  |  519|      0|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
  |  Branch (3408:13): [True: 0, False: 0]
  |  Branch (3408:34): [True: 0, False: 0]
  |  Branch (3408:63): [True: 0, False: 0]
  ------------------
 3409|      0|		struct sc_lv_data *der = &keygen_args.prkey_args.key.u.ec.params.der;
 3410|      0|		void *ptr = NULL;
 3411|       |
 3412|      0|		rv = attr_find_and_allocate_ptr(pPubTpl, ulPubCnt, CKA_EC_PARAMS, &ptr, &der->len);
  ------------------
  |  |  200|      0|#define CKA_EC_PARAMS 0x00000180UL
  ------------------
 3413|      0|		der->value = (unsigned char *) ptr;
 3414|      0|		if (rv != CKR_OK)   {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3414:7): [True: 0, False: 0]
  ------------------
 3415|      0|			sc_unlock(p11card->card);
 3416|      0|			return rv;
 3417|      0|		}
 3418|      0|		if (sc_pkcs15_fix_ec_parameters(context, &keygen_args.prkey_args.key.u.ec.params) < 0) {
  ------------------
  |  Branch (3418:7): [True: 0, False: 0]
  ------------------
 3419|      0|			rv = CKR_CURVE_NOT_SUPPORTED;
  ------------------
  |  | 1164|      0|#define CKR_CURVE_NOT_SUPPORTED 0x00000140UL
  ------------------
 3420|      0|			goto kpgen_done;
 3421|      0|		}
 3422|      0|	} else {
 3423|       |		/* CKA_KEY_TYPE is set, but keytype isn't correct */
 3424|      0|		rv = CKR_ATTRIBUTE_VALUE_INVALID;
  ------------------
  |  | 1099|      0|#define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013UL
  ------------------
 3425|      0|		goto kpgen_done;
 3426|      0|	}
 3427|       |
 3428|      0|	if (keytype == CKK_EC) {
  ------------------
  |  |  467|      0|#define CKK_EC 0x00000003UL
  ------------------
  |  Branch (3428:6): [True: 0, False: 0]
  ------------------
 3429|      0|		keygen_args.prkey_args.key.algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
 3430|      0|	} else if (keytype == CKK_EC_EDWARDS) {
  ------------------
  |  |  518|      0|#define CKK_EC_EDWARDS 0x00000040UL
  ------------------
  |  Branch (3430:13): [True: 0, False: 0]
  ------------------
 3431|      0|		keygen_args.prkey_args.key.algorithm = SC_ALGORITHM_EDDSA;
  ------------------
  |  |   72|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
 3432|      0|	} else if (keytype == CKK_EC_MONTGOMERY) {
  ------------------
  |  |  519|      0|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
  |  Branch (3432:13): [True: 0, False: 0]
  ------------------
 3433|      0|		keygen_args.prkey_args.key.algorithm = SC_ALGORITHM_XEDDSA;
  ------------------
  |  |   73|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
 3434|      0|	}
 3435|       |
 3436|      0|	id.len = SC_PKCS15_MAX_ID_SIZE;
  ------------------
  |  |   36|      0|#define SC_PKCS15_MAX_ID_SIZE		255
  ------------------
 3437|      0|	rv = attr_find2(pPubTpl, ulPubCnt, pPrivTpl, ulPrivCnt,	CKA_ID, &id.value, &id.len);
  ------------------
  |  |  161|      0|#define CKA_ID 0x00000102UL
  ------------------
 3438|      0|	if (rv == CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3438:6): [True: 0, False: 0]
  ------------------
 3439|      0|		keygen_args.prkey_args.id = id;
 3440|       |
 3441|      0|	len = sizeof(priv_label) - 1;
 3442|      0|	rv = attr_find(pPrivTpl, ulPrivCnt, CKA_LABEL, priv_label, &len);
  ------------------
  |  |  140|      0|#define CKA_LABEL 0x00000003UL
  ------------------
 3443|      0|	if (rv == CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3443:6): [True: 0, False: 0]
  ------------------
 3444|      0|		priv_label[len] = '\0';
 3445|      0|		keygen_args.prkey_args.label = priv_label;
 3446|      0|	}
 3447|      0|	len = sizeof(pub_label) - 1;
 3448|      0|	rv = attr_find(pPubTpl, ulPubCnt, CKA_LABEL, pub_label, &len);
  ------------------
  |  |  140|      0|#define CKA_LABEL 0x00000003UL
  ------------------
 3449|      0|	if (rv == CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3449:6): [True: 0, False: 0]
  ------------------
 3450|      0|		pub_label[len] = '\0';
 3451|      0|		keygen_args.pubkey_label = pub_label;
 3452|      0|	}
 3453|       |
 3454|      0|	rv = get_usage_privk(pPrivTpl, ulPrivCnt, &keygen_args.prkey_args.x509_usage, &keygen_args.prkey_args.usage);
 3455|      0|	if (rv == CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3455:6): [True: 0, False: 0]
  ------------------
 3456|      0|		rv = get_usage_pubk(pPubTpl, ulPubCnt, &keygen_args.prkey_args.x509_usage, &keygen_args.pubkey_usage);
 3457|      0|	if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (3457:6): [True: 0, False: 0]
  ------------------
 3458|      0|		goto kpgen_done;
 3459|       |
 3460|      0|	len = sizeof(always_auth);
 3461|      0|	rv = attr_find(pPrivTpl, ulPrivCnt, CKA_ALWAYS_AUTHENTICATE, &always_auth, &len);
  ------------------
  |  |  202|      0|#define CKA_ALWAYS_AUTHENTICATE 0x00000202UL
  ------------------
 3462|      0|	if (rv == CKR_OK && always_auth == CK_TRUE) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
              	if (rv == CKR_OK && always_auth == CK_TRUE) {
  ------------------
  |  |   34|      0|#define CK_TRUE 1
  ------------------
  |  Branch (3462:6): [True: 0, False: 0]
  |  Branch (3462:22): [True: 0, False: 0]
  ------------------
 3463|      0|		keygen_args.prkey_args.user_consent = 1;
 3464|      0|	}
 3465|       |
 3466|       |	/* set EXTRACTABLE and SENSITIVESE flags */
 3467|      0|	len = sizeof(extractable);
 3468|      0|	rv = attr_find(pPrivTpl, ulPrivCnt, CKA_EXTRACTABLE, &extractable, &len);
  ------------------
  |  |  192|      0|#define CKA_EXTRACTABLE 0x00000162UL
  ------------------
 3469|      0|	if (rv == CKR_OK && extractable == CK_TRUE)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
              	if (rv == CKR_OK && extractable == CK_TRUE)
  ------------------
  |  |   34|      0|#define CK_TRUE 1
  ------------------
  |  Branch (3469:6): [True: 0, False: 0]
  |  Branch (3469:22): [True: 0, False: 0]
  ------------------
 3470|      0|		keygen_args.prkey_args.access_flags |= SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE;
  ------------------
  |  |  317|      0|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
 3471|      0|	else
 3472|      0|		keygen_args.prkey_args.access_flags |= SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE;
  ------------------
  |  |  319|      0|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
 3473|       |
 3474|      0|	len = sizeof(sensitive);
 3475|      0|	rv = attr_find(pPrivTpl, ulPrivCnt, CKA_SENSITIVE, &sensitive, &len);
  ------------------
  |  |  162|      0|#define CKA_SENSITIVE 0x00000103UL
  ------------------
 3476|      0|	if (rv == CKR_OK && sensitive == CK_TRUE) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
              	if (rv == CKR_OK && sensitive == CK_TRUE) {
  ------------------
  |  |   34|      0|#define CK_TRUE 1
  ------------------
  |  Branch (3476:6): [True: 0, False: 0]
  |  Branch (3476:22): [True: 0, False: 0]
  ------------------
 3477|      0|		keygen_args.prkey_args.access_flags |= SC_PKCS15_PRKEY_ACCESS_SENSITIVE;
  ------------------
  |  |  316|      0|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
 3478|      0|		keygen_args.prkey_args.access_flags |= SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE;
  ------------------
  |  |  318|      0|#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE	0x04
  ------------------
 3479|      0|	}
 3480|       |
 3481|       |	/* This is called form C_GenerateKey, key is alwways LOCAL (PKCS#11 v3.0 section 4.7.2) */
 3482|      0|	keygen_args.prkey_args.access_flags |= SC_PKCS15_PRKEY_ACCESS_LOCAL;
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
 3483|       |
 3484|       |	/* 3.a Try on-card key pair generation */
 3485|       |
 3486|      0|	sc_pkcs15init_set_p15card(profile, fw_data->p15_card);
 3487|       |
 3488|      0|	sc_log(context, "Try on-card key pair generation");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3489|      0|	rc = sc_pkcs15init_generate_key(fw_data->p15_card, profile, &keygen_args, (unsigned int) keybits, &priv_key_obj);
 3490|      0|	if (rc >= 0) {
  ------------------
  |  Branch (3490:6): [True: 0, False: 0]
  ------------------
 3491|      0|		id = ((struct sc_pkcs15_prkey_info *) priv_key_obj->data)->id;
 3492|      0|		rc = sc_pkcs15_find_pubkey_by_id(fw_data->p15_card, &id, &pub_key_obj);
 3493|      0|		if (rc != 0) {
  ------------------
  |  Branch (3493:7): [True: 0, False: 0]
  ------------------
 3494|      0|			sc_log(context, "sc_pkcs15_find_pubkey_by_id returned %d", rc);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3495|      0|			rv = sc_to_cryptoki_error(rc, "C_GenerateKeyPair");
 3496|      0|			goto kpgen_done;
 3497|      0|		}
 3498|      0|	}
 3499|      0|	else {
 3500|      0|		sc_log(context, "sc_pkcs15init_generate_key returned %d", rc);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3501|      0|		rv = sc_to_cryptoki_error(rc, "C_GenerateKeyPair");
 3502|      0|		goto kpgen_done;
 3503|      0|	}
 3504|       |
 3505|       |	/* 4. Create new pkcs11 public and private key object */
 3506|       |
 3507|      0|	rc = __pkcs15_create_prkey_object(fw_data, priv_key_obj, &priv_any_obj);
 3508|      0|	if (rc == 0)
  ------------------
  |  Branch (3508:6): [True: 0, False: 0]
  ------------------
 3509|      0|		rc = __pkcs15_create_pubkey_object(fw_data, pub_key_obj, &pub_any_obj);
 3510|      0|	if (rc != 0) {
  ------------------
  |  Branch (3510:6): [True: 0, False: 0]
  ------------------
 3511|      0|		sc_log(context, "__pkcs15_create_pr/pubkey_object returned %d", rc);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3512|      0|		rv = sc_to_cryptoki_error(rc, "C_GenerateKeyPair");
 3513|      0|		goto kpgen_done;
 3514|      0|	}
 3515|      0|	pkcs15_add_object(slot, priv_any_obj, phPrivKey);
 3516|      0|	pkcs15_add_object(slot, pub_any_obj, phPubKey);
 3517|       |
 3518|      0|	priv_prk_obj = (struct pkcs15_prkey_object *) priv_any_obj;
 3519|       |
 3520|      0|	priv_prk_obj->prv_pubkey = (struct pkcs15_pubkey_object *)pub_any_obj;
  ------------------
  |  |  106|      0|#define prv_pubkey		base.related_pubkey
  ------------------
 3521|       |
 3522|       |	/* Duplicate public key so that parameters can be retrieved even if public key object is deleted */
 3523|      0|	rv = sc_pkcs15_dup_pubkey(context, ((struct pkcs15_pubkey_object *)pub_any_obj)->pub_data, &priv_prk_obj->pub_data);
 3524|       |
 3525|      0|kpgen_done:
 3526|      0|	sc_pkcs15_erase_prkey(&keygen_args.prkey_args.key);
 3527|      0|	sc_pkcs15init_unbind(profile);
 3528|      0|	sc_unlock(p11card->card);
 3529|       |
 3530|      0|	return rv;
 3531|      0|}
framework-pkcs15.c:pkcs15_get_random:
 3673|  7.86k|{
 3674|  7.86k|	struct sc_pkcs11_card *p11card = slot->p11card;
 3675|  7.86k|	struct pkcs15_fw_data *fw_data = NULL;
 3676|  7.86k|	int rc;
 3677|       |
 3678|  7.86k|	if (!p11card)
  ------------------
  |  Branch (3678:6): [True: 0, False: 7.86k]
  ------------------
 3679|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GenerateRandom");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3680|  7.86k|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[slot->fw_data_idx];
 3681|  7.86k|	if (!fw_data)
  ------------------
  |  Branch (3681:6): [True: 0, False: 7.86k]
  ------------------
 3682|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GenerateRandom");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3683|  7.86k|	if (!fw_data->p15_card)
  ------------------
  |  Branch (3683:6): [True: 4.60k, False: 3.25k]
  ------------------
 3684|  4.60k|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GenerateRandom");
  ------------------
  |  |   60|  4.60k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3685|       |
 3686|  3.25k|	rc = sc_get_challenge(fw_data->p15_card->card, p, (size_t)len);
 3687|  3.25k|	return sc_to_cryptoki_error(rc, "C_GenerateRandom");
 3688|  7.86k|}
framework-pkcs15.c:pkcs15_cert_release:
 3805|  2.69k|{
 3806|  2.69k|	struct pkcs15_cert_object *cert = (struct pkcs15_cert_object *) obj;
 3807|  2.69k|	struct sc_pkcs15_cert      *cert_data = cert->cert_data;
 3808|       |
 3809|  2.69k|	if (__pkcs15_release_object((struct pkcs15_any_object *) obj) == 0)
  ------------------
  |  Branch (3809:6): [True: 1.34k, False: 1.34k]
  ------------------
 3810|  1.34k|		if (cert_data) /* may never have been read */
  ------------------
  |  Branch (3810:7): [True: 1.13k, False: 215]
  ------------------
 3811|  1.13k|			sc_pkcs15_free_certificate(cert_data);
 3812|  2.69k|}
framework-pkcs15.c:pkcs15_cert_get_attribute:
 3825|  6.74k|{
 3826|  6.74k|	struct sc_pkcs11_card *p11card = NULL;
 3827|  6.74k|	struct pkcs15_cert_object *cert = (struct pkcs15_cert_object*) object;
 3828|  6.74k|	struct pkcs15_fw_data *fw_data = NULL;
 3829|  6.74k|	size_t len;
 3830|       |
 3831|  6.74k|	sc_log(context, "pkcs15_cert_get_attribute() called");
  ------------------
  |  |   71|  6.74k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3832|  6.74k|	p11card = session->slot->p11card;
 3833|  6.74k|	if (!p11card)
  ------------------
  |  Branch (3833:6): [True: 0, False: 6.74k]
  ------------------
 3834|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GetAttributeValue");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3835|  6.74k|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[session->slot->fw_data_idx];
 3836|  6.74k|	if (!fw_data)
  ------------------
  |  Branch (3836:6): [True: 0, False: 6.74k]
  ------------------
 3837|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetAttributeValue");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3838|  6.74k|	if (!fw_data->p15_card)
  ------------------
  |  Branch (3838:6): [True: 0, False: 6.74k]
  ------------------
 3839|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GetAttributeValue");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3840|       |
 3841|  6.74k|	switch (attr->type) {
 3842|  3.62k|	case CKA_CLASS:
  ------------------
  |  |  137|  3.62k|#define CKA_CLASS 0x00000000UL
  ------------------
  |  Branch (3842:2): [True: 3.62k, False: 3.11k]
  ------------------
 3843|  3.62k|		check_attribute_buffer(attr, sizeof(CK_OBJECT_CLASS));
  ------------------
  |  |   56|  3.62k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  7.24k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 1.81k, False: 1.81k]
  |  |  ------------------
  |  |   57|  1.81k|		attr->ulValueLen = size;        \
  |  |   58|  1.81k|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|  1.81k|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|  1.81k|	}                                       \
  |  |   60|  3.62k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 1.81k]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|  1.81k|	attr->ulValueLen = size;
  ------------------
 3844|  1.81k|		*(CK_OBJECT_CLASS*)attr->pValue = CKO_CERTIFICATE;
  ------------------
  |  | 1028|  1.81k|#define CKO_CERTIFICATE 0x00000001UL
  ------------------
 3845|  1.81k|		break;
 3846|      0|	case CKA_TOKEN:
  ------------------
  |  |  138|      0|#define CKA_TOKEN 0x00000001UL
  ------------------
  |  Branch (3846:2): [True: 0, False: 6.74k]
  ------------------
 3847|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 3848|      0|		*(CK_BBOOL*)attr->pValue = TRUE;
  ------------------
  |  |   51|      0|#define TRUE 1
  ------------------
 3849|      0|		break;
 3850|  1.69k|	case CKA_PRIVATE:
  ------------------
  |  |  139|  1.69k|#define CKA_PRIVATE 0x00000002UL
  ------------------
  |  Branch (3850:2): [True: 1.69k, False: 5.05k]
  ------------------
 3851|  1.69k|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|  1.69k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  3.38k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 1.69k]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|  1.69k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 1.69k]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|  1.69k|	attr->ulValueLen = size;
  ------------------
 3852|  1.69k|		*(CK_BBOOL*)attr->pValue = (cert->base.p15_object->flags & SC_PKCS15_CO_FLAG_PRIVATE) != 0;
  ------------------
  |  |   50|  1.69k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 3853|  1.69k|		break;
 3854|      0|	case CKA_MODIFIABLE:
  ------------------
  |  |  197|      0|#define CKA_MODIFIABLE 0x00000170UL
  ------------------
  |  Branch (3854:2): [True: 0, False: 6.74k]
  ------------------
 3855|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 3856|      0|		*(CK_BBOOL*)attr->pValue = FALSE;
  ------------------
  |  |   48|      0|#define FALSE 0
  ------------------
 3857|      0|		break;
 3858|      0|	case CKA_LABEL:
  ------------------
  |  |  140|      0|#define CKA_LABEL 0x00000003UL
  ------------------
  |  Branch (3858:2): [True: 0, False: 6.74k]
  ------------------
 3859|      0|		if (check_cert_data_read(fw_data, cert) != 0) {
  ------------------
  |  Branch (3859:7): [True: 0, False: 0]
  ------------------
 3860|      0|			attr->ulValueLen = 0;
 3861|      0|			return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 3862|      0|		}
 3863|      0|		len = strnlen(cert->cert_p15obj->label, sizeof cert->cert_p15obj->label);
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
              		len = strnlen(cert->cert_p15obj->label, sizeof cert->cert_p15obj->label);
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
 3864|      0|		check_attribute_buffer(attr, len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 3865|      0|		memcpy(attr->pValue, cert->cert_p15obj->label, len);
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
 3866|      0|		break;
 3867|      0|	case CKA_CERTIFICATE_TYPE:
  ------------------
  |  |  145|      0|#define CKA_CERTIFICATE_TYPE 0x00000080UL
  ------------------
  |  Branch (3867:2): [True: 0, False: 6.74k]
  ------------------
 3868|      0|		check_attribute_buffer(attr, sizeof(CK_CERTIFICATE_TYPE));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 3869|      0|		*(CK_CERTIFICATE_TYPE*)attr->pValue = CKC_X_509;
  ------------------
  |  |  303|      0|#define CKC_X_509 0x00000000UL
  ------------------
 3870|      0|		break;
 3871|  1.42k|	case CKA_ID:
  ------------------
  |  |  161|  1.42k|#define CKA_ID 0x00000102UL
  ------------------
  |  Branch (3871:2): [True: 1.42k, False: 5.31k]
  ------------------
 3872|       |#ifdef ZERO_CKAID_FOR_CA_CERTS
 3873|       |		if (cert->cert_info->authority) {
 3874|       |			check_attribute_buffer(attr, 1);
 3875|       |			*(unsigned char*)attr->pValue = 0;
 3876|       |			break;
 3877|       |		}
 3878|       |#endif
 3879|  1.42k|		check_attribute_buffer(attr, cert->cert_info->id.len);
  ------------------
  |  |   56|  1.42k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  2.85k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 728, False: 699]
  |  |  ------------------
  |  |   57|    728|		attr->ulValueLen = size;        \
  |  |   58|    728|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|    728|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|    728|	}                                       \
  |  |   60|  1.42k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 699]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|    699|	attr->ulValueLen = size;
  ------------------
 3880|    699|		memcpy(attr->pValue, cert->cert_info->id.value, cert->cert_info->id.len);
 3881|    699|		break;
 3882|      0|	case CKA_TRUSTED:
  ------------------
  |  |  151|      0|#define CKA_TRUSTED 0x00000086UL
  ------------------
  |  Branch (3882:2): [True: 0, False: 6.74k]
  ------------------
 3883|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 3884|      0|		*(CK_BBOOL*)attr->pValue = cert->cert_info->authority ? TRUE : FALSE;
  ------------------
  |  |   51|      0|#define TRUE 1
  ------------------
              		*(CK_BBOOL*)attr->pValue = cert->cert_info->authority ? TRUE : FALSE;
  ------------------
  |  |   48|      0|#define FALSE 0
  ------------------
  |  Branch (3884:30): [True: 0, False: 0]
  ------------------
 3885|      0|		break;
 3886|      0|	case CKA_VALUE:
  ------------------
  |  |  143|      0|#define CKA_VALUE 0x00000011UL
  ------------------
  |  Branch (3886:2): [True: 0, False: 6.74k]
  ------------------
 3887|      0|		if (check_cert_data_read(fw_data, cert) != 0) {
  ------------------
  |  Branch (3887:7): [True: 0, False: 0]
  ------------------
 3888|      0|			attr->ulValueLen = 0;
 3889|      0|			return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 3890|      0|		}
 3891|      0|		check_attribute_buffer(attr, cert->cert_data->data.len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 3892|      0|		memcpy(attr->pValue, cert->cert_data->data.value, cert->cert_data->data.len);
 3893|      0|		break;
 3894|      0|	case CKA_SERIAL_NUMBER:
  ------------------
  |  |  147|      0|#define CKA_SERIAL_NUMBER 0x00000082UL
  ------------------
  |  Branch (3894:2): [True: 0, False: 6.74k]
  ------------------
 3895|      0|		if (check_cert_data_read(fw_data, cert) != 0) {
  ------------------
  |  Branch (3895:7): [True: 0, False: 0]
  ------------------
 3896|      0|			attr->ulValueLen = 0;
 3897|      0|			return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 3898|      0|		}
 3899|      0|		check_attribute_buffer(attr, cert->cert_data->serial_len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 3900|      0|		memcpy(attr->pValue, cert->cert_data->serial, cert->cert_data->serial_len);
 3901|      0|		break;
 3902|      0|	case CKA_SUBJECT:
  ------------------
  |  |  160|      0|#define CKA_SUBJECT 0x00000101UL
  ------------------
  |  Branch (3902:2): [True: 0, False: 6.74k]
  ------------------
 3903|      0|		if (check_cert_data_read(fw_data, cert) != 0) {
  ------------------
  |  Branch (3903:7): [True: 0, False: 0]
  ------------------
 3904|      0|			attr->ulValueLen = 0;
 3905|      0|			return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 3906|      0|		}
 3907|      0|		check_attribute_buffer(attr, cert->cert_data->subject_len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 3908|      0|		memcpy(attr->pValue, cert->cert_data->subject, cert->cert_data->subject_len);
 3909|      0|		return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 3910|      0|	case CKA_ISSUER:
  ------------------
  |  |  146|      0|#define CKA_ISSUER 0x00000081UL
  ------------------
  |  Branch (3910:2): [True: 0, False: 6.74k]
  ------------------
 3911|      0|		if (check_cert_data_read(fw_data, cert) != 0) {
  ------------------
  |  Branch (3911:7): [True: 0, False: 0]
  ------------------
 3912|      0|			attr->ulValueLen = 0;
 3913|      0|			return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 3914|      0|		}
 3915|      0|		check_attribute_buffer(attr, cert->cert_data->issuer_len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 3916|      0|		memcpy(attr->pValue, cert->cert_data->issuer, cert->cert_data->issuer_len);
 3917|      0|		return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 3918|      0|	default:
  ------------------
  |  Branch (3918:2): [True: 0, False: 6.74k]
  ------------------
 3919|      0|		return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 3920|  6.74k|	}
 3921|       |
 3922|  4.20k|	return CKR_OK;
  ------------------
  |  | 1086|  4.20k|#define CKR_OK 0x00000000UL
  ------------------
 3923|  6.74k|}
framework-pkcs15.c:check_cert_data_read:
  982|      5|{
  983|      5|	struct pkcs15_pubkey_object *obj2;
  984|      5|	int rv;
  985|      5|	int private_obj;
  986|       |
  987|      5|	if (!cert)
  ------------------
  |  Branch (987:6): [True: 1, False: 4]
  ------------------
  988|      1|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      1|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  989|       |
  990|      4|	if (cert->cert_data)
  ------------------
  |  Branch (990:6): [True: 1, False: 3]
  ------------------
  991|      1|		return 0;
  992|      3|	private_obj = cert->cert_flags & SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   92|      3|#define cert_flags		base.base.flags
  ------------------
              	private_obj = cert->cert_flags & SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      3|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  993|      3|	rv = sc_pkcs15_read_certificate(fw_data->p15_card, cert->cert_info, private_obj, &cert->cert_data);
  994|      3|	if (rv < 0)
  ------------------
  |  Branch (994:6): [True: 3, False: 0]
  ------------------
  995|      3|		return rv;
  996|       |
  997|      0|	obj2 = cert->cert_pubkey;
  ------------------
  |  |   94|      0|#define cert_pubkey		base.related_pubkey
  ------------------
  998|       |	/* make a copy of public key from the cert data */
  999|      0|	if (!obj2->pub_data)
  ------------------
  |  Branch (999:6): [True: 0, False: 0]
  ------------------
 1000|      0|		rv = sc_pkcs15_pubkey_from_cert(context, &cert->cert_data->data, &obj2->pub_data);
 1001|       |
 1002|       |	/* Find missing labels for certificate */
 1003|      0|	pkcs15_cert_extract_label(cert);
 1004|       |
 1005|       |	/* now that we have the cert and pub key, lets see if we can bind anything else */
 1006|      0|	pkcs15_bind_related_objects(fw_data);
 1007|       |
 1008|      0|	return rv;
 1009|      3|}
framework-pkcs15.c:pkcs15_cert_cmp_attribute:
 3931|  2.54k|{
 3932|  2.54k|	struct pkcs15_cert_object *cert = (struct pkcs15_cert_object*) object;
 3933|  2.54k|	struct sc_pkcs11_card *p11card = session->slot->p11card;
 3934|  2.54k|	struct pkcs15_fw_data *fw_data = NULL;
 3935|  2.54k|	const unsigned char *data = NULL, *_data = NULL;
 3936|  2.54k|	size_t	len, _len;
 3937|       |
 3938|  2.54k|	sc_log(context, "pkcs15_cert_cmp_attribute() called");
  ------------------
  |  |   71|  2.54k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3939|  2.54k|	if (!p11card)
  ------------------
  |  Branch (3939:6): [True: 0, False: 2.54k]
  ------------------
 3940|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GetAttributeValue");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3941|  2.54k|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[session->slot->fw_data_idx];
 3942|  2.54k|	if (!fw_data)   {
  ------------------
  |  Branch (3942:6): [True: 0, False: 2.54k]
  ------------------
 3943|      0|		sc_log(context, "pkcs15_cert_cmp_attribute() returns SC_ERROR_INTERNAL");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3944|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetAttributeValue");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3945|      0|	}
 3946|  2.54k|	if (!fw_data->p15_card)
  ------------------
  |  Branch (3946:6): [True: 0, False: 2.54k]
  ------------------
 3947|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GetAttributeValue");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 3948|       |
 3949|  2.54k|	switch (attr->type) {
 3950|       |	/* Check the issuer/subject. Some pkcs11 callers (i.e. netscape) will pass
 3951|       |	 * in the ASN.1 encoded SEQUENCE OF SET,
 3952|       |	 * while OpenSC just keeps the SET in the issuer/subject field. */
 3953|      0|	case CKA_ISSUER:
  ------------------
  |  |  146|      0|#define CKA_ISSUER 0x00000081UL
  ------------------
  |  Branch (3953:2): [True: 0, False: 2.54k]
  ------------------
 3954|      0|		if (check_cert_data_read(fw_data, cert) != 0)
  ------------------
  |  Branch (3954:7): [True: 0, False: 0]
  ------------------
 3955|      0|			break;
 3956|      0|		if (cert->cert_data->issuer_len == 0)
  ------------------
  |  Branch (3956:7): [True: 0, False: 0]
  ------------------
 3957|      0|			break;
 3958|       |
 3959|      0|		data = _data = (u8 *) attr->pValue;
 3960|      0|		len = _len = attr->ulValueLen;
 3961|      0|		if (cert->cert_data->issuer[0] == ASN1_SET_TAG && data[0] == ASN1_SEQ_TAG && len >= 2)
  ------------------
  |  | 3926|      0|#define ASN1_SET_TAG (SC_ASN1_SET | SC_ASN1_TAG_CONSTRUCTED)
  |  |  ------------------
  |  |  |  |  163|      0|#define SC_ASN1_SET                     17
  |  |  ------------------
  |  |               #define ASN1_SET_TAG (SC_ASN1_SET | SC_ASN1_TAG_CONSTRUCTED)
  |  |  ------------------
  |  |  |  |  190|      0|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  |  |  ------------------
  ------------------
              		if (cert->cert_data->issuer[0] == ASN1_SET_TAG && data[0] == ASN1_SEQ_TAG && len >= 2)
  ------------------
  |  | 3927|      0|#define ASN1_SEQ_TAG (SC_ASN1_SEQUENCE | SC_ASN1_TAG_CONSTRUCTED)
  |  |  ------------------
  |  |  |  |  162|      0|#define SC_ASN1_SEQUENCE                16
  |  |  ------------------
  |  |               #define ASN1_SEQ_TAG (SC_ASN1_SEQUENCE | SC_ASN1_TAG_CONSTRUCTED)
  |  |  ------------------
  |  |  |  |  190|      0|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  |  |  ------------------
  ------------------
  |  Branch (3961:7): [True: 0, False: 0]
  |  Branch (3961:53): [True: 0, False: 0]
  |  Branch (3961:80): [True: 0, False: 0]
  ------------------
 3962|      0|			data = sc_asn1_skip_tag(context, &_data, &_len, SC_ASN1_CONS | SC_ASN1_TAG_SEQUENCE, &len);
  ------------------
  |  |  141|      0|#define SC_ASN1_CONS			0x20000000
  ------------------
              			data = sc_asn1_skip_tag(context, &_data, &_len, SC_ASN1_CONS | SC_ASN1_TAG_SEQUENCE, &len);
  ------------------
  |  |  206|      0|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
 3963|       |
 3964|      0|		if (len == cert->cert_data->issuer_len && !memcmp(cert->cert_data->issuer, data, len))   {
  ------------------
  |  Branch (3964:7): [True: 0, False: 0]
  |  Branch (3964:45): [True: 0, False: 0]
  ------------------
 3965|      0|			sc_log(context, "pkcs15_cert_cmp_attribute() returns CKA_ISSUER matched");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3966|      0|			return 1;
 3967|      0|		}
 3968|      0|		break;
 3969|      0|	case CKA_SUBJECT:
  ------------------
  |  |  160|      0|#define CKA_SUBJECT 0x00000101UL
  ------------------
  |  Branch (3969:2): [True: 0, False: 2.54k]
  ------------------
 3970|      0|		if (check_cert_data_read(fw_data, cert) != 0)
  ------------------
  |  Branch (3970:7): [True: 0, False: 0]
  ------------------
 3971|      0|			break;
 3972|      0|		if (cert->cert_data->subject_len == 0)
  ------------------
  |  Branch (3972:7): [True: 0, False: 0]
  ------------------
 3973|      0|			break;
 3974|       |
 3975|      0|		data = _data = (u8 *) attr->pValue;
 3976|      0|		len = _len = attr->ulValueLen;
 3977|      0|		if (cert->cert_data->subject[0] == ASN1_SET_TAG && data[0] == ASN1_SEQ_TAG && len >= 2)
  ------------------
  |  | 3926|      0|#define ASN1_SET_TAG (SC_ASN1_SET | SC_ASN1_TAG_CONSTRUCTED)
  |  |  ------------------
  |  |  |  |  163|      0|#define SC_ASN1_SET                     17
  |  |  ------------------
  |  |               #define ASN1_SET_TAG (SC_ASN1_SET | SC_ASN1_TAG_CONSTRUCTED)
  |  |  ------------------
  |  |  |  |  190|      0|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  |  |  ------------------
  ------------------
              		if (cert->cert_data->subject[0] == ASN1_SET_TAG && data[0] == ASN1_SEQ_TAG && len >= 2)
  ------------------
  |  | 3927|      0|#define ASN1_SEQ_TAG (SC_ASN1_SEQUENCE | SC_ASN1_TAG_CONSTRUCTED)
  |  |  ------------------
  |  |  |  |  162|      0|#define SC_ASN1_SEQUENCE                16
  |  |  ------------------
  |  |               #define ASN1_SEQ_TAG (SC_ASN1_SEQUENCE | SC_ASN1_TAG_CONSTRUCTED)
  |  |  ------------------
  |  |  |  |  190|      0|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  |  |  ------------------
  ------------------
  |  Branch (3977:7): [True: 0, False: 0]
  |  Branch (3977:54): [True: 0, False: 0]
  |  Branch (3977:81): [True: 0, False: 0]
  ------------------
 3978|      0|			data = sc_asn1_skip_tag(context, &_data, &_len, SC_ASN1_CONS | SC_ASN1_TAG_SEQUENCE, &len);
  ------------------
  |  |  141|      0|#define SC_ASN1_CONS			0x20000000
  ------------------
              			data = sc_asn1_skip_tag(context, &_data, &_len, SC_ASN1_CONS | SC_ASN1_TAG_SEQUENCE, &len);
  ------------------
  |  |  206|      0|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
 3979|       |
 3980|      0|		if (len == cert->cert_data->subject_len && !memcmp(cert->cert_data->subject, data, len))   {
  ------------------
  |  Branch (3980:7): [True: 0, False: 0]
  |  Branch (3980:46): [True: 0, False: 0]
  ------------------
 3981|      0|			sc_log(context, "pkcs15_cert_cmp_attribute() returns CKA_SUBJECT matched");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3982|      0|			return 1;
 3983|      0|		}
 3984|      0|		break;
 3985|  2.54k|	default:
  ------------------
  |  Branch (3985:2): [True: 2.54k, False: 0]
  ------------------
 3986|  2.54k|		return sc_pkcs11_any_cmp_attribute(session, object, attr);
 3987|  2.54k|	}
 3988|      0|	sc_log(context, "pkcs15_cert_cmp_attribute() returns not matched");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3989|      0|	return 0;
 3990|  2.54k|}
framework-pkcs15.c:pkcs15_prkey_release:
 4013|  6.46k|{
 4014|  6.46k|	struct pkcs15_prkey_object *prkey = (struct pkcs15_prkey_object*) object;
 4015|  6.46k|	struct sc_pkcs15_pubkey *key_data = prkey->pub_data;
 4016|       |
 4017|  6.46k|	if (__pkcs15_release_object((struct pkcs15_any_object *) object) == 0)
  ------------------
  |  Branch (4017:6): [True: 3.63k, False: 2.83k]
  ------------------
 4018|  3.63k|		if (key_data)
  ------------------
  |  Branch (4018:7): [True: 1.10k, False: 2.53k]
  ------------------
 4019|  1.10k|			sc_pkcs15_free_pubkey(key_data);
 4020|  6.46k|}
framework-pkcs15.c:pkcs15_prkey_get_attribute:
 4034|  6.42k|{
 4035|  6.42k|	struct pkcs15_prkey_object *prkey = (struct pkcs15_prkey_object*) object;
 4036|  6.42k|	struct sc_pkcs11_card *p11card = NULL;
 4037|  6.42k|	struct pkcs15_fw_data *fw_data = NULL;
 4038|  6.42k|	struct sc_pkcs15_pubkey *key = NULL;
 4039|  6.42k|	unsigned int usage;
 4040|  6.42k|	size_t len;
 4041|       |
 4042|  6.42k|	sc_log(context, "pkcs15_prkey_get_attribute() called");
  ------------------
  |  |   71|  6.42k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4043|  6.42k|	p11card = session->slot->p11card;
 4044|  6.42k|	if (!p11card)
  ------------------
  |  Branch (4044:6): [True: 0, False: 6.42k]
  ------------------
 4045|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GetAttributeValue");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 4046|  6.42k|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[session->slot->fw_data_idx];
 4047|  6.42k|	if (!fw_data)
  ------------------
  |  Branch (4047:6): [True: 0, False: 6.42k]
  ------------------
 4048|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetAttributeValue");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4049|  6.42k|	if (!fw_data->p15_card)
  ------------------
  |  Branch (4049:6): [True: 0, False: 6.42k]
  ------------------
 4050|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GetAttributeValue");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 4051|       |
 4052|       |	/* PKCS#11 requires us to supply CKA_MODULUS for private keys,
 4053|       |	 * although that is not generally available from a smart card
 4054|       |	 * (the key is supposed to be safely locked away after all).
 4055|       |	 *
 4056|       |	 * To work around this, we hope that we either have an associated
 4057|       |	 * public key, or we try to find a certificate with the
 4058|       |	 * corresponding public key.
 4059|       |	 *
 4060|       |	 * Note: We do the same thing for CKA_PUBLIC_EXPONENT as some
 4061|       |	 *       applications assume they can get that from the private
 4062|       |	 *       key, something PKCS#11 doesn't guarantee.
 4063|       |	 */
 4064|  6.42k|	if ((attr->type == CKA_MODULUS) || (attr->type == CKA_PUBLIC_EXPONENT) ||
  ------------------
  |  |  174|  6.42k|#define CKA_MODULUS 0x00000120UL
  ------------------
              	if ((attr->type == CKA_MODULUS) || (attr->type == CKA_PUBLIC_EXPONENT) ||
  ------------------
  |  |  176|  6.42k|#define CKA_PUBLIC_EXPONENT 0x00000122UL
  ------------------
  |  Branch (4064:6): [True: 0, False: 6.42k]
  |  Branch (4064:37): [True: 0, False: 6.42k]
  ------------------
 4065|  6.42k|		((attr->type == CKA_MODULUS_BITS) && (prkey->prv_p15obj->type == SC_PKCS15_TYPE_PRKEY_EC)) ||
  ------------------
  |  |  175|  6.42k|#define CKA_MODULUS_BITS 0x00000121UL
  ------------------
              		((attr->type == CKA_MODULUS_BITS) && (prkey->prv_p15obj->type == SC_PKCS15_TYPE_PRKEY_EC)) ||
  ------------------
  |  |  105|    245|#define prv_p15obj		base.p15_object
  ------------------
              		((attr->type == CKA_MODULUS_BITS) && (prkey->prv_p15obj->type == SC_PKCS15_TYPE_PRKEY_EC)) ||
  ------------------
  |  |  421|    245|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (4065:4): [True: 245, False: 6.17k]
  |  Branch (4065:40): [True: 32, False: 213]
  ------------------
 4066|  6.38k|		(attr->type == CKA_EC_PARAMS)) {
  ------------------
  |  |  200|  6.38k|#define CKA_EC_PARAMS 0x00000180UL
  ------------------
  |  Branch (4066:3): [True: 0, False: 6.38k]
  ------------------
 4067|       |		/* First see if we have an associated public key */
 4068|     32|		if (prkey->pub_data) {
  ------------------
  |  Branch (4068:7): [True: 31, False: 1]
  ------------------
 4069|     31|			key = prkey->pub_data;
 4070|     31|		} else {
 4071|       |			/* Try to find public key or certificate with the public key */
 4072|      1|			unsigned int i;
 4073|       |
 4074|     20|			for (i = 0; i < fw_data->num_objects; i++) {
  ------------------
  |  Branch (4074:16): [True: 19, False: 1]
  ------------------
 4075|     19|				struct pkcs15_any_object *obj = fw_data->objects[i];
 4076|     19|				struct pkcs15_cert_object *cert;
 4077|       |
 4078|     19|				if (is_cert(obj))   {
  ------------------
  |  |  122|     19|#define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  119|     19|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 19, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 19, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_cert(obj)		(__p15_type(obj) == SC_PKCS15_TYPE_CERT_X509)
  |  |  ------------------
  |  |  |  |  439|     19|#define SC_PKCS15_TYPE_CERT_X509		0x401
  |  |  ------------------
  |  |  |  Branch (122:23): [True: 1, False: 18]
  |  |  ------------------
  ------------------
 4079|      1|					cert = (struct pkcs15_cert_object*) obj;
 4080|       |
 4081|      1|					if (cert->cert_prvkey != prkey)
  ------------------
  |  |   96|      1|#define cert_prvkey		base.related_privkey
  ------------------
  |  Branch (4081:10): [True: 0, False: 1]
  ------------------
 4082|      0|						continue;
 4083|       |
 4084|      1|					if (check_cert_data_read(fw_data, cert) == 0)   {
  ------------------
  |  Branch (4084:10): [True: 1, False: 0]
  ------------------
 4085|      1|						key = cert->cert_pubkey->pub_data;
  ------------------
  |  |   94|      1|#define cert_pubkey		base.related_pubkey
  ------------------
 4086|      1|						sc_log(context, "found friend certificate's public key %p", key);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4087|      1|					}
 4088|      1|				}
 4089|     18|				else if (is_pubkey(obj)) {
  ------------------
  |  |  121|     18|#define is_pubkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY)
  |  |  ------------------
  |  |  |  |  119|     18|#define __p15_type(obj)		(((obj) && (obj)->p15_object)? ((obj)->p15_object->type) : (unsigned int)-1)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (119:28): [True: 18, False: 0]
  |  |  |  |  |  Branch (119:37): [True: 18, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define is_pubkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY)
  |  |  ------------------
  |  |  |  |  416|     18|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  |  |  ------------------
  |  |               #define is_pubkey(obj)		((__p15_type(obj) & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PUBKEY)
  |  |  ------------------
  |  |  |  |  425|     18|#define SC_PKCS15_TYPE_PUBKEY			0x200
  |  |  ------------------
  |  |  |  Branch (121:25): [True: 1, False: 17]
  |  |  ------------------
  ------------------
 4090|      1|					struct pkcs15_pubkey_object *pubkey = (struct pkcs15_pubkey_object *) obj;
 4091|       |
 4092|      1|					if (!pubkey->pub_data)
  ------------------
  |  Branch (4092:10): [True: 0, False: 1]
  ------------------
 4093|      0|						continue;
 4094|       |
 4095|      1|					if (sc_pkcs15_compare_id(&pubkey->pub_info->id, &prkey->prv_info->id))   {
  ------------------
  |  Branch (4095:10): [True: 1, False: 0]
  ------------------
 4096|      1|						prkey->prv_pubkey = pubkey;
  ------------------
  |  |  106|      1|#define prv_pubkey		base.related_pubkey
  ------------------
 4097|      1|						key = pubkey->pub_data;
 4098|      1|						sc_log(context, "found friend public key %p", key);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4099|      1|					}
 4100|      1|				}
 4101|     19|			}
 4102|      1|		}
 4103|     32|	}
 4104|       |
 4105|  6.42k|	switch (attr->type) {
 4106|  2.58k|	case CKA_CLASS:
  ------------------
  |  |  137|  2.58k|#define CKA_CLASS 0x00000000UL
  ------------------
  |  Branch (4106:2): [True: 2.58k, False: 3.84k]
  ------------------
 4107|  2.58k|		check_attribute_buffer(attr, sizeof(CK_OBJECT_CLASS));
  ------------------
  |  |   56|  2.58k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  5.16k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 1.29k, False: 1.29k]
  |  |  ------------------
  |  |   57|  1.29k|		attr->ulValueLen = size;        \
  |  |   58|  1.29k|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|  1.29k|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|  1.29k|	}                                       \
  |  |   60|  2.58k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 1.29k]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|  1.29k|	attr->ulValueLen = size;
  ------------------
 4108|  1.29k|		*(CK_OBJECT_CLASS*)attr->pValue = CKO_PRIVATE_KEY;
  ------------------
  |  | 1030|  1.29k|#define CKO_PRIVATE_KEY 0x00000003UL
  ------------------
 4109|  1.29k|		break;
 4110|      0|	case CKA_TOKEN:
  ------------------
  |  |  138|      0|#define CKA_TOKEN 0x00000001UL
  ------------------
  |  Branch (4110:2): [True: 0, False: 6.42k]
  ------------------
 4111|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4112|      0|		*(CK_BBOOL*)attr->pValue = TRUE;
  ------------------
  |  |   51|      0|#define TRUE 1
  ------------------
 4113|      0|		break;
 4114|      0|	case CKA_ALWAYS_SENSITIVE:
  ------------------
  |  |  195|      0|#define CKA_ALWAYS_SENSITIVE 0x00000165UL
  ------------------
  |  Branch (4114:2): [True: 0, False: 6.42k]
  ------------------
 4115|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4116|      0|		*(CK_BBOOL*)attr->pValue = (prkey->prv_info->access_flags & SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE) != 0;
  ------------------
  |  |  318|      0|#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE	0x04
  ------------------
 4117|      0|		break;
 4118|      0|	case CKA_NEVER_EXTRACTABLE:
  ------------------
  |  |  194|      0|#define CKA_NEVER_EXTRACTABLE 0x00000164UL
  ------------------
  |  Branch (4118:2): [True: 0, False: 6.42k]
  ------------------
 4119|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4120|      0|		*(CK_BBOOL*)attr->pValue = (prkey->prv_info->access_flags & SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE) != 0;
  ------------------
  |  |  319|      0|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
 4121|      0|		break;
 4122|      0|	case CKA_SENSITIVE:
  ------------------
  |  |  162|      0|#define CKA_SENSITIVE 0x00000103UL
  ------------------
  |  Branch (4122:2): [True: 0, False: 6.42k]
  ------------------
 4123|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4124|      0|		*(CK_BBOOL*)attr->pValue = (prkey->prv_info->access_flags & SC_PKCS15_PRKEY_ACCESS_SENSITIVE) != 0;
  ------------------
  |  |  316|      0|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
 4125|      0|		break;
 4126|      0|	case CKA_LOCAL:
  ------------------
  |  |  193|      0|#define CKA_LOCAL 0x00000163UL
  ------------------
  |  Branch (4126:2): [True: 0, False: 6.42k]
  ------------------
 4127|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4128|      0|		*(CK_BBOOL*)attr->pValue = (prkey->prv_info->access_flags & SC_PKCS15_PRKEY_ACCESS_LOCAL) != 0;
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
 4129|      0|		break;
 4130|      0|	case CKA_ALWAYS_AUTHENTICATE:
  ------------------
  |  |  202|      0|#define CKA_ALWAYS_AUTHENTICATE 0x00000202UL
  ------------------
  |  Branch (4130:2): [True: 0, False: 6.42k]
  ------------------
 4131|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4132|      0|		if (fw_data->p15_card->opts.pin_cache_ignore_user_consent) {
  ------------------
  |  Branch (4132:7): [True: 0, False: 0]
  ------------------
 4133|      0|			*(CK_BBOOL*)attr->pValue = CK_FALSE;
  ------------------
  |  |   35|      0|#define CK_FALSE 0
  ------------------
 4134|      0|		} else {
 4135|      0|			*(CK_BBOOL*)attr->pValue = prkey->prv_p15obj->user_consent >= 1 ? CK_TRUE : CK_FALSE;
  ------------------
  |  |  105|      0|#define prv_p15obj		base.p15_object
  ------------------
              			*(CK_BBOOL*)attr->pValue = prkey->prv_p15obj->user_consent >= 1 ? CK_TRUE : CK_FALSE;
  ------------------
  |  |   34|      0|#define CK_TRUE 1
  ------------------
              			*(CK_BBOOL*)attr->pValue = prkey->prv_p15obj->user_consent >= 1 ? CK_TRUE : CK_FALSE;
  ------------------
  |  |   35|      0|#define CK_FALSE 0
  ------------------
  |  Branch (4135:31): [True: 0, False: 0]
  ------------------
 4136|      0|		}
 4137|      0|		break;
 4138|  1.98k|	case CKA_PRIVATE:
  ------------------
  |  |  139|  1.98k|#define CKA_PRIVATE 0x00000002UL
  ------------------
  |  Branch (4138:2): [True: 1.98k, False: 4.43k]
  ------------------
 4139|  1.98k|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|  1.98k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  3.97k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 1.98k]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|  1.98k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 1.98k]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|  1.98k|	attr->ulValueLen = size;
  ------------------
 4140|  1.98k|		*(CK_BBOOL*)attr->pValue = (prkey->prv_p15obj->flags & SC_PKCS15_CO_FLAG_PRIVATE) != 0;
  ------------------
  |  |  105|  1.98k|#define prv_p15obj		base.p15_object
  ------------------
              		*(CK_BBOOL*)attr->pValue = (prkey->prv_p15obj->flags & SC_PKCS15_CO_FLAG_PRIVATE) != 0;
  ------------------
  |  |   50|  1.98k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 4141|  1.98k|		break;
 4142|      0|	case CKA_MODIFIABLE:
  ------------------
  |  |  197|      0|#define CKA_MODIFIABLE 0x00000170UL
  ------------------
  |  Branch (4142:2): [True: 0, False: 6.42k]
  ------------------
 4143|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4144|      0|		*(CK_BBOOL*)attr->pValue = (prkey->prv_p15obj->flags & SC_PKCS15_CO_FLAG_MODIFIABLE) != 0;
  ------------------
  |  |  105|      0|#define prv_p15obj		base.p15_object
  ------------------
              		*(CK_BBOOL*)attr->pValue = (prkey->prv_p15obj->flags & SC_PKCS15_CO_FLAG_MODIFIABLE) != 0;
  ------------------
  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
 4145|      0|		break;
 4146|      0|	case CKA_EXTRACTABLE:
  ------------------
  |  |  192|      0|#define CKA_EXTRACTABLE 0x00000162UL
  ------------------
  |  Branch (4146:2): [True: 0, False: 6.42k]
  ------------------
 4147|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4148|      0|		*(CK_BBOOL *)attr->pValue = (prkey->prv_info->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) != 0;
  ------------------
  |  |  317|      0|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
 4149|      0|		break;
 4150|      0|	case CKA_LABEL:
  ------------------
  |  |  140|      0|#define CKA_LABEL 0x00000003UL
  ------------------
  |  Branch (4150:2): [True: 0, False: 6.42k]
  ------------------
 4151|      0|		len = strnlen(prkey->prv_p15obj->label, sizeof prkey->prv_p15obj->label);
  ------------------
  |  |  105|      0|#define prv_p15obj		base.p15_object
  ------------------
              		len = strnlen(prkey->prv_p15obj->label, sizeof prkey->prv_p15obj->label);
  ------------------
  |  |  105|      0|#define prv_p15obj		base.p15_object
  ------------------
 4152|      0|		check_attribute_buffer(attr, len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4153|      0|		memcpy(attr->pValue, prkey->prv_p15obj->label, len);
  ------------------
  |  |  105|      0|#define prv_p15obj		base.p15_object
  ------------------
 4154|      0|		break;
 4155|    756|	case CKA_KEY_TYPE:
  ------------------
  |  |  159|    756|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  |  Branch (4155:2): [True: 756, False: 5.66k]
  ------------------
 4156|  1.51k|		check_attribute_buffer(attr, sizeof(CK_KEY_TYPE));
  ------------------
  |  |   56|    756|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  1.51k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 756]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|    756|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 756]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|    756|	attr->ulValueLen = size;
  ------------------
 4157|  1.51k|		switch (prkey->prv_p15obj->type) {
  ------------------
  |  |  105|    756|#define prv_p15obj		base.p15_object
  ------------------
 4158|    689|			case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    689|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (4158:4): [True: 689, False: 67]
  ------------------
 4159|    689|				*(CK_KEY_TYPE*)attr->pValue = CKK_RSA;
  ------------------
  |  |  464|    689|#define CKK_RSA 0x00000000UL
  ------------------
 4160|    689|				break;
 4161|      0|			case SC_PKCS15_TYPE_PRKEY_GOSTR3410:
  ------------------
  |  |  420|      0|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  |  Branch (4161:4): [True: 0, False: 756]
  ------------------
 4162|      0|				*(CK_KEY_TYPE*)attr->pValue = CKK_GOSTR3410;
  ------------------
  |  |  502|      0|#define CKK_GOSTR3410 0x00000030UL
  ------------------
 4163|      0|				break;
 4164|      0|			case SC_PKCS15_TYPE_PRKEY_EDDSA:
  ------------------
  |  |  422|      0|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
  |  Branch (4164:4): [True: 0, False: 756]
  ------------------
 4165|      0|				*(CK_KEY_TYPE*)attr->pValue = CKK_EC_EDWARDS;
  ------------------
  |  |  518|      0|#define CKK_EC_EDWARDS 0x00000040UL
  ------------------
 4166|      0|				break;
 4167|      0|			case SC_PKCS15_TYPE_PRKEY_XEDDSA:
  ------------------
  |  |  423|      0|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
  |  Branch (4167:4): [True: 0, False: 756]
  ------------------
 4168|      0|				*(CK_KEY_TYPE*)attr->pValue = CKK_EC_MONTGOMERY;
  ------------------
  |  |  519|      0|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
 4169|      0|				break;
 4170|     67|			case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     67|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (4170:4): [True: 67, False: 689]
  ------------------
 4171|     67|				*(CK_KEY_TYPE*)attr->pValue = CKK_EC;
  ------------------
  |  |  467|     67|#define CKK_EC 0x00000003UL
  ------------------
 4172|     67|				break;
 4173|      0|			default:
  ------------------
  |  Branch (4173:4): [True: 0, False: 756]
  ------------------
 4174|      0|				return CKR_GENERAL_ERROR; /* Internal error*/
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
 4175|  1.51k|		}
 4176|    756|		break;
 4177|    756|	case CKA_ID:
  ------------------
  |  |  161|     92|#define CKA_ID 0x00000102UL
  ------------------
  |  Branch (4177:2): [True: 92, False: 6.32k]
  ------------------
 4178|     92|		check_attribute_buffer(attr, prkey->prv_info->id.len);
  ------------------
  |  |   56|     92|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|    184|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 65, False: 27]
  |  |  ------------------
  |  |   57|     65|		attr->ulValueLen = size;        \
  |  |   58|     65|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|     65|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|     65|	}                                       \
  |  |   60|     92|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 27]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|     27|	attr->ulValueLen = size;
  ------------------
 4179|     27|		memcpy(attr->pValue, prkey->prv_info->id.value, prkey->prv_info->id.len);
 4180|     27|		break;
 4181|      0|	case CKA_KEY_GEN_MECHANISM:
  ------------------
  |  |  196|      0|#define CKA_KEY_GEN_MECHANISM 0x00000166UL
  ------------------
  |  Branch (4181:2): [True: 0, False: 6.42k]
  ------------------
 4182|      0|		check_attribute_buffer(attr, sizeof(CK_MECHANISM_TYPE));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4183|      0|		*(CK_MECHANISM_TYPE*)attr->pValue = CK_UNAVAILABLE_INFORMATION;
  ------------------
  |  |   32|      0|#define CK_UNAVAILABLE_INFORMATION ~0UL
  ------------------
 4184|      0|		break;
 4185|    362|	case CKA_DECRYPT:
  ------------------
  |  |  164|    362|#define CKA_DECRYPT 0x00000105UL
  ------------------
  |  Branch (4185:2): [True: 362, False: 6.05k]
  ------------------
 4186|    628|	case CKA_SIGN:
  ------------------
  |  |  167|    628|#define CKA_SIGN 0x00000108UL
  ------------------
  |  Branch (4186:2): [True: 266, False: 6.15k]
  ------------------
 4187|    628|	case CKA_SIGN_RECOVER:
  ------------------
  |  |  168|    628|#define CKA_SIGN_RECOVER 0x00000109UL
  ------------------
  |  Branch (4187:2): [True: 0, False: 6.42k]
  ------------------
 4188|    757|	case CKA_UNWRAP:
  ------------------
  |  |  166|    757|#define CKA_UNWRAP 0x00000107UL
  ------------------
  |  Branch (4188:2): [True: 129, False: 6.29k]
  ------------------
 4189|    759|	case CKA_DERIVE:
  ------------------
  |  |  171|    759|#define CKA_DERIVE 0x0000010CUL
  ------------------
  |  Branch (4189:2): [True: 2, False: 6.41k]
  ------------------
 4190|    759|	case CKA_OPENSC_NON_REPUDIATION:
  ------------------
  |  |   19|    759|#define CKA_OPENSC_NON_REPUDIATION      (CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 1UL)
  |  |  ------------------
  |  |  |  |  289|    759|#define CKA_VENDOR_DEFINED 0x80000000UL
  |  |  ------------------
  |  |               #define CKA_OPENSC_NON_REPUDIATION      (CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 1UL)
  |  |  ------------------
  |  |  |  |   12|    759|#define SC_VENDOR_DEFINED 0x4F534300  /* OSC */
  |  |  ------------------
  ------------------
  |  Branch (4190:2): [True: 0, False: 6.42k]
  ------------------
 4191|       |		/* TODO seems to be obsolete */
 4192|       |		/* Combine the usage bits of all split keys */
 4193|  1.80k|		for (usage = 0; prkey; prkey = prkey->prv_next)
  ------------------
  |  |  107|  1.04k|#define prv_next		base.related_privkey
  ------------------
  |  Branch (4193:19): [True: 1.04k, False: 759]
  ------------------
 4194|  1.04k|			usage |= prkey->prv_info->usage;
 4195|    759|		return get_usage_bit(usage, attr);
 4196|      0|	case CKA_MODULUS:
  ------------------
  |  |  174|      0|#define CKA_MODULUS 0x00000120UL
  ------------------
  |  Branch (4196:2): [True: 0, False: 6.42k]
  ------------------
 4197|      0|		return get_modulus(key, attr);
 4198|    245|	case CKA_MODULUS_BITS:
  ------------------
  |  |  175|    245|#define CKA_MODULUS_BITS 0x00000121UL
  ------------------
  |  Branch (4198:2): [True: 245, False: 6.17k]
  ------------------
 4199|    490|		check_attribute_buffer(attr, sizeof(CK_ULONG));
  ------------------
  |  |   56|    245|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|    490|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 245]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|    245|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 245]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|    245|	attr->ulValueLen = size;
  ------------------
 4200|    490|		switch (prkey->prv_p15obj->type) {
  ------------------
  |  |  105|    245|#define prv_p15obj		base.p15_object
  ------------------
 4201|      0|			case SC_PKCS15_TYPE_PRKEY_EDDSA:
  ------------------
  |  |  422|      0|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
  |  Branch (4201:4): [True: 0, False: 245]
  ------------------
 4202|      0|			case SC_PKCS15_TYPE_PRKEY_XEDDSA:
  ------------------
  |  |  423|      0|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
  |  Branch (4202:4): [True: 0, False: 245]
  ------------------
 4203|       |				/* TODO where to get field length ? */
 4204|      0|				*(CK_ULONG *) attr->pValue = 255;
 4205|      0|				return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 4206|     32|			case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     32|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (4206:4): [True: 32, False: 213]
  ------------------
 4207|     32|				if (key) {
  ------------------
  |  Branch (4207:9): [True: 32, False: 0]
  ------------------
 4208|     32|					if (key->u.ec.params.field_length > 0)
  ------------------
  |  Branch (4208:10): [True: 1, False: 31]
  ------------------
 4209|      1|						*(CK_ULONG *) attr->pValue = key->u.ec.params.field_length;
 4210|     31|					else
 4211|     31|						*(CK_ULONG *) attr->pValue = (key->u.ec.ecpointQ.len - 1) / 2 *8;
 4212|     32|				}
 4213|     32|				return CKR_OK;
  ------------------
  |  | 1086|     32|#define CKR_OK 0x00000000UL
  ------------------
 4214|    213|			default:
  ------------------
  |  Branch (4214:4): [True: 213, False: 32]
  ------------------
 4215|    213|				*(CK_ULONG *) attr->pValue = prkey->prv_info->modulus_length;
 4216|    213|				return CKR_OK;
  ------------------
  |  | 1086|    213|#define CKR_OK 0x00000000UL
  ------------------
 4217|    490|		}
 4218|      0|	case CKA_PUBLIC_EXPONENT:
  ------------------
  |  |  176|      0|#define CKA_PUBLIC_EXPONENT 0x00000122UL
  ------------------
  |  Branch (4218:2): [True: 0, False: 6.42k]
  ------------------
 4219|      0|		return get_public_exponent(key, attr);
 4220|      0|	case CKA_PRIVATE_EXPONENT:
  ------------------
  |  |  177|      0|#define CKA_PRIVATE_EXPONENT 0x00000123UL
  ------------------
  |  Branch (4220:2): [True: 0, False: 6.42k]
  ------------------
 4221|      0|	case CKA_PRIME_1:
  ------------------
  |  |  178|      0|#define CKA_PRIME_1 0x00000124UL
  ------------------
  |  Branch (4221:2): [True: 0, False: 6.42k]
  ------------------
 4222|      0|	case CKA_PRIME_2:
  ------------------
  |  |  179|      0|#define CKA_PRIME_2 0x00000125UL
  ------------------
  |  Branch (4222:2): [True: 0, False: 6.42k]
  ------------------
 4223|      0|	case CKA_EXPONENT_1:
  ------------------
  |  |  180|      0|#define CKA_EXPONENT_1 0x00000126UL
  ------------------
  |  Branch (4223:2): [True: 0, False: 6.42k]
  ------------------
 4224|      0|	case CKA_EXPONENT_2:
  ------------------
  |  |  181|      0|#define CKA_EXPONENT_2 0x00000127UL
  ------------------
  |  Branch (4224:2): [True: 0, False: 6.42k]
  ------------------
 4225|      0|	case CKA_COEFFICIENT:
  ------------------
  |  |  182|      0|#define CKA_COEFFICIENT 0x00000128UL
  ------------------
  |  Branch (4225:2): [True: 0, False: 6.42k]
  ------------------
 4226|      0|		return CKR_ATTRIBUTE_SENSITIVE;
  ------------------
  |  | 1097|      0|#define CKR_ATTRIBUTE_SENSITIVE 0x00000011UL
  ------------------
 4227|      0|	case CKA_SUBJECT:
  ------------------
  |  |  160|      0|#define CKA_SUBJECT 0x00000101UL
  ------------------
  |  Branch (4227:2): [True: 0, False: 6.42k]
  ------------------
 4228|      0|	case CKA_START_DATE:
  ------------------
  |  |  172|      0|#define CKA_START_DATE 0x00000110UL
  ------------------
  |  Branch (4228:2): [True: 0, False: 6.42k]
  ------------------
 4229|      0|	case CKA_END_DATE:
  ------------------
  |  |  173|      0|#define CKA_END_DATE 0x00000111UL
  ------------------
  |  Branch (4229:2): [True: 0, False: 6.42k]
  ------------------
 4230|      0|		attr->ulValueLen = 0;
 4231|      0|		return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 4232|      0|	case CKA_GOSTR3410_PARAMS:
  ------------------
  |  |  218|      0|#define CKA_GOSTR3410_PARAMS 0x00000250UL
  ------------------
  |  Branch (4232:2): [True: 0, False: 6.42k]
  ------------------
 4233|      0|		if (prkey->prv_info && prkey->prv_info->params.len)
  ------------------
  |  Branch (4233:7): [True: 0, False: 0]
  |  Branch (4233:26): [True: 0, False: 0]
  ------------------
 4234|      0|			return get_gostr3410_params(prkey->prv_info->params.data,
 4235|      0|					prkey->prv_info->params.len, attr);
 4236|      0|		else
 4237|      0|			return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 4238|      0|	case CKA_EC_PARAMS:
  ------------------
  |  |  200|      0|#define CKA_EC_PARAMS 0x00000180UL
  ------------------
  |  Branch (4238:2): [True: 0, False: 6.42k]
  ------------------
 4239|      0|		return get_ec_pubkey_params(key, attr); /* get from pubkey for now */
 4240|      0|	default:
  ------------------
  |  Branch (4240:2): [True: 0, False: 6.42k]
  ------------------
 4241|      0|		return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 4242|  6.42k|	}
 4243|       |
 4244|  4.06k|	return CKR_OK;
  ------------------
  |  | 1086|  4.06k|#define CKR_OK 0x00000000UL
  ------------------
 4245|  6.42k|}
framework-pkcs15.c:get_usage_bit:
 6094|    759|{
 6095|    759|	static struct {
 6096|    759|		CK_ATTRIBUTE_TYPE type;
 6097|    759|		unsigned int	flag;
 6098|    759|	} flag_mapping[] = {
 6099|    759|		{ CKA_ENCRYPT,		SC_PKCS15_PRKEY_USAGE_ENCRYPT },
  ------------------
  |  |  163|    759|#define CKA_ENCRYPT 0x00000104UL
  ------------------
              		{ CKA_ENCRYPT,		SC_PKCS15_PRKEY_USAGE_ENCRYPT },
  ------------------
  |  |  305|    759|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
 6100|    759|		{ CKA_DECRYPT,		SC_PKCS15_PRKEY_USAGE_DECRYPT },
  ------------------
  |  |  164|    759|#define CKA_DECRYPT 0x00000105UL
  ------------------
              		{ CKA_DECRYPT,		SC_PKCS15_PRKEY_USAGE_DECRYPT },
  ------------------
  |  |  306|    759|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
 6101|    759|		{ CKA_SIGN,		SC_PKCS15_PRKEY_USAGE_SIGN|SC_PKCS15_PRKEY_USAGE_NONREPUDIATION },
  ------------------
  |  |  167|    759|#define CKA_SIGN 0x00000108UL
  ------------------
              		{ CKA_SIGN,		SC_PKCS15_PRKEY_USAGE_SIGN|SC_PKCS15_PRKEY_USAGE_NONREPUDIATION },
  ------------------
  |  |  307|    759|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
              		{ CKA_SIGN,		SC_PKCS15_PRKEY_USAGE_SIGN|SC_PKCS15_PRKEY_USAGE_NONREPUDIATION },
  ------------------
  |  |  314|    759|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
 6102|    759|		{ CKA_SIGN_RECOVER,	SC_PKCS15_PRKEY_USAGE_SIGNRECOVER },
  ------------------
  |  |  168|    759|#define CKA_SIGN_RECOVER 0x00000109UL
  ------------------
              		{ CKA_SIGN_RECOVER,	SC_PKCS15_PRKEY_USAGE_SIGNRECOVER },
  ------------------
  |  |  308|    759|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
 6103|    759|		{ CKA_WRAP,		SC_PKCS15_PRKEY_USAGE_WRAP },
  ------------------
  |  |  165|    759|#define CKA_WRAP 0x00000106UL
  ------------------
              		{ CKA_WRAP,		SC_PKCS15_PRKEY_USAGE_WRAP },
  ------------------
  |  |  309|    759|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  ------------------
 6104|    759|		{ CKA_UNWRAP,		SC_PKCS15_PRKEY_USAGE_UNWRAP },
  ------------------
  |  |  166|    759|#define CKA_UNWRAP 0x00000107UL
  ------------------
              		{ CKA_UNWRAP,		SC_PKCS15_PRKEY_USAGE_UNWRAP },
  ------------------
  |  |  310|    759|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
 6105|    759|		{ CKA_VERIFY,		SC_PKCS15_PRKEY_USAGE_VERIFY },
  ------------------
  |  |  169|    759|#define CKA_VERIFY 0x0000010AUL
  ------------------
              		{ CKA_VERIFY,		SC_PKCS15_PRKEY_USAGE_VERIFY },
  ------------------
  |  |  311|    759|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
 6106|    759|		{ CKA_VERIFY_RECOVER,	SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER },
  ------------------
  |  |  170|    759|#define CKA_VERIFY_RECOVER 0x0000010BUL
  ------------------
              		{ CKA_VERIFY_RECOVER,	SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER },
  ------------------
  |  |  312|    759|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
 6107|    759|		{ CKA_DERIVE,		SC_PKCS15_PRKEY_USAGE_DERIVE },
  ------------------
  |  |  171|    759|#define CKA_DERIVE 0x0000010CUL
  ------------------
              		{ CKA_DERIVE,		SC_PKCS15_PRKEY_USAGE_DERIVE },
  ------------------
  |  |  313|    759|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
 6108|    759|		{ CKA_OPENSC_NON_REPUDIATION, SC_PKCS15_PRKEY_USAGE_NONREPUDIATION },
  ------------------
  |  |   19|    759|#define CKA_OPENSC_NON_REPUDIATION      (CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 1UL)
  |  |  ------------------
  |  |  |  |  289|    759|#define CKA_VENDOR_DEFINED 0x80000000UL
  |  |  ------------------
  |  |               #define CKA_OPENSC_NON_REPUDIATION      (CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 1UL)
  |  |  ------------------
  |  |  |  |   12|    759|#define SC_VENDOR_DEFINED 0x4F534300  /* OSC */
  |  |  ------------------
  ------------------
              		{ CKA_OPENSC_NON_REPUDIATION, SC_PKCS15_PRKEY_USAGE_NONREPUDIATION },
  ------------------
  |  |  314|    759|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
 6109|    759|		{ 0, 0 }
 6110|    759|	};
 6111|    759|	unsigned int mask = 0, j;
 6112|       |
 6113|  2.31k|	for (j = 0; (mask = flag_mapping[j].flag) != 0; j++) {
  ------------------
  |  Branch (6113:14): [True: 2.31k, False: 0]
  ------------------
 6114|  2.31k|		if (flag_mapping[j].type == attr->type)
  ------------------
  |  Branch (6114:7): [True: 759, False: 1.55k]
  ------------------
 6115|    759|			break;
 6116|  2.31k|	}
 6117|    759|	if (mask == 0)
  ------------------
  |  Branch (6117:6): [True: 0, False: 759]
  ------------------
 6118|      0|		return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 6119|       |
 6120|    759|	check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|    759|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  1.51k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 759]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|    759|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 759]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|    759|	attr->ulValueLen = size;
  ------------------
 6121|    759|	*(CK_BBOOL*)attr->pValue = (usage & mask)? TRUE : FALSE;
  ------------------
  |  |   51|    511|#define TRUE 1
  ------------------
              	*(CK_BBOOL*)attr->pValue = (usage & mask)? TRUE : FALSE;
  ------------------
  |  |   48|  1.00k|#define FALSE 0
  ------------------
  |  Branch (6121:29): [True: 511, False: 248]
  ------------------
 6122|       |
 6123|    759|	return CKR_OK;
  ------------------
  |  | 1086|    759|#define CKR_OK 0x00000000UL
  ------------------
 6124|  1.51k|}
framework-pkcs15.c:pkcs15_prkey_sign:
 4296|    245|{
 4297|    245|	struct pkcs15_prkey_object *prkey = (struct pkcs15_prkey_object *) obj;
 4298|    245|	struct sc_pkcs11_card *p11card = session->slot->p11card;
 4299|    245|	struct pkcs15_fw_data *fw_data = NULL;
 4300|    245|	CK_RV rv;
 4301|    245|	int flags = 0, rc;
 4302|    245|	unsigned sign_flags = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_SIGNRECOVER
  ------------------
  |  |  307|    245|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
              	unsigned sign_flags = SC_PKCS15_PRKEY_USAGE_SIGN | SC_PKCS15_PRKEY_USAGE_SIGNRECOVER
  ------------------
  |  |  308|    245|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
 4303|    245|			| SC_PKCS15_PRKEY_USAGE_NONREPUDIATION;
  ------------------
  |  |  314|    245|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
 4304|       |
 4305|    245|	sc_log(context, "Initiating signing operation, mechanism 0x%lx.",
  ------------------
  |  |   71|    245|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4306|    245|		   pMechanism->mechanism);
 4307|    245|	if (!p11card)
  ------------------
  |  Branch (4307:6): [True: 0, False: 245]
  ------------------
 4308|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_Sign");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 4309|    245|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[session->slot->fw_data_idx];
 4310|    245|	if (!fw_data)
  ------------------
  |  Branch (4310:6): [True: 0, False: 245]
  ------------------
 4311|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_Sign");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4312|    245|	if (!fw_data->p15_card)
  ------------------
  |  Branch (4312:6): [True: 0, False: 245]
  ------------------
 4313|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_Sign");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 4314|       |
 4315|       |	/* See which of the alternative keys supports signing */
 4316|    259|	while (prkey && !(prkey->prv_info->usage & sign_flags))
  ------------------
  |  Branch (4316:9): [True: 259, False: 0]
  |  Branch (4316:18): [True: 14, False: 245]
  ------------------
 4317|     14|		prkey = prkey->prv_next;
  ------------------
  |  |  107|    259|#define prv_next		base.related_privkey
  ------------------
 4318|       |
 4319|    245|	if (prkey == NULL)
  ------------------
  |  Branch (4319:6): [True: 0, False: 245]
  ------------------
 4320|      0|		return CKR_KEY_FUNCTION_NOT_PERMITTED;
  ------------------
  |  | 1119|      0|#define CKR_KEY_FUNCTION_NOT_PERMITTED 0x00000068UL
  ------------------
 4321|       |
 4322|    245|	switch (pMechanism->mechanism) {
 4323|     71|	case CKM_RSA_PKCS:
  ------------------
  |  |  539|     71|#define CKM_RSA_PKCS 0x00000001UL
  ------------------
  |  Branch (4323:2): [True: 71, False: 174]
  ------------------
 4324|     71|		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  109|     71|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|     71|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
 4325|     71|		break;
 4326|     44|	case CKM_MD5_RSA_PKCS:
  ------------------
  |  |  543|     44|#define CKM_MD5_RSA_PKCS 0x00000005UL
  ------------------
  |  Branch (4326:2): [True: 44, False: 201]
  ------------------
 4327|     44|		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_MD5;
  ------------------
  |  |  109|     44|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_MD5;
  ------------------
  |  |  135|     44|#define SC_ALGORITHM_RSA_HASH_MD5	0x00000400
  ------------------
 4328|     44|		break;
 4329|     15|	case CKM_SHA1_RSA_PKCS:
  ------------------
  |  |  544|     15|#define CKM_SHA1_RSA_PKCS 0x00000006UL
  ------------------
  |  Branch (4329:2): [True: 15, False: 230]
  ------------------
 4330|     15|		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  109|     15|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|     15|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
 4331|     15|		break;
 4332|     14|	case CKM_SHA224_RSA_PKCS:
  ------------------
  |  |  604|     14|#define CKM_SHA224_RSA_PKCS 0x00000046UL
  ------------------
  |  Branch (4332:2): [True: 14, False: 231]
  ------------------
 4333|     14|		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA224;
  ------------------
  |  |  109|     14|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA224;
  ------------------
  |  |  141|     14|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  ------------------
 4334|     14|		break;
 4335|     17|	case CKM_SHA256_RSA_PKCS:
  ------------------
  |  |  598|     17|#define CKM_SHA256_RSA_PKCS 0x00000040UL
  ------------------
  |  Branch (4335:2): [True: 17, False: 228]
  ------------------
 4336|     17|		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  109|     17|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  138|     17|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
 4337|     17|		break;
 4338|      7|	case CKM_SHA384_RSA_PKCS:
  ------------------
  |  |  599|      7|#define CKM_SHA384_RSA_PKCS 0x00000041UL
  ------------------
  |  Branch (4338:2): [True: 7, False: 238]
  ------------------
 4339|      7|		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA384;
  ------------------
  |  |  109|      7|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA384;
  ------------------
  |  |  139|      7|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
 4340|      7|		break;
 4341|      2|	case CKM_SHA512_RSA_PKCS:
  ------------------
  |  |  600|      2|#define CKM_SHA512_RSA_PKCS 0x00000042UL
  ------------------
  |  Branch (4341:2): [True: 2, False: 243]
  ------------------
 4342|      2|		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA512;
  ------------------
  |  |  109|      2|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_SHA512;
  ------------------
  |  |  140|      2|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
 4343|      2|		break;
 4344|     24|	case CKM_RIPEMD160_RSA_PKCS:
  ------------------
  |  |  546|     24|#define CKM_RIPEMD160_RSA_PKCS 0x00000008UL
  ------------------
  |  Branch (4344:2): [True: 24, False: 221]
  ------------------
 4345|     24|		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_RIPEMD160;
  ------------------
  |  |  109|     24|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		flags = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_HASH_RIPEMD160;
  ------------------
  |  |  137|     24|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
 4346|     24|		break;
 4347|     17|	case CKM_RSA_X_509:
  ------------------
  |  |  541|     17|#define CKM_RSA_X_509 0x00000003UL
  ------------------
  |  Branch (4347:2): [True: 17, False: 228]
  ------------------
 4348|     17|		flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|     17|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
 4349|     17|		break;
 4350|      0|	case CKM_RSA_PKCS_PSS:
  ------------------
  |  |  551|      0|#define CKM_RSA_PKCS_PSS 0x0000000DUL
  ------------------
  |  Branch (4350:2): [True: 0, False: 245]
  ------------------
 4351|      0|		flags = SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  107|      0|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
 4352|       |		/* The hash was done outside of the module */
 4353|      0|		flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  133|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
 4354|       |		/* Omitted parameter can use MGF1-SHA1 ? */
 4355|      0|		if (pMechanism->pParameter == NULL) {
  ------------------
  |  Branch (4355:7): [True: 0, False: 0]
  ------------------
 4356|      0|			flags |= SC_ALGORITHM_MGF1_SHA1;
  ------------------
  |  |  145|      0|#define SC_ALGORITHM_MGF1_SHA1		0x00100000
  ------------------
 4357|      0|			if (ulDataLen != SHA_DIGEST_LENGTH)
  ------------------
  |  Branch (4357:8): [True: 0, False: 0]
  ------------------
 4358|      0|				return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      0|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
 4359|      0|			break;
 4360|      0|		}
 4361|       |
 4362|       |		/* Check the data length matches the selected hash */
 4363|      0|		rv = pkcs15_prkey_check_pss_param(pMechanism, (int)ulDataLen);
 4364|      0|		if (rv != CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (4364:7): [True: 0, False: 0]
  ------------------
 4365|      0|			sc_log(context, "Invalid data length for the selected "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4366|      0|			    "PSS parameters");
 4367|      0|			return rv;
 4368|      0|		}
 4369|       |
 4370|       |		/* The MGF parameter was already verified in SignInit() */
 4371|      0|		flags |=  mgf2flags(((CK_RSA_PKCS_PSS_PARAMS*)pMechanism->pParameter)->mgf);
 4372|       |
 4373|       |		/* Assuming salt is the size of hash */
 4374|      0|		break;
 4375|      0|	case CKM_SHA1_RSA_PKCS_PSS:
  ------------------
  |  |  552|      0|#define CKM_SHA1_RSA_PKCS_PSS 0x0000000EUL
  ------------------
  |  Branch (4375:2): [True: 0, False: 245]
  ------------------
 4376|      0|	case CKM_SHA224_RSA_PKCS_PSS:
  ------------------
  |  |  605|      0|#define CKM_SHA224_RSA_PKCS_PSS 0x00000047UL
  ------------------
  |  Branch (4376:2): [True: 0, False: 245]
  ------------------
 4377|      0|	case CKM_SHA256_RSA_PKCS_PSS:
  ------------------
  |  |  601|      0|#define CKM_SHA256_RSA_PKCS_PSS 0x00000043UL
  ------------------
  |  Branch (4377:2): [True: 0, False: 245]
  ------------------
 4378|      0|	case CKM_SHA384_RSA_PKCS_PSS:
  ------------------
  |  |  602|      0|#define CKM_SHA384_RSA_PKCS_PSS 0x00000044UL
  ------------------
  |  Branch (4378:2): [True: 0, False: 245]
  ------------------
 4379|      0|	case CKM_SHA512_RSA_PKCS_PSS:
  ------------------
  |  |  603|      0|#define CKM_SHA512_RSA_PKCS_PSS 0x00000045UL
  ------------------
  |  Branch (4379:2): [True: 0, False: 245]
  ------------------
 4380|      0|		flags = SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  107|      0|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
 4381|       |		/* Omitted parameter can use MGF1-SHA1 and SHA1 hash ? */
 4382|      0|		if (pMechanism->pParameter == NULL) {
  ------------------
  |  Branch (4382:7): [True: 0, False: 0]
  ------------------
 4383|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|      0|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
 4384|      0|			flags |= SC_ALGORITHM_MGF1_SHA1;
  ------------------
  |  |  145|      0|#define SC_ALGORITHM_MGF1_SHA1		0x00100000
  ------------------
 4385|      0|			break;
 4386|      0|		}
 4387|       |
 4388|      0|		switch (((CK_RSA_PKCS_PSS_PARAMS*)pMechanism->pParameter)->hashAlg) {
 4389|      0|		case CKM_SHA_1:
  ------------------
  |  |  667|      0|#define CKM_SHA_1 0x00000220UL
  ------------------
  |  Branch (4389:3): [True: 0, False: 0]
  ------------------
 4390|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|      0|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
 4391|      0|			break;
 4392|      0|		case CKM_SHA224:
  ------------------
  |  |  679|      0|#define CKM_SHA224 0x00000255UL
  ------------------
  |  Branch (4392:3): [True: 0, False: 0]
  ------------------
 4393|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA224;
  ------------------
  |  |  141|      0|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  ------------------
 4394|      0|			break;
 4395|      0|		case CKM_SHA256:
  ------------------
  |  |  676|      0|#define CKM_SHA256 0x00000250UL
  ------------------
  |  Branch (4395:3): [True: 0, False: 0]
  ------------------
 4396|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  138|      0|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
 4397|      0|			break;
 4398|      0|		case CKM_SHA384:
  ------------------
  |  |  682|      0|#define CKM_SHA384 0x00000260UL
  ------------------
  |  Branch (4398:3): [True: 0, False: 0]
  ------------------
 4399|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA384;
  ------------------
  |  |  139|      0|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
 4400|      0|			break;
 4401|      0|		case CKM_SHA512:
  ------------------
  |  |  685|      0|#define CKM_SHA512 0x00000270UL
  ------------------
  |  Branch (4401:3): [True: 0, False: 0]
  ------------------
 4402|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA512;
  ------------------
  |  |  140|      0|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
 4403|      0|			break;
 4404|      0|		default:
  ------------------
  |  Branch (4404:3): [True: 0, False: 0]
  ------------------
 4405|      0|			return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      0|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
 4406|      0|		}
 4407|       |
 4408|       |		/* The MGF parameter was already verified in SignInit() */
 4409|      0|		flags |= mgf2flags(((CK_RSA_PKCS_PSS_PARAMS*)pMechanism->pParameter)->mgf);
 4410|       |
 4411|      0|		break;
 4412|      0|	case CKM_GOSTR3410:
  ------------------
  |  |  909|      0|#define CKM_GOSTR3410 0x00001201UL
  ------------------
  |  Branch (4412:2): [True: 0, False: 245]
  ------------------
 4413|      0|		flags = SC_ALGORITHM_GOSTR3410_HASH_NONE;
  ------------------
  |  |  157|      0|#define SC_ALGORITHM_GOSTR3410_HASH_NONE	SC_ALGORITHM_GOSTR3410_RAW /*XXX*/
  |  |  ------------------
  |  |  |  |  156|      0|#define SC_ALGORITHM_GOSTR3410_RAW		0x00020000
  |  |  ------------------
  ------------------
 4414|      0|		break;
 4415|      0|	case CKM_GOSTR3410_WITH_GOSTR3411:
  ------------------
  |  |  910|      0|#define CKM_GOSTR3410_WITH_GOSTR3411 0x00001202UL
  ------------------
  |  Branch (4415:2): [True: 0, False: 245]
  ------------------
 4416|      0|		flags = SC_ALGORITHM_GOSTR3410_HASH_GOSTR3411;
  ------------------
  |  |  158|      0|#define SC_ALGORITHM_GOSTR3410_HASH_GOSTR3411	0x00080000
  ------------------
 4417|      0|		break;
 4418|      0|	case CKM_EDDSA:
  ------------------
  |  |  990|      0|#define CKM_EDDSA 0x00001057UL
  ------------------
  |  Branch (4418:2): [True: 0, False: 245]
  ------------------
 4419|      0|		flags = SC_ALGORITHM_EDDSA_RAW;
  ------------------
  |  |  188|      0|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
 4420|      0|		break;
 4421|      0|	case CKM_XEDDSA:
  ------------------
  |  |  979|      0|#define CKM_XEDDSA 0x00004029UL
  ------------------
  |  Branch (4421:2): [True: 0, False: 245]
  ------------------
 4422|      0|		flags = SC_ALGORITHM_XEDDSA_RAW;
  ------------------
  |  |  189|      0|#define SC_ALGORITHM_XEDDSA_RAW		0x00800000
  ------------------
 4423|      0|		break;
 4424|      1|	case CKM_ECDSA:
  ------------------
  |  |  860|      1|#define CKM_ECDSA 0x00001041UL
  ------------------
  |  Branch (4424:2): [True: 1, False: 244]
  ------------------
 4425|      1|		flags = SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  175|      1|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  133|      1|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
 4426|      1|		break;
 4427|      2|	case CKM_ECDSA_SHA1:
  ------------------
  |  |  861|      2|#define CKM_ECDSA_SHA1 0x00001042UL
  ------------------
  |  Branch (4427:2): [True: 2, False: 243]
  ------------------
 4428|      2|		flags = SC_ALGORITHM_ECDSA_HASH_SHA1;
  ------------------
  |  |  176|      2|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  134|      2|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
 4429|      2|		break;
 4430|      1|	case CKM_ECDSA_SHA224:
  ------------------
  |  |  862|      1|#define CKM_ECDSA_SHA224 0x00001043UL
  ------------------
  |  Branch (4430:2): [True: 1, False: 244]
  ------------------
 4431|      1|		flags = SC_ALGORITHM_ECDSA_HASH_SHA224;
  ------------------
  |  |  177|      1|#define SC_ALGORITHM_ECDSA_HASH_SHA224		SC_ALGORITHM_RSA_HASH_SHA224
  |  |  ------------------
  |  |  |  |  141|      1|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  |  |  ------------------
  ------------------
 4432|      1|		break;
 4433|      1|	case CKM_ECDSA_SHA256:
  ------------------
  |  |  863|      1|#define CKM_ECDSA_SHA256 0x00001044UL
  ------------------
  |  Branch (4433:2): [True: 1, False: 244]
  ------------------
 4434|      1|		flags = SC_ALGORITHM_ECDSA_HASH_SHA256;
  ------------------
  |  |  178|      1|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  138|      1|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
 4435|      1|		break;
 4436|      1|	case CKM_ECDSA_SHA384:
  ------------------
  |  |  864|      1|#define CKM_ECDSA_SHA384 0x00001045UL
  ------------------
  |  Branch (4436:2): [True: 1, False: 244]
  ------------------
 4437|      1|		flags = SC_ALGORITHM_ECDSA_HASH_SHA384;
  ------------------
  |  |  179|      1|#define SC_ALGORITHM_ECDSA_HASH_SHA384		SC_ALGORITHM_RSA_HASH_SHA384
  |  |  ------------------
  |  |  |  |  139|      1|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  |  |  ------------------
  ------------------
 4438|      1|		break;
 4439|     26|	case CKM_ECDSA_SHA512:
  ------------------
  |  |  865|     26|#define CKM_ECDSA_SHA512 0x00001046UL
  ------------------
  |  Branch (4439:2): [True: 26, False: 219]
  ------------------
 4440|     26|		flags = SC_ALGORITHM_ECDSA_HASH_SHA512;
  ------------------
  |  |  180|     26|#define SC_ALGORITHM_ECDSA_HASH_SHA512		SC_ALGORITHM_RSA_HASH_SHA512
  |  |  ------------------
  |  |  |  |  140|     26|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  |  |  ------------------
  ------------------
 4441|     26|		break;
 4442|      2|	default:
  ------------------
  |  Branch (4442:2): [True: 2, False: 243]
  ------------------
 4443|      2|		sc_log(context, "DEE - need EC for %lu", pMechanism->mechanism);
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4444|      2|		return CKR_MECHANISM_INVALID;
  ------------------
  |  | 1122|      2|#define CKR_MECHANISM_INVALID 0x00000070UL
  ------------------
 4445|    245|	}
 4446|       |
 4447|    243|	rc = sc_lock(p11card->card);
 4448|    243|	if (rc < 0)
  ------------------
  |  Branch (4448:6): [True: 0, False: 243]
  ------------------
 4449|      0|		return sc_to_cryptoki_error(rc, "C_Sign");
 4450|       |
 4451|    243|	sc_log(context,
  ------------------
  |  |   71|    243|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4452|    243|	       "Selected flags %X. Now computing signature for %lu bytes. %lu bytes reserved.",
 4453|    243|	       flags, ulDataLen, *pulDataLen);
 4454|    243|	rc = sc_pkcs15_compute_signature(fw_data->p15_card, prkey->prv_p15obj, flags,
  ------------------
  |  |  105|    243|#define prv_p15obj		base.p15_object
  ------------------
 4455|    243|			pData, ulDataLen, pSignature, *pulDataLen, pMechanism);
 4456|       |
 4457|    243|	sc_unlock(p11card->card);
 4458|       |
 4459|    243|	sc_log(context, "Sign complete. Result %d.", rc);
  ------------------
  |  |   71|    243|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4460|       |
 4461|    243|	if (rc > 0) {
  ------------------
  |  Branch (4461:6): [True: 33, False: 210]
  ------------------
 4462|     33|		*pulDataLen = rc;
 4463|     33|		return CKR_OK;
  ------------------
  |  | 1086|     33|#define CKR_OK 0x00000000UL
  ------------------
 4464|     33|	}
 4465|       |
 4466|    210|	return sc_to_cryptoki_error(rc, "C_Sign");
 4467|    243|}
framework-pkcs15.c:pkcs15_prkey_decrypt:
 4540|    421|{
 4541|    421|	struct sc_pkcs11_card *p11card = session->slot->p11card;
 4542|    421|	struct pkcs15_fw_data *fw_data = NULL;
 4543|    421|	struct pkcs15_prkey_object *prkey;
 4544|    421|	unsigned char decrypted[512]; /* FIXME: Will not work for keys above 4096 bits */
 4545|    421|	int rv, flags = 0;
 4546|    421|	CK_ULONG mask, good, rv_pkcs11;
 4547|       |
 4548|    421|	if (pulDataLen == NULL) {
  ------------------
  |  Branch (4548:6): [True: 205, False: 216]
  ------------------
 4549|       |		/* This is call from the C_DecyptInit function */
 4550|    205|		sc_log(context, "C_DecryptInit...");
  ------------------
  |  |   71|    205|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4551|    205|		return CKR_OK;
  ------------------
  |  | 1086|    205|#define CKR_OK 0x00000000UL
  ------------------
 4552|    205|	}
 4553|    216|	if (pEncryptedData == NULL && ulEncryptedDataLen == 0) {
  ------------------
  |  Branch (4553:6): [True: 12, False: 204]
  |  Branch (4553:32): [True: 12, False: 0]
  ------------------
 4554|       |		/* This is call from the C_DecryptFinalize function */
 4555|     12|		sc_log(context, "C_DecryptFinalize...");
  ------------------
  |  |   71|     12|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4556|     12|		*pulDataLen = 0;
 4557|     12|		return CKR_OK;
  ------------------
  |  | 1086|     12|#define CKR_OK 0x00000000UL
  ------------------
 4558|     12|	}
 4559|       |	/* DecryptUpdate: we assume this code is called only once per session, either
 4560|       |	 * from the C_Decrypt function or from an application using the C_DecryptUpdate call
 4561|       |	 */
 4562|       |
 4563|    204|	sc_log(context, "Initiating decryption.");
  ------------------
  |  |   71|    204|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4564|       |
 4565|    204|	if (!p11card)
  ------------------
  |  Branch (4565:6): [True: 0, False: 204]
  ------------------
 4566|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_Decrypt");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 4567|    204|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[session->slot->fw_data_idx];
 4568|    204|	if (!fw_data)
  ------------------
  |  Branch (4568:6): [True: 0, False: 204]
  ------------------
 4569|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_Decrypt");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4570|    204|	if (!fw_data->p15_card)
  ------------------
  |  Branch (4570:6): [True: 0, False: 204]
  ------------------
 4571|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_Decrypt");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 4572|       |
 4573|       |	/* See which of the alternative keys supports decrypt */
 4574|    204|	prkey = (struct pkcs15_prkey_object *) obj;
 4575|    226|	while (prkey  && !(prkey->prv_info->usage & (SC_PKCS15_PRKEY_USAGE_DECRYPT|SC_PKCS15_PRKEY_USAGE_UNWRAP)))
  ------------------
  |  |  306|    226|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              	while (prkey  && !(prkey->prv_info->usage & (SC_PKCS15_PRKEY_USAGE_DECRYPT|SC_PKCS15_PRKEY_USAGE_UNWRAP)))
  ------------------
  |  |  310|    226|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  |  Branch (4575:9): [True: 226, False: 0]
  |  Branch (4575:19): [True: 22, False: 204]
  ------------------
 4576|     22|		prkey = prkey->prv_next;
  ------------------
  |  |  107|    226|#define prv_next		base.related_privkey
  ------------------
 4577|    204|	if (prkey == NULL)
  ------------------
  |  Branch (4577:6): [True: 0, False: 204]
  ------------------
 4578|      0|		return CKR_KEY_FUNCTION_NOT_PERMITTED;
  ------------------
  |  | 1119|      0|#define CKR_KEY_FUNCTION_NOT_PERMITTED 0x00000068UL
  ------------------
 4579|       |
 4580|       |	/* Select the proper padding mechanism */
 4581|    204|	switch (pMechanism->mechanism) {
 4582|    187|	case CKM_RSA_PKCS:
  ------------------
  |  |  539|    187|#define CKM_RSA_PKCS 0x00000001UL
  ------------------
  |  Branch (4582:2): [True: 187, False: 17]
  ------------------
 4583|    187|		flags |= SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  110|    187|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
 4584|    187|		break;
 4585|     16|	case CKM_RSA_X_509:
  ------------------
  |  |  541|     16|#define CKM_RSA_X_509 0x00000003UL
  ------------------
  |  Branch (4585:2): [True: 16, False: 188]
  ------------------
 4586|     16|		flags |= SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  102|     16|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
 4587|     16|		break;
 4588|      0|	case CKM_RSA_PKCS_OAEP:
  ------------------
  |  |  547|      0|#define CKM_RSA_PKCS_OAEP 0x00000009UL
  ------------------
  |  Branch (4588:2): [True: 0, False: 204]
  ------------------
 4589|      0|		flags |= SC_ALGORITHM_RSA_PAD_OAEP;
  ------------------
  |  |  108|      0|#define SC_ALGORITHM_RSA_PAD_OAEP	0x00000020 /* PKCS#1 v2.0 OAEP */
  ------------------
 4590|       |
 4591|       |		/* Omitted parameter can use MGF1-SHA1 and SHA1 hash ? */
 4592|      0|		if (pMechanism->pParameter == NULL) {
  ------------------
  |  Branch (4592:7): [True: 0, False: 0]
  ------------------
 4593|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|      0|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
 4594|      0|			flags |= SC_ALGORITHM_MGF1_SHA1;
  ------------------
  |  |  145|      0|#define SC_ALGORITHM_MGF1_SHA1		0x00100000
  ------------------
 4595|      0|			break;
 4596|      0|		}
 4597|       |
 4598|      0|		switch (((CK_RSA_PKCS_OAEP_PARAMS*)pMechanism->pParameter)->hashAlg) {
 4599|      0|		case CKM_SHA_1:
  ------------------
  |  |  667|      0|#define CKM_SHA_1 0x00000220UL
  ------------------
  |  Branch (4599:3): [True: 0, False: 0]
  ------------------
 4600|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  134|      0|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
 4601|      0|			break;
 4602|      0|		case CKM_SHA224:
  ------------------
  |  |  679|      0|#define CKM_SHA224 0x00000255UL
  ------------------
  |  Branch (4602:3): [True: 0, False: 0]
  ------------------
 4603|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA224;
  ------------------
  |  |  141|      0|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  ------------------
 4604|      0|			break;
 4605|      0|		case CKM_SHA256:
  ------------------
  |  |  676|      0|#define CKM_SHA256 0x00000250UL
  ------------------
  |  Branch (4605:3): [True: 0, False: 0]
  ------------------
 4606|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA256;
  ------------------
  |  |  138|      0|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
 4607|      0|			break;
 4608|      0|		case CKM_SHA384:
  ------------------
  |  |  682|      0|#define CKM_SHA384 0x00000260UL
  ------------------
  |  Branch (4608:3): [True: 0, False: 0]
  ------------------
 4609|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA384;
  ------------------
  |  |  139|      0|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
 4610|      0|			break;
 4611|      0|		case CKM_SHA512:
  ------------------
  |  |  685|      0|#define CKM_SHA512 0x00000270UL
  ------------------
  |  Branch (4611:3): [True: 0, False: 0]
  ------------------
 4612|      0|			flags |= SC_ALGORITHM_RSA_HASH_SHA512;
  ------------------
  |  |  140|      0|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
 4613|      0|			break;
 4614|      0|		default:
  ------------------
  |  Branch (4614:3): [True: 0, False: 0]
  ------------------
 4615|      0|			return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      0|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
 4616|      0|		}
 4617|       |
 4618|       |		/* The MGF parameter was already verified in SignInit() */
 4619|      0|		flags |= mgf2flags(((CK_RSA_PKCS_OAEP_PARAMS*)pMechanism->pParameter)->mgf);
 4620|      0|		break;
 4621|      1|	default:
  ------------------
  |  Branch (4621:2): [True: 1, False: 203]
  ------------------
 4622|      1|		return CKR_MECHANISM_INVALID;
  ------------------
  |  | 1122|      1|#define CKR_MECHANISM_INVALID 0x00000070UL
  ------------------
 4623|    204|	}
 4624|       |
 4625|    203|	rv = sc_lock(p11card->card);
 4626|    203|	if (rv < 0)
  ------------------
  |  Branch (4626:6): [True: 0, False: 203]
  ------------------
 4627|      0|		return sc_to_cryptoki_error(rv, "C_Decrypt");
 4628|       |
 4629|    203|	rv = sc_pkcs15_decipher(fw_data->p15_card, prkey->prv_p15obj, flags,
  ------------------
  |  |  105|    203|#define prv_p15obj		base.p15_object
  ------------------
 4630|    203|			pEncryptedData, ulEncryptedDataLen, decrypted, sizeof(decrypted), pMechanism);
 4631|       |
 4632|    203|	sc_unlock(p11card->card);
 4633|       |
 4634|    203|	sc_log(context, "Decryption complete.");
  ------------------
  |  |   71|    203|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4635|       |
 4636|       |	/* Handle following code in constant-time
 4637|       |	 * to prevent Marvin attack for PKCS#1 v1.5 padding. */
 4638|       |
 4639|       |	/* only padding error must be handled in constant-time way,
 4640|       |	 * other error can be returned straight away */
 4641|    203|	if ((~constant_time_eq_s((size_t)rv, (size_t)SC_ERROR_WRONG_PADDING) & constant_time_lt_s(sizeof(decrypted), (size_t)rv)))
  ------------------
  |  |   93|    203|#define SC_ERROR_WRONG_PADDING			-1412
  ------------------
  |  Branch (4641:6): [True: 136, False: 67]
  ------------------
 4642|    136|		return sc_to_cryptoki_error(rv, "C_Decrypt");
 4643|       |
 4644|       |	/* check rv for padding error */
 4645|     67|	good = ~constant_time_eq_i(rv, SC_ERROR_WRONG_PADDING);
  ------------------
  |  |   93|     67|#define SC_ERROR_WRONG_PADDING			-1412
  ------------------
 4646|     67|	rv_pkcs11 = sc_to_cryptoki_error(SC_ERROR_WRONG_PADDING, "C_Decrypt");
  ------------------
  |  |   93|     67|#define SC_ERROR_WRONG_PADDING			-1412
  ------------------
 4647|     67|	rv_pkcs11 = constant_time_select_s(good, CKR_OK, rv_pkcs11);
  ------------------
  |  | 1086|     67|#define CKR_OK 0x00000000UL
  ------------------
 4648|       |
 4649|     67|	if (pData == NULL_PTR) {
  ------------------
  |  |   27|     67|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (4649:6): [True: 0, False: 67]
  ------------------
 4650|       |		/* set length only if no error */
 4651|      0|		*pulDataLen = constant_time_select_s(good, rv, *pulDataLen);
 4652|       |		/* return error only if original rv < 0 */
 4653|      0|		return rv_pkcs11;
 4654|      0|	}
 4655|       |
 4656|       |	/* check whether *pulDataLen < rv and set return value for small output buffer */
 4657|     67|	mask = good & constant_time_lt_s(*pulDataLen, rv);
 4658|     67|	rv_pkcs11 = constant_time_select_s(mask, CKR_BUFFER_TOO_SMALL, rv_pkcs11);
  ------------------
  |  | 1165|     67|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
 4659|     67|	good &= ~mask;
 4660|       |
 4661|       |	/* move everything from decrypted into out buffer constant-time, if rv is ok */
 4662|  68.6k|	for (CK_ULONG i = 0; i < *pulDataLen; i++) { /* iterate over whole pData to not disclose real depadded length */
  ------------------
  |  Branch (4662:23): [True: 68.6k, False: 67]
  ------------------
 4663|  68.6k|		CK_ULONG msg_index;
 4664|  68.6k|		mask = good & constant_time_lt_s(i, sizeof(decrypted));		    /* i should be in the bounds of decrypted */
 4665|  68.6k|		mask &= constant_time_lt_s(i, constant_time_select_s(good, rv, 0)); /* check that is in bounds of depadded message */
 4666|  68.6k|		msg_index = constant_time_select_s(mask, i, 0);
 4667|  68.6k|		pData[i] = constant_time_select_8(mask, decrypted[msg_index], pData[i]);
 4668|  68.6k|	}
 4669|     67|	*pulDataLen = constant_time_select_s(good, rv, *pulDataLen);
 4670|       |	/* do not log error code to prevent side channel attack */
 4671|     67|	return rv_pkcs11;
 4672|     67|}
framework-pkcs15.c:pkcs15_prkey_can_do:
 4751|    456|{
 4752|    456|	struct sc_pkcs11_card *p11card = session->slot->p11card;
 4753|    456|	struct pkcs15_fw_data *fw_data = NULL;
 4754|    456|	struct pkcs15_prkey_object *prkey = (struct pkcs15_prkey_object *) obj;
 4755|    456|	struct sc_pkcs15_prkey_info *pkinfo = NULL;
 4756|    456|	struct sc_supported_algo_info *token_algos = NULL;
 4757|    456|	int ii, jj;
 4758|       |
 4759|    456|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|    456|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    456|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    456|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    456|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 456]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4760|    456|	sc_log(context, "check hardware capabilities: CK_MECHANISM_TYPE=0x%lx (CKM) and CKF_xxx=0x%x", mech_type, flags);
  ------------------
  |  |   71|    456|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4761|       |
 4762|    456|	if (!prkey || !prkey->prv_info)
  ------------------
  |  Branch (4762:6): [True: 0, False: 456]
  |  Branch (4762:16): [True: 0, False: 456]
  ------------------
 4763|    456|		LOG_FUNC_RETURN(context, CKR_KEY_FUNCTION_NOT_PERMITTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4764|       |
 4765|    456|	pkinfo = prkey->prv_info;
 4766|       |	/* Return if there are no usage algorithms specified for this key. */
 4767|    456|	if (!pkinfo->algo_refs[0])
  ------------------
  |  Branch (4767:6): [True: 456, False: 0]
  ------------------
 4768|    456|		LOG_FUNC_RETURN(context, CKR_FUNCTION_NOT_SUPPORTED);
  ------------------
  |  |  164|    456|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    456|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    456|	int _ret = r; \
  |  |  |  |  155|    456|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 456]
  |  |  |  |  ------------------
  |  |  |  |  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|    456|	} else { \
  |  |  |  |  159|    456|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    456|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    456|	} \
  |  |  |  |  162|    456|	return _ret; \
  |  |  |  |  163|    456|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4769|       |
 4770|      0|	if (!p11card)
  ------------------
  |  Branch (4770:6): [True: 0, False: 0]
  ------------------
 4771|      0|		LOG_FUNC_RETURN(context, CKR_FUNCTION_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4772|      0|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[session->slot->fw_data_idx];
 4773|      0|	if (!fw_data->p15_card)
  ------------------
  |  Branch (4773:6): [True: 0, False: 0]
  ------------------
 4774|      0|		LOG_FUNC_RETURN(context, CKR_FUNCTION_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4775|      0|	token_algos = &fw_data->p15_card->tokeninfo->supported_algos[0];
 4776|       |
 4777|      0|	for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS && pkinfo->algo_refs[ii];ii++)   {
  ------------------
  |  |   61|      0|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (4777:12): [True: 0, False: 0]
  |  Branch (4777:46): [True: 0, False: 0]
  ------------------
 4778|       |		/* Look for algorithm supported by token referenced in the list of key's algorithms */
 4779|      0|		for (jj=0;jj<SC_MAX_SUPPORTED_ALGORITHMS && (token_algos + jj)->reference; jj++)
  ------------------
  |  |   61|      0|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (4779:13): [True: 0, False: 0]
  |  Branch (4779:47): [True: 0, False: 0]
  ------------------
 4780|      0|			if (pkinfo->algo_refs[ii] == (token_algos + jj)->reference)
  ------------------
  |  Branch (4780:8): [True: 0, False: 0]
  ------------------
 4781|      0|				break;
 4782|      0|		if ((jj == SC_MAX_SUPPORTED_ALGORITHMS) || !(token_algos + jj)->reference)
  ------------------
  |  |   61|      0|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (4782:7): [True: 0, False: 0]
  |  Branch (4782:46): [True: 0, False: 0]
  ------------------
 4783|      0|			LOG_FUNC_RETURN(context, CKR_GENERAL_ERROR);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4784|       |
 4785|      0|		if ((token_algos + jj)->mechanism != mech_type)
  ------------------
  |  Branch (4785:7): [True: 0, False: 0]
  ------------------
 4786|      0|			continue;
 4787|       |
 4788|      0|		if (flags == CKF_SIGN)
  ------------------
  |  |  363|      0|#define CKF_SIGN 0x00000800UL
  ------------------
  |  Branch (4788:7): [True: 0, False: 0]
  ------------------
 4789|      0|			if ((token_algos + jj)->operations & SC_PKCS15_ALGO_OP_COMPUTE_SIGNATURE)
  ------------------
  |  |  138|      0|#define SC_PKCS15_ALGO_OP_COMPUTE_SIGNATURE	0x02
  ------------------
  |  Branch (4789:8): [True: 0, False: 0]
  ------------------
 4790|      0|				break;
 4791|       |
 4792|      0|		if (flags == CKF_DECRYPT)
  ------------------
  |  |  361|      0|#define CKF_DECRYPT 0x00000200UL
  ------------------
  |  Branch (4792:7): [True: 0, False: 0]
  ------------------
 4793|      0|			if ((token_algos + jj)->operations & SC_PKCS15_ALGO_OP_DECIPHER)
  ------------------
  |  |  142|      0|#define SC_PKCS15_ALGO_OP_DECIPHER		0x20
  ------------------
  |  Branch (4793:8): [True: 0, False: 0]
  ------------------
 4794|      0|				break;
 4795|      0|	}
 4796|       |
 4797|      0|	if (ii == SC_MAX_SUPPORTED_ALGORITHMS || !pkinfo->algo_refs[ii])
  ------------------
  |  |   61|      0|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (4797:6): [True: 0, False: 0]
  |  Branch (4797:43): [True: 0, False: 0]
  ------------------
 4798|      0|		LOG_FUNC_RETURN(context, CKR_MECHANISM_INVALID);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4799|       |
 4800|      0|	LOG_FUNC_RETURN(context, CKR_OK);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4801|      0|}
framework-pkcs15.c:pkcs15_prkey_init_params:
 4807|    456|{
 4808|    456|	const CK_RSA_PKCS_PSS_PARAMS *pss_params;
 4809|    456|	unsigned int expected_hash = 0, i;
 4810|    456|	const unsigned int hashes[5] = { CKM_SHA_1, CKM_SHA256,
  ------------------
  |  |  667|    456|#define CKM_SHA_1 0x00000220UL
  ------------------
              	const unsigned int hashes[5] = { CKM_SHA_1, CKM_SHA256,
  ------------------
  |  |  676|    456|#define CKM_SHA256 0x00000250UL
  ------------------
 4811|    456|		CKM_SHA384, CKM_SHA512, CKM_SHA224 };
  ------------------
  |  |  682|    456|#define CKM_SHA384 0x00000260UL
  ------------------
              		CKM_SHA384, CKM_SHA512, CKM_SHA224 };
  ------------------
  |  |  685|    456|#define CKM_SHA512 0x00000270UL
  ------------------
              		CKM_SHA384, CKM_SHA512, CKM_SHA224 };
  ------------------
  |  |  679|    456|#define CKM_SHA224 0x00000255UL
  ------------------
 4812|    456|	const CK_RSA_PKCS_OAEP_PARAMS *oaep_params;
 4813|       |
 4814|    456|	switch (pMechanism->mechanism) {
  ------------------
  |  Branch (4814:10): [True: 7, False: 449]
  ------------------
 4815|      1|	case CKM_RSA_PKCS_PSS:
  ------------------
  |  |  551|      1|#define CKM_RSA_PKCS_PSS 0x0000000DUL
  ------------------
  |  Branch (4815:2): [True: 1, False: 455]
  ------------------
 4816|      2|	case CKM_SHA1_RSA_PKCS_PSS:
  ------------------
  |  |  552|      2|#define CKM_SHA1_RSA_PKCS_PSS 0x0000000EUL
  ------------------
  |  Branch (4816:2): [True: 1, False: 455]
  ------------------
 4817|      3|	case CKM_SHA224_RSA_PKCS_PSS:
  ------------------
  |  |  605|      3|#define CKM_SHA224_RSA_PKCS_PSS 0x00000047UL
  ------------------
  |  Branch (4817:2): [True: 1, False: 455]
  ------------------
 4818|      4|	case CKM_SHA256_RSA_PKCS_PSS:
  ------------------
  |  |  601|      4|#define CKM_SHA256_RSA_PKCS_PSS 0x00000043UL
  ------------------
  |  Branch (4818:2): [True: 1, False: 455]
  ------------------
 4819|      5|	case CKM_SHA384_RSA_PKCS_PSS:
  ------------------
  |  |  602|      5|#define CKM_SHA384_RSA_PKCS_PSS 0x00000044UL
  ------------------
  |  Branch (4819:2): [True: 1, False: 455]
  ------------------
 4820|      6|	case CKM_SHA512_RSA_PKCS_PSS:
  ------------------
  |  |  603|      6|#define CKM_SHA512_RSA_PKCS_PSS 0x00000045UL
  ------------------
  |  Branch (4820:2): [True: 1, False: 455]
  ------------------
 4821|      6|		if (!pMechanism->pParameter ||
  ------------------
  |  Branch (4821:7): [True: 6, False: 0]
  ------------------
 4822|      0|			pMechanism->ulParameterLen != sizeof(CK_RSA_PKCS_PSS_PARAMS))
  ------------------
  |  Branch (4822:4): [True: 0, False: 0]
  ------------------
 4823|      6|			return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      6|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
 4824|       |
 4825|      0|		pss_params = (CK_RSA_PKCS_PSS_PARAMS*)pMechanism->pParameter;
 4826|      0|		if (pss_params->mgf < CKG_MGF1_SHA1 || pss_params->mgf > CKG_MGF1_SHA224)
  ------------------
  |  |  442|      0|#define CKG_MGF1_SHA1 0x00000001UL
  ------------------
              		if (pss_params->mgf < CKG_MGF1_SHA1 || pss_params->mgf > CKG_MGF1_SHA224)
  ------------------
  |  |  446|      0|#define CKG_MGF1_SHA224 0x00000005UL
  ------------------
  |  Branch (4826:7): [True: 0, False: 0]
  |  Branch (4826:42): [True: 0, False: 0]
  ------------------
 4827|      0|			return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      0|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
 4828|       |
 4829|       |		/* The hashAlg field can have any value for CKM_RSA_PKCS_PSS and must be
 4830|       |		 * used again in the PSS padding; for the other mechanisms it strictly
 4831|       |		 * must match the padding declared in the mechanism.
 4832|       |		 */
 4833|      0|		if (pMechanism->mechanism == CKM_SHA1_RSA_PKCS_PSS) {
  ------------------
  |  |  552|      0|#define CKM_SHA1_RSA_PKCS_PSS 0x0000000EUL
  ------------------
  |  Branch (4833:7): [True: 0, False: 0]
  ------------------
 4834|      0|			expected_hash = CKM_SHA_1;
  ------------------
  |  |  667|      0|#define CKM_SHA_1 0x00000220UL
  ------------------
 4835|      0|		} else if (pMechanism->mechanism == CKM_SHA224_RSA_PKCS_PSS) {
  ------------------
  |  |  605|      0|#define CKM_SHA224_RSA_PKCS_PSS 0x00000047UL
  ------------------
  |  Branch (4835:14): [True: 0, False: 0]
  ------------------
 4836|      0|			expected_hash = CKM_SHA224;
  ------------------
  |  |  679|      0|#define CKM_SHA224 0x00000255UL
  ------------------
 4837|      0|		} else if (pMechanism->mechanism == CKM_SHA256_RSA_PKCS_PSS) {
  ------------------
  |  |  601|      0|#define CKM_SHA256_RSA_PKCS_PSS 0x00000043UL
  ------------------
  |  Branch (4837:14): [True: 0, False: 0]
  ------------------
 4838|      0|			expected_hash = CKM_SHA256;
  ------------------
  |  |  676|      0|#define CKM_SHA256 0x00000250UL
  ------------------
 4839|      0|		} else if (pMechanism->mechanism == CKM_SHA384_RSA_PKCS_PSS) {
  ------------------
  |  |  602|      0|#define CKM_SHA384_RSA_PKCS_PSS 0x00000044UL
  ------------------
  |  Branch (4839:14): [True: 0, False: 0]
  ------------------
 4840|      0|			expected_hash = CKM_SHA384;
  ------------------
  |  |  682|      0|#define CKM_SHA384 0x00000260UL
  ------------------
 4841|      0|		} else if (pMechanism->mechanism == CKM_SHA512_RSA_PKCS_PSS) {
  ------------------
  |  |  603|      0|#define CKM_SHA512_RSA_PKCS_PSS 0x00000045UL
  ------------------
  |  Branch (4841:14): [True: 0, False: 0]
  ------------------
 4842|      0|			expected_hash = CKM_SHA512;
  ------------------
  |  |  685|      0|#define CKM_SHA512 0x00000270UL
  ------------------
 4843|      0|		} else if (pMechanism->mechanism == CKM_RSA_PKCS_PSS) {
  ------------------
  |  |  551|      0|#define CKM_RSA_PKCS_PSS 0x0000000DUL
  ------------------
  |  Branch (4843:14): [True: 0, False: 0]
  ------------------
 4844|      0|			for (i = 0; i < 5; ++i) {
  ------------------
  |  Branch (4844:16): [True: 0, False: 0]
  ------------------
 4845|      0|				if (hashes[i] == pss_params->hashAlg) {
  ------------------
  |  Branch (4845:9): [True: 0, False: 0]
  ------------------
 4846|      0|					expected_hash = hashes[i];
 4847|      0|				}
 4848|      0|			}
 4849|      0|		}
 4850|       |
 4851|      0|		if (expected_hash != pss_params->hashAlg)
  ------------------
  |  Branch (4851:7): [True: 0, False: 0]
  ------------------
 4852|      0|			return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      0|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
 4853|       |
 4854|      0|		break;
 4855|      1|	case CKM_RSA_PKCS_OAEP:
  ------------------
  |  |  547|      1|#define CKM_RSA_PKCS_OAEP 0x00000009UL
  ------------------
  |  Branch (4855:2): [True: 1, False: 455]
  ------------------
 4856|      1|		if (!pMechanism->pParameter ||
  ------------------
  |  Branch (4856:7): [True: 1, False: 0]
  ------------------
 4857|      0|			pMechanism->ulParameterLen != sizeof(CK_RSA_PKCS_OAEP_PARAMS))
  ------------------
  |  Branch (4857:4): [True: 0, False: 0]
  ------------------
 4858|      1|			return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      1|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
 4859|       |
 4860|      0|		oaep_params = (CK_RSA_PKCS_OAEP_PARAMS*)pMechanism->pParameter;
 4861|      0|		switch (oaep_params->mgf) {
 4862|      0|		case CKG_MGF1_SHA1:
  ------------------
  |  |  442|      0|#define CKG_MGF1_SHA1 0x00000001UL
  ------------------
  |  Branch (4862:3): [True: 0, False: 0]
  ------------------
 4863|      0|		case CKG_MGF1_SHA224:
  ------------------
  |  |  446|      0|#define CKG_MGF1_SHA224 0x00000005UL
  ------------------
  |  Branch (4863:3): [True: 0, False: 0]
  ------------------
 4864|      0|		case CKG_MGF1_SHA256:
  ------------------
  |  |  443|      0|#define CKG_MGF1_SHA256 0x00000002UL
  ------------------
  |  Branch (4864:3): [True: 0, False: 0]
  ------------------
 4865|      0|		case CKG_MGF1_SHA384:
  ------------------
  |  |  444|      0|#define CKG_MGF1_SHA384 0x00000003UL
  ------------------
  |  Branch (4865:3): [True: 0, False: 0]
  ------------------
 4866|      0|		case CKG_MGF1_SHA512:
  ------------------
  |  |  445|      0|#define CKG_MGF1_SHA512 0x00000004UL
  ------------------
  |  Branch (4866:3): [True: 0, False: 0]
  ------------------
 4867|       |			/* OK */
 4868|      0|			break;
 4869|      0|		default:
  ------------------
  |  Branch (4869:3): [True: 0, False: 0]
  ------------------
 4870|      0|			return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      0|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
 4871|      0|		}
 4872|       |		/* TODO is there something more to check */
 4873|      0|		break;
 4874|    456|	}
 4875|    449|	return CKR_OK;
  ------------------
  |  | 1086|    449|#define CKR_OK 0x00000000UL
  ------------------
 4876|    456|}
framework-pkcs15.c:pkcs15_pubkey_release:
 4901|  2.85k|{
 4902|  2.85k|	struct pkcs15_pubkey_object *pubkey = (struct pkcs15_pubkey_object*) object;
 4903|  2.85k|	struct sc_pkcs15_pubkey *key_data = pubkey->pub_data;
 4904|       |
 4905|  2.85k|	if (__pkcs15_release_object((struct pkcs15_any_object *) object) == 0)
  ------------------
  |  Branch (4905:6): [True: 1.44k, False: 1.41k]
  ------------------
 4906|  1.44k|		if (key_data)
  ------------------
  |  Branch (4906:7): [True: 1.13k, False: 310]
  ------------------
 4907|  1.13k|			sc_pkcs15_free_pubkey(key_data);
 4908|  2.85k|}
framework-pkcs15.c:pkcs15_pubkey_get_attribute:
 4922|  7.00k|{
 4923|  7.00k|	struct sc_pkcs11_card *p11card = NULL;
 4924|  7.00k|	struct pkcs15_pubkey_object *pubkey = (struct pkcs15_pubkey_object*) object;
 4925|  7.00k|	struct pkcs15_cert_object *cert = NULL;
 4926|  7.00k|	struct pkcs15_fw_data *fw_data = NULL;
 4927|  7.00k|	size_t len;
 4928|       |
 4929|  7.00k|	sc_log(context, "pkcs15_pubkey_get_attribute() called");
  ------------------
  |  |   71|  7.00k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4930|       |
 4931|  7.00k|	p11card = session->slot->p11card;
 4932|  7.00k|	cert = pubkey->pub_genfrom;
  ------------------
  |  |  117|  7.00k|#define pub_genfrom		base.related_cert
  ------------------
 4933|       |
 4934|  7.00k|	if (!p11card)
  ------------------
  |  Branch (4934:6): [True: 0, False: 7.00k]
  ------------------
 4935|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GetAttributeValue");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 4936|  7.00k|	fw_data = (struct pkcs15_fw_data *) p11card->fws_data[session->slot->fw_data_idx];
 4937|  7.00k|	if (!fw_data)
  ------------------
  |  Branch (4937:6): [True: 0, False: 7.00k]
  ------------------
 4938|      0|		return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetAttributeValue");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4939|  7.00k|	if (!fw_data->p15_card)
  ------------------
  |  Branch (4939:6): [True: 0, False: 7.00k]
  ------------------
 4940|      0|		return sc_to_cryptoki_error(SC_ERROR_INVALID_CARD, "C_GetAttributeValue");
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 4941|       |
 4942|       |	/* We may need to get these from cert */
 4943|  7.00k|	switch (attr->type) {
  ------------------
  |  Branch (4943:10): [True: 93, False: 6.91k]
  ------------------
 4944|      0|		case CKA_MODULUS:
  ------------------
  |  |  174|      0|#define CKA_MODULUS 0x00000120UL
  ------------------
  |  Branch (4944:3): [True: 0, False: 7.00k]
  ------------------
 4945|      0|		case CKA_MODULUS_BITS:
  ------------------
  |  |  175|      0|#define CKA_MODULUS_BITS 0x00000121UL
  ------------------
  |  Branch (4945:3): [True: 0, False: 7.00k]
  ------------------
 4946|      0|		case CKA_VALUE:
  ------------------
  |  |  143|      0|#define CKA_VALUE 0x00000011UL
  ------------------
  |  Branch (4946:3): [True: 0, False: 7.00k]
  ------------------
 4947|     93|		case CKA_SPKI:
  ------------------
  |  |   21|     93|#define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |  289|     93|#define CKA_VENDOR_DEFINED 0x80000000UL
  |  |  ------------------
  |  |               #define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |   12|     93|#define SC_VENDOR_DEFINED 0x4F534300  /* OSC */
  |  |  ------------------
  ------------------
  |  Branch (4947:3): [True: 93, False: 6.91k]
  ------------------
 4948|     93|		case CKA_PUBLIC_KEY_INFO:
  ------------------
  |  |  183|     93|#define CKA_PUBLIC_KEY_INFO 0x00000129UL
  ------------------
  |  Branch (4948:3): [True: 0, False: 7.00k]
  ------------------
 4949|     93|		case CKA_PUBLIC_EXPONENT:
  ------------------
  |  |  176|     93|#define CKA_PUBLIC_EXPONENT 0x00000122UL
  ------------------
  |  Branch (4949:3): [True: 0, False: 7.00k]
  ------------------
 4950|     93|		case CKA_EC_PARAMS:
  ------------------
  |  |  200|     93|#define CKA_EC_PARAMS 0x00000180UL
  ------------------
  |  Branch (4950:3): [True: 0, False: 7.00k]
  ------------------
 4951|     93|		case CKA_EC_POINT:
  ------------------
  |  |  201|     93|#define CKA_EC_POINT 0x00000181UL
  ------------------
  |  Branch (4951:3): [True: 0, False: 7.00k]
  ------------------
 4952|     93|			if (pubkey->pub_data == NULL)
  ------------------
  |  Branch (4952:8): [True: 4, False: 89]
  ------------------
 4953|      4|				if (SC_SUCCESS != check_cert_data_read(fw_data, cert))
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  |  Branch (4953:9): [True: 4, False: 0]
  ------------------
 4954|      4|					return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "check_cert_data_read");
  ------------------
  |  |   81|      4|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4955|     89|			break;
 4956|  7.00k|	}
 4957|       |
 4958|  7.00k|	switch (attr->type) {
 4959|  3.65k|	case CKA_CLASS:
  ------------------
  |  |  137|  3.65k|#define CKA_CLASS 0x00000000UL
  ------------------
  |  Branch (4959:2): [True: 3.65k, False: 3.35k]
  ------------------
 4960|  3.65k|		check_attribute_buffer(attr, sizeof(CK_OBJECT_CLASS));
  ------------------
  |  |   56|  3.65k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  7.30k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 1.82k, False: 1.82k]
  |  |  ------------------
  |  |   57|  1.82k|		attr->ulValueLen = size;        \
  |  |   58|  1.82k|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|  1.82k|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|  1.82k|	}                                       \
  |  |   60|  3.65k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 1.82k]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|  1.82k|	attr->ulValueLen = size;
  ------------------
 4961|  1.82k|		*(CK_OBJECT_CLASS*)attr->pValue = CKO_PUBLIC_KEY;
  ------------------
  |  | 1029|  1.82k|#define CKO_PUBLIC_KEY 0x00000002UL
  ------------------
 4962|  1.82k|		break;
 4963|      0|	case CKA_TOKEN:
  ------------------
  |  |  138|      0|#define CKA_TOKEN 0x00000001UL
  ------------------
  |  Branch (4963:2): [True: 0, False: 7.00k]
  ------------------
 4964|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4965|      0|		*(CK_BBOOL*)attr->pValue = TRUE;
  ------------------
  |  |   51|      0|#define TRUE 1
  ------------------
 4966|      0|		break;
 4967|      0|	case CKA_SENSITIVE:
  ------------------
  |  |  162|      0|#define CKA_SENSITIVE 0x00000103UL
  ------------------
  |  Branch (4967:2): [True: 0, False: 7.00k]
  ------------------
 4968|       |		/* By PKCS#11 v2.20 public key cannot have SENSITIVE attr TRUE */
 4969|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4970|      0|		*(CK_BBOOL*)attr->pValue = FALSE;
  ------------------
  |  |   48|      0|#define FALSE 0
  ------------------
 4971|      0|		break;
 4972|      0|	case CKA_LOCAL:
  ------------------
  |  |  193|      0|#define CKA_LOCAL 0x00000163UL
  ------------------
  |  Branch (4972:2): [True: 0, False: 7.00k]
  ------------------
 4973|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4974|      0|		if (pubkey->pub_info)
  ------------------
  |  Branch (4974:7): [True: 0, False: 0]
  ------------------
 4975|      0|			*(CK_BBOOL*)attr->pValue = (pubkey->pub_info->access_flags & SC_PKCS15_PRKEY_ACCESS_LOCAL) != 0;
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
 4976|      0|		else /* no pub_info structure, falling back to TRUE */
 4977|      0|			*(CK_BBOOL*)attr->pValue = TRUE;
  ------------------
  |  |   51|      0|#define TRUE 1
  ------------------
 4978|      0|		break;
 4979|  1.69k|	case CKA_PRIVATE:
  ------------------
  |  |  139|  1.69k|#define CKA_PRIVATE 0x00000002UL
  ------------------
  |  Branch (4979:2): [True: 1.69k, False: 5.30k]
  ------------------
 4980|  3.39k|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|  1.69k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  3.39k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 1.69k]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|  1.69k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 1.69k]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|  1.69k|	attr->ulValueLen = size;
  ------------------
 4981|  3.39k|		if (pubkey->pub_p15obj)
  ------------------
  |  |  116|  1.69k|#define pub_p15obj		base.p15_object
  ------------------
  |  Branch (4981:7): [True: 1.53k, False: 166]
  ------------------
 4982|  1.53k|			*(CK_BBOOL*)attr->pValue = (pubkey->pub_p15obj->flags & SC_PKCS15_CO_FLAG_PRIVATE) != 0;
  ------------------
  |  |  116|  1.53k|#define pub_p15obj		base.p15_object
  ------------------
              			*(CK_BBOOL*)attr->pValue = (pubkey->pub_p15obj->flags & SC_PKCS15_CO_FLAG_PRIVATE) != 0;
  ------------------
  |  |   50|  1.53k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 4983|    166|		else if (cert && cert->cert_p15obj)
  ------------------
  |  |   93|    166|#define cert_p15obj		base.p15_object
  ------------------
  |  Branch (4983:12): [True: 166, False: 0]
  |  Branch (4983:20): [True: 166, False: 0]
  ------------------
 4984|    166|			*(CK_BBOOL*)attr->pValue = (cert->pub_p15obj->flags & SC_PKCS15_CO_FLAG_PRIVATE) != 0;
  ------------------
  |  |  116|    166|#define pub_p15obj		base.p15_object
  ------------------
              			*(CK_BBOOL*)attr->pValue = (cert->pub_p15obj->flags & SC_PKCS15_CO_FLAG_PRIVATE) != 0;
  ------------------
  |  |   50|    166|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 4985|      0|		else
 4986|      0|			return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 4987|  1.69k|		break;
 4988|  1.69k|	case CKA_MODIFIABLE:
  ------------------
  |  |  197|      0|#define CKA_MODIFIABLE 0x00000170UL
  ------------------
  |  Branch (4988:2): [True: 0, False: 7.00k]
  ------------------
 4989|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4990|      0|		if (pubkey->pub_p15obj)
  ------------------
  |  |  116|      0|#define pub_p15obj		base.p15_object
  ------------------
  |  Branch (4990:7): [True: 0, False: 0]
  ------------------
 4991|      0|			*(CK_BBOOL*)attr->pValue = (pubkey->pub_p15obj->flags & SC_PKCS15_CO_FLAG_MODIFIABLE) != 0;
  ------------------
  |  |  116|      0|#define pub_p15obj		base.p15_object
  ------------------
              			*(CK_BBOOL*)attr->pValue = (pubkey->pub_p15obj->flags & SC_PKCS15_CO_FLAG_MODIFIABLE) != 0;
  ------------------
  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
 4992|      0|		else if (cert && cert->cert_p15obj)
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
  |  Branch (4992:12): [True: 0, False: 0]
  |  Branch (4992:20): [True: 0, False: 0]
  ------------------
 4993|      0|			*(CK_BBOOL*)attr->pValue = (cert->pub_p15obj->flags & SC_PKCS15_CO_FLAG_MODIFIABLE) != 0;
  ------------------
  |  |  116|      0|#define pub_p15obj		base.p15_object
  ------------------
              			*(CK_BBOOL*)attr->pValue = (cert->pub_p15obj->flags & SC_PKCS15_CO_FLAG_MODIFIABLE) != 0;
  ------------------
  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
 4994|      0|		else
 4995|      0|			return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 4996|      0|		break;
 4997|      0|	case CKA_EXTRACTABLE:
  ------------------
  |  |  192|      0|#define CKA_EXTRACTABLE 0x00000162UL
  ------------------
  |  Branch (4997:2): [True: 0, False: 7.00k]
  ------------------
 4998|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 4999|      0|		if (pubkey->pub_info)
  ------------------
  |  Branch (4999:7): [True: 0, False: 0]
  ------------------
 5000|      0|			*(CK_BBOOL*)attr->pValue = (pubkey->pub_info->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) != 0;
  ------------------
  |  |  317|      0|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
 5001|      0|		else /* no pub_info structure, falling back to TRUE */
 5002|      0|			*(CK_BBOOL*)attr->pValue = TRUE;
  ------------------
  |  |   51|      0|#define TRUE 1
  ------------------
 5003|      0|		break;
 5004|      0|	case CKA_LABEL:
  ------------------
  |  |  140|      0|#define CKA_LABEL 0x00000003UL
  ------------------
  |  Branch (5004:2): [True: 0, False: 7.00k]
  ------------------
 5005|      0|		if (pubkey->pub_p15obj) {
  ------------------
  |  |  116|      0|#define pub_p15obj		base.p15_object
  ------------------
  |  Branch (5005:7): [True: 0, False: 0]
  ------------------
 5006|      0|			len = strnlen(pubkey->pub_p15obj->label, sizeof pubkey->pub_p15obj->label);
  ------------------
  |  |  116|      0|#define pub_p15obj		base.p15_object
  ------------------
              			len = strnlen(pubkey->pub_p15obj->label, sizeof pubkey->pub_p15obj->label);
  ------------------
  |  |  116|      0|#define pub_p15obj		base.p15_object
  ------------------
 5007|      0|			check_attribute_buffer(attr, len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5008|      0|			memcpy(attr->pValue, pubkey->pub_p15obj->label, len);
  ------------------
  |  |  116|      0|#define pub_p15obj		base.p15_object
  ------------------
 5009|      0|		}
 5010|      0|		else if (cert && cert->cert_p15obj) {
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
  |  Branch (5010:12): [True: 0, False: 0]
  |  Branch (5010:20): [True: 0, False: 0]
  ------------------
 5011|      0|			len = strnlen(cert->cert_p15obj->label, sizeof cert->cert_p15obj->label);
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
              			len = strnlen(cert->cert_p15obj->label, sizeof cert->cert_p15obj->label);
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
 5012|      0|			check_attribute_buffer(attr, len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5013|      0|			memcpy(attr->pValue, cert->cert_p15obj->label, len);
  ------------------
  |  |   93|      0|#define cert_p15obj		base.p15_object
  ------------------
 5014|      0|		}
 5015|      0|		else {
 5016|      0|			return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 5017|      0|		}
 5018|      0|		break;
 5019|    123|	case CKA_KEY_TYPE:
  ------------------
  |  |  159|    123|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  |  Branch (5019:2): [True: 123, False: 6.88k]
  ------------------
 5020|    123|		check_attribute_buffer(attr, sizeof(CK_KEY_TYPE));
  ------------------
  |  |   56|    123|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|    246|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 123]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|    123|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 123]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|    123|	attr->ulValueLen = size;
  ------------------
 5021|       |		/* TODO: -DEE why would we not have a pubkey->pub_data? */
 5022|       |		/* even if we do not, we should not assume RSA */
 5023|    123|		if (pubkey->pub_data && pubkey->pub_data->algorithm == SC_ALGORITHM_GOSTR3410)
  ------------------
  |  |   71|    111|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (5023:7): [True: 111, False: 12]
  |  Branch (5023:27): [True: 0, False: 111]
  ------------------
 5024|      0|			*(CK_KEY_TYPE*)attr->pValue = CKK_GOSTR3410;
  ------------------
  |  |  502|      0|#define CKK_GOSTR3410 0x00000030UL
  ------------------
 5025|    123|		else if (pubkey->pub_data && pubkey->pub_data->algorithm == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   72|    111|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (5025:12): [True: 111, False: 12]
  |  Branch (5025:32): [True: 0, False: 111]
  ------------------
 5026|      0|			*(CK_KEY_TYPE*)attr->pValue = CKK_EC_EDWARDS;
  ------------------
  |  |  518|      0|#define CKK_EC_EDWARDS 0x00000040UL
  ------------------
 5027|    123|		else if (pubkey->pub_data && pubkey->pub_data->algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   73|    111|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (5027:12): [True: 111, False: 12]
  |  Branch (5027:32): [True: 0, False: 111]
  ------------------
 5028|      0|			*(CK_KEY_TYPE*)attr->pValue = CKK_EC_MONTGOMERY;
  ------------------
  |  |  519|      0|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
 5029|    123|		else if (pubkey->pub_data && pubkey->pub_data->algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   70|    111|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (5029:12): [True: 111, False: 12]
  |  Branch (5029:32): [True: 68, False: 43]
  ------------------
 5030|     68|			*(CK_KEY_TYPE*)attr->pValue = CKK_EC;
  ------------------
  |  |  467|     68|#define CKK_EC 0x00000003UL
  ------------------
 5031|     55|		else
 5032|     55|			*(CK_KEY_TYPE*)attr->pValue = CKK_RSA;
  ------------------
  |  |  464|     55|#define CKK_RSA 0x00000000UL
  ------------------
 5033|    123|		break;
 5034|  1.44k|	case CKA_ID:
  ------------------
  |  |  161|  1.44k|#define CKA_ID 0x00000102UL
  ------------------
  |  Branch (5034:2): [True: 1.44k, False: 5.55k]
  ------------------
 5035|  1.44k|		if (pubkey->pub_info) {
  ------------------
  |  Branch (5035:7): [True: 1.41k, False: 28]
  ------------------
 5036|  1.41k|			check_attribute_buffer(attr, pubkey->pub_info->id.len);
  ------------------
  |  |   56|  1.41k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  2.83k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 723, False: 695]
  |  |  ------------------
  |  |   57|    723|		attr->ulValueLen = size;        \
  |  |   58|    723|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|    723|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|    723|	}                                       \
  |  |   60|  1.41k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 695]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|    695|	attr->ulValueLen = size;
  ------------------
 5037|  1.39k|			memcpy(attr->pValue, pubkey->pub_info->id.value, pubkey->pub_info->id.len);
 5038|  1.39k|		}
 5039|     28|		else if (cert && cert->cert_info) {
  ------------------
  |  Branch (5039:12): [True: 28, False: 0]
  |  Branch (5039:20): [True: 28, False: 0]
  ------------------
 5040|     28|			check_attribute_buffer(attr, cert->cert_info->id.len);
  ------------------
  |  |   56|     28|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|     56|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 15, False: 13]
  |  |  ------------------
  |  |   57|     15|		attr->ulValueLen = size;        \
  |  |   58|     15|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|     15|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|     15|	}                                       \
  |  |   60|     28|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 13]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|     13|	attr->ulValueLen = size;
  ------------------
 5041|     26|			memcpy(attr->pValue, cert->cert_info->id.value, cert->cert_info->id.len);
 5042|     26|		}
 5043|      0|		else {
 5044|      0|			return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 5045|      0|		}
 5046|    708|		break;
 5047|    708|	case CKA_KEY_GEN_MECHANISM:
  ------------------
  |  |  196|      0|#define CKA_KEY_GEN_MECHANISM 0x00000166UL
  ------------------
  |  Branch (5047:2): [True: 0, False: 7.00k]
  ------------------
 5048|      0|		check_attribute_buffer(attr, sizeof(CK_MECHANISM_TYPE));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5049|      0|		*(CK_MECHANISM_TYPE*)attr->pValue = CK_UNAVAILABLE_INFORMATION;
  ------------------
  |  |   32|      0|#define CK_UNAVAILABLE_INFORMATION ~0UL
  ------------------
 5050|      0|		break;
 5051|      0|	case CKA_ENCRYPT:
  ------------------
  |  |  163|      0|#define CKA_ENCRYPT 0x00000104UL
  ------------------
  |  Branch (5051:2): [True: 0, False: 7.00k]
  ------------------
 5052|      0|	case CKA_WRAP:
  ------------------
  |  |  165|      0|#define CKA_WRAP 0x00000106UL
  ------------------
  |  Branch (5052:2): [True: 0, False: 7.00k]
  ------------------
 5053|      0|	case CKA_VERIFY:
  ------------------
  |  |  169|      0|#define CKA_VERIFY 0x0000010AUL
  ------------------
  |  Branch (5053:2): [True: 0, False: 7.00k]
  ------------------
 5054|      0|	case CKA_VERIFY_RECOVER:
  ------------------
  |  |  170|      0|#define CKA_VERIFY_RECOVER 0x0000010BUL
  ------------------
  |  Branch (5054:2): [True: 0, False: 7.00k]
  ------------------
 5055|      0|	case CKA_DERIVE:
  ------------------
  |  |  171|      0|#define CKA_DERIVE 0x0000010CUL
  ------------------
  |  Branch (5055:2): [True: 0, False: 7.00k]
  ------------------
 5056|      0|		if (pubkey->pub_info)
  ------------------
  |  Branch (5056:7): [True: 0, False: 0]
  ------------------
 5057|      0|			return get_usage_bit(pubkey->pub_info->usage, attr);
 5058|      0|		else
 5059|      0|			return get_usage_bit(SC_PKCS15_PRKEY_USAGE_ENCRYPT |SC_PKCS15_PRKEY_USAGE_VERIFY | SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER, attr);
  ------------------
  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              			return get_usage_bit(SC_PKCS15_PRKEY_USAGE_ENCRYPT |SC_PKCS15_PRKEY_USAGE_VERIFY | SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER, attr);
  ------------------
  |  |  311|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
              			return get_usage_bit(SC_PKCS15_PRKEY_USAGE_ENCRYPT |SC_PKCS15_PRKEY_USAGE_VERIFY | SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER, attr);
  ------------------
  |  |  312|      0|#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER	0x80
  ------------------
 5060|      0|	case CKA_MODULUS:
  ------------------
  |  |  174|      0|#define CKA_MODULUS 0x00000120UL
  ------------------
  |  Branch (5060:2): [True: 0, False: 7.00k]
  ------------------
 5061|      0|		return get_modulus(pubkey->pub_data, attr);
 5062|      0|	case CKA_MODULUS_BITS:
  ------------------
  |  |  175|      0|#define CKA_MODULUS_BITS 0x00000121UL
  ------------------
  |  Branch (5062:2): [True: 0, False: 7.00k]
  ------------------
 5063|      0|		return get_modulus_bits(pubkey->pub_data, attr);
 5064|      0|	case CKA_PUBLIC_EXPONENT:
  ------------------
  |  |  176|      0|#define CKA_PUBLIC_EXPONENT 0x00000122UL
  ------------------
  |  Branch (5064:2): [True: 0, False: 7.00k]
  ------------------
 5065|      0|		return get_public_exponent(pubkey->pub_data, attr);
 5066|       |	/*
 5067|       |	 * PKCS#11 does not define a CKA_VALUE for a CKO_PUBLIC_KEY.
 5068|       |	 * OpenSC does, but it is not consistent it what it returns
 5069|       |	 * Internally to do verify, with OpenSSL, we need a SPKI that
 5070|       |	 * can be converted into a EVP_KEY with d2i_PUBKEY
 5071|       |	 * CKA_SPKI is defined internally as a CKA_VENDOR_DFINED attribute.
 5072|       |	 */
 5073|      0|	case CKA_VALUE:
  ------------------
  |  |  143|      0|#define CKA_VALUE 0x00000011UL
  ------------------
  |  Branch (5073:2): [True: 0, False: 7.00k]
  ------------------
 5074|     89|	case CKA_SPKI:
  ------------------
  |  |   21|     89|#define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |  289|     89|#define CKA_VENDOR_DEFINED 0x80000000UL
  |  |  ------------------
  |  |               #define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |   12|     89|#define SC_VENDOR_DEFINED 0x4F534300  /* OSC */
  |  |  ------------------
  ------------------
  |  Branch (5074:2): [True: 89, False: 6.91k]
  ------------------
 5075|     89|	case CKA_PUBLIC_KEY_INFO:
  ------------------
  |  |  183|     89|#define CKA_PUBLIC_KEY_INFO 0x00000129UL
  ------------------
  |  Branch (5075:2): [True: 0, False: 7.00k]
  ------------------
 5076|       |
 5077|     89|		if (attr->type != CKA_SPKI && attr->type != CKA_PUBLIC_KEY_INFO && pubkey->pub_info && pubkey->pub_info->direct.raw.value && pubkey->pub_info->direct.raw.len) {
  ------------------
  |  |   21|    178|#define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |  289|     89|#define CKA_VENDOR_DEFINED 0x80000000UL
  |  |  ------------------
  |  |               #define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |   12|     89|#define SC_VENDOR_DEFINED 0x4F534300  /* OSC */
  |  |  ------------------
  ------------------
              		if (attr->type != CKA_SPKI && attr->type != CKA_PUBLIC_KEY_INFO && pubkey->pub_info && pubkey->pub_info->direct.raw.value && pubkey->pub_info->direct.raw.len) {
  ------------------
  |  |  183|     89|#define CKA_PUBLIC_KEY_INFO 0x00000129UL
  ------------------
  |  Branch (5077:7): [True: 0, False: 89]
  |  Branch (5077:33): [True: 0, False: 0]
  |  Branch (5077:70): [True: 0, False: 0]
  |  Branch (5077:90): [True: 0, False: 0]
  |  Branch (5077:128): [True: 0, False: 0]
  ------------------
 5078|      0|			check_attribute_buffer(attr, pubkey->pub_info->direct.raw.len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5079|      0|			memcpy(attr->pValue, pubkey->pub_info->direct.raw.value, pubkey->pub_info->direct.raw.len);
 5080|     89|		} else if (pubkey->pub_info && pubkey->pub_info->direct.spki.value && pubkey->pub_info->direct.spki.len) {
  ------------------
  |  Branch (5080:14): [True: 82, False: 7]
  |  Branch (5080:34): [True: 82, False: 0]
  |  Branch (5080:73): [True: 82, False: 0]
  ------------------
 5081|     82|			check_attribute_buffer(attr, pubkey->pub_info->direct.spki.len);
  ------------------
  |  |   56|     82|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|    164|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 41, False: 41]
  |  |  ------------------
  |  |   57|     41|		attr->ulValueLen = size;        \
  |  |   58|     41|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|     41|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|     41|	}                                       \
  |  |   60|     82|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 41]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|     41|	attr->ulValueLen = size;
  ------------------
 5082|     82|			memcpy(attr->pValue, pubkey->pub_info->direct.spki.value, pubkey->pub_info->direct.spki.len);
 5083|     82|		} else if (pubkey->pub_data) {
  ------------------
  |  Branch (5083:14): [True: 7, False: 0]
  ------------------
 5084|      7|			unsigned char *value = NULL;
 5085|      7|			size_t len;
 5086|       |
 5087|      7|			if (attr->type != CKA_SPKI && attr->type != CKA_PUBLIC_KEY_INFO) {
  ------------------
  |  |   21|     14|#define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |  289|      7|#define CKA_VENDOR_DEFINED 0x80000000UL
  |  |  ------------------
  |  |               #define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |   12|      7|#define SC_VENDOR_DEFINED 0x4F534300  /* OSC */
  |  |  ------------------
  ------------------
              			if (attr->type != CKA_SPKI && attr->type != CKA_PUBLIC_KEY_INFO) {
  ------------------
  |  |  183|      0|#define CKA_PUBLIC_KEY_INFO 0x00000129UL
  ------------------
  |  Branch (5087:8): [True: 0, False: 7]
  |  Branch (5087:34): [True: 0, False: 0]
  ------------------
 5088|      0|				if (sc_pkcs15_encode_pubkey(context, pubkey->pub_data, &value, &len))
  ------------------
  |  Branch (5088:9): [True: 0, False: 0]
  ------------------
 5089|      0|					return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetAttributeValue");
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 5090|      7|			} else {
 5091|      7|				if (sc_pkcs15_encode_pubkey_as_spki(context, pubkey->pub_data, &value, &len))
  ------------------
  |  Branch (5091:9): [True: 1, False: 6]
  ------------------
 5092|      1|					return sc_to_cryptoki_error(SC_ERROR_INTERNAL, "C_GetAttributeValue");
  ------------------
  |  |   81|      1|#define SC_ERROR_INTERNAL			-1400
  ------------------
 5093|      7|			}
 5094|       |
 5095|      6|			if (attr->pValue == NULL_PTR) {
  ------------------
  |  |   27|      6|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (5095:8): [True: 3, False: 3]
  ------------------
 5096|      3|				attr->ulValueLen = len;
 5097|      3|				free(value);
 5098|      3|				return CKR_OK;
  ------------------
  |  | 1086|      3|#define CKR_OK 0x00000000UL
  ------------------
 5099|      3|			}
 5100|      3|			if (attr->ulValueLen < len) {
  ------------------
  |  Branch (5100:8): [True: 0, False: 3]
  ------------------
 5101|      0|				attr->ulValueLen = len;
 5102|      0|				free(value);
 5103|      0|				return CKR_BUFFER_TOO_SMALL;
  ------------------
  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
 5104|      0|			}
 5105|      3|			attr->ulValueLen = len;
 5106|      3|			memcpy(attr->pValue, value, len);
 5107|       |
 5108|      3|			free(value);
 5109|      3|		} else if (attr->type != CKA_SPKI && attr->type != CKA_PUBLIC_KEY_INFO && pubkey->base.p15_object && pubkey->base.p15_object->content.value && pubkey->base.p15_object->content.len) {
  ------------------
  |  |   21|      0|#define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |  289|      0|#define CKA_VENDOR_DEFINED 0x80000000UL
  |  |  ------------------
  |  |               #define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |   12|      0|#define SC_VENDOR_DEFINED 0x4F534300  /* OSC */
  |  |  ------------------
  ------------------
              		} else if (attr->type != CKA_SPKI && attr->type != CKA_PUBLIC_KEY_INFO && pubkey->base.p15_object && pubkey->base.p15_object->content.value && pubkey->base.p15_object->content.len) {
  ------------------
  |  |  183|      0|#define CKA_PUBLIC_KEY_INFO 0x00000129UL
  ------------------
  |  Branch (5109:14): [True: 0, False: 0]
  |  Branch (5109:40): [True: 0, False: 0]
  |  Branch (5109:77): [True: 0, False: 0]
  |  Branch (5109:104): [True: 0, False: 0]
  |  Branch (5109:146): [True: 0, False: 0]
  ------------------
 5110|      0|			check_attribute_buffer(attr, pubkey->base.p15_object->content.len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5111|      0|			memcpy(attr->pValue, pubkey->base.p15_object->content.value, pubkey->base.p15_object->content.len);
 5112|      0|		} else if (cert && cert->cert_data) {
  ------------------
  |  Branch (5112:14): [True: 0, False: 0]
  |  Branch (5112:22): [True: 0, False: 0]
  ------------------
 5113|      0|			check_attribute_buffer(attr, cert->cert_data->data.len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5114|      0|			memcpy(attr->pValue, cert->cert_data->data.value, cert->cert_data->data.len);
 5115|      0|		} else {
 5116|      0|			return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 5117|      0|		}
 5118|     44|		break;
 5119|     44|	case CKA_GOSTR3410_PARAMS:
  ------------------
  |  |  218|      0|#define CKA_GOSTR3410_PARAMS 0x00000250UL
  ------------------
  |  Branch (5119:2): [True: 0, False: 7.00k]
  ------------------
 5120|      0|		if (pubkey->pub_info && pubkey->pub_info->params.len)
  ------------------
  |  Branch (5120:7): [True: 0, False: 0]
  |  Branch (5120:27): [True: 0, False: 0]
  ------------------
 5121|      0|			return get_gostr3410_params(pubkey->pub_info->params.data, pubkey->pub_info->params.len, attr);
 5122|      0|		else
 5123|      0|			return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 5124|      0|	case CKA_EC_PARAMS:
  ------------------
  |  |  200|      0|#define CKA_EC_PARAMS 0x00000180UL
  ------------------
  |  Branch (5124:2): [True: 0, False: 7.00k]
  ------------------
 5125|      0|		return get_ec_pubkey_params(pubkey->pub_data, attr);
 5126|      0|	case CKA_EC_POINT:
  ------------------
  |  |  201|      0|#define CKA_EC_POINT 0x00000181UL
  ------------------
  |  Branch (5126:2): [True: 0, False: 7.00k]
  ------------------
 5127|      0|		return get_ec_pubkey_point(pubkey->pub_data, attr);
 5128|       |
 5129|      0|	default:
  ------------------
  |  Branch (5129:2): [True: 0, False: 7.00k]
  ------------------
 5130|      0|		return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 5131|  7.00k|	}
 5132|       |
 5133|  4.39k|	return CKR_OK;
  ------------------
  |  | 1086|  4.39k|#define CKR_OK 0x00000000UL
  ------------------
 5134|  7.00k|}
framework-pkcs15.c:pkcs15_dobj_release:
 5157|  41.2k|{
 5158|  41.2k|	__pkcs15_release_object((struct pkcs15_any_object *) object);
 5159|  41.2k|}
framework-pkcs15.c:pkcs15_dobj_get_attribute:
 5229|  26.0k|{
 5230|  26.0k|	struct pkcs15_data_object *dobj = (struct pkcs15_data_object*) object;
 5231|  26.0k|	struct sc_pkcs15_data *data = NULL;
 5232|  26.0k|	CK_RV rv;
 5233|  26.0k|	size_t len;
 5234|  26.0k|	int r;
 5235|  26.0k|	unsigned char *buf = NULL;
 5236|       |
 5237|  26.0k|	sc_log(context, "pkcs15_dobj_get_attribute() called");
  ------------------
  |  |   71|  26.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5238|  26.0k|	switch (attr->type) {
 5239|  17.0k|	case CKA_CLASS:
  ------------------
  |  |  137|  17.0k|#define CKA_CLASS 0x00000000UL
  ------------------
  |  Branch (5239:2): [True: 17.0k, False: 8.99k]
  ------------------
 5240|  17.0k|		check_attribute_buffer(attr, sizeof(CK_OBJECT_CLASS));
  ------------------
  |  |   56|  17.0k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  34.0k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 8.52k, False: 8.52k]
  |  |  ------------------
  |  |   57|  8.52k|		attr->ulValueLen = size;        \
  |  |   58|  8.52k|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|  8.52k|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|  8.52k|	}                                       \
  |  |   60|  17.0k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 8.52k]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|  8.52k|	attr->ulValueLen = size;
  ------------------
 5241|  8.52k|		*(CK_OBJECT_CLASS*)attr->pValue = CKO_DATA;
  ------------------
  |  | 1027|  8.52k|#define CKO_DATA 0x00000000UL
  ------------------
 5242|  8.52k|		break;
 5243|      0|	case CKA_TOKEN:
  ------------------
  |  |  138|      0|#define CKA_TOKEN 0x00000001UL
  ------------------
  |  Branch (5243:2): [True: 0, False: 26.0k]
  ------------------
 5244|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5245|      0|		*(CK_BBOOL*)attr->pValue = TRUE;
  ------------------
  |  |   51|      0|#define TRUE 1
  ------------------
 5246|      0|		break;
 5247|  8.99k|	case CKA_PRIVATE:
  ------------------
  |  |  139|  8.99k|#define CKA_PRIVATE 0x00000002UL
  ------------------
  |  Branch (5247:2): [True: 8.99k, False: 17.0k]
  ------------------
 5248|  8.99k|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|  8.99k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  17.9k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 8.99k]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|  8.99k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 8.99k]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|  8.99k|	attr->ulValueLen = size;
  ------------------
 5249|  8.99k|		*(CK_BBOOL*)attr->pValue = (dobj->base.p15_object->flags & SC_PKCS15_CO_FLAG_PRIVATE) != 0;
  ------------------
  |  |   50|  8.99k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 5250|  8.99k|		break;
 5251|      0|	case CKA_MODIFIABLE:
  ------------------
  |  |  197|      0|#define CKA_MODIFIABLE 0x00000170UL
  ------------------
  |  Branch (5251:2): [True: 0, False: 26.0k]
  ------------------
 5252|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5253|      0|		*(CK_BBOOL*)attr->pValue = (dobj->base.p15_object->flags & 0x02) != 0;
 5254|      0|		break;
 5255|      0|	case CKA_LABEL:
  ------------------
  |  |  140|      0|#define CKA_LABEL 0x00000003UL
  ------------------
  |  Branch (5255:2): [True: 0, False: 26.0k]
  ------------------
 5256|      0|		len = strnlen(dobj->base.p15_object->label, sizeof dobj->base.p15_object->label);
 5257|      0|		check_attribute_buffer(attr, len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5258|      0|		memcpy(attr->pValue, dobj->base.p15_object->label, len);
 5259|      0|		break;
 5260|      0|	case CKA_APPLICATION:
  ------------------
  |  |  142|      0|#define CKA_APPLICATION 0x00000010UL
  ------------------
  |  Branch (5260:2): [True: 0, False: 26.0k]
  ------------------
 5261|      0|		len = strlen(dobj->info->app_label);
 5262|      0|		check_attribute_buffer(attr, len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5263|      0|		memcpy(attr->pValue, dobj->info->app_label, len);
 5264|      0|		break;
 5265|       |#if 0
 5266|       |	case CKA_ID:
 5267|       |		check_attribute_buffer(attr, dobj->info->id.len);
 5268|       |		memcpy(attr->pValue, dobj->info->id.value, dobj->info->id.len);
 5269|       |		break;
 5270|       |#endif
 5271|      0|	case CKA_OBJECT_ID:
  ------------------
  |  |  144|      0|#define CKA_OBJECT_ID 0x00000012UL
  ------------------
  |  Branch (5271:2): [True: 0, False: 26.0k]
  ------------------
 5272|      0|		if (!sc_valid_oid(&dobj->info->app_oid))   {
  ------------------
  |  Branch (5272:7): [True: 0, False: 0]
  ------------------
 5273|      0|			attr->ulValueLen = -1;
 5274|      0|			return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 5275|      0|		}
 5276|      0|		r = sc_asn1_encode_object_id(NULL, &len, &dobj->info->app_oid);
 5277|      0|		if (r)   {
  ------------------
  |  Branch (5277:7): [True: 0, False: 0]
  ------------------
 5278|      0|			sc_log(context, "data_get_attr(): encode OID error %i", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5279|      0|			return CKR_FUNCTION_FAILED;
  ------------------
  |  | 1091|      0|#define CKR_FUNCTION_FAILED 0x00000006UL
  ------------------
 5280|      0|		}
 5281|       |
 5282|      0|		check_attribute_buffer(attr, len);
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5283|       |
 5284|      0|		r = sc_asn1_encode_object_id(&buf, &len, &dobj->info->app_oid);
 5285|      0|		if (r)   {
  ------------------
  |  Branch (5285:7): [True: 0, False: 0]
  ------------------
 5286|      0|			sc_log(context, "data_get_attr(): encode OID error %i", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5287|      0|			return CKR_FUNCTION_FAILED;
  ------------------
  |  | 1091|      0|#define CKR_FUNCTION_FAILED 0x00000006UL
  ------------------
 5288|      0|		}
 5289|       |
 5290|      0|		memcpy(attr->pValue, buf, len);
 5291|      0|		free(buf);
 5292|      0|		break;
 5293|      0|	case CKA_VALUE:
  ------------------
  |  |  143|      0|#define CKA_VALUE 0x00000011UL
  ------------------
  |  Branch (5293:2): [True: 0, False: 26.0k]
  ------------------
 5294|       |		/* if CKA_VALUE is empty, sets data to NULL */
 5295|      0|		rv = pkcs15_dobj_get_value(session, dobj, &data);
 5296|      0|		if (rv == CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (5296:7): [True: 0, False: 0]
  ------------------
 5297|      0|			if (data) {
  ------------------
  |  Branch (5297:8): [True: 0, False: 0]
  ------------------
 5298|      0|				rv = data_value_to_attr(attr, data);
 5299|      0|			}
 5300|      0|			else {
 5301|      0|				attr->ulValueLen = 0;
 5302|      0|				attr->pValue = NULL_PTR;
  ------------------
  |  |   27|      0|#define NULL_PTR ((void *)0)
  ------------------
 5303|      0|			}
 5304|      0|		}
 5305|      0|		if (data) {
  ------------------
  |  Branch (5305:7): [True: 0, False: 0]
  ------------------
 5306|      0|			free(data->data);
 5307|      0|			free(data);
 5308|      0|		}
 5309|      0|		if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (5309:7): [True: 0, False: 0]
  ------------------
 5310|      0|			return rv;
 5311|      0|		break;
 5312|      0|	default:
  ------------------
  |  Branch (5312:2): [True: 0, False: 26.0k]
  ------------------
 5313|      0|		return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 5314|  26.0k|	}
 5315|       |
 5316|  17.5k|	return CKR_OK;
  ------------------
  |  | 1086|  17.5k|#define CKR_OK 0x00000000UL
  ------------------
 5317|  26.0k|}
framework-pkcs15.c:pkcs15_profile_release:
 5339|  11.9k|{
 5340|  11.9k|	struct pkcs15_any_object *object = (struct pkcs15_any_object *) obj;
 5341|  11.9k|	struct sc_pkcs15_object *p15_obj = object->p15_object;
 5342|       |
 5343|  11.9k|	if (__pkcs15_release_object((struct pkcs15_any_object *) obj) < 1) {
  ------------------
  |  Branch (5343:6): [True: 5.97k, False: 5.97k]
  ------------------
 5344|       |		/* This is not a real pkcs15 object. We need to free it here */
 5345|  5.97k|		free(p15_obj);
 5346|  5.97k|	}
 5347|  11.9k|}
framework-pkcs15.c:pkcs15_profile_get_attribute:
 5360|  3.52k|{
 5361|  3.52k|	struct pkcs15_profile_object *pobj = (struct pkcs15_profile_object*) object;
 5362|       |
 5363|  3.52k|	sc_log(context, "pkcs15_profile_get_attribute() called");
  ------------------
  |  |   71|  3.52k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5364|  3.52k|	switch (attr->type) {
 5365|  2.88k|	case CKA_CLASS:
  ------------------
  |  |  137|  2.88k|#define CKA_CLASS 0x00000000UL
  ------------------
  |  Branch (5365:2): [True: 2.88k, False: 643]
  ------------------
 5366|  2.88k|		check_attribute_buffer(attr, sizeof(CK_OBJECT_CLASS));
  ------------------
  |  |   56|  2.88k|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  5.76k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 1.44k, False: 1.44k]
  |  |  ------------------
  |  |   57|  1.44k|		attr->ulValueLen = size;        \
  |  |   58|  1.44k|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|  1.44k|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|  1.44k|	}                                       \
  |  |   60|  2.88k|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 1.44k]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|  1.44k|	attr->ulValueLen = size;
  ------------------
 5367|  1.44k|		*(CK_OBJECT_CLASS*)attr->pValue = CKO_PROFILE;
  ------------------
  |  | 1036|  1.44k|#define CKO_PROFILE 0x00000009UL
  ------------------
 5368|  1.44k|		break;
 5369|    643|	case CKA_PRIVATE:
  ------------------
  |  |  139|    643|#define CKA_PRIVATE 0x00000002UL
  ------------------
  |  Branch (5369:2): [True: 643, False: 2.88k]
  ------------------
 5370|       |		/* This is needed internally for the object to be visible */
 5371|    643|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|    643|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|  1.28k|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 643]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|    643|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 643]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|    643|	attr->ulValueLen = size;
  ------------------
 5372|    643|		*(CK_BBOOL*)attr->pValue = CK_FALSE;
  ------------------
  |  |   35|    643|#define CK_FALSE 0
  ------------------
 5373|    643|		break;
 5374|      0|	case CKA_PROFILE_ID:
  ------------------
  |  |  238|      0|#define CKA_PROFILE_ID 0x00000601UL
  ------------------
  |  Branch (5374:2): [True: 0, False: 3.52k]
  ------------------
 5375|       |		/* TODO */
 5376|      0|		check_attribute_buffer(attr, sizeof(CK_ULONG));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5377|      0|		*(CK_ULONG*)attr->pValue = pobj->profile_id;
 5378|      0|		break;
 5379|      0|	case CKA_TOKEN:
  ------------------
  |  |  138|      0|#define CKA_TOKEN 0x00000001UL
  ------------------
  |  Branch (5379:2): [True: 0, False: 3.52k]
  ------------------
 5380|      0|		check_attribute_buffer(attr, sizeof(CK_BBOOL));
  ------------------
  |  |   56|      0|	if (attr->pValue == NULL_PTR) {         \
  |  |  ------------------
  |  |  |  |   27|      0|#define NULL_PTR ((void *)0)
  |  |  ------------------
  |  |  |  Branch (56:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   57|      0|		attr->ulValueLen = size;        \
  |  |   58|      0|		return CKR_OK;                  \
  |  |  ------------------
  |  |  |  | 1086|      0|#define CKR_OK 0x00000000UL
  |  |  ------------------
  |  |   59|      0|	}                                       \
  |  |   60|      0|	if (attr->ulValueLen < size) {		\
  |  |  ------------------
  |  |  |  Branch (60:6): [True: 0, False: 0]
  |  |  ------------------
  |  |   61|      0|		attr->ulValueLen = size;	\
  |  |   62|      0|		return CKR_BUFFER_TOO_SMALL;    \
  |  |  ------------------
  |  |  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  |  |  ------------------
  |  |   63|      0|	}                                       \
  |  |   64|      0|	attr->ulValueLen = size;
  ------------------
 5381|      0|		*(CK_BBOOL*)attr->pValue = CK_TRUE;
  ------------------
  |  |   34|      0|#define CK_TRUE 1
  ------------------
 5382|      0|		break;
 5383|      0|	default:
  ------------------
  |  Branch (5383:2): [True: 0, False: 3.52k]
  ------------------
 5384|      0|		return CKR_ATTRIBUTE_TYPE_INVALID;
  ------------------
  |  | 1098|      0|#define CKR_ATTRIBUTE_TYPE_INVALID 0x00000012UL
  ------------------
 5385|  3.52k|	}
 5386|       |
 5387|  2.08k|	return CKR_OK;
  ------------------
  |  | 1086|  2.08k|#define CKR_OK 0x00000000UL
  ------------------
 5388|  3.52k|}

_update_mech_info:
   90|     94|void _update_mech_info(CK_MECHANISM_INFO_PTR mech_info, CK_MECHANISM_INFO_PTR new_mech_info) {
   91|     94|	if (new_mech_info->ulMaxKeySize > mech_info->ulMaxKeySize)
  ------------------
  |  Branch (91:6): [True: 0, False: 94]
  ------------------
   92|      0|		mech_info->ulMaxKeySize = new_mech_info->ulMaxKeySize;
   93|     94|	if (new_mech_info->ulMinKeySize < mech_info->ulMinKeySize)
  ------------------
  |  Branch (93:6): [True: 94, False: 0]
  ------------------
   94|     94|		mech_info->ulMinKeySize = new_mech_info->ulMinKeySize;
   95|     94|	mech_info->flags |= new_mech_info->flags;
   96|     94|}
sc_pkcs11_register_mechanism:
  131|   143k|{
  132|   143k|	sc_pkcs11_mechanism_type_t *existing_mt;
  133|   143k|	sc_pkcs11_mechanism_type_t *copy_mt = NULL;
  134|   143k|	sc_pkcs11_mechanism_type_t **p;
  135|   143k|	int i;
  136|   143k|	CK_RV rv;
  137|       |
  138|   143k|	if (mt == NULL)
  ------------------
  |  Branch (138:6): [True: 0, False: 143k]
  ------------------
  139|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  140|       |
  141|   143k|	if ((existing_mt = sc_pkcs11_find_mechanism(p11card, mt->mech, mt->mech_info.flags))) {
  ------------------
  |  Branch (141:6): [True: 94, False: 143k]
  ------------------
  142|    188|		for (i = 0; i < MAX_KEY_TYPES; i++) {
  ------------------
  |  |  281|    188|#define MAX_KEY_TYPES 2
  ------------------
  |  Branch (142:15): [True: 188, False: 0]
  ------------------
  143|    188|			if (existing_mt->key_types[i] == mt->key_types[0]) {
  ------------------
  |  Branch (143:8): [True: 0, False: 188]
  ------------------
  144|       |				/* Mechanism already registered with the same key_type,
  145|       |				 * just update it's info */
  146|      0|				_update_mech_info(&existing_mt->mech_info, &mt->mech_info);
  147|      0|				return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  148|      0|			}
  149|    188|			if (existing_mt->key_types[i] < 0) {
  ------------------
  |  Branch (149:8): [True: 94, False: 94]
  ------------------
  150|       |				/* There is a free slot for new key type, let's add it and
  151|       |				 * update mechanism info */
  152|     94|				_update_mech_info(&existing_mt->mech_info, &mt->mech_info);
  153|       |				/* XXX Should be changed to loop over mt->key_types, if
  154|       |				 * we allow to register mechanism with multiple key types
  155|       |				 * in one operation */
  156|     94|				existing_mt->key_types[i] = mt->key_types[0];
  157|     94|				if (i + 1 < MAX_KEY_TYPES) {
  ------------------
  |  |  281|     94|#define MAX_KEY_TYPES 2
  ------------------
  |  Branch (157:9): [True: 0, False: 94]
  ------------------
  158|      0|					existing_mt->key_types[i + 1] = -1;
  159|      0|				}
  160|     94|				return CKR_OK;
  ------------------
  |  | 1086|     94|#define CKR_OK 0x00000000UL
  ------------------
  161|     94|			}
  162|    188|		}
  163|      0|		sc_log(p11card->card->ctx, "Too many key types in mechanism 0x%lx, more than %d", mt->mech, MAX_KEY_TYPES);
  ------------------
  |  |   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)
  |  |  ------------------
  |  |  |  |  163|      0|		sc_log(p11card->card->ctx, "Too many key types in mechanism 0x%lx, more than %d", mt->mech, MAX_KEY_TYPES);
  |  |  |  |  ------------------
  |  |  |  |  |  |  281|      0|#define MAX_KEY_TYPES 2
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|      0|		return CKR_BUFFER_TOO_SMALL;
  ------------------
  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
  165|     94|	}
  166|       |
  167|   143k|	p = (sc_pkcs11_mechanism_type_t **) realloc(p11card->mechanisms,
  168|   143k|			(p11card->nmechanisms + 2) * sizeof(*p));
  169|   143k|	if (p == NULL)
  ------------------
  |  Branch (169:6): [True: 0, False: 143k]
  ------------------
  170|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  171|   143k|	if ((rv = sc_pkcs11_copy_mechanism(mt, &copy_mt)) != CKR_OK) {
  ------------------
  |  | 1086|   143k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (171:6): [True: 0, False: 143k]
  ------------------
  172|      0|		free(p);
  173|      0|		return rv;
  174|      0|	}
  175|   143k|	p11card->mechanisms = p;
  176|   143k|	p[p11card->nmechanisms++] = copy_mt;
  177|   143k|	p[p11card->nmechanisms] = NULL;
  178|       |	/* Return registered mechanism for further use */
  179|   143k|	if (result_mt)
  ------------------
  |  Branch (179:6): [True: 12.4k, False: 130k]
  ------------------
  180|  12.4k|		*result_mt = copy_mt;
  181|   143k|	return CKR_OK;
  ------------------
  |  | 1086|   143k|#define CKR_OK 0x00000000UL
  ------------------
  182|   143k|}
_validate_key_type:
  186|    509|_validate_key_type(sc_pkcs11_mechanism_type_t *mech, CK_KEY_TYPE key_type) {
  187|    509|	int i;
  188|    513|	for (i = 0; i < MAX_KEY_TYPES; i++) {
  ------------------
  |  |  281|    513|#define MAX_KEY_TYPES 2
  ------------------
  |  Branch (188:14): [True: 513, False: 0]
  ------------------
  189|    513|		if (mech->key_types[i] < 0)
  ------------------
  |  Branch (189:7): [True: 4, False: 509]
  ------------------
  190|      4|			break;
  191|    509|		if ((CK_KEY_TYPE)mech->key_types[i] == key_type)
  ------------------
  |  Branch (191:7): [True: 505, False: 4]
  ------------------
  192|    505|			return CKR_OK;
  ------------------
  |  | 1086|    505|#define CKR_OK 0x00000000UL
  ------------------
  193|    509|	}
  194|      4|	return CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      4|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  195|    509|}
sc_pkcs11_find_mechanism:
  202|   210k|{
  203|   210k|	sc_pkcs11_mechanism_type_t *mt;
  204|   210k|	unsigned int n;
  205|       |
  206|   210k|	if (p11card == NULL)
  ------------------
  |  Branch (206:6): [True: 0, False: 210k]
  ------------------
  207|      0|		return NULL;
  208|  2.20M|	for (n = 0; n < p11card->nmechanisms; n++) {
  ------------------
  |  Branch (208:14): [True: 2.05M, False: 143k]
  ------------------
  209|  2.05M|		mt = p11card->mechanisms[n];
  210|  2.05M|		if (mt && mt->mech == mech && ((mt->mech_info.flags & flags) == flags))
  ------------------
  |  Branch (210:7): [True: 2.05M, False: 0]
  |  Branch (210:13): [True: 66.7k, False: 1.99M]
  |  Branch (210:33): [True: 66.7k, False: 2]
  ------------------
  211|  66.7k|			return mt;
  212|  2.05M|	}
  213|   143k|	return NULL;
  214|   210k|}
sc_pkcs11_new_operation:
  268|  2.23k|{
  269|  2.23k|	sc_pkcs11_operation_t *res;
  270|       |
  271|  2.23k|	res = calloc(1, type->obj_size);
  272|  2.23k|	if (res) {
  ------------------
  |  Branch (272:6): [True: 2.23k, False: 0]
  ------------------
  273|  2.23k|		res->session = session;
  274|  2.23k|		res->type = type;
  275|  2.23k|	}
  276|  2.23k|	return res;
  277|  2.23k|}
sc_pkcs11_release_operation:
  281|   104k|{
  282|   104k|	sc_pkcs11_operation_t *operation = *ptr;
  283|       |
  284|   104k|	if (!operation)
  ------------------
  |  Branch (284:6): [True: 102k, False: 2.23k]
  ------------------
  285|   102k|		return;
  286|  2.23k|	if (operation->type && operation->type->release)
  ------------------
  |  Branch (286:6): [True: 2.23k, False: 0]
  |  Branch (286:25): [True: 2.23k, False: 0]
  ------------------
  287|  2.23k|		operation->type->release(operation);
  288|  2.23k|	memset(operation, 0, sizeof(*operation));
  289|  2.23k|	free(operation);
  290|       |	*ptr = NULL;
  291|  2.23k|}
sc_pkcs11_md_init:
  296|    310|{
  297|    310|	struct sc_pkcs11_card *p11card;
  298|    310|	sc_pkcs11_operation_t *operation;
  299|    310|	sc_pkcs11_mechanism_type_t *mt;
  300|    310|	CK_RV rv;
  301|       |
  302|    310|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|    310|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    310|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    310|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    310|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 310]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  303|    310|	if (!session || !session->slot || !(p11card = session->slot->p11card))
  ------------------
  |  Branch (303:6): [True: 0, False: 310]
  |  Branch (303:18): [True: 0, False: 310]
  |  Branch (303:36): [True: 0, False: 310]
  ------------------
  304|    310|		LOG_FUNC_RETURN(context, CKR_ARGUMENTS_BAD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  305|       |
  306|       |	/* See if we support this mechanism type */
  307|    310|	mt = sc_pkcs11_find_mechanism(p11card, pMechanism->mechanism, CKF_DIGEST);
  ------------------
  |  |  362|    310|#define CKF_DIGEST 0x00000400UL
  ------------------
  308|    310|	if (mt == NULL)
  ------------------
  |  Branch (308:6): [True: 298, False: 12]
  ------------------
  309|    310|		LOG_FUNC_RETURN(context, CKR_MECHANISM_INVALID);
  ------------------
  |  |  164|    298|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    298|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    298|	int _ret = r; \
  |  |  |  |  155|    298|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 298]
  |  |  |  |  ------------------
  |  |  |  |  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|    298|	} else { \
  |  |  |  |  159|    298|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    298|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    298|	} \
  |  |  |  |  162|    298|	return _ret; \
  |  |  |  |  163|    298|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  310|       |
  311|     12|	rv = session_start_operation(session, SC_PKCS11_OPERATION_DIGEST, mt, &operation);
  312|     12|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     12|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (312:6): [True: 0, False: 12]
  ------------------
  313|     12|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  314|       |
  315|     12|	memcpy(&operation->mechanism, pMechanism, sizeof(CK_MECHANISM));
  316|       |
  317|     12|	rv = mt->md_init(operation);
  318|       |
  319|     12|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     12|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (319:6): [True: 1, False: 11]
  ------------------
  320|      1|		session_stop_operation(session, SC_PKCS11_OPERATION_DIGEST);
  321|       |
  322|     12|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|     12|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     12|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     12|	int _ret = r; \
  |  |  |  |  155|     12|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  156|     11|		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: 11]
  |  |  |  |  ------------------
  |  |  |  |  157|     11|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     11|	} else { \
  |  |  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      1|	} \
  |  |  |  |  162|     12|	return _ret; \
  |  |  |  |  163|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  323|     12|}
sc_pkcs11_md_update:
  328|    186|{
  329|    186|	sc_pkcs11_operation_t *op;
  330|    186|	CK_RV rv;
  331|       |
  332|    186|	rv = session_get_operation(session, SC_PKCS11_OPERATION_DIGEST, &op);
  333|    186|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    186|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (333:6): [True: 0, False: 186]
  ------------------
  334|      0|		goto done;
  335|       |
  336|    186|	rv = op->type->md_update(op, pData, ulDataLen);
  337|       |
  338|    186|done:
  339|    186|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    186|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (339:6): [True: 0, False: 186]
  ------------------
  340|      0|		session_stop_operation(session, SC_PKCS11_OPERATION_DIGEST);
  341|       |
  342|    186|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|    186|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    186|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    186|	int _ret = r; \
  |  |  |  |  155|    186|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 186, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    186|		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: 186]
  |  |  |  |  ------------------
  |  |  |  |  157|    186|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    186|	} 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|    186|	return _ret; \
  |  |  |  |  163|    186|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  343|    186|}
sc_pkcs11_md_final:
  348|     12|{
  349|     12|	sc_pkcs11_operation_t *op;
  350|     12|	CK_RV rv;
  351|       |
  352|     12|	rv = session_get_operation(session, SC_PKCS11_OPERATION_DIGEST, &op);
  353|     12|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     12|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (353:6): [True: 0, False: 12]
  ------------------
  354|     12|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|       |
  356|       |	/* This is a request for the digest length */
  357|     12|	if (pData == NULL)
  ------------------
  |  Branch (357:6): [True: 1, False: 11]
  ------------------
  358|      1|		*pulDataLen = 0;
  359|       |
  360|     12|	rv = op->type->md_final(op, pData, pulDataLen);
  361|     12|	if (rv == CKR_BUFFER_TOO_SMALL)
  ------------------
  |  | 1165|     12|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
  |  Branch (361:6): [True: 1, False: 11]
  ------------------
  362|     12|		LOG_FUNC_RETURN(context,  pData == NULL ? CKR_OK : CKR_BUFFER_TOO_SMALL);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      2|	int _ret = r; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (154:13): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      1|		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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|      1|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      1|	} 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|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|       |
  364|     11|	session_stop_operation(session, SC_PKCS11_OPERATION_DIGEST);
  365|     11|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|     11|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     11|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     11|	int _ret = r; \
  |  |  |  |  155|     11|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     11|		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: 11]
  |  |  |  |  ------------------
  |  |  |  |  157|     11|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     11|	} 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|     11|	return _ret; \
  |  |  |  |  163|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  366|     11|}
sc_pkcs11_sign_init:
  375|    263|{
  376|    263|	struct sc_pkcs11_card *p11card;
  377|    263|	sc_pkcs11_operation_t *operation;
  378|    263|	sc_pkcs11_mechanism_type_t *mt;
  379|    263|	CK_RV rv;
  380|       |
  381|    263|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|    263|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    263|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    263|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    263|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 263]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|    263|	if (!session || !session->slot || !(p11card = session->slot->p11card))
  ------------------
  |  Branch (382:6): [True: 0, False: 263]
  |  Branch (382:18): [True: 0, False: 263]
  |  Branch (382:36): [True: 0, False: 263]
  ------------------
  383|    263|		LOG_FUNC_RETURN(context, CKR_ARGUMENTS_BAD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|       |
  385|       |	/* See if we support this mechanism type */
  386|    263|	sc_log(context, "mechanism 0x%lX, key-type 0x%lX",
  ------------------
  |  |   71|    263|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  387|    263|	       pMechanism->mechanism, key_type);
  388|    263|	mt = sc_pkcs11_find_mechanism(p11card, pMechanism->mechanism, CKF_SIGN);
  ------------------
  |  |  363|    263|#define CKF_SIGN 0x00000800UL
  ------------------
  389|    263|	if (mt == NULL)
  ------------------
  |  Branch (389:6): [True: 11, False: 252]
  ------------------
  390|    263|		LOG_FUNC_RETURN(context, CKR_MECHANISM_INVALID);
  ------------------
  |  |  164|     11|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     11|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     11|	int _ret = r; \
  |  |  |  |  155|     11|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  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|     11|	} else { \
  |  |  |  |  159|     11|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     11|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     11|	} \
  |  |  |  |  162|     11|	return _ret; \
  |  |  |  |  163|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  391|       |
  392|       |	/* See if compatible with key type */
  393|    252|	rv = _validate_key_type(mt, key_type);
  394|    252|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    252|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (394:6): [True: 1, False: 251]
  ------------------
  395|    252|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|      1|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      1|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      1|	int _ret = r; \
  |  |  |  |  155|      1|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|      1|	} else { \
  |  |  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      1|	} \
  |  |  |  |  162|      1|	return _ret; \
  |  |  |  |  163|      1|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  396|       |
  397|    251|	if (pMechanism->pParameter &&
  ------------------
  |  Branch (397:6): [True: 0, False: 251]
  ------------------
  398|      0|			pMechanism->ulParameterLen > sizeof(operation->mechanism_params))
  ------------------
  |  Branch (398:4): [True: 0, False: 0]
  ------------------
  399|    251|		LOG_FUNC_RETURN(context, CKR_ARGUMENTS_BAD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  400|       |
  401|    251|	rv = session_start_operation(session, SC_PKCS11_OPERATION_SIGN, mt, &operation);
  402|    251|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    251|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (402:6): [True: 0, False: 251]
  ------------------
  403|    251|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  404|       |
  405|    251|	memcpy(&operation->mechanism, pMechanism, sizeof(CK_MECHANISM));
  406|    251|	if (pMechanism->pParameter) {
  ------------------
  |  Branch (406:6): [True: 0, False: 251]
  ------------------
  407|      0|		memcpy(&operation->mechanism_params, pMechanism->pParameter,
  408|      0|				pMechanism->ulParameterLen);
  409|      0|		operation->mechanism.pParameter = &operation->mechanism_params;
  410|      0|	}
  411|    251|	rv = mt->sign_init(operation, key);
  412|    251|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    251|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (412:6): [True: 6, False: 245]
  ------------------
  413|      6|		session_stop_operation(session, SC_PKCS11_OPERATION_SIGN);
  414|       |
  415|    251|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|    251|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    251|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    251|	int _ret = r; \
  |  |  |  |  155|    251|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 245, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  156|    245|		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: 245]
  |  |  |  |  ------------------
  |  |  |  |  157|    245|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    245|	} else { \
  |  |  |  |  159|      6|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      6|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      6|	} \
  |  |  |  |  162|    251|	return _ret; \
  |  |  |  |  163|    251|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|    251|}
sc_pkcs11_sign_update:
  421|    262|{
  422|    262|	sc_pkcs11_operation_t *op;
  423|    262|	CK_RV rv;
  424|       |
  425|    262|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|    262|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    262|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    262|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    262|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 262]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|    262|	rv = session_get_operation(session, SC_PKCS11_OPERATION_SIGN, &op);
  427|    262|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    262|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (427:6): [True: 0, False: 262]
  ------------------
  428|    262|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  429|       |
  430|    262|	if (op->type->sign_update == NULL) {
  ------------------
  |  Branch (430:6): [True: 0, False: 262]
  ------------------
  431|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  432|      0|		goto done;
  433|      0|	}
  434|       |
  435|    262|	rv = op->type->sign_update(op, pData, ulDataLen);
  436|       |
  437|    262|done:
  438|    262|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    262|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (438:6): [True: 0, False: 262]
  ------------------
  439|      0|		session_stop_operation(session, SC_PKCS11_OPERATION_SIGN);
  440|       |
  441|    262|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|    262|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    262|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    262|	int _ret = r; \
  |  |  |  |  155|    262|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 262, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    262|		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: 262]
  |  |  |  |  ------------------
  |  |  |  |  157|    262|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    262|	} 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|    262|	return _ret; \
  |  |  |  |  163|    262|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  442|    262|}
sc_pkcs11_sign_final:
  447|    245|{
  448|    245|	sc_pkcs11_operation_t *op;
  449|    245|	CK_RV rv;
  450|       |
  451|    245|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|    245|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    245|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    245|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    245|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 245]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  452|    245|	rv = session_get_operation(session, SC_PKCS11_OPERATION_SIGN, &op);
  453|    245|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    245|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (453:6): [True: 0, False: 245]
  ------------------
  454|    245|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  455|       |
  456|       |	/* Bail out for signature mechanisms that don't do hashing */
  457|    245|	if (op->type->sign_final == NULL) {
  ------------------
  |  Branch (457:6): [True: 0, False: 245]
  ------------------
  458|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  459|      0|		goto done;
  460|      0|	}
  461|       |
  462|    245|	rv = op->type->sign_final(op, pSignature, pulSignatureLen);
  463|       |
  464|    245|done:
  465|    245|	if (rv != CKR_BUFFER_TOO_SMALL && pSignature != NULL)
  ------------------
  |  | 1165|    490|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
  |  Branch (465:6): [True: 244, False: 1]
  |  Branch (465:36): [True: 244, False: 0]
  ------------------
  466|    244|		session_stop_operation(session, SC_PKCS11_OPERATION_SIGN);
  467|       |
  468|    245|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|    245|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    245|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    245|	int _ret = r; \
  |  |  |  |  155|    245|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 33, False: 212]
  |  |  |  |  ------------------
  |  |  |  |  156|     33|		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: 33]
  |  |  |  |  ------------------
  |  |  |  |  157|     33|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    212|	} else { \
  |  |  |  |  159|    212|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    212|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    212|	} \
  |  |  |  |  162|    245|	return _ret; \
  |  |  |  |  163|    245|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  469|    245|}
sc_pkcs11_sign_size:
  473|    245|{
  474|    245|	sc_pkcs11_operation_t *op;
  475|    245|	CK_RV rv;
  476|       |
  477|    245|	rv = session_get_operation(session, SC_PKCS11_OPERATION_SIGN, &op);
  478|    245|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    245|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (478:6): [True: 0, False: 245]
  ------------------
  479|    245|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|       |
  481|       |	/* Bail out for signature mechanisms that don't do hashing */
  482|    245|	if (op->type->sign_size == NULL) {
  ------------------
  |  Branch (482:6): [True: 0, False: 245]
  ------------------
  483|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  484|      0|		goto done;
  485|      0|	}
  486|       |
  487|    245|	rv = op->type->sign_size(op, pLength);
  488|       |
  489|    245|done:
  490|    245|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    245|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (490:6): [True: 0, False: 245]
  ------------------
  491|      0|		session_stop_operation(session, SC_PKCS11_OPERATION_SIGN);
  492|       |
  493|    245|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|    245|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    245|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    245|	int _ret = r; \
  |  |  |  |  155|    245|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 245, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    245|		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: 245]
  |  |  |  |  ------------------
  |  |  |  |  157|    245|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    245|	} 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|    245|	return _ret; \
  |  |  |  |  163|    245|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|    245|}
sc_pkcs11_verif_init:
  676|     74|{
  677|     74|	struct sc_pkcs11_card *p11card;
  678|     74|	sc_pkcs11_operation_t *operation;
  679|     74|	sc_pkcs11_mechanism_type_t *mt;
  680|     74|	CK_RV rv;
  681|       |
  682|     74|	if (!session || !session->slot
  ------------------
  |  Branch (682:6): [True: 0, False: 74]
  |  Branch (682:18): [True: 0, False: 74]
  ------------------
  683|     74|	 || !(p11card = session->slot->p11card))
  ------------------
  |  Branch (683:6): [True: 0, False: 74]
  ------------------
  684|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  685|       |
  686|       |	/* See if we support this mechanism type */
  687|     74|	mt = sc_pkcs11_find_mechanism(p11card, pMechanism->mechanism, CKF_VERIFY);
  ------------------
  |  |  365|     74|#define CKF_VERIFY 0x00002000UL
  ------------------
  688|     74|	if (mt == NULL)
  ------------------
  |  Branch (688:6): [True: 22, False: 52]
  ------------------
  689|     22|		return CKR_MECHANISM_INVALID;
  ------------------
  |  | 1122|     22|#define CKR_MECHANISM_INVALID 0x00000070UL
  ------------------
  690|       |
  691|       |	/* See if compatible with key type */
  692|     52|	rv = _validate_key_type(mt, key_type);
  693|     52|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     52|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (693:6): [True: 3, False: 49]
  ------------------
  694|     52|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|      3|	} else { \
  |  |  |  |  159|      3|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      3|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      3|	} \
  |  |  |  |  162|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  695|       |
  696|     49|	if (pMechanism->pParameter &&
  ------------------
  |  Branch (696:6): [True: 0, False: 49]
  ------------------
  697|      0|			pMechanism->ulParameterLen > sizeof(operation->mechanism_params))
  ------------------
  |  Branch (697:4): [True: 0, False: 0]
  ------------------
  698|     49|		LOG_FUNC_RETURN(context, CKR_ARGUMENTS_BAD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  699|       |
  700|     49|	rv = session_start_operation(session, SC_PKCS11_OPERATION_VERIFY, mt, &operation);
  701|     49|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (701:6): [True: 0, False: 49]
  ------------------
  702|      0|		return rv;
  703|       |
  704|     49|	memcpy(&operation->mechanism, pMechanism, sizeof(CK_MECHANISM));
  705|     49|	if (pMechanism->pParameter) {
  ------------------
  |  Branch (705:6): [True: 0, False: 49]
  ------------------
  706|      0|		memcpy(&operation->mechanism_params, pMechanism->pParameter,
  707|      0|				pMechanism->ulParameterLen);
  708|      0|		operation->mechanism.pParameter = &operation->mechanism_params;
  709|      0|	}
  710|       |
  711|     49|	rv = mt->verif_init(operation, key);
  712|       |
  713|     49|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (713:6): [True: 0, False: 49]
  ------------------
  714|      0|		session_stop_operation(session, SC_PKCS11_OPERATION_VERIFY);
  715|       |
  716|     49|	return rv;
  717|       |
  718|     49|}
sc_pkcs11_verif_update:
  723|     49|{
  724|     49|	sc_pkcs11_operation_t *op;
  725|     49|	CK_RV rv;
  726|       |
  727|     49|	rv = session_get_operation(session, SC_PKCS11_OPERATION_VERIFY, &op);
  728|     49|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (728:6): [True: 0, False: 49]
  ------------------
  729|      0|		return rv;
  730|       |
  731|     49|	if (op->type->verif_update == NULL) {
  ------------------
  |  Branch (731:6): [True: 0, False: 49]
  ------------------
  732|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  733|      0|		goto done;
  734|      0|	}
  735|       |
  736|     49|	rv = op->type->verif_update(op, pData, ulDataLen);
  737|       |
  738|     49|done:
  739|     49|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (739:6): [True: 0, False: 49]
  ------------------
  740|      0|		session_stop_operation(session, SC_PKCS11_OPERATION_VERIFY);
  741|       |
  742|     49|	return rv;
  743|     49|}
sc_pkcs11_verif_final:
  748|     49|{
  749|     49|	sc_pkcs11_operation_t *op;
  750|     49|	CK_RV rv;
  751|       |
  752|     49|	rv = session_get_operation(session, SC_PKCS11_OPERATION_VERIFY, &op);
  753|     49|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (753:6): [True: 0, False: 49]
  ------------------
  754|      0|		return rv;
  755|       |
  756|     49|	if (op->type->verif_final == NULL) {
  ------------------
  |  Branch (756:6): [True: 0, False: 49]
  ------------------
  757|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  758|      0|		goto done;
  759|      0|	}
  760|       |
  761|     49|	rv = op->type->verif_final(op, pSignature, ulSignatureLen);
  762|       |
  763|     49|done:
  764|     49|	session_stop_operation(session, SC_PKCS11_OPERATION_VERIFY);
  765|     49|	return rv;
  766|     49|}
sc_pkcs11_decr_init:
 1042|    246|{
 1043|    246|	struct sc_pkcs11_card *p11card;
 1044|    246|	sc_pkcs11_operation_t *operation;
 1045|    246|	sc_pkcs11_mechanism_type_t *mt;
 1046|    246|	CK_RV rv;
 1047|       |
 1048|    246|	if (!session || !session->slot
  ------------------
  |  Branch (1048:6): [True: 0, False: 246]
  |  Branch (1048:18): [True: 0, False: 246]
  ------------------
 1049|    246|	 || !(p11card = session->slot->p11card))
  ------------------
  |  Branch (1049:6): [True: 0, False: 246]
  ------------------
 1050|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
 1051|       |
 1052|       |	/* See if we support this mechanism type */
 1053|    246|	mt = sc_pkcs11_find_mechanism(p11card, pMechanism->mechanism, CKF_DECRYPT);
  ------------------
  |  |  361|    246|#define CKF_DECRYPT 0x00000200UL
  ------------------
 1054|    246|	if (mt == NULL)
  ------------------
  |  Branch (1054:6): [True: 41, False: 205]
  ------------------
 1055|     41|		return CKR_MECHANISM_INVALID;
  ------------------
  |  | 1122|     41|#define CKR_MECHANISM_INVALID 0x00000070UL
  ------------------
 1056|       |
 1057|       |	/* See if compatible with key type */
 1058|    205|	rv = _validate_key_type(mt, key_type);
 1059|    205|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    205|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1059:6): [True: 0, False: 205]
  ------------------
 1060|    205|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1061|       |
 1062|    205|	if (pMechanism->pParameter &&
  ------------------
  |  Branch (1062:6): [True: 0, False: 205]
  ------------------
 1063|      0|			pMechanism->ulParameterLen > sizeof(operation->mechanism_params))
  ------------------
  |  Branch (1063:4): [True: 0, False: 0]
  ------------------
 1064|    205|		LOG_FUNC_RETURN(context, CKR_ARGUMENTS_BAD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1065|       |
 1066|    205|	rv = session_start_operation(session, SC_PKCS11_OPERATION_DECRYPT, mt, &operation);
 1067|    205|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    205|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1067:6): [True: 0, False: 205]
  ------------------
 1068|      0|		return rv;
 1069|       |
 1070|    205|	memcpy(&operation->mechanism, pMechanism, sizeof(CK_MECHANISM));
 1071|    205|	if (pMechanism->pParameter) {
  ------------------
  |  Branch (1071:6): [True: 0, False: 205]
  ------------------
 1072|      0|		memcpy(&operation->mechanism_params, pMechanism->pParameter,
 1073|      0|				pMechanism->ulParameterLen);
 1074|      0|		operation->mechanism.pParameter = &operation->mechanism_params;
 1075|      0|	}
 1076|    205|	rv = mt->decrypt_init(operation, key);
 1077|       |
 1078|       |	/* Validate the mechanism parameters */
 1079|    205|	if (rv == CKR_OK && key->ops->init_params) {
  ------------------
  |  | 1086|    410|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1079:6): [True: 205, False: 0]
  |  Branch (1079:22): [True: 205, False: 0]
  ------------------
 1080|    205|		rv = key->ops->init_params(operation->session, &operation->mechanism);
 1081|    205|	}
 1082|       |
 1083|    205|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    205|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1083:6): [True: 1, False: 204]
  ------------------
 1084|      1|		session_stop_operation(session, SC_PKCS11_OPERATION_DECRYPT);
 1085|       |
 1086|    205|	LOG_FUNC_RETURN(context, (int)rv);
  ------------------
  |  |  164|    205|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    205|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    205|	int _ret = r; \
  |  |  |  |  155|    205|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 204, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  156|    204|		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: 204]
  |  |  |  |  ------------------
  |  |  |  |  157|    204|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    204|	} else { \
  |  |  |  |  159|      1|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      1|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      1|	} \
  |  |  |  |  162|    205|	return _ret; \
  |  |  |  |  163|    205|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1087|    205|}
sc_pkcs11_decr:
 1093|    204|{
 1094|    204|	sc_pkcs11_operation_t *op;
 1095|    204|	CK_RV rv;
 1096|       |
 1097|    204|	rv = session_get_operation(session, SC_PKCS11_OPERATION_DECRYPT, &op);
 1098|    204|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    204|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1098:6): [True: 0, False: 204]
  ------------------
 1099|      0|		return rv;
 1100|       |
 1101|    204|	rv = op->type->decrypt(op, pEncryptedData, ulEncryptedDataLen,
 1102|    204|	                       pData, pulDataLen);
 1103|       |
 1104|       |	/* terminate session for any return value except CKR_BUFFER_TOO_SMALL,
 1105|       |	 * perform check in time side-channel free way to prevent Marvin attack */
 1106|    204|	if (!constant_time_eq_s(rv, CKR_BUFFER_TOO_SMALL) && pData != NULL)
  ------------------
  |  | 1165|    204|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
  |  Branch (1106:6): [True: 204, False: 0]
  |  Branch (1106:55): [True: 204, False: 0]
  ------------------
 1107|    204|		session_stop_operation(session, SC_PKCS11_OPERATION_DECRYPT);
 1108|       |
 1109|    204|	return rv;
 1110|    204|}
sc_pkcs11_new_fw_mechanism:
 1691|  95.0k|{
 1692|  95.0k|	sc_pkcs11_mechanism_type_t *mt;
 1693|       |
 1694|  95.0k|	mt = calloc(1, sizeof(*mt));
 1695|  95.0k|	if (mt == NULL)
  ------------------
  |  Branch (1695:6): [True: 0, False: 95.0k]
  ------------------
 1696|      0|		return mt;
 1697|  95.0k|	mt->mech = mech;
 1698|  95.0k|	mt->mech_info = *pInfo;
 1699|  95.0k|	mt->key_types[0] = (int)key_type;
 1700|  95.0k|	mt->key_types[1] = -1;
 1701|  95.0k|	mt->mech_data = priv_data;
 1702|  95.0k|	mt->free_mech_data = free_priv_data;
 1703|  95.0k|	mt->copy_mech_data = copy_priv_data;
 1704|  95.0k|	mt->obj_size = sizeof(sc_pkcs11_operation_t);
 1705|       |
 1706|  95.0k|	mt->release = sc_pkcs11_operation_release;
 1707|       |
 1708|  95.0k|	if (pInfo->flags & CKF_SIGN) {
  ------------------
  |  |  363|  95.0k|#define CKF_SIGN 0x00000800UL
  ------------------
  |  Branch (1708:6): [True: 84.6k, False: 10.4k]
  ------------------
 1709|  84.6k|		mt->sign_init = sc_pkcs11_signature_init;
 1710|  84.6k|		mt->sign_update = sc_pkcs11_signature_update;
 1711|  84.6k|		mt->sign_final = sc_pkcs11_signature_final;
 1712|  84.6k|		mt->sign_size = sc_pkcs11_signature_size;
 1713|  84.6k|#ifdef ENABLE_OPENSSL
 1714|  84.6k|		mt->verif_init = sc_pkcs11_verify_init;
 1715|  84.6k|		mt->verif_update = sc_pkcs11_verify_update;
 1716|  84.6k|		mt->verif_final = sc_pkcs11_verify_final;
 1717|  84.6k|#endif
 1718|  84.6k|	}
 1719|  95.0k|	if (pInfo->flags & CKF_WRAP) {
  ------------------
  |  |  369|  95.0k|#define CKF_WRAP 0x00020000UL
  ------------------
  |  Branch (1719:6): [True: 87, False: 94.9k]
  ------------------
 1720|     87|		mt->wrap = sc_pkcs11_wrap_operation;
 1721|     87|	}
 1722|  95.0k|	if (pInfo->flags & CKF_UNWRAP) {
  ------------------
  |  |  370|  95.0k|#define CKF_UNWRAP 0x00040000UL
  ------------------
  |  Branch (1722:6): [True: 87, False: 94.9k]
  ------------------
 1723|     87|		mt->unwrap = sc_pkcs11_unwrap_operation;
 1724|     87|	}
 1725|  95.0k|	if (pInfo->flags & CKF_DERIVE) {
  ------------------
  |  |  371|  95.0k|#define CKF_DERIVE 0x00080000UL
  ------------------
  |  Branch (1725:6): [True: 4.38k, False: 90.6k]
  ------------------
 1726|  4.38k|		mt->derive = sc_pkcs11_derive;
 1727|  4.38k|	}
 1728|  95.0k|	if (pInfo->flags & CKF_DECRYPT) {
  ------------------
  |  |  361|  95.0k|#define CKF_DECRYPT 0x00000200UL
  ------------------
  |  Branch (1728:6): [True: 15.0k, False: 79.9k]
  ------------------
 1729|  15.0k|		mt->decrypt_init = sc_pkcs11_decrypt_init;
 1730|  15.0k|		mt->decrypt = sc_pkcs11_decrypt;
 1731|  15.0k|		mt->decrypt_update = sc_pkcs11_decrypt_update;
 1732|  15.0k|		mt->decrypt_final = sc_pkcs11_decrypt_final;
 1733|  15.0k|	}
 1734|  95.0k|	if (pInfo->flags & CKF_ENCRYPT) {
  ------------------
  |  |  360|  95.0k|#define CKF_ENCRYPT 0x00000100UL
  ------------------
  |  Branch (1734:6): [True: 12, False: 95.0k]
  ------------------
 1735|     12|		mt->encrypt_init = sc_pkcs11_encrypt_init;
 1736|     12|		mt->encrypt = sc_pkcs11_encrypt;
 1737|     12|		mt->encrypt_update = sc_pkcs11_encrypt_update;
 1738|     12|		mt->encrypt_final = sc_pkcs11_encrypt_final;
 1739|     12|	}
 1740|       |
 1741|  95.0k|	return mt;
 1742|  95.0k|}
sc_pkcs11_free_mechanism:
 1745|   145k|{
 1746|   145k|	if (!mt || !(*mt))
  ------------------
  |  Branch (1746:6): [True: 0, False: 145k]
  |  Branch (1746:13): [True: 2.26k, False: 143k]
  ------------------
 1747|  2.26k|		return;
 1748|   143k|	if ((*mt)->free_mech_data)
  ------------------
  |  Branch (1748:6): [True: 108k, False: 34.9k]
  ------------------
 1749|   108k|		(*mt)->free_mech_data((*mt)->mech_data);
 1750|   143k|	free(*mt);
 1751|       |	*mt = NULL;
 1752|   143k|}
sc_pkcs11_register_generic_mechanisms:
 1759|  6.01k|{
 1760|  6.01k|#ifdef ENABLE_OPENSSL
 1761|  6.01k|	sc_pkcs11_register_openssl_mechanisms(p11card);
 1762|  6.01k|#endif
 1763|  6.01k|	return CKR_OK;
  ------------------
  |  | 1086|  6.01k|#define CKR_OK 0x00000000UL
  ------------------
 1764|  6.01k|}
free_info:
 1767|   132k|{
 1768|   132k|	free((void *) info);
 1769|   132k|}
copy_hash_signature_info:
 1772|  66.0k|{
 1773|  66.0k|	if (mech_data == NULL || new_data == NULL)
  ------------------
  |  Branch (1773:6): [True: 0, False: 66.0k]
  |  Branch (1773:27): [True: 0, False: 66.0k]
  ------------------
 1774|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
 1775|       |
 1776|  66.0k|	*new_data = calloc(1, sizeof(struct hash_signature_info));
 1777|  66.0k|	if (!(*new_data))
  ------------------
  |  Branch (1777:6): [True: 0, False: 66.0k]
  ------------------
 1778|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 1779|       |
 1780|  66.0k|	memcpy(*new_data, mech_data, sizeof(struct hash_signature_info));
 1781|  66.0k|	return CKR_OK;
  ------------------
  |  | 1086|  66.0k|#define CKR_OK 0x00000000UL
  ------------------
 1782|  66.0k|}
sc_pkcs11_register_sign_and_hash_mechanism:
 1793|  66.0k|{
 1794|  66.0k|	sc_pkcs11_mechanism_type_t *hash_type, *new_type;
 1795|  66.0k|	struct hash_signature_info *info;
 1796|  66.0k|	CK_MECHANISM_INFO mech_info;
 1797|  66.0k|	CK_RV rv;
 1798|       |
 1799|  66.0k|	LOG_FUNC_CALLED(p11card->card->ctx);
  ------------------
  |  |  151|  66.0k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  66.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  66.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  66.0k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 66.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1800|  66.0k|	sc_log(p11card->card->ctx, "mech = 0x%lx, hash_mech = 0x%lx", mech, hash_mech);
  ------------------
  |  |   71|  66.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1801|       |
 1802|  66.0k|	if (!sign_type)
  ------------------
  |  Branch (1802:6): [True: 0, False: 66.0k]
  ------------------
 1803|  66.0k|		LOG_FUNC_RETURN(p11card->card->ctx, CKR_MECHANISM_INVALID);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1804|  66.0k|	mech_info = sign_type->mech_info;
 1805|       |
 1806|  66.0k|	if (!(hash_type = sc_pkcs11_find_mechanism(p11card, hash_mech, CKF_DIGEST)))
  ------------------
  |  |  362|  66.0k|#define CKF_DIGEST 0x00000400UL
  ------------------
  |  Branch (1806:6): [True: 0, False: 66.0k]
  ------------------
 1807|  66.0k|		LOG_FUNC_RETURN(p11card->card->ctx, CKR_MECHANISM_INVALID);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1808|       |
 1809|       |	/* These hash-based mechs can only be used for sign/verify */
 1810|  66.0k|	mech_info.flags &= (CKF_SIGN | CKF_SIGN_RECOVER | CKF_VERIFY | CKF_VERIFY_RECOVER);
  ------------------
  |  |  363|  66.0k|#define CKF_SIGN 0x00000800UL
  ------------------
              	mech_info.flags &= (CKF_SIGN | CKF_SIGN_RECOVER | CKF_VERIFY | CKF_VERIFY_RECOVER);
  ------------------
  |  |  364|  66.0k|#define CKF_SIGN_RECOVER 0x00001000UL
  ------------------
              	mech_info.flags &= (CKF_SIGN | CKF_SIGN_RECOVER | CKF_VERIFY | CKF_VERIFY_RECOVER);
  ------------------
  |  |  365|  66.0k|#define CKF_VERIFY 0x00002000UL
  ------------------
              	mech_info.flags &= (CKF_SIGN | CKF_SIGN_RECOVER | CKF_VERIFY | CKF_VERIFY_RECOVER);
  ------------------
  |  |  366|  66.0k|#define CKF_VERIFY_RECOVER 0x00004000UL
  ------------------
 1811|       |
 1812|  66.0k|	info = calloc(1, sizeof(*info));
 1813|  66.0k|	if (!info)
  ------------------
  |  Branch (1813:6): [True: 0, False: 66.0k]
  ------------------
 1814|  66.0k|		LOG_FUNC_RETURN(p11card->card->ctx, CKR_HOST_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1815|       |
 1816|  66.0k|	info->mech = mech;
 1817|  66.0k|	info->hash_type = hash_type;
 1818|  66.0k|	info->sign_mech = sign_type->mech;
 1819|  66.0k|	info->hash_mech = hash_mech;
 1820|       |
 1821|  66.0k|	new_type = sc_pkcs11_new_fw_mechanism(mech, &mech_info, sign_type->key_types[0],
 1822|  66.0k|			info, free_info, copy_hash_signature_info);
 1823|  66.0k|	if (!new_type) {
  ------------------
  |  Branch (1823:6): [True: 0, False: 66.0k]
  ------------------
 1824|      0|		free_info(info);
 1825|      0|		LOG_FUNC_RETURN(p11card->card->ctx, CKR_HOST_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1826|      0|	}
 1827|       |
 1828|  66.0k|	rv = sc_pkcs11_register_mechanism(p11card, new_type, NULL);
 1829|  66.0k|	sc_pkcs11_free_mechanism(&new_type);
 1830|       |
 1831|  66.0k|	LOG_FUNC_RETURN(p11card->card->ctx, (int)rv);
  ------------------
  |  |  164|  66.0k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  66.0k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  66.0k|	int _ret = r; \
  |  |  |  |  155|  66.0k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 66.0k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  66.0k|		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: 66.0k]
  |  |  |  |  ------------------
  |  |  |  |  157|  66.0k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  66.0k|	} 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|  66.0k|	return _ret; \
  |  |  |  |  163|  66.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1832|  66.0k|}
mechanism.c:sc_pkcs11_copy_mechanism:
  104|   143k|{
  105|   143k|	CK_RV rv;
  106|       |
  107|   143k|	*new_mt = calloc(1, sizeof(sc_pkcs11_mechanism_type_t));
  108|   143k|	if (!(*new_mt))
  ------------------
  |  Branch (108:6): [True: 0, False: 143k]
  ------------------
  109|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  110|       |
  111|   143k|	memcpy(*new_mt, mt, sizeof(sc_pkcs11_mechanism_type_t));
  112|       |	/* mech_data needs specific function for making copy*/
  113|   143k|	if (mt->copy_mech_data
  ------------------
  |  Branch (113:6): [True: 108k, False: 34.8k]
  ------------------
  114|   108k|		&& (rv = mt->copy_mech_data(mt->mech_data, (void **) &(*new_mt)->mech_data)) != CKR_OK) {
  ------------------
  |  | 1086|   108k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (114:6): [True: 0, False: 108k]
  ------------------
  115|      0|		free(*new_mt);
  116|      0|		return rv;
  117|      0|	}
  118|       |
  119|   143k|	return CKR_OK;
  ------------------
  |  | 1086|   143k|#define CKR_OK 0x00000000UL
  ------------------
  120|   143k|}
mechanism.c:sc_pkcs11_operation_release:
  662|    505|{
  663|    505|	if (!operation)
  ------------------
  |  Branch (663:6): [True: 0, False: 505]
  ------------------
  664|      0|	    return;
  665|    505|	operation_data_release(operation->priv_data);
  666|    505|}
mechanism.c:operation_data_release:
   56|    511|{
   57|    511|	if (!data)
  ------------------
  |  Branch (57:6): [True: 6, False: 505]
  ------------------
   58|      6|		return;
   59|    505|	sc_pkcs11_release_operation(&data->md);
   60|    505|	sc_mem_secure_clear_free(data->buffer, data->buffer_len);
  ------------------
  |  | 1580|    505|#define sc_mem_secure_clear_free(ptr, len) do { \
  |  | 1581|    505|	sc_mem_clear(ptr, len); \
  |  | 1582|    505|	sc_mem_secure_free(ptr, len); \
  |  | 1583|    505|} while (0);
  |  |  ------------------
  |  |  |  Branch (1583:10): [Folded, False: 505]
  |  |  ------------------
  ------------------
   61|    505|	free(data);
   62|    505|}
mechanism.c:sc_pkcs11_signature_init:
  502|    251|{
  503|    251|	struct hash_signature_info *info;
  504|    251|	struct operation_data *data;
  505|    251|	CK_RV rv;
  506|    251|	int can_do_it = 0;
  507|       |
  508|    251|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|    251|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    251|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    251|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    251|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 251]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  509|    251|	if (!(data = new_operation_data()))
  ------------------
  |  Branch (509:6): [True: 0, False: 251]
  ------------------
  510|    251|		LOG_FUNC_RETURN(context, CKR_HOST_MEMORY);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  511|    251|	data->info = NULL;
  512|    251|	data->key = key;
  513|       |
  514|    251|	if (key->ops->can_do)   {
  ------------------
  |  Branch (514:6): [True: 251, False: 0]
  ------------------
  515|    251|		rv = key->ops->can_do(operation->session, key, operation->type->mech, CKF_SIGN);
  ------------------
  |  |  363|    251|#define CKF_SIGN 0x00000800UL
  ------------------
  516|    251|		if (rv == CKR_OK)   {
  ------------------
  |  | 1086|    251|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (516:7): [True: 0, False: 251]
  ------------------
  517|       |			/* Mechanism recognised and can be performed by pkcs#15 card */
  518|      0|			can_do_it = 1;
  519|      0|		}
  520|    251|		else if (rv == CKR_FUNCTION_NOT_SUPPORTED)   {
  ------------------
  |  | 1111|    251|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
  |  Branch (520:12): [True: 251, False: 0]
  ------------------
  521|       |			/* Mechanism not recognised by pkcs#15 card */
  522|    251|			can_do_it = 0;
  523|    251|		}
  524|      0|		else  {
  525|       |			/* Mechanism recognised but cannot be performed by pkcs#15 card, or some general error. */
  526|      0|			operation_data_release(data);
  527|      0|			LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  528|      0|		}
  529|    251|	}
  530|       |
  531|       |	/* Validate the mechanism parameters */
  532|    251|	if (key->ops->init_params) {
  ------------------
  |  Branch (532:6): [True: 251, False: 0]
  ------------------
  533|    251|		rv = key->ops->init_params(operation->session, &operation->mechanism);
  534|    251|		if (rv != CKR_OK) {
  ------------------
  |  | 1086|    251|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (534:7): [True: 6, False: 245]
  ------------------
  535|       |			/* Probably bad arguments */
  536|      6|			operation_data_release(data);
  537|      6|			LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|      6|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      6|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      6|	int _ret = r; \
  |  |  |  |  155|      6|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|      6|	} else { \
  |  |  |  |  159|      6|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      6|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      6|	} \
  |  |  |  |  162|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  538|      6|		}
  539|    251|	}
  540|       |
  541|       |	/* If this is a signature with hash operation,
  542|       |	 * and card cannot perform itself signature with hash operation,
  543|       |	 * set up the hash operation */
  544|    245|	info = (struct hash_signature_info *)operation->type->mech_data;
  545|    245|	if (info != NULL && !can_do_it) {
  ------------------
  |  Branch (545:6): [True: 154, False: 91]
  |  Branch (545:22): [True: 154, False: 0]
  ------------------
  546|       |		/* Initialize hash operation */
  547|       |
  548|    154|		data->md = sc_pkcs11_new_operation(operation->session, info->hash_type);
  549|    154|		if (data->md == NULL)
  ------------------
  |  Branch (549:7): [True: 0, False: 154]
  ------------------
  550|      0|			rv = CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  551|    154|		else
  552|    154|			rv = info->hash_type->md_init(data->md);
  553|    154|		if (rv != CKR_OK) {
  ------------------
  |  | 1086|    154|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (553:7): [True: 0, False: 154]
  ------------------
  554|      0|			sc_pkcs11_release_operation(&data->md);
  555|      0|			operation_data_release(data);
  556|      0|			LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  557|      0|		}
  558|    154|		data->info = info;
  559|    154|	}
  560|       |
  561|    245|	operation->priv_data = data;
  562|    245|	LOG_FUNC_RETURN(context, CKR_OK);
  ------------------
  |  |  164|    245|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    245|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    245|	int _ret = r; \
  |  |  |  |  155|    245|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 245, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    245|		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: 245]
  |  |  |  |  ------------------
  |  |  |  |  157|    245|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    245|	} 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|    245|	return _ret; \
  |  |  |  |  163|    245|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  563|    245|}
mechanism.c:new_operation_data:
   50|    505|{
   51|    505|	return calloc(1, sizeof(struct operation_data));
   52|    505|}
mechanism.c:sc_pkcs11_signature_update:
  568|    262|{
  569|    262|	struct operation_data *data;
  570|    262|	CK_RV rv;
  571|       |
  572|    262|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|    262|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    262|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    262|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    262|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 262]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  573|    262|	sc_log(context, "data part length %li", ulPartLen);
  ------------------
  |  |   71|    262|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  574|    262|	data = (struct operation_data *)operation->priv_data;
  575|    262|	if (data->md) {
  ------------------
  |  Branch (575:6): [True: 160, False: 102]
  ------------------
  576|    160|		rv = data->md->type->md_update(data->md, pPart, ulPartLen);
  577|    160|		LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|    160|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    160|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    160|	int _ret = r; \
  |  |  |  |  155|    160|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 160, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    160|		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: 160]
  |  |  |  |  ------------------
  |  |  |  |  157|    160|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    160|	} 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|    160|	return _ret; \
  |  |  |  |  163|    160|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  578|    160|	}
  579|       |
  580|       |	/* This signature mechanism operates on the raw data */
  581|    102|	rv = signature_data_buffer_append(data, pPart, ulPartLen);
  582|    102|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|    102|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    102|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    102|	int _ret = r; \
  |  |  |  |  155|    102|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 102, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    102|		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: 102]
  |  |  |  |  ------------------
  |  |  |  |  157|    102|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    102|	} 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|    102|	return _ret; \
  |  |  |  |  163|    102|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|    102|}
mechanism.c:signature_data_buffer_append:
   67|    271|{
   68|    271|	if (!data)
  ------------------
  |  Branch (68:6): [True: 0, False: 271]
  ------------------
   69|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
   70|    271|	if (in_len == 0)
  ------------------
  |  Branch (70:6): [True: 0, False: 271]
  ------------------
   71|      0|		return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
   72|       |
   73|    271|	CK_ULONG new_len;
   74|    271|	if (__builtin_uaddl_overflow(data->buffer_len, in_len, &new_len))
  ------------------
  |  Branch (74:6): [True: 0, False: 271]
  ------------------
   75|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
   76|    271|	CK_BYTE *new_buffer = sc_mem_secure_alloc(new_len);
   77|    271|	if (!new_buffer)
  ------------------
  |  Branch (77:6): [True: 0, False: 271]
  ------------------
   78|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
   79|       |
   80|    271|	if (data->buffer_len != 0)
  ------------------
  |  Branch (80:6): [True: 11, False: 260]
  ------------------
   81|     11|		memcpy(new_buffer, data->buffer, data->buffer_len);
   82|    271|	memcpy(new_buffer+data->buffer_len, in, in_len);
   83|       |
   84|    271|	sc_mem_secure_clear_free(data->buffer, data->buffer_len);
  ------------------
  |  | 1580|    271|#define sc_mem_secure_clear_free(ptr, len) do { \
  |  | 1581|    271|	sc_mem_clear(ptr, len); \
  |  | 1582|    271|	sc_mem_secure_free(ptr, len); \
  |  | 1583|    271|} while (0);
  |  |  ------------------
  |  |  |  Branch (1583:10): [Folded, False: 271]
  |  |  ------------------
  ------------------
   85|    271|	data->buffer = new_buffer;
   86|    271|	data->buffer_len = new_len;
   87|    271|	return CKR_OK;
  ------------------
  |  | 1086|    271|#define CKR_OK 0x00000000UL
  ------------------
   88|    271|}
mechanism.c:sc_pkcs11_signature_final:
  588|    245|{
  589|    245|	struct operation_data *data;
  590|    245|	CK_RV rv;
  591|       |
  592|    245|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|    245|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    245|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    245|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    245|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 245]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  593|    245|	data = (struct operation_data *)operation->priv_data;
  594|    245|	if (data->md) {
  ------------------
  |  Branch (594:6): [True: 154, False: 91]
  ------------------
  595|    154|		sc_pkcs11_operation_t	*md = data->md;
  596|    154|		CK_BYTE hash[64];
  597|    154|		CK_ULONG len = sizeof(hash);
  598|       |
  599|    154|		rv = md->type->md_final(md, hash, &len);
  600|    154|		if (rv == CKR_BUFFER_TOO_SMALL)
  ------------------
  |  | 1165|    154|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
  |  Branch (600:7): [True: 0, False: 154]
  ------------------
  601|      0|			rv = CKR_FUNCTION_FAILED;
  ------------------
  |  | 1091|      0|#define CKR_FUNCTION_FAILED 0x00000006UL
  ------------------
  602|    154|		if (rv != CKR_OK)
  ------------------
  |  | 1086|    154|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (602:7): [True: 0, False: 154]
  ------------------
  603|    154|			LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  604|    154|		rv = signature_data_buffer_append(data, hash, len);
  605|    154|		if (rv != CKR_OK)
  ------------------
  |  | 1086|    154|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (605:7): [True: 0, False: 154]
  ------------------
  606|    154|			LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  607|    154|	}
  608|       |
  609|    245|	rv = data->key->ops->sign(operation->session, data->key, &operation->mechanism,
  610|    245|			data->buffer, data->buffer_len, pSignature, pulSignatureLen);
  611|    245|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|    245|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    245|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    245|	int _ret = r; \
  |  |  |  |  155|    245|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 33, False: 212]
  |  |  |  |  ------------------
  |  |  |  |  156|     33|		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: 33]
  |  |  |  |  ------------------
  |  |  |  |  157|     33|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    212|	} else { \
  |  |  |  |  159|    212|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    212|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    212|	} \
  |  |  |  |  162|    245|	return _ret; \
  |  |  |  |  163|    245|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|    245|}
mechanism.c:sc_pkcs11_signature_size:
  616|    245|{
  617|    245|	struct sc_pkcs11_object *key;
  618|    245|	CK_ATTRIBUTE attr = { CKA_MODULUS_BITS, pLength, sizeof(*pLength) };
  ------------------
  |  |  175|    245|#define CKA_MODULUS_BITS 0x00000121UL
  ------------------
  619|    245|	CK_KEY_TYPE key_type;
  620|    245|	CK_ATTRIBUTE attr_key_type = { CKA_KEY_TYPE, &key_type, sizeof(key_type) };
  ------------------
  |  |  159|    245|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  621|    245|	CK_RV rv;
  622|       |
  623|    245|	key = ((struct operation_data *)operation->priv_data)->key;
  624|       |	/*
  625|       |	 * EC and GOSTR do not have CKA_MODULUS_BITS attribute.
  626|       |	 * But other code in framework treats them as if they do.
  627|       |	 * So should do switch(key_type)
  628|       |	 * and then get what ever attributes are needed.
  629|       |	 */
  630|    245|	rv = key->ops->get_attribute(operation->session, key, &attr_key_type);
  631|    245|	if (rv == CKR_OK) {
  ------------------
  |  | 1086|    245|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (631:6): [True: 245, False: 0]
  ------------------
  632|    245|		switch(key_type) {
  633|    213|			case CKK_RSA:
  ------------------
  |  |  464|    213|#define CKK_RSA 0x00000000UL
  ------------------
  |  Branch (633:4): [True: 213, False: 32]
  ------------------
  634|    213|				rv = key->ops->get_attribute(operation->session, key, &attr);
  635|       |				/* convert bits to bytes */
  636|    213|				if (rv == CKR_OK)
  ------------------
  |  | 1086|    213|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (636:9): [True: 213, False: 0]
  ------------------
  637|    213|					*pLength = BYTES4BITS(*pLength);
  ------------------
  |  |  145|    213|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  638|    213|				break;
  639|     32|			case CKK_EC:
  ------------------
  |  |  467|     32|#define CKK_EC 0x00000003UL
  ------------------
  |  Branch (639:4): [True: 32, False: 213]
  ------------------
  640|     32|			case CKK_EC_EDWARDS:
  ------------------
  |  |  518|     32|#define CKK_EC_EDWARDS 0x00000040UL
  ------------------
  |  Branch (640:4): [True: 0, False: 245]
  ------------------
  641|     32|			case CKK_EC_MONTGOMERY:
  ------------------
  |  |  519|     32|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
  |  Branch (641:4): [True: 0, False: 245]
  ------------------
  642|       |				/* TODO: -DEE we should use something other then CKA_MODULUS_BITS... */
  643|     32|				rv = key->ops->get_attribute(operation->session, key, &attr);
  644|     32|				if (rv == CKR_OK)
  ------------------
  |  | 1086|     32|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (644:9): [True: 32, False: 0]
  ------------------
  645|     32|					*pLength = BYTES4BITS(*pLength) * 2 ; /* 2*nLen in bytes */
  ------------------
  |  |  145|     32|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  646|     32|				break;
  647|      0|			case CKK_GOSTR3410:
  ------------------
  |  |  502|      0|#define CKK_GOSTR3410 0x00000030UL
  ------------------
  |  Branch (647:4): [True: 0, False: 245]
  ------------------
  648|      0|				rv = key->ops->get_attribute(operation->session, key, &attr);
  649|      0|				if (rv == CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (649:9): [True: 0, False: 0]
  ------------------
  650|      0|					*pLength = BYTES4BITS(*pLength) * 2;
  ------------------
  |  |  145|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  651|      0|				break;
  652|      0|			default:
  ------------------
  |  Branch (652:4): [True: 0, False: 245]
  ------------------
  653|      0|				rv = CKR_MECHANISM_INVALID;
  ------------------
  |  | 1122|      0|#define CKR_MECHANISM_INVALID 0x00000070UL
  ------------------
  654|    245|		}
  655|    245|	}
  656|       |
  657|    245|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|    245|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    245|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    245|	int _ret = r; \
  |  |  |  |  155|    245|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 245, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    245|		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: 245]
  |  |  |  |  ------------------
  |  |  |  |  157|    245|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    245|	} 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|    245|	return _ret; \
  |  |  |  |  163|    245|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  658|    245|}
mechanism.c:sc_pkcs11_verify_init:
  774|     49|{
  775|     49|	struct hash_signature_info *info;
  776|     49|	struct operation_data *data;
  777|     49|	CK_RV rv;
  778|       |
  779|     49|	if (!(data = new_operation_data()))
  ------------------
  |  Branch (779:6): [True: 0, False: 49]
  ------------------
  780|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  781|       |
  782|     49|	data->info = NULL;
  783|     49|	data->key = key;
  784|       |
  785|     49|	if (key->ops->can_do)   {
  ------------------
  |  Branch (785:6): [True: 0, False: 49]
  ------------------
  786|      0|		rv = key->ops->can_do(operation->session, key, operation->type->mech, CKF_SIGN);
  ------------------
  |  |  363|      0|#define CKF_SIGN 0x00000800UL
  ------------------
  787|      0|		if ((rv == CKR_OK) || (rv == CKR_FUNCTION_NOT_SUPPORTED))   {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
              		if ((rv == CKR_OK) || (rv == CKR_FUNCTION_NOT_SUPPORTED))   {
  ------------------
  |  | 1111|      0|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
  |  Branch (787:7): [True: 0, False: 0]
  |  Branch (787:25): [True: 0, False: 0]
  ------------------
  788|       |			/* Mechanism recognized and can be performed by pkcs#15 card or algorithm references not supported */
  789|      0|		}
  790|      0|		else {
  791|       |			/* Mechanism cannot be performed by pkcs#15 card, or some general error. */
  792|      0|			free(data);
  793|      0|			LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  794|      0|		}
  795|      0|	}
  796|       |
  797|       |	/* Validate the mechanism parameters */
  798|     49|	if (key->ops->init_params) {
  ------------------
  |  Branch (798:6): [True: 0, False: 49]
  ------------------
  799|      0|		rv = key->ops->init_params(operation->session, &operation->mechanism);
  800|      0|		if (rv != CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (800:7): [True: 0, False: 0]
  ------------------
  801|       |			/* Probably bad arguments */
  802|      0|			free(data);
  803|      0|			LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  804|      0|		}
  805|      0|	}
  806|       |
  807|       |	/* If this is a verify with hash operation, set up the
  808|       |	 * hash operation */
  809|     49|	info = (struct hash_signature_info *) operation->type->mech_data;
  810|     49|	if (info != NULL) {
  ------------------
  |  Branch (810:6): [True: 34, False: 15]
  ------------------
  811|       |		/* Initialize hash operation */
  812|     34|		data->md = sc_pkcs11_new_operation(operation->session,
  813|     34|						   info->hash_type);
  814|     34|		if (data->md == NULL)
  ------------------
  |  Branch (814:7): [True: 0, False: 34]
  ------------------
  815|      0|			rv = CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  816|     34|		else
  817|     34|			rv = info->hash_type->md_init(data->md);
  818|     34|		if (rv != CKR_OK) {
  ------------------
  |  | 1086|     34|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (818:7): [True: 0, False: 34]
  ------------------
  819|      0|			sc_pkcs11_release_operation(&data->md);
  820|      0|			free(data);
  821|      0|			return rv;
  822|      0|		}
  823|     34|		data->info = info;
  824|     34|	}
  825|       |
  826|     49|	operation->priv_data = data;
  827|     49|	return CKR_OK;
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  828|     49|}
mechanism.c:sc_pkcs11_verify_update:
  833|     49|{
  834|     49|	struct operation_data *data;
  835|       |
  836|     49|	data = (struct operation_data *)operation->priv_data;
  837|     49|	if (data->md) {
  ------------------
  |  Branch (837:6): [True: 34, False: 15]
  ------------------
  838|     34|		sc_pkcs11_operation_t	*md = data->md;
  839|       |
  840|     34|		return md->type->md_update(md, pPart, ulPartLen);
  841|     34|	}
  842|       |
  843|       |	/* This verification mechanism operates on the raw data */
  844|     15|	CK_RV rv = signature_data_buffer_append(data, pPart, ulPartLen);
  845|     15|	LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  164|     15|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     15|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     15|	int _ret = r; \
  |  |  |  |  155|     15|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 15, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     15|		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: 15]
  |  |  |  |  ------------------
  |  |  |  |  157|     15|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     15|	} 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|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  846|     15|}
mechanism.c:sc_pkcs11_verify_final:
  851|     49|{
  852|     49|	struct operation_data *data;
  853|     49|	struct sc_pkcs11_object *key;
  854|     49|	unsigned char *pubkey_value = NULL;
  855|     49|	CK_KEY_TYPE key_type;
  856|     49|	CK_BYTE params[9 /* GOST_PARAMS_ENCODED_OID_SIZE */] = { 0 };
  857|     49|	CK_ATTRIBUTE attr = {CKA_VALUE, NULL, 0};
  ------------------
  |  |  143|     49|#define CKA_VALUE 0x00000011UL
  ------------------
  858|     49|	CK_ATTRIBUTE attr_key_type = {CKA_KEY_TYPE, &key_type, sizeof(key_type)};
  ------------------
  |  |  159|     49|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  859|     49|	CK_ATTRIBUTE attr_key_params = {CKA_GOSTR3410_PARAMS, &params, sizeof(params)};
  ------------------
  |  |  218|     49|#define CKA_GOSTR3410_PARAMS 0x00000250UL
  ------------------
  860|     49|	CK_RV rv;
  861|       |
  862|     49|	data = (struct operation_data *)operation->priv_data;
  863|       |
  864|     49|	if (pSignature == NULL)
  ------------------
  |  Branch (864:6): [True: 0, False: 49]
  ------------------
  865|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  866|       |
  867|     49|	key = data->key;
  868|     49|	rv = key->ops->get_attribute(operation->session, key, &attr_key_type);
  869|     49|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (869:6): [True: 0, False: 49]
  ------------------
  870|      0|		return rv;
  871|       |
  872|     49|	if (key_type != CKK_GOSTR3410)
  ------------------
  |  |  502|     49|#define CKK_GOSTR3410 0x00000030UL
  ------------------
  |  Branch (872:6): [True: 49, False: 0]
  ------------------
  873|     49|		attr.type = CKA_SPKI;
  ------------------
  |  |   21|     49|#define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |  289|     49|#define CKA_VENDOR_DEFINED 0x80000000UL
  |  |  ------------------
  |  |               #define CKA_SPKI			(CKA_VENDOR_DEFINED | SC_VENDOR_DEFINED | 2UL)
  |  |  ------------------
  |  |  |  |   12|     49|#define SC_VENDOR_DEFINED 0x4F534300  /* OSC */
  |  |  ------------------
  ------------------
  874|       |
  875|     49|	rv = key->ops->get_attribute(operation->session, key, &attr);
  876|     49|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (876:6): [True: 5, False: 44]
  ------------------
  877|      5|		return rv;
  878|     44|	pubkey_value = calloc(1, attr.ulValueLen);
  879|     44|	if (!pubkey_value) {
  ------------------
  |  Branch (879:6): [True: 0, False: 44]
  ------------------
  880|      0|		rv = CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  881|      0|		goto done;
  882|      0|	}
  883|     44|	attr.pValue = pubkey_value;
  884|     44|	rv = key->ops->get_attribute(operation->session, key, &attr);
  885|     44|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     44|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (885:6): [True: 0, False: 44]
  ------------------
  886|      0|		goto done;
  887|       |
  888|     44|	if (key_type == CKK_GOSTR3410) {
  ------------------
  |  |  502|     44|#define CKK_GOSTR3410 0x00000030UL
  ------------------
  |  Branch (888:6): [True: 0, False: 44]
  ------------------
  889|      0|		rv = key->ops->get_attribute(operation->session, key, &attr_key_params);
  890|      0|		if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (890:7): [True: 0, False: 0]
  ------------------
  891|      0|			goto done;
  892|      0|	}
  893|       |
  894|     44|	rv = sc_pkcs11_verify_data(pubkey_value, attr.ulValueLen,
  895|     44|		params, sizeof(params),
  896|     44|		&operation->mechanism, data->md,
  897|     44|		data->buffer, data->buffer_len, pSignature, ulSignatureLen);
  898|       |
  899|     44|done:
  900|     44|	free(pubkey_value);
  901|       |
  902|     44|	return rv;
  903|     44|}
mechanism.c:sc_pkcs11_decrypt_init:
 1496|    205|{
 1497|    205|	struct operation_data *data;
 1498|    205|	CK_RV rv;
 1499|       |
 1500|    205|	if (!(data = new_operation_data()))
  ------------------
  |  Branch (1500:6): [True: 0, False: 205]
  ------------------
 1501|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
 1502|       |
 1503|    205|	data->key = key;
 1504|       |
 1505|    205|	if (key->ops->can_do)   {
  ------------------
  |  Branch (1505:6): [True: 205, False: 0]
  ------------------
 1506|    205|		rv = key->ops->can_do(operation->session, key, operation->type->mech, CKF_DECRYPT);
  ------------------
  |  |  361|    205|#define CKF_DECRYPT 0x00000200UL
  ------------------
 1507|    205|		if ((rv == CKR_OK) || (rv == CKR_FUNCTION_NOT_SUPPORTED))   {
  ------------------
  |  | 1086|    205|#define CKR_OK 0x00000000UL
  ------------------
              		if ((rv == CKR_OK) || (rv == CKR_FUNCTION_NOT_SUPPORTED))   {
  ------------------
  |  | 1111|    205|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
  |  Branch (1507:7): [True: 0, False: 205]
  |  Branch (1507:25): [True: 205, False: 0]
  ------------------
 1508|       |			/* Mechanism recognized and can be performed by pkcs#15 card or algorithm references not supported */
 1509|    205|		}
 1510|      0|		else {
 1511|       |			/* Mechanism cannot be performed by pkcs#15 card, or some general error. */
 1512|      0|			free(data);
 1513|      0|			LOG_FUNC_RETURN(context, (int) rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1514|      0|		}
 1515|    205|	}
 1516|    205|	operation->priv_data = data;
 1517|       |
 1518|       |	/* The last parameter is NULL - this is call to INIT code in underlying functions */
 1519|    205|	return key->ops->decrypt(operation->session,
 1520|    205|			key, &operation->mechanism, NULL, 0, NULL, NULL);
 1521|    205|}
mechanism.c:sc_pkcs11_decrypt:
 1527|    204|{
 1528|    204|	struct operation_data *data;
 1529|    204|	struct sc_pkcs11_object *key;
 1530|    204|	CK_RV rv;
 1531|    204|	CK_ULONG ulDataLen, ulLastDataLen;
 1532|       |
 1533|       |	/* PKCS#11: If pBuf is not NULL_PTR, then *pulBufLen must contain the size in bytes.. */
 1534|    204|	if (pData && !pulDataLen)
  ------------------
  |  Branch (1534:6): [True: 204, False: 0]
  |  Branch (1534:15): [True: 0, False: 204]
  ------------------
 1535|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
 1536|       |
 1537|    204|	ulDataLen = pulDataLen ? *pulDataLen : 0;
  ------------------
  |  Branch (1537:14): [True: 204, False: 0]
  ------------------
 1538|    204|	ulLastDataLen = ulDataLen;
 1539|       |
 1540|    204|	data = (struct operation_data *)operation->priv_data;
 1541|       |
 1542|    204|	key = data->key;
 1543|       |
 1544|       |	/* Decrypt */
 1545|    204|	rv = key->ops->decrypt(operation->session, key, &operation->mechanism,
 1546|    204|			pEncryptedData, ulEncryptedDataLen, pData, &ulDataLen);
 1547|       |
 1548|    204|	if (pulDataLen)
  ------------------
  |  Branch (1548:6): [True: 204, False: 0]
  ------------------
 1549|    204|		*pulDataLen = ulDataLen;
 1550|       |
 1551|       |	/* Skip DecryptFinalize for PKCS#1 v1.5 padding to prevent time side-channel leakage */
 1552|    204|	if (((CK_MECHANISM_PTR)&operation->mechanism)->mechanism == CKM_RSA_PKCS)
  ------------------
  |  |  539|    204|#define CKM_RSA_PKCS 0x00000001UL
  ------------------
  |  Branch (1552:6): [True: 187, False: 17]
  ------------------
 1553|    187|		return rv;
 1554|       |
 1555|     17|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     17|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1555:6): [True: 5, False: 12]
  ------------------
 1556|      5|		return rv;
 1557|       |
 1558|       |	/* recalculate buffer space */
 1559|     12|	if (ulDataLen <= ulLastDataLen)
  ------------------
  |  Branch (1559:6): [True: 12, False: 0]
  ------------------
 1560|     12|		ulLastDataLen -= ulDataLen;
 1561|      0|	else
 1562|      0|		ulLastDataLen = 0;
 1563|       |
 1564|       |	/* DecryptFinalize */
 1565|     12|	rv = key->ops->decrypt(operation->session, key, &operation->mechanism,
 1566|     12|			NULL, 0, pData ? pData + ulDataLen : NULL,
  ------------------
  |  Branch (1566:13): [True: 12, False: 0]
  ------------------
 1567|     12|			&ulLastDataLen);
 1568|     12|	if (pulDataLen)
  ------------------
  |  Branch (1568:6): [True: 12, False: 0]
  ------------------
 1569|     12|		*pulDataLen = ulDataLen + ulLastDataLen;
 1570|     12|	return rv;
 1571|     17|}

strcpy_bp:
   46|   117k|{
   47|   117k|	if (!dst || !dstsize)
  ------------------
  |  Branch (47:6): [True: 0, False: 117k]
  |  Branch (47:14): [True: 0, False: 117k]
  ------------------
   48|      0|		return;
   49|       |
   50|   117k|	memset((char *)dst, ' ', dstsize);
   51|       |
   52|   117k|	if (src) {
  ------------------
  |  Branch (52:6): [True: 65.5k, False: 52.2k]
  ------------------
   53|  65.5k|		size_t src_len = strlen(src);
   54|       |
   55|  65.5k|		if (src_len > dstsize) {
  ------------------
  |  Branch (55:7): [True: 1, False: 65.5k]
  ------------------
   56|       |			/* string will be truncated */
   57|      1|			memcpy((char *)dst, src, dstsize);
   58|      1|			if (dstsize > 3) {
  ------------------
  |  Branch (58:8): [True: 1, False: 0]
  ------------------
   59|       |				/* show truncation with '...' */
   60|       |				/* FIXME avoid breaking an UTF-8 character on multiple bytes */
   61|      1|				memset((char *)dst + dstsize - 3, '.', 3);
   62|      1|			}
   63|  65.5k|		} else {
   64|  65.5k|			memcpy((char *)dst, src, src_len);
   65|  65.5k|		}
   66|  65.5k|	}
   67|   117k|}
sc_to_cryptoki_error:
  127|  35.8k|{
  128|  35.8k|	if (ctx)   {
  ------------------
  |  Branch (128:6): [True: 10.7k, False: 25.1k]
  ------------------
  129|  10.7k|		int ii;
  130|       |
  131|  42.9k|		for (ii = 0; sc_to_cryptoki_error_map[ii].context; ii++) {
  ------------------
  |  Branch (131:16): [True: 32.2k, False: 10.7k]
  ------------------
  132|  32.2k|			if (sc_to_cryptoki_error_map[ii].sc_error != rc)
  ------------------
  |  Branch (132:8): [True: 31.9k, False: 231]
  ------------------
  133|  31.9k|				continue;
  134|    231|			if (strcmp(sc_to_cryptoki_error_map[ii].context, ctx))
  ------------------
  |  Branch (134:8): [True: 227, False: 4]
  ------------------
  135|    227|				continue;
  136|      4|			return sc_to_cryptoki_error_map[ii].ck_error;
  137|    231|		}
  138|  10.7k|	}
  139|  35.8k|	return sc_to_cryptoki_error_common(rc);
  140|  35.8k|}
restore_login_state:
  150|  3.44k|{
  151|  3.44k|	CK_RV r = CKR_OK;
  ------------------
  |  | 1086|  3.44k|#define CKR_OK 0x00000000UL
  ------------------
  152|       |
  153|  3.44k|	if (sc_pkcs11_conf.atomic && slot) {
  ------------------
  |  Branch (153:6): [True: 0, False: 3.44k]
  |  Branch (153:31): [True: 0, False: 0]
  ------------------
  154|      0|		if (list_iterator_start(&slot->logins)) {
  ------------------
  |  Branch (154:7): [True: 0, False: 0]
  ------------------
  155|      0|			struct sc_pkcs11_login *login = list_iterator_next(&slot->logins);
  156|      0|			while (login && slot->p11card && slot->p11card->framework) {
  ------------------
  |  Branch (156:11): [True: 0, False: 0]
  |  Branch (156:20): [True: 0, False: 0]
  |  Branch (156:37): [True: 0, False: 0]
  ------------------
  157|      0|				r = slot->p11card->framework->login(slot, login->userType,
  158|      0|						login->pPin, login->ulPinLen);
  159|      0|				if (r != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (159:9): [True: 0, False: 0]
  ------------------
  160|      0|					break;
  161|      0|				login = list_iterator_next(&slot->logins);
  162|      0|			}
  163|      0|			list_iterator_stop(&slot->logins);
  164|      0|		}
  165|      0|	}
  166|       |
  167|  3.44k|	return r;
  168|  3.44k|}
reset_login_state:
  171|  3.44k|{
  172|  3.44k|	if (slot) {
  ------------------
  |  Branch (172:6): [True: 3.44k, False: 0]
  ------------------
  173|  3.44k|		if (sc_pkcs11_conf.atomic
  ------------------
  |  Branch (173:7): [True: 0, False: 3.44k]
  ------------------
  174|      0|				&& slot->p11card && slot->p11card->framework) {
  ------------------
  |  Branch (174:8): [True: 0, False: 0]
  |  Branch (174:25): [True: 0, False: 0]
  ------------------
  175|      0|			slot->p11card->framework->logout(slot);
  176|      0|		}
  177|       |
  178|  3.44k|		if (constant_time_eq_s(rv, CKR_USER_NOT_LOGGED_IN)) {
  ------------------
  |  | 1151|  3.44k|#define CKR_USER_NOT_LOGGED_IN 0x00000101UL
  ------------------
  |  Branch (178:7): [True: 12, False: 3.43k]
  ------------------
  179|     12|			slot->login_user = -1;
  180|     12|			pop_all_login_states(slot);
  181|     12|		}
  182|  3.44k|	}
  183|       |
  184|  3.44k|	return rv;
  185|  3.44k|}
push_login_state:
  189|    908|{
  190|    908|	CK_RV r = CKR_HOST_MEMORY;
  ------------------
  |  | 1088|    908|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  191|    908|	struct sc_pkcs11_login *login = NULL;
  192|       |
  193|    908|	if (!sc_pkcs11_conf.atomic || !slot) {
  ------------------
  |  Branch (193:6): [True: 908, False: 0]
  |  Branch (193:32): [True: 0, False: 0]
  ------------------
  194|    908|		return CKR_OK;
  ------------------
  |  | 1086|    908|#define CKR_OK 0x00000000UL
  ------------------
  195|    908|	}
  196|       |
  197|      0|	login = (struct sc_pkcs11_login *) calloc(1, sizeof *login);
  198|      0|	if (login == NULL) {
  ------------------
  |  Branch (198:6): [True: 0, False: 0]
  ------------------
  199|      0|		goto err;
  200|      0|	}
  201|       |
  202|      0|	if (pPin && ulPinLen) {
  ------------------
  |  Branch (202:6): [True: 0, False: 0]
  |  Branch (202:14): [True: 0, False: 0]
  ------------------
  203|      0|		login->pPin = sc_mem_secure_alloc((sizeof *pPin)*ulPinLen);
  204|      0|		if (login->pPin == NULL) {
  ------------------
  |  Branch (204:7): [True: 0, False: 0]
  ------------------
  205|      0|			goto err;
  206|      0|		}
  207|      0|		memcpy(login->pPin, pPin, (sizeof *pPin)*ulPinLen);
  208|      0|		login->ulPinLen = ulPinLen;
  209|      0|	}
  210|      0|	login->userType = userType;
  211|       |
  212|      0|	if (0 > list_append(&slot->logins, login)) {
  ------------------
  |  Branch (212:6): [True: 0, False: 0]
  ------------------
  213|      0|		goto err;
  214|      0|	}
  215|       |
  216|      0|	login = NULL;
  217|      0|	r = CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  218|       |
  219|      0|err:
  220|      0|	if (login) {
  ------------------
  |  Branch (220:6): [True: 0, False: 0]
  ------------------
  221|      0|		if (login->pPin) {
  ------------------
  |  Branch (221:7): [True: 0, False: 0]
  ------------------
  222|      0|			sc_mem_secure_clear_free(login->pPin, login->ulPinLen);
  ------------------
  |  | 1580|      0|#define sc_mem_secure_clear_free(ptr, len) do { \
  |  | 1581|      0|	sc_mem_clear(ptr, len); \
  |  | 1582|      0|	sc_mem_secure_free(ptr, len); \
  |  | 1583|      0|} while (0);
  |  |  ------------------
  |  |  |  Branch (1583:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  223|      0|		}
  224|      0|		free(login);
  225|      0|	}
  226|       |
  227|      0|	return r;
  228|      0|}
pop_all_login_states:
  247|  17.0k|{
  248|  17.0k|	if (sc_pkcs11_conf.atomic && slot) {
  ------------------
  |  Branch (248:6): [True: 0, False: 17.0k]
  |  Branch (248:31): [True: 0, False: 0]
  ------------------
  249|      0|		struct sc_pkcs11_login *login = list_fetch(&slot->logins);
  250|      0|		while (login) {
  ------------------
  |  Branch (250:10): [True: 0, False: 0]
  ------------------
  251|      0|			sc_mem_secure_clear_free(login->pPin, login->ulPinLen);
  ------------------
  |  | 1580|      0|#define sc_mem_secure_clear_free(ptr, len) do { \
  |  | 1581|      0|	sc_mem_clear(ptr, len); \
  |  | 1582|      0|	sc_mem_secure_free(ptr, len); \
  |  | 1583|      0|} while (0);
  |  |  ------------------
  |  |  |  Branch (1583:10): [Folded, False: 0]
  |  |  ------------------
  ------------------
  252|      0|			free(login);
  253|      0|			login = list_fetch(&slot->logins);
  254|      0|		}
  255|      0|	}
  256|  17.0k|}
session_start_operation:
  262|  2.04k|{
  263|  2.04k|	sc_pkcs11_operation_t *op;
  264|       |
  265|  2.04k|	if (context == NULL)
  ------------------
  |  Branch (265:6): [True: 0, False: 2.04k]
  ------------------
  266|      0|		return CKR_CRYPTOKI_NOT_INITIALIZED;
  ------------------
  |  | 1169|      0|#define CKR_CRYPTOKI_NOT_INITIALIZED 0x00000190UL
  ------------------
  267|       |
  268|  2.04k|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|  2.04k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.04k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.04k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.04k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.04k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  269|  2.04k|	sc_log(context, "Session 0x%lx, type %d", session->handle, type);
  ------------------
  |  |   71|  2.04k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  270|  2.04k|	if (type < 0 || type >= SC_PKCS11_OPERATION_MAX)
  ------------------
  |  Branch (270:6): [True: 0, False: 2.04k]
  |  Branch (270:18): [True: 0, False: 2.04k]
  ------------------
  271|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  272|       |
  273|  2.04k|	if (session->operation[type] != NULL)
  ------------------
  |  Branch (273:6): [True: 0, False: 2.04k]
  ------------------
  274|      0|		return CKR_OPERATION_ACTIVE;
  ------------------
  |  | 1125|      0|#define CKR_OPERATION_ACTIVE 0x00000090UL
  ------------------
  275|       |
  276|  2.04k|	if (!(op = sc_pkcs11_new_operation(session, mech)))
  ------------------
  |  Branch (276:6): [True: 0, False: 2.04k]
  ------------------
  277|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  278|       |
  279|  2.04k|	session->operation[type] = op;
  280|  2.04k|	if (operation)
  ------------------
  |  Branch (280:6): [True: 2.04k, False: 0]
  ------------------
  281|  2.04k|		*operation = op;
  282|       |
  283|  2.04k|	return CKR_OK;
  ------------------
  |  | 1086|  2.04k|#define CKR_OK 0x00000000UL
  ------------------
  284|  2.04k|}
session_get_operation:
  287|  4.31k|{
  288|  4.31k|	sc_pkcs11_operation_t *op;
  289|       |
  290|  4.31k|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|  4.31k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.31k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.31k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.31k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|       |
  292|  4.31k|	if (type < 0 || type >= SC_PKCS11_OPERATION_MAX)
  ------------------
  |  Branch (292:6): [True: 0, False: 4.31k]
  |  Branch (292:18): [True: 0, False: 4.31k]
  ------------------
  293|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  294|       |
  295|  4.31k|	if (!(op = session->operation[type]))
  ------------------
  |  Branch (295:6): [True: 0, False: 4.31k]
  ------------------
  296|      0|		return CKR_OPERATION_NOT_INITIALIZED;
  ------------------
  |  | 1126|      0|#define CKR_OPERATION_NOT_INITIALIZED 0x00000091UL
  ------------------
  297|       |
  298|  4.31k|	if (operation)
  ------------------
  |  Branch (298:6): [True: 2.78k, False: 1.53k]
  ------------------
  299|  2.78k|		*operation = op;
  300|       |
  301|  4.31k|	return CKR_OK;
  ------------------
  |  | 1086|  4.31k|#define CKR_OK 0x00000000UL
  ------------------
  302|  4.31k|}
session_stop_operation:
  305|  2.04k|{
  306|  2.04k|	if (type < 0 || type >= SC_PKCS11_OPERATION_MAX)
  ------------------
  |  Branch (306:6): [True: 0, False: 2.04k]
  |  Branch (306:18): [True: 0, False: 2.04k]
  ------------------
  307|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  308|       |
  309|  2.04k|	if (session->operation[type] == NULL)
  ------------------
  |  Branch (309:6): [True: 0, False: 2.04k]
  ------------------
  310|      0|		return CKR_OPERATION_NOT_INITIALIZED;
  ------------------
  |  | 1126|      0|#define CKR_OPERATION_NOT_INITIALIZED 0x00000091UL
  ------------------
  311|       |
  312|  2.04k|	sc_pkcs11_release_operation(&session->operation[type]);
  313|  2.04k|	return CKR_OK;
  ------------------
  |  | 1086|  2.04k|#define CKR_OK 0x00000000UL
  ------------------
  314|  2.04k|}
attr_extract:
  317|    668|{
  318|    668|	size_t size;
  319|       |
  320|    668|	if (sizep) {
  ------------------
  |  Branch (320:6): [True: 0, False: 668]
  ------------------
  321|      0|		size = *sizep;
  322|      0|		if (size < pAttr->ulValueLen)
  ------------------
  |  Branch (322:7): [True: 0, False: 0]
  ------------------
  323|      0|			return CKR_ATTRIBUTE_VALUE_INVALID;
  ------------------
  |  | 1099|      0|#define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013UL
  ------------------
  324|      0|		*sizep = pAttr->ulValueLen;
  325|    668|	} else {
  326|    668|		switch (pAttr->type) {
  327|    152|		case CKA_CLASS:
  ------------------
  |  |  137|    152|#define CKA_CLASS 0x00000000UL
  ------------------
  |  Branch (327:3): [True: 152, False: 516]
  ------------------
  328|    152|			size = sizeof(CK_OBJECT_CLASS);
  329|    152|			break;
  330|      0|		case CKA_KEY_TYPE:
  ------------------
  |  |  159|      0|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  |  Branch (330:3): [True: 0, False: 668]
  ------------------
  331|      0|			size = sizeof(CK_KEY_TYPE);
  332|      0|			break;
  333|     37|		case CKA_PRIVATE:
  ------------------
  |  |  139|     37|#define CKA_PRIVATE 0x00000002UL
  ------------------
  |  Branch (333:3): [True: 37, False: 631]
  ------------------
  334|    509|		case CKA_TOKEN:
  ------------------
  |  |  138|    509|#define CKA_TOKEN 0x00000001UL
  ------------------
  |  Branch (334:3): [True: 472, False: 196]
  ------------------
  335|    509|			size = sizeof(CK_BBOOL);
  336|    509|			break;
  337|      7|		case CKA_CERTIFICATE_TYPE:
  ------------------
  |  |  145|      7|#define CKA_CERTIFICATE_TYPE 0x00000080UL
  ------------------
  |  Branch (337:3): [True: 7, False: 661]
  ------------------
  338|      7|			size = sizeof(CK_CERTIFICATE_TYPE);
  339|      7|			break;
  340|      0|		case CKA_VALUE_LEN:
  ------------------
  |  |  191|      0|#define CKA_VALUE_LEN 0x00000161UL
  ------------------
  |  Branch (340:3): [True: 0, False: 668]
  ------------------
  341|      0|		case CKA_MODULUS_BITS:
  ------------------
  |  |  175|      0|#define CKA_MODULUS_BITS 0x00000121UL
  ------------------
  |  Branch (341:3): [True: 0, False: 668]
  ------------------
  342|      0|			size = sizeof(CK_ULONG);
  343|      0|			break;
  344|      0|		case CKA_OBJECT_ID:
  ------------------
  |  |  144|      0|#define CKA_OBJECT_ID 0x00000012UL
  ------------------
  |  Branch (344:3): [True: 0, False: 668]
  ------------------
  345|      0|			size = sizeof(struct sc_object_id);
  346|      0|			break;
  347|      0|		default:
  ------------------
  |  Branch (347:3): [True: 0, False: 668]
  ------------------
  348|      0|			return CKR_FUNCTION_FAILED;
  ------------------
  |  | 1091|      0|#define CKR_FUNCTION_FAILED 0x00000006UL
  ------------------
  349|    668|		}
  350|    668|		if (size != pAttr->ulValueLen)
  ------------------
  |  Branch (350:7): [True: 0, False: 668]
  ------------------
  351|      0|			return CKR_ATTRIBUTE_VALUE_INVALID;
  ------------------
  |  | 1099|      0|#define CKR_ATTRIBUTE_VALUE_INVALID 0x00000013UL
  ------------------
  352|    668|	}
  353|    668|	memcpy(ptr, pAttr->pValue, pAttr->ulValueLen);
  354|    668|	return CKR_OK;
  ------------------
  |  | 1086|    668|#define CKR_OK 0x00000000UL
  ------------------
  355|    668|}
attr_find:
  358|    631|{
  359|    631|	unsigned int n;
  360|       |
  361|  1.57k|	for (n = 0; n < ulCount; n++, pTemplate++) {
  ------------------
  |  Branch (361:14): [True: 1.57k, False: 0]
  ------------------
  362|  1.57k|		if (pTemplate->type == type)
  ------------------
  |  Branch (362:7): [True: 631, False: 941]
  ------------------
  363|    631|			break;
  364|  1.57k|	}
  365|       |
  366|    631|	if (n >= ulCount)
  ------------------
  |  Branch (366:6): [True: 0, False: 631]
  ------------------
  367|      0|		return CKR_TEMPLATE_INCOMPLETE;
  ------------------
  |  | 1142|      0|#define CKR_TEMPLATE_INCOMPLETE 0x000000D0UL
  ------------------
  368|    631|	return attr_extract(pTemplate, ptr, sizep);
  369|    631|}
load_pkcs11_parameters:
  478|  17.0k|{
  479|  17.0k|	scconf_block *conf_block = NULL;
  480|  17.0k|	char *unblock_style = NULL;
  481|  17.0k|	char *create_slots_for_pins = NULL, *op, *tmp;
  482|       |
  483|       |	/* Set defaults */
  484|  17.0k|	conf->max_virtual_slots = 16;
  485|  17.0k|	if (is_nss_browser(ctx)) {
  ------------------
  |  Branch (485:6): [True: 0, False: 17.0k]
  ------------------
  486|       |		/* NSS verifies *every* PIN even though only a single one would be
  487|       |		 * needed to use one specific key. In known NSS browsers, we set
  488|       |		 * slots_per_card to `1` to only look at the authentication PIN, i.e.
  489|       |		 * ignoring a potential signature PIN. */
  490|      0|		conf->slots_per_card = 1;
  491|  17.0k|	} else {
  492|  17.0k|		conf->slots_per_card = 4;
  493|  17.0k|	}
  494|  17.0k|	conf->atomic = 0;
  495|  17.0k|	conf->lock_login = 0;
  496|  17.0k|	conf->init_sloppy = 1;
  497|  17.0k|	conf->pin_unblock_style = SC_PKCS11_PIN_UNBLOCK_NOT_ALLOWED;
  ------------------
  |  |   39|  17.0k|#define SC_PKCS11_PIN_UNBLOCK_NOT_ALLOWED	0
  ------------------
  498|  17.0k|	conf->create_puk_slot = 0;
  499|  17.0k|	conf->create_slots_flags = SC_PKCS11_SLOT_CREATE_ALL;
  ------------------
  |  |   46|  17.0k|#define SC_PKCS11_SLOT_CREATE_ALL	8
  ------------------
  500|       |
  501|  17.0k|	conf_block = sc_get_conf_block(ctx, "pkcs11", NULL, 1);
  502|  17.0k|	if (!conf_block)
  ------------------
  |  Branch (502:6): [True: 17.0k, False: 0]
  ------------------
  503|  17.0k|		goto out;
  504|       |
  505|       |	/* contains the defaults, if there is a "pkcs11" config block */
  506|      0|	conf->max_virtual_slots = scconf_get_int(conf_block, "max_virtual_slots", conf->max_virtual_slots);
  507|      0|	conf->slots_per_card = scconf_get_int(conf_block, "slots_per_card", conf->slots_per_card);
  508|      0|	conf->atomic = scconf_get_bool(conf_block, "atomic", conf->atomic);
  509|      0|	if (conf->atomic)
  ------------------
  |  Branch (509:6): [True: 0, False: 0]
  ------------------
  510|      0|		conf->lock_login = 1;
  511|      0|	conf->lock_login = scconf_get_bool(conf_block, "lock_login", conf->lock_login);
  512|      0|	conf->init_sloppy = scconf_get_bool(conf_block, "init_sloppy", conf->init_sloppy);
  513|       |
  514|      0|	unblock_style = (char *)scconf_get_str(conf_block, "user_pin_unblock_style", NULL);
  515|      0|	if (unblock_style && !strcmp(unblock_style, "set_pin_in_unlogged_session"))
  ------------------
  |  Branch (515:6): [True: 0, False: 0]
  |  Branch (515:23): [True: 0, False: 0]
  ------------------
  516|      0|		conf->pin_unblock_style = SC_PKCS11_PIN_UNBLOCK_UNLOGGED_SETPIN;
  ------------------
  |  |   40|      0|#define SC_PKCS11_PIN_UNBLOCK_UNLOGGED_SETPIN	1
  ------------------
  517|      0|	else if (unblock_style && !strcmp(unblock_style, "set_pin_in_specific_context"))
  ------------------
  |  Branch (517:11): [True: 0, False: 0]
  |  Branch (517:28): [True: 0, False: 0]
  ------------------
  518|      0|		conf->pin_unblock_style = SC_PKCS11_PIN_UNBLOCK_SCONTEXT_SETPIN;
  ------------------
  |  |   41|      0|#define SC_PKCS11_PIN_UNBLOCK_SCONTEXT_SETPIN	2
  ------------------
  519|      0|	else if (unblock_style && !strcmp(unblock_style, "init_pin_in_so_session"))
  ------------------
  |  Branch (519:11): [True: 0, False: 0]
  |  Branch (519:28): [True: 0, False: 0]
  ------------------
  520|      0|		conf->pin_unblock_style = SC_PKCS11_PIN_UNBLOCK_SO_LOGGED_INITPIN;
  ------------------
  |  |   42|      0|#define SC_PKCS11_PIN_UNBLOCK_SO_LOGGED_INITPIN	3
  ------------------
  521|       |
  522|      0|	conf->create_puk_slot = scconf_get_bool(conf_block, "create_puk_slot", conf->create_puk_slot);
  523|       |
  524|      0|	create_slots_for_pins = (char *)scconf_get_str(conf_block, "create_slots_for_pins", "all");
  525|      0|	conf->create_slots_flags = 0;
  526|      0|	tmp = strdup(create_slots_for_pins);
  527|      0|	op = strtok(tmp, " ,");
  528|      0|	while (op) {
  ------------------
  |  Branch (528:9): [True: 0, False: 0]
  ------------------
  529|      0|		if (!strcmp(op, "user"))
  ------------------
  |  Branch (529:7): [True: 0, False: 0]
  ------------------
  530|      0|			conf->create_slots_flags |= SC_PKCS11_SLOT_FOR_PIN_USER;
  ------------------
  |  |   44|      0|#define SC_PKCS11_SLOT_FOR_PIN_USER	1
  ------------------
  531|      0|		else if (!strcmp(op, "sign"))
  ------------------
  |  Branch (531:12): [True: 0, False: 0]
  ------------------
  532|      0|			conf->create_slots_flags |= SC_PKCS11_SLOT_FOR_PIN_SIGN;
  ------------------
  |  |   45|      0|#define SC_PKCS11_SLOT_FOR_PIN_SIGN	2
  ------------------
  533|      0|		else if (!strcmp(op, "all"))
  ------------------
  |  Branch (533:12): [True: 0, False: 0]
  ------------------
  534|      0|			conf->create_slots_flags |= SC_PKCS11_SLOT_CREATE_ALL;
  ------------------
  |  |   46|      0|#define SC_PKCS11_SLOT_CREATE_ALL	8
  ------------------
  535|      0|		op = strtok(NULL, " ,");
  536|      0|	}
  537|      0|	free(tmp);
  538|       |
  539|  17.0k|out:
  540|  17.0k|	sc_log(ctx, "PKCS#11 options: max_virtual_slots=%d slots_per_card=%d "
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  541|  17.0k|		 "lock_login=%d atomic=%d pin_unblock_style=%d "
  542|  17.0k|		 "create_slots_flags=0x%X",
  543|  17.0k|		 conf->max_virtual_slots, conf->slots_per_card,
  544|  17.0k|		 conf->lock_login, conf->atomic, conf->pin_unblock_style,
  545|  17.0k|		 conf->create_slots_flags);
  546|  17.0k|}
misc.c:sc_to_cryptoki_error_common:
   71|  35.8k|{
   72|  35.8k|	sc_log(context, "libopensc return value: %d (%s)\n", rc, sc_strerror(rc));
  ------------------
  |  |   71|  35.8k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   73|  35.8k|	switch (rc) {
  ------------------
  |  Branch (73:10): [True: 30.4k, False: 5.40k]
  ------------------
   74|  15.6k|	case SC_SUCCESS:
  ------------------
  |  |   28|  15.6k|#define SC_SUCCESS				0
  ------------------
  |  Branch (74:2): [True: 15.6k, False: 20.1k]
  ------------------
   75|  15.6k|		return CKR_OK;
  ------------------
  |  | 1086|  15.6k|#define CKR_OK 0x00000000UL
  ------------------
   76|  1.46k|	case SC_ERROR_NOT_SUPPORTED:
  ------------------
  |  |   89|  1.46k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (76:2): [True: 1.46k, False: 34.3k]
  ------------------
   77|  1.46k|		return CKR_FUNCTION_NOT_SUPPORTED;
  ------------------
  |  | 1111|  1.46k|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
   78|      0|	case SC_ERROR_OUT_OF_MEMORY:
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  |  Branch (78:2): [True: 0, False: 35.8k]
  ------------------
   79|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
   80|     11|	case SC_ERROR_PIN_CODE_INCORRECT:
  ------------------
  |  |   64|     11|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (80:2): [True: 11, False: 35.8k]
  ------------------
   81|     11|		return CKR_PIN_INCORRECT;
  ------------------
  |  | 1127|     11|#define CKR_PIN_INCORRECT 0x000000A0UL
  ------------------
   82|      2|	case SC_ERROR_AUTH_METHOD_BLOCKED:
  ------------------
  |  |   62|      2|#define SC_ERROR_AUTH_METHOD_BLOCKED		-1212
  ------------------
  |  Branch (82:2): [True: 2, False: 35.8k]
  ------------------
   83|      2|		return CKR_PIN_LOCKED;
  ------------------
  |  | 1131|      2|#define CKR_PIN_LOCKED 0x000000A4UL
  ------------------
   84|      1|	case SC_ERROR_BUFFER_TOO_SMALL:
  ------------------
  |  |   76|      1|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  |  Branch (84:2): [True: 1, False: 35.8k]
  ------------------
   85|      1|		return CKR_BUFFER_TOO_SMALL;
  ------------------
  |  | 1165|      1|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
   86|      0|	case SC_ERROR_CARD_NOT_PRESENT:
  ------------------
  |  |   35|      0|#define SC_ERROR_CARD_NOT_PRESENT		-1104
  ------------------
  |  Branch (86:2): [True: 0, False: 35.8k]
  ------------------
   87|      0|		return CKR_TOKEN_NOT_PRESENT;
  ------------------
  |  | 1144|      0|#define CKR_TOKEN_NOT_PRESENT 0x000000E0UL
  ------------------
   88|  5.05k|	case SC_ERROR_INVALID_CARD:
  ------------------
  |  |   60|  5.05k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  |  Branch (88:2): [True: 5.05k, False: 30.8k]
  ------------------
   89|  12.6k|	case SC_ERROR_WRONG_CARD:
  ------------------
  |  |   94|  12.6k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  |  Branch (89:2): [True: 7.62k, False: 28.2k]
  ------------------
   90|  12.6k|	case SC_ERROR_NO_CARD_SUPPORT:
  ------------------
  |  |   58|  12.6k|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
  |  Branch (90:2): [True: 12, False: 35.8k]
  ------------------
   91|  12.6k|		return CKR_TOKEN_NOT_RECOGNIZED;
  ------------------
  |  | 1145|  12.6k|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
   92|     48|	case SC_ERROR_WRONG_LENGTH:
  ------------------
  |  |   56|     48|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  |  Branch (92:2): [True: 48, False: 35.8k]
  ------------------
   93|     48|		return CKR_DATA_LEN_RANGE;
  ------------------
  |  | 1102|     48|#define CKR_DATA_LEN_RANGE 0x00000021UL
  ------------------
   94|    207|	case SC_ERROR_INVALID_PIN_LENGTH:
  ------------------
  |  |   77|    207|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
  |  Branch (94:2): [True: 207, False: 35.6k]
  ------------------
   95|    207|		return CKR_PIN_LEN_RANGE;
  ------------------
  |  | 1129|    207|#define CKR_PIN_LEN_RANGE 0x000000A2UL
  ------------------
   96|      0|	case SC_ERROR_KEYPAD_CANCELLED:
  ------------------
  |  |   40|      0|#define SC_ERROR_KEYPAD_CANCELLED		-1109
  ------------------
  |  Branch (96:2): [True: 0, False: 35.8k]
  ------------------
   97|      0|	case SC_ERROR_KEYPAD_TIMEOUT:
  ------------------
  |  |   39|      0|#define SC_ERROR_KEYPAD_TIMEOUT			-1108
  ------------------
  |  Branch (97:2): [True: 0, False: 35.8k]
  ------------------
   98|      0|		return CKR_FUNCTION_CANCELED;
  ------------------
  |  | 1109|      0|#define CKR_FUNCTION_CANCELED 0x00000050UL
  ------------------
   99|      0|	case SC_ERROR_CARD_REMOVED:
  ------------------
  |  |   36|      0|#define SC_ERROR_CARD_REMOVED			-1105
  ------------------
  |  Branch (99:2): [True: 0, False: 35.8k]
  ------------------
  100|      0|		return CKR_DEVICE_REMOVED;
  ------------------
  |  | 1105|      0|#define CKR_DEVICE_REMOVED 0x00000032UL
  ------------------
  101|     22|	case SC_ERROR_SECURITY_STATUS_NOT_SATISFIED:
  ------------------
  |  |   61|     22|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (101:2): [True: 22, False: 35.8k]
  ------------------
  102|     22|		return CKR_USER_NOT_LOGGED_IN;
  ------------------
  |  | 1151|     22|#define CKR_USER_NOT_LOGGED_IN 0x00000101UL
  ------------------
  103|      0|	case SC_ERROR_KEYPAD_PIN_MISMATCH:
  ------------------
  |  |   41|      0|#define SC_ERROR_KEYPAD_PIN_MISMATCH		-1110
  ------------------
  |  Branch (103:2): [True: 0, False: 35.8k]
  ------------------
  104|      0|		return CKR_PIN_INVALID;
  ------------------
  |  | 1128|      0|#define CKR_PIN_INVALID 0x000000A1UL
  ------------------
  105|     79|	case SC_ERROR_INVALID_ARGUMENTS:
  ------------------
  |  |   73|     79|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  |  Branch (105:2): [True: 79, False: 35.7k]
  ------------------
  106|     79|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|     79|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  107|    136|	case SC_ERROR_INVALID_DATA:
  ------------------
  |  |   78|    136|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  |  Branch (107:2): [True: 136, False: 35.7k]
  ------------------
  108|    160|	case SC_ERROR_INCORRECT_PARAMETERS:
  ------------------
  |  |   55|    160|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (108:2): [True: 24, False: 35.8k]
  ------------------
  109|    160|		return CKR_DATA_INVALID;
  ------------------
  |  | 1101|    160|#define CKR_DATA_INVALID 0x00000020UL
  ------------------
  110|      0|	case SC_ERROR_CARD_UNRESPONSIVE:
  ------------------
  |  |   44|      0|#define SC_ERROR_CARD_UNRESPONSIVE		-1113
  ------------------
  |  Branch (110:2): [True: 0, False: 35.8k]
  ------------------
  111|      0|	case SC_ERROR_READER_LOCKED:
  ------------------
  |  |   47|      0|#define SC_ERROR_READER_LOCKED			-1116
  ------------------
  |  Branch (111:2): [True: 0, False: 35.8k]
  ------------------
  112|      0|		return CKR_DEVICE_ERROR;
  ------------------
  |  | 1103|      0|#define CKR_DEVICE_ERROR 0x00000030UL
  ------------------
  113|      0|	case SC_ERROR_READER_DETACHED:
  ------------------
  |  |   45|      0|#define SC_ERROR_READER_DETACHED		-1114
  ------------------
  |  Branch (113:2): [True: 0, False: 35.8k]
  ------------------
  114|      0|		return CKR_TOKEN_NOT_PRESENT;	/* Maybe CKR_DEVICE_REMOVED ? */
  ------------------
  |  | 1144|      0|#define CKR_TOKEN_NOT_PRESENT 0x000000E0UL
  ------------------
  115|     25|	case SC_ERROR_NOT_ENOUGH_MEMORY:
  ------------------
  |  |   67|     25|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  |  Branch (115:2): [True: 25, False: 35.8k]
  ------------------
  116|     25|		return CKR_DEVICE_MEMORY;
  ------------------
  |  | 1104|     25|#define CKR_DEVICE_MEMORY 0x00000031UL
  ------------------
  117|      1|	case SC_ERROR_MEMORY_FAILURE:	/* EEPROM has failed */
  ------------------
  |  |   57|      1|#define SC_ERROR_MEMORY_FAILURE			-1207
  ------------------
  |  Branch (117:2): [True: 1, False: 35.8k]
  ------------------
  118|      1|		return CKR_DEVICE_ERROR;
  ------------------
  |  | 1103|      1|#define CKR_DEVICE_ERROR 0x00000030UL
  ------------------
  119|     67|	case SC_ERROR_WRONG_PADDING:
  ------------------
  |  |   93|     67|#define SC_ERROR_WRONG_PADDING			-1412
  ------------------
  |  Branch (119:2): [True: 67, False: 35.7k]
  ------------------
  120|     67|		return CKR_ENCRYPTED_DATA_INVALID;
  ------------------
  |  | 1106|     67|#define CKR_ENCRYPTED_DATA_INVALID 0x00000040UL
  ------------------
  121|  35.8k|	}
  122|  5.40k|	return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|  5.40k|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  123|  35.8k|}
misc.c:is_nss_browser:
  453|  17.0k|{
  454|  17.0k|	const char *basename;
  455|       |#ifdef _WIN32
  456|       |	const char sep = '\\';
  457|       |#else
  458|  17.0k|	const char sep = '/';
  459|  17.0k|#endif
  460|  17.0k|	if (!ctx || !ctx->exe_path)
  ------------------
  |  Branch (460:6): [True: 0, False: 17.0k]
  |  Branch (460:14): [True: 0, False: 17.0k]
  ------------------
  461|      0|		return 0;
  462|       |
  463|  17.0k|	basename = strrchr(ctx->exe_path, sep);
  464|  17.0k|	if (!basename)
  ------------------
  |  Branch (464:6): [True: 0, False: 17.0k]
  ------------------
  465|      0|		basename = ctx->exe_path;
  466|  17.0k|	else
  467|       |		/* discard the separator */
  468|  17.0k|		basename += sizeof(char);
  469|       |
  470|  17.0k|	if (strstr(basename, "chromium") || strstr(basename, "chrome")
  ------------------
  |  Branch (470:6): [True: 0, False: 17.0k]
  |  Branch (470:38): [True: 0, False: 17.0k]
  ------------------
  471|  17.0k|			|| strstr(basename, "firefox") || strstr(basename, "msedge"))
  ------------------
  |  Branch (471:7): [True: 0, False: 17.0k]
  |  Branch (471:38): [True: 0, False: 17.0k]
  ------------------
  472|      0|		return 1;
  473|       |
  474|  17.0k|	return 0;
  475|  17.0k|}

sc_pkcs11_register_openssl_mechanisms:
  256|  6.01k|{
  257|  6.01k|	sc_pkcs11_mechanism_type_t *mt = NULL;
  258|       |/*
  259|       | * Engine support is being deprecated in 3.0. OpenSC loads GOST as engine.
  260|       | * When GOST developers convert to provider, we can load the provider
  261|       | */
  262|  6.01k|#if !defined(OPENSSL_NO_ENGINE)
  263|  6.01k|	ENGINE *e = ENGINE_by_id("gost");
  264|  6.01k|	if (!e)
  ------------------
  |  Branch (264:6): [True: 6.01k, False: 0]
  ------------------
  265|  6.01k|	{
  266|  6.01k|#if defined(OPENSSL_NO_STATIC_ENGINE) || defined(OPENSSL_NO_GOST) || defined(LIBRESSL_VERSION_NUMBER)
  267|       |		/* try to load dynamic gost engine */
  268|  6.01k|		e = ENGINE_by_id("dynamic");
  269|  6.01k|		if (!e) {
  ------------------
  |  Branch (269:7): [True: 1, False: 6.01k]
  ------------------
  270|      1|			ENGINE_load_dynamic();
  271|      1|			e = ENGINE_by_id("dynamic");
  272|      1|		}
  273|  6.01k|		if (e && (!ENGINE_ctrl_cmd_string(e, "SO_PATH", "gost", 0) ||
  ------------------
  |  Branch (273:7): [True: 6.01k, False: 0]
  |  Branch (273:13): [True: 0, False: 6.01k]
  ------------------
  274|  6.01k|					!ENGINE_ctrl_cmd_string(e, "LOAD", NULL, 0))) {
  ------------------
  |  Branch (274:6): [True: 6.01k, False: 0]
  ------------------
  275|  6.01k|			ENGINE_free(e);
  276|  6.01k|			e = NULL;
  277|  6.01k|		}
  278|  6.01k|#endif /* OPENSSL_NO_STATIC_ENGINE || OPENSSL_NO_GOST || LIBRESSL_VERSION_NUMBER */
  279|  6.01k|	}
  280|  6.01k|	if (e) {
  ------------------
  |  Branch (280:6): [True: 0, False: 6.01k]
  ------------------
  281|      0|		ENGINE_set_default(e, ENGINE_METHOD_ALL);
  282|      0|		ENGINE_free(e);
  283|      0|	}
  284|       |
  285|  6.01k|#endif /* !defined(OPENSSL_NO_ENGINE) */
  286|       |
  287|  6.01k|	openssl_sha1_mech.mech_data = sc_evp_md(context, "sha1");
  288|  6.01k|	openssl_sha1_mech.free_mech_data = ossl_md_free;
  289|  6.01k|	openssl_sha1_mech.copy_mech_data = ossl_md_copy;
  290|  6.01k|	mt = dup_mem(&openssl_sha1_mech, sizeof openssl_sha1_mech);
  291|  6.01k|	sc_pkcs11_register_mechanism(p11card, mt, NULL);
  292|  6.01k|	sc_pkcs11_free_mechanism(&mt);
  293|       |
  294|  6.01k|	openssl_sha224_mech.mech_data = sc_evp_md(context, "sha224");
  295|  6.01k|	openssl_sha224_mech.free_mech_data = ossl_md_free;
  296|  6.01k|	openssl_sha224_mech.copy_mech_data = ossl_md_copy;
  297|  6.01k|	mt = dup_mem(&openssl_sha224_mech, sizeof openssl_sha224_mech);
  298|  6.01k|	sc_pkcs11_register_mechanism(p11card, mt, NULL);
  299|  6.01k|	sc_pkcs11_free_mechanism(&mt);
  300|       |
  301|  6.01k|	openssl_sha256_mech.mech_data = sc_evp_md(context, "sha256");
  302|  6.01k|	openssl_sha256_mech.free_mech_data = ossl_md_free;
  303|  6.01k|	openssl_sha256_mech.copy_mech_data = ossl_md_copy;
  304|  6.01k|	mt = dup_mem(&openssl_sha256_mech, sizeof openssl_sha256_mech);
  305|  6.01k|	sc_pkcs11_register_mechanism(p11card, mt, NULL);
  306|  6.01k|	sc_pkcs11_free_mechanism(&mt);
  307|       |
  308|  6.01k|	openssl_sha384_mech.mech_data = sc_evp_md(context, "sha384");
  309|  6.01k|	openssl_sha384_mech.free_mech_data = ossl_md_free;
  310|  6.01k|	openssl_sha384_mech.copy_mech_data = ossl_md_copy;
  311|  6.01k|	mt = dup_mem(&openssl_sha384_mech, sizeof openssl_sha384_mech);
  312|  6.01k|	sc_pkcs11_register_mechanism(p11card, mt, NULL);
  313|  6.01k|	sc_pkcs11_free_mechanism(&mt);
  314|       |
  315|  6.01k|	openssl_sha512_mech.mech_data = sc_evp_md(context, "sha512");
  316|  6.01k|	openssl_sha512_mech.free_mech_data = ossl_md_free;
  317|  6.01k|	openssl_sha512_mech.copy_mech_data = ossl_md_copy;
  318|  6.01k|	mt = dup_mem(&openssl_sha512_mech, sizeof openssl_sha512_mech);
  319|  6.01k|	sc_pkcs11_register_mechanism(p11card, mt, NULL);
  320|  6.01k|	sc_pkcs11_free_mechanism(&mt);
  321|       |
  322|  6.01k|	if (!FIPS_mode()) {
  ------------------
  |  Branch (322:6): [True: 6.01k, False: 0]
  ------------------
  323|  6.01k|		openssl_md5_mech.mech_data = sc_evp_md(context, "md5");
  324|  6.01k|		openssl_md5_mech.free_mech_data = ossl_md_free;
  325|  6.01k|		openssl_md5_mech.copy_mech_data = ossl_md_copy;
  326|  6.01k|		mt = dup_mem(&openssl_md5_mech, sizeof openssl_md5_mech);
  327|  6.01k|		sc_pkcs11_register_mechanism(p11card, mt, NULL);
  328|  6.01k|		sc_pkcs11_free_mechanism(&mt);
  329|       |
  330|  6.01k|		openssl_ripemd160_mech.mech_data = sc_evp_md(context, "ripemd160");
  331|  6.01k|		openssl_ripemd160_mech.free_mech_data = ossl_md_free;
  332|  6.01k|		openssl_ripemd160_mech.copy_mech_data = ossl_md_copy;
  333|  6.01k|		mt = dup_mem(&openssl_ripemd160_mech, sizeof openssl_ripemd160_mech);
  334|  6.01k|		sc_pkcs11_register_mechanism(p11card, mt, NULL);
  335|  6.01k|		sc_pkcs11_free_mechanism(&mt);
  336|       |
  337|  6.01k|	}
  338|  6.01k|	openssl_gostr3411_mech.mech_data = EVP_get_digestbynid(NID_id_GostR3411_94);
  339|  6.01k|	mt = dup_mem(&openssl_gostr3411_mech, sizeof openssl_gostr3411_mech);
  340|  6.01k|	sc_pkcs11_register_mechanism(p11card, mt, NULL);
  341|  6.01k|	sc_pkcs11_free_mechanism(&mt);
  342|       |
  343|  6.01k|}
sc_pkcs11_verify_data:
  595|     44|{
  596|     44|	int res;
  597|     44|	CK_RV rv = CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|     44|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  598|     44|	EVP_PKEY *pkey = NULL;
  599|     44|	const unsigned char *pubkey_tmp = NULL;
  600|     44|	EVP_MD_CTX *md_ctx = NULL;
  601|     44|	int sLen;
  602|       |
  603|     44|	if (mech->mechanism == CKM_GOSTR3410)
  ------------------
  |  |  909|     44|#define CKM_GOSTR3410 0x00001201UL
  ------------------
  |  Branch (603:6): [True: 0, False: 44]
  ------------------
  604|      0|	{
  605|      0|#if !defined(OPENSSL_NO_EC)
  606|      0|		return gostr3410_verify_data(pubkey, pubkey_len,
  607|      0|				pubkey_params, pubkey_params_len,
  608|      0|				data, data_len, signat, signat_len);
  609|       |#else
  610|       |		(void)pubkey_params, (void)pubkey_params_len; /* no warning */
  611|       |		return CKR_FUNCTION_NOT_SUPPORTED;
  612|       |#endif
  613|      0|	}
  614|       |
  615|       |	/*
  616|       |	 * PKCS#11 does not define CKA_VALUE for public keys, and different cards
  617|       |	 * return either the raw or spki versions as defined in PKCS#15
  618|       |	 * And we need to support more then just RSA.
  619|       |	 * We can use d2i_PUBKEY which works for SPKI and any key type.
  620|       |	 */
  621|     44|	pubkey_tmp = pubkey; /* pass in so pubkey pointer is not modified */
  622|       |
  623|     44|	pkey = d2i_PUBKEY(NULL, &pubkey_tmp, pubkey_len);
  624|     44|	if (pkey == NULL) {
  ------------------
  |  Branch (624:6): [True: 3, False: 41]
  ------------------
  625|      3|		sc_log_openssl(context);
  ------------------
  |  |   72|      3|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  626|      3|		return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      3|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  627|      3|	}
  628|       |
  629|     41|	if (md != NULL && (mech->mechanism == CKM_SHA1_RSA_PKCS
  ------------------
  |  |  544|     58|#define CKM_SHA1_RSA_PKCS 0x00000006UL
  ------------------
  |  Branch (629:6): [True: 29, False: 12]
  |  Branch (629:21): [True: 1, False: 28]
  ------------------
  630|     28|		|| mech->mechanism == CKM_MD5_RSA_PKCS
  ------------------
  |  |  543|     57|#define CKM_MD5_RSA_PKCS 0x00000005UL
  ------------------
  |  Branch (630:6): [True: 1, False: 27]
  ------------------
  631|     27|		|| mech->mechanism == CKM_RIPEMD160_RSA_PKCS
  ------------------
  |  |  546|     56|#define CKM_RIPEMD160_RSA_PKCS 0x00000008UL
  ------------------
  |  Branch (631:6): [True: 2, False: 25]
  ------------------
  632|     25|		|| mech->mechanism == CKM_SHA224_RSA_PKCS
  ------------------
  |  |  604|     54|#define CKM_SHA224_RSA_PKCS 0x00000046UL
  ------------------
  |  Branch (632:6): [True: 1, False: 24]
  ------------------
  633|     24|		|| mech->mechanism == CKM_SHA256_RSA_PKCS
  ------------------
  |  |  598|     53|#define CKM_SHA256_RSA_PKCS 0x00000040UL
  ------------------
  |  Branch (633:6): [True: 1, False: 23]
  ------------------
  634|     23|		|| mech->mechanism == CKM_SHA384_RSA_PKCS
  ------------------
  |  |  599|     52|#define CKM_SHA384_RSA_PKCS 0x00000041UL
  ------------------
  |  Branch (634:6): [True: 1, False: 22]
  ------------------
  635|     22|		|| mech->mechanism == CKM_SHA512_RSA_PKCS
  ------------------
  |  |  600|     51|#define CKM_SHA512_RSA_PKCS 0x00000042UL
  ------------------
  |  Branch (635:6): [True: 1, False: 21]
  ------------------
  636|     21|		|| mech->mechanism == CKM_ECDSA_SHA1
  ------------------
  |  |  861|     50|#define CKM_ECDSA_SHA1 0x00001042UL
  ------------------
  |  Branch (636:6): [True: 2, False: 19]
  ------------------
  637|     19|		|| mech->mechanism == CKM_ECDSA_SHA224
  ------------------
  |  |  862|     48|#define CKM_ECDSA_SHA224 0x00001043UL
  ------------------
  |  Branch (637:6): [True: 3, False: 16]
  ------------------
  638|     16|		|| mech->mechanism == CKM_ECDSA_SHA256
  ------------------
  |  |  863|     45|#define CKM_ECDSA_SHA256 0x00001044UL
  ------------------
  |  Branch (638:6): [True: 1, False: 15]
  ------------------
  639|     15|		|| mech->mechanism == CKM_ECDSA_SHA384
  ------------------
  |  |  864|     44|#define CKM_ECDSA_SHA384 0x00001045UL
  ------------------
  |  Branch (639:6): [True: 8, False: 7]
  ------------------
  640|      7|		|| mech->mechanism == CKM_ECDSA_SHA512
  ------------------
  |  |  865|      7|#define CKM_ECDSA_SHA512 0x00001046UL
  ------------------
  |  Branch (640:6): [True: 1, False: 6]
  ------------------
  641|     29|		)) {
  642|     23|		md_ctx = DIGEST_CTX(md);
  ------------------
  |  |  350|     23|	(op ? (EVP_MD_CTX *) (op)->priv_data : NULL)
  |  |  ------------------
  |  |  |  Branch (350:3): [True: 23, False: 0]
  |  |  ------------------
  ------------------
  643|       |
  644|       |		/* This does not really use the data argument, but the data
  645|       |		 * are already collected in the md_ctx
  646|       |		 */
  647|     23|		sc_log(context, "Trying to verify using EVP");
  ------------------
  |  |   71|     23|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  648|     23|		if (md_ctx) {
  ------------------
  |  Branch (648:7): [True: 23, False: 0]
  ------------------
  649|       |
  650|     23|			if (EVP_PKEY_base_id(pkey) == EVP_PKEY_EC) {
  ------------------
  |  Branch (650:8): [True: 15, False: 8]
  ------------------
  651|     15|				unsigned char *signat_tmp = NULL;
  652|     15|				size_t signat_len_tmp;
  653|     15|				int r;
  654|     15|				r = sc_asn1_sig_value_rs_to_sequence(NULL, signat,
  655|     15|						signat_len, &signat_tmp, &signat_len_tmp);
  656|     15|				if (r == 0 && signat_len_tmp < UINT_MAX) {
  ------------------
  |  Branch (656:9): [True: 14, False: 1]
  |  Branch (656:19): [True: 14, False: 0]
  ------------------
  657|     14|					res = EVP_VerifyFinal(md_ctx, signat_tmp, (unsigned int) signat_len_tmp, pkey);
  658|     14|				} else {
  659|      1|					sc_log(context, "sc_asn1_sig_value_rs_to_sequence failed r:%d "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  660|      1|							"or output too long signat_len_tmp:%zu",
  661|      1|							r, signat_len_tmp);
  662|      1|					res = -1;
  663|      1|				}
  664|     15|				free(signat_tmp);
  665|     15|			} else
  666|      8|				res = EVP_VerifyFinal(md_ctx, signat, (unsigned int) signat_len, pkey);
  667|     23|		} else {
  668|      0|			res = -1;
  669|      0|		}
  670|     23|		EVP_PKEY_free(pkey);
  671|     23|		if (res == 1)
  ------------------
  |  Branch (671:7): [True: 0, False: 23]
  ------------------
  672|      0|			return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  673|     23|		else if (res == 0) {
  ------------------
  |  Branch (673:12): [True: 22, False: 1]
  ------------------
  674|     22|			sc_log_openssl(context);
  ------------------
  |  |   72|     22|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  675|     22|			sc_log(context, "EVP_VerifyFinal(): Signature invalid");
  ------------------
  |  |   71|     22|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  676|     22|			return CKR_SIGNATURE_INVALID;
  ------------------
  |  | 1140|     22|#define CKR_SIGNATURE_INVALID 0x000000C0UL
  ------------------
  677|     22|		} else {
  678|      1|			sc_log_openssl(context);
  ------------------
  |  |   72|      1|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  679|      1|			sc_log(context, "EVP_VerifyFinal() returned %d\n", res);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  680|      1|			return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      1|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  681|      1|		}
  682|     23|	} else	/* If plain CKM_ECDSA (without any hashing) is used or card supports
  683|       |		 * on-card CKM_ECDSA_SHAx only we land here. Since for CKM_ECDSA_SHAx no
  684|       |		 * hashing happened in C_VerifyUpdate() we do it here instead.
  685|       |		 */
  686|     18|		if (md == NULL && (mech->mechanism == CKM_ECDSA
  ------------------
  |  |  860|     24|#define CKM_ECDSA 0x00001041UL
  ------------------
  |  Branch (686:7): [True: 12, False: 6]
  |  Branch (686:22): [True: 6, False: 6]
  ------------------
  687|      6|		    || mech->mechanism == CKM_ECDSA_SHA1
  ------------------
  |  |  861|     18|#define CKM_ECDSA_SHA1 0x00001042UL
  ------------------
  |  Branch (687:10): [True: 0, False: 6]
  ------------------
  688|      6|		    || mech->mechanism == CKM_ECDSA_SHA224
  ------------------
  |  |  862|     18|#define CKM_ECDSA_SHA224 0x00001043UL
  ------------------
  |  Branch (688:10): [True: 0, False: 6]
  ------------------
  689|      6|		    || mech->mechanism == CKM_ECDSA_SHA256
  ------------------
  |  |  863|     18|#define CKM_ECDSA_SHA256 0x00001044UL
  ------------------
  |  Branch (689:10): [True: 0, False: 6]
  ------------------
  690|      6|		    || mech->mechanism == CKM_ECDSA_SHA384
  ------------------
  |  |  864|     18|#define CKM_ECDSA_SHA384 0x00001045UL
  ------------------
  |  Branch (690:10): [True: 0, False: 6]
  ------------------
  691|      6|		    || mech->mechanism == CKM_ECDSA_SHA512)) {
  ------------------
  |  |  865|      6|#define CKM_ECDSA_SHA512 0x00001046UL
  ------------------
  |  Branch (691:10): [True: 0, False: 6]
  ------------------
  692|      6|		size_t signat_len_tmp;
  693|      6|		unsigned char *signat_tmp = NULL;
  694|      6|		unsigned int mdbuf_len;
  695|      6|		unsigned char *mdbuf = NULL;
  696|      6|		EVP_PKEY_CTX *ctx;
  697|      6|		int r;
  698|       |
  699|      6|		sc_log(context, "Trying to verify using EVP");
  ------------------
  |  |   71|      6|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  700|       |
  701|       |		/* If needed, hash input first
  702|       |		 */
  703|      6|		if (mech->mechanism == CKM_ECDSA_SHA1
  ------------------
  |  |  861|     12|#define CKM_ECDSA_SHA1 0x00001042UL
  ------------------
  |  Branch (703:7): [True: 0, False: 6]
  ------------------
  704|      6|		    || mech->mechanism == CKM_ECDSA_SHA224
  ------------------
  |  |  862|     12|#define CKM_ECDSA_SHA224 0x00001043UL
  ------------------
  |  Branch (704:10): [True: 0, False: 6]
  ------------------
  705|      6|		    || mech->mechanism == CKM_ECDSA_SHA256
  ------------------
  |  |  863|     12|#define CKM_ECDSA_SHA256 0x00001044UL
  ------------------
  |  Branch (705:10): [True: 0, False: 6]
  ------------------
  706|      6|		    || mech->mechanism == CKM_ECDSA_SHA384
  ------------------
  |  |  864|     12|#define CKM_ECDSA_SHA384 0x00001045UL
  ------------------
  |  Branch (706:10): [True: 0, False: 6]
  ------------------
  707|      6|		    || mech->mechanism == CKM_ECDSA_SHA512) {
  ------------------
  |  |  865|      6|#define CKM_ECDSA_SHA512 0x00001046UL
  ------------------
  |  Branch (707:10): [True: 0, False: 6]
  ------------------
  708|      0|			EVP_MD_CTX *mdctx;
  709|      0|			EVP_MD *md = NULL;
  710|      0|			switch (mech->mechanism) {
  711|      0|				case CKM_ECDSA_SHA1:
  ------------------
  |  |  861|      0|#define CKM_ECDSA_SHA1 0x00001042UL
  ------------------
  |  Branch (711:5): [True: 0, False: 0]
  ------------------
  712|      0|					md = sc_evp_md(context, "sha1");
  713|      0|					break;
  714|      0|				case CKM_ECDSA_SHA224:
  ------------------
  |  |  862|      0|#define CKM_ECDSA_SHA224 0x00001043UL
  ------------------
  |  Branch (714:5): [True: 0, False: 0]
  ------------------
  715|      0|					md = sc_evp_md(context, "sha224");
  716|      0|					break;
  717|      0|				case CKM_ECDSA_SHA256:
  ------------------
  |  |  863|      0|#define CKM_ECDSA_SHA256 0x00001044UL
  ------------------
  |  Branch (717:5): [True: 0, False: 0]
  ------------------
  718|      0|					md = sc_evp_md(context, "sha256");
  719|      0|					break;
  720|      0|				case CKM_ECDSA_SHA384:
  ------------------
  |  |  864|      0|#define CKM_ECDSA_SHA384 0x00001045UL
  ------------------
  |  Branch (720:5): [True: 0, False: 0]
  ------------------
  721|      0|					md = sc_evp_md(context, "sha384");
  722|      0|					break;
  723|      0|				case CKM_ECDSA_SHA512:
  ------------------
  |  |  865|      0|#define CKM_ECDSA_SHA512 0x00001046UL
  ------------------
  |  Branch (723:5): [True: 0, False: 0]
  ------------------
  724|      0|					md = sc_evp_md(context, "sha512");
  725|      0|					break;
  726|      0|				default:
  ------------------
  |  Branch (726:5): [True: 0, False: 0]
  ------------------
  727|      0|					EVP_PKEY_free(pkey);
  728|      0|					return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  729|      0|			}
  730|      0|			mdbuf_len = EVP_MD_size(md);
  731|      0|			mdbuf = calloc(1, mdbuf_len);
  732|      0|			if (mdbuf == NULL) {
  ------------------
  |  Branch (732:8): [True: 0, False: 0]
  ------------------
  733|      0|				EVP_PKEY_free(pkey);
  734|      0|				sc_evp_md_free(md);
  735|      0|				return CKR_DEVICE_MEMORY;
  ------------------
  |  | 1104|      0|#define CKR_DEVICE_MEMORY 0x00000031UL
  ------------------
  736|      0|			}
  737|      0|			if ((mdctx = EVP_MD_CTX_new()) == NULL) {
  ------------------
  |  Branch (737:8): [True: 0, False: 0]
  ------------------
  738|      0|				sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  739|      0|				free(mdbuf);
  740|      0|				EVP_PKEY_free(pkey);
  741|      0|				sc_evp_md_free(md);
  742|      0|				return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  743|      0|			}
  744|      0|			if (!EVP_DigestInit(mdctx, md)
  ------------------
  |  Branch (744:8): [True: 0, False: 0]
  ------------------
  745|      0|				|| !EVP_DigestUpdate(mdctx, data, data_len)
  ------------------
  |  Branch (745:8): [True: 0, False: 0]
  ------------------
  746|      0|				|| !EVP_DigestFinal(mdctx, mdbuf, &mdbuf_len)) {
  ------------------
  |  Branch (746:8): [True: 0, False: 0]
  ------------------
  747|      0|				sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  748|      0|				EVP_PKEY_free(pkey);
  749|      0|				EVP_MD_CTX_free(mdctx);
  750|      0|				sc_evp_md_free(md);
  751|      0|				free(mdbuf);
  752|      0|				return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  753|      0|			}
  754|      0|			EVP_MD_CTX_free(mdctx);
  755|      0|			sc_evp_md_free(md);
  756|      0|			data = mdbuf;
  757|      0|			data_len = mdbuf_len;
  758|      0|		}
  759|       |
  760|      6|		res = 0;
  761|      6|		switch (EVP_PKEY_base_id(pkey)) {
  762|      6|		case EVP_PKEY_EC:
  ------------------
  |  Branch (762:3): [True: 6, False: 0]
  ------------------
  763|      6|			ctx = sc_evp_pkey_ctx_new(context, pkey);
  764|      6|			r = sc_asn1_sig_value_rs_to_sequence(NULL, signat, signat_len,
  765|      6|					&signat_tmp, &signat_len_tmp);
  766|      6|			if (r == 0 && ctx && EVP_PKEY_verify_init(ctx) == 1) {
  ------------------
  |  Branch (766:8): [True: 5, False: 1]
  |  Branch (766:18): [True: 5, False: 0]
  |  Branch (766:25): [True: 5, False: 0]
  ------------------
  767|      5|				res = EVP_PKEY_verify(ctx, signat_tmp, signat_len_tmp, data, data_len);
  768|      5|			}
  769|      6|			free(signat_tmp);
  770|      6|			EVP_PKEY_CTX_free(ctx);
  771|      6|			break;
  772|      0|#ifdef EVP_PKEY_ED25519
  773|      0|		case EVP_PKEY_ED25519:
  ------------------
  |  Branch (773:3): [True: 0, False: 6]
  ------------------
  774|      0|#endif
  775|      0|#ifdef EVP_PKEY_ED448
  776|      0|		case EVP_PKEY_ED448:
  ------------------
  |  Branch (776:3): [True: 0, False: 6]
  ------------------
  777|      0|#endif
  778|      0|#if defined(EVP_PKEY_ED25519) || defined(EVP_PKEY_ED448)
  779|      0|			md_ctx = EVP_MD_CTX_create();
  780|      0|			if (md_ctx == NULL) {
  ------------------
  |  Branch (780:8): [True: 0, False: 0]
  ------------------
  781|      0|				EVP_PKEY_free(pkey);
  782|      0|				free(mdbuf);
  783|      0|				return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  784|      0|			}
  785|       |
  786|      0|			rv = EVP_DigestVerifyInit(md_ctx, NULL, NULL, NULL, pkey);
  787|      0|			if (rv == 1) {
  ------------------
  |  Branch (787:8): [True: 0, False: 0]
  ------------------
  788|      0|				res = EVP_DigestVerify(md_ctx, signat, signat_len, data, data_len);
  789|      0|			}
  790|      0|			EVP_MD_CTX_free(md_ctx);
  791|      0|			break;
  792|      0|#endif /* defined(EVP_PKEY_ED25519) || defined(EVP_PKEY_ED448) */
  793|      0|		default:
  ------------------
  |  Branch (793:3): [True: 0, False: 6]
  ------------------
  794|      0|			sc_log(context, "Unknown base type %u.", EVP_PKEY_base_id(pkey));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  795|      6|		}
  796|       |
  797|      6|		free(mdbuf);
  798|      6|		EVP_PKEY_free(pkey);
  799|       |
  800|      6|		if (res == 1) {
  ------------------
  |  Branch (800:7): [True: 0, False: 6]
  ------------------
  801|      0|			return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  802|      6|		} else if (res == 0) {
  ------------------
  |  Branch (802:14): [True: 2, False: 4]
  ------------------
  803|      2|			sc_log_openssl(context);
  ------------------
  |  |   72|      2|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  804|      2|			return CKR_SIGNATURE_INVALID;
  ------------------
  |  | 1140|      2|#define CKR_SIGNATURE_INVALID 0x000000C0UL
  ------------------
  805|      4|		} else {
  806|      4|			sc_log_openssl(context);
  ------------------
  |  |   72|      4|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  807|      4|			return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      4|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  808|      4|		}
  809|     12|	} else {
  810|     12|		unsigned char *rsa_out = NULL, pad;
  811|     12|		size_t rsa_outlen = 0;
  812|     12|		EVP_PKEY_CTX *ctx = sc_evp_pkey_ctx_new(context, pkey);
  813|     12|		if (!ctx) {
  ------------------
  |  Branch (813:7): [True: 0, False: 12]
  ------------------
  814|      0|			sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  815|      0|			EVP_PKEY_free(pkey);
  816|      0|			return CKR_DEVICE_MEMORY;
  ------------------
  |  | 1104|      0|#define CKR_DEVICE_MEMORY 0x00000031UL
  ------------------
  817|      0|		}
  818|       |
  819|     12|		sc_log(context, "Trying to verify using low-level API");
  ------------------
  |  |   71|     12|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  820|     12|		switch (mech->mechanism) {
  821|      1|		case CKM_RSA_PKCS:
  ------------------
  |  |  539|      1|#define CKM_RSA_PKCS 0x00000001UL
  ------------------
  |  Branch (821:3): [True: 1, False: 11]
  ------------------
  822|      1|		case CKM_MD5_RSA_PKCS:
  ------------------
  |  |  543|      1|#define CKM_MD5_RSA_PKCS 0x00000005UL
  ------------------
  |  Branch (822:3): [True: 0, False: 12]
  ------------------
  823|      1|		case CKM_RIPEMD160_RSA_PKCS:
  ------------------
  |  |  546|      1|#define CKM_RIPEMD160_RSA_PKCS 0x00000008UL
  ------------------
  |  Branch (823:3): [True: 0, False: 12]
  ------------------
  824|      1|		 	pad = RSA_PKCS1_PADDING;
  825|      1|		 	break;
  826|      4|		case CKM_RSA_X_509:
  ------------------
  |  |  541|      4|#define CKM_RSA_X_509 0x00000003UL
  ------------------
  |  Branch (826:3): [True: 4, False: 8]
  ------------------
  827|      4|			pad = RSA_NO_PADDING;
  828|      4|			break;
  829|      1|		case CKM_RSA_PKCS_PSS:
  ------------------
  |  |  551|      1|#define CKM_RSA_PKCS_PSS 0x0000000DUL
  ------------------
  |  Branch (829:3): [True: 1, False: 11]
  ------------------
  830|      3|		case CKM_SHA1_RSA_PKCS_PSS:
  ------------------
  |  |  552|      3|#define CKM_SHA1_RSA_PKCS_PSS 0x0000000EUL
  ------------------
  |  Branch (830:3): [True: 2, False: 10]
  ------------------
  831|      4|		case CKM_SHA224_RSA_PKCS_PSS:
  ------------------
  |  |  605|      4|#define CKM_SHA224_RSA_PKCS_PSS 0x00000047UL
  ------------------
  |  Branch (831:3): [True: 1, False: 11]
  ------------------
  832|      5|		case CKM_SHA256_RSA_PKCS_PSS:
  ------------------
  |  |  601|      5|#define CKM_SHA256_RSA_PKCS_PSS 0x00000043UL
  ------------------
  |  Branch (832:3): [True: 1, False: 11]
  ------------------
  833|      6|		case CKM_SHA384_RSA_PKCS_PSS:
  ------------------
  |  |  602|      6|#define CKM_SHA384_RSA_PKCS_PSS 0x00000044UL
  ------------------
  |  Branch (833:3): [True: 1, False: 11]
  ------------------
  834|      7|		case CKM_SHA512_RSA_PKCS_PSS:
  ------------------
  |  |  603|      7|#define CKM_SHA512_RSA_PKCS_PSS 0x00000045UL
  ------------------
  |  Branch (834:3): [True: 1, False: 11]
  ------------------
  835|      7|			pad = RSA_NO_PADDING;
  836|      7|			break;
  837|      0|		default:
  ------------------
  |  Branch (837:3): [True: 0, False: 12]
  ------------------
  838|      0|			EVP_PKEY_free(pkey);
  839|      0|			EVP_PKEY_CTX_free(ctx);
  840|      0|			return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  841|     12|		}
  842|       |
  843|     12|		if (EVP_PKEY_verify_recover_init(ctx) != 1 ||
  ------------------
  |  Branch (843:7): [True: 0, False: 12]
  ------------------
  844|     12|			EVP_PKEY_CTX_set_rsa_padding(ctx, pad) != 1) {
  ------------------
  |  Branch (844:4): [True: 0, False: 12]
  ------------------
  845|      0|			sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  846|      0|			EVP_PKEY_CTX_free(ctx);
  847|      0|			EVP_PKEY_free(pkey);
  848|      0|			return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  849|      0|		}
  850|       |
  851|     12|		rsa_outlen = EVP_PKEY_size(pkey);
  852|     12|		rsa_out = calloc(1, rsa_outlen);
  853|     12|		if (rsa_out == NULL) {
  ------------------
  |  Branch (853:7): [True: 0, False: 12]
  ------------------
  854|      0|			EVP_PKEY_free(pkey);
  855|      0|			EVP_PKEY_CTX_free(ctx);
  856|      0|			return CKR_DEVICE_MEMORY;
  ------------------
  |  | 1104|      0|#define CKR_DEVICE_MEMORY 0x00000031UL
  ------------------
  857|      0|		}
  858|     12|		if (EVP_PKEY_verify_recover(ctx, rsa_out, &rsa_outlen, signat, signat_len) != 1) {
  ------------------
  |  Branch (858:7): [True: 2, False: 10]
  ------------------
  859|      2|			sc_log_openssl(context);
  ------------------
  |  |   72|      2|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  860|      2|			free(rsa_out);
  861|      2|			EVP_PKEY_free(pkey);
  862|      2|			EVP_PKEY_CTX_free(ctx);
  863|      2|			sc_log(context, "RSA_public_decrypt() returned %d\n", (int) rsa_outlen);
  ------------------
  |  |   71|      2|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  864|      2|			return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      2|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  865|      2|		}
  866|     10|		EVP_PKEY_CTX_free(ctx);
  867|       |		/* For PSS mechanisms we can not simply compare the "decrypted"
  868|       |		 * data -- we need to verify the PSS padding is valid
  869|       |		 */
  870|     10|		if (mech->mechanism == CKM_RSA_PKCS_PSS ||
  ------------------
  |  |  551|     20|#define CKM_RSA_PKCS_PSS 0x0000000DUL
  ------------------
  |  Branch (870:7): [True: 1, False: 9]
  ------------------
  871|      9|		    mech->mechanism == CKM_SHA1_RSA_PKCS_PSS ||
  ------------------
  |  |  552|     19|#define CKM_SHA1_RSA_PKCS_PSS 0x0000000EUL
  ------------------
  |  Branch (871:7): [True: 1, False: 8]
  ------------------
  872|      8|		    mech->mechanism == CKM_SHA224_RSA_PKCS_PSS ||
  ------------------
  |  |  605|     18|#define CKM_SHA224_RSA_PKCS_PSS 0x00000047UL
  ------------------
  |  Branch (872:7): [True: 1, False: 7]
  ------------------
  873|      7|		    mech->mechanism == CKM_SHA256_RSA_PKCS_PSS ||
  ------------------
  |  |  601|     17|#define CKM_SHA256_RSA_PKCS_PSS 0x00000043UL
  ------------------
  |  Branch (873:7): [True: 1, False: 6]
  ------------------
  874|      6|		    mech->mechanism == CKM_SHA384_RSA_PKCS_PSS ||
  ------------------
  |  |  602|     16|#define CKM_SHA384_RSA_PKCS_PSS 0x00000044UL
  ------------------
  |  Branch (874:7): [True: 1, False: 5]
  ------------------
  875|      6|		    mech->mechanism == CKM_SHA512_RSA_PKCS_PSS) {
  ------------------
  |  |  603|      5|#define CKM_SHA512_RSA_PKCS_PSS 0x00000045UL
  ------------------
  |  Branch (875:7): [True: 1, False: 4]
  ------------------
  876|      6|			CK_RSA_PKCS_PSS_PARAMS* param = NULL;
  877|      6|			EVP_MD *mgf_md = NULL, *pss_md = NULL;
  878|      6|			unsigned char digest[EVP_MAX_MD_SIZE];
  879|       |
  880|      6|			if (mech->pParameter == NULL) {
  ------------------
  |  Branch (880:8): [True: 6, False: 0]
  ------------------
  881|      6|				free(rsa_out);
  882|      6|				EVP_PKEY_free(pkey);
  883|      6|				sc_log(context, "PSS mechanism requires parameter");
  ------------------
  |  |   71|      6|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  884|      6|				return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      6|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
  885|      6|			}
  886|       |
  887|      0|			param = (CK_RSA_PKCS_PSS_PARAMS*)mech->pParameter;
  888|      0|			switch (param->mgf) {
  889|      0|			case CKG_MGF1_SHA1:
  ------------------
  |  |  442|      0|#define CKG_MGF1_SHA1 0x00000001UL
  ------------------
  |  Branch (889:4): [True: 0, False: 0]
  ------------------
  890|      0|				mgf_md = sc_evp_md(context, "sha1");
  891|      0|				break;
  892|      0|			case CKG_MGF1_SHA224:
  ------------------
  |  |  446|      0|#define CKG_MGF1_SHA224 0x00000005UL
  ------------------
  |  Branch (892:4): [True: 0, False: 0]
  ------------------
  893|      0|				mgf_md = sc_evp_md(context, "sha224");
  894|      0|				break;
  895|      0|			case CKG_MGF1_SHA256:
  ------------------
  |  |  443|      0|#define CKG_MGF1_SHA256 0x00000002UL
  ------------------
  |  Branch (895:4): [True: 0, False: 0]
  ------------------
  896|      0|				mgf_md = sc_evp_md(context, "sha256");
  897|      0|				break;
  898|      0|			case CKG_MGF1_SHA384:
  ------------------
  |  |  444|      0|#define CKG_MGF1_SHA384 0x00000003UL
  ------------------
  |  Branch (898:4): [True: 0, False: 0]
  ------------------
  899|      0|				mgf_md = sc_evp_md(context, "sha384");
  900|      0|				break;
  901|      0|			case CKG_MGF1_SHA512:
  ------------------
  |  |  445|      0|#define CKG_MGF1_SHA512 0x00000004UL
  ------------------
  |  Branch (901:4): [True: 0, False: 0]
  ------------------
  902|      0|				mgf_md = sc_evp_md(context, "sha512");
  903|      0|				break;
  904|      0|			default:
  ------------------
  |  Branch (904:4): [True: 0, False: 0]
  ------------------
  905|      0|				free(rsa_out);
  906|      0|				EVP_PKEY_free(pkey);
  907|      0|				return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      0|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
  908|      0|			}
  909|       |
  910|      0|			switch (param->hashAlg) {
  911|      0|			case CKM_SHA_1:
  ------------------
  |  |  667|      0|#define CKM_SHA_1 0x00000220UL
  ------------------
  |  Branch (911:4): [True: 0, False: 0]
  ------------------
  912|      0|				pss_md = sc_evp_md(context, "sha1");
  913|      0|				break;
  914|      0|			case CKM_SHA224:
  ------------------
  |  |  679|      0|#define CKM_SHA224 0x00000255UL
  ------------------
  |  Branch (914:4): [True: 0, False: 0]
  ------------------
  915|      0|				pss_md = sc_evp_md(context, "sha224");
  916|      0|				break;
  917|      0|			case CKM_SHA256:
  ------------------
  |  |  676|      0|#define CKM_SHA256 0x00000250UL
  ------------------
  |  Branch (917:4): [True: 0, False: 0]
  ------------------
  918|      0|				pss_md = sc_evp_md(context, "sha256");
  919|      0|				break;
  920|      0|			case CKM_SHA384:
  ------------------
  |  |  682|      0|#define CKM_SHA384 0x00000260UL
  ------------------
  |  Branch (920:4): [True: 0, False: 0]
  ------------------
  921|      0|				pss_md = sc_evp_md(context, "sha384");
  922|      0|				break;
  923|      0|			case CKM_SHA512:
  ------------------
  |  |  685|      0|#define CKM_SHA512 0x00000270UL
  ------------------
  |  Branch (923:4): [True: 0, False: 0]
  ------------------
  924|      0|				pss_md = sc_evp_md(context, "sha512");
  925|      0|				break;
  926|      0|			default:
  ------------------
  |  Branch (926:4): [True: 0, False: 0]
  ------------------
  927|      0|				sc_evp_md_free(mgf_md);
  928|      0|				free(rsa_out);
  929|      0|				EVP_PKEY_free(pkey);
  930|      0|				return CKR_MECHANISM_PARAM_INVALID;
  ------------------
  |  | 1123|      0|#define CKR_MECHANISM_PARAM_INVALID 0x00000071UL
  ------------------
  931|      0|			}
  932|       |
  933|       |			/* for the mechanisms with hash algorithm, the data
  934|       |			 * is already added to the hash buffer, so we need
  935|       |			 * to finish the hash operation here
  936|       |			 */
  937|      0|			if (mech->mechanism != CKM_RSA_PKCS_PSS) {
  ------------------
  |  |  551|      0|#define CKM_RSA_PKCS_PSS 0x0000000DUL
  ------------------
  |  Branch (937:8): [True: 0, False: 0]
  ------------------
  938|      0|				EVP_MD_CTX *md_ctx = DIGEST_CTX(md);
  ------------------
  |  |  350|      0|	(op ? (EVP_MD_CTX *) (op)->priv_data : NULL)
  |  |  ------------------
  |  |  |  Branch (350:3): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  939|      0|				unsigned char *tmp = digest;
  940|      0|				unsigned int tmp_len;
  941|       |
  942|      0|				if (!md_ctx || !EVP_DigestFinal(md_ctx, tmp, &tmp_len)) {
  ------------------
  |  Branch (942:9): [True: 0, False: 0]
  |  Branch (942:20): [True: 0, False: 0]
  ------------------
  943|      0|					sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  944|      0|					sc_evp_md_free(mgf_md);
  945|      0|					sc_evp_md_free(pss_md);
  946|      0|					free(rsa_out);
  947|      0|					EVP_PKEY_free(pkey);
  948|      0|					return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  949|      0|				}
  950|      0|				data = tmp;
  951|      0|				data_len = tmp_len;
  952|      0|			}
  953|      0|			rv = CKR_SIGNATURE_INVALID;
  ------------------
  |  | 1140|      0|#define CKR_SIGNATURE_INVALID 0x000000C0UL
  ------------------
  954|       |
  955|       |			/* special mode - autodetect sLen from signature */
  956|       |			/* https://github.com/openssl/openssl/blob/master/crypto/rsa/rsa_pss.c */
  957|       |			/* there is no way to pass negative value here, we using maximal value for this */
  958|      0|			if (((CK_ULONG) 1 ) << (sizeof(CK_ULONG) * CHAR_BIT -1) == param->sLen || param->sLen > INT_MAX)
  ------------------
  |  Branch (958:8): [True: 0, False: 0]
  |  Branch (958:78): [True: 0, False: 0]
  ------------------
  959|      0|				sLen = RSA_PSS_SALTLEN_AUTO;
  960|      0|			else
  961|      0|				sLen = (int) param->sLen;
  962|       |
  963|      0|			if ((ctx = sc_evp_pkey_ctx_new(context, pkey)) == NULL ||
  ------------------
  |  Branch (963:8): [True: 0, False: 0]
  ------------------
  964|      0|				EVP_PKEY_verify_init(ctx) != 1 ||
  ------------------
  |  Branch (964:5): [True: 0, False: 0]
  ------------------
  965|      0|				EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PSS_PADDING) != 1 ||
  ------------------
  |  Branch (965:5): [True: 0, False: 0]
  ------------------
  966|      0|				EVP_PKEY_CTX_set_signature_md(ctx, pss_md) != 1 ||
  ------------------
  |  Branch (966:5): [True: 0, False: 0]
  ------------------
  967|      0|				EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, sLen) != 1 ||
  ------------------
  |  Branch (967:5): [True: 0, False: 0]
  ------------------
  968|      0|				EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, mgf_md) != 1) {
  ------------------
  |  Branch (968:5): [True: 0, False: 0]
  ------------------
  969|      0|				sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  970|      0|				sc_evp_md_free(mgf_md);
  971|      0|				sc_evp_md_free(pss_md);
  972|      0|				free(rsa_out);
  973|      0|				EVP_PKEY_free(pkey);
  974|      0|				EVP_PKEY_CTX_free(ctx);
  975|      0|				sc_log(context, "Failed to initialize EVP_PKEY_CTX");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  976|      0|				return rv;
  977|      0|			}
  978|       |
  979|      0|			if (data_len == (unsigned int)EVP_MD_size(pss_md) &&
  ------------------
  |  Branch (979:8): [True: 0, False: 0]
  ------------------
  980|      0|					EVP_PKEY_verify(ctx, signat, signat_len, data, data_len) == 1) {
  ------------------
  |  Branch (980:6): [True: 0, False: 0]
  ------------------
  981|      0|				rv = CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  982|      0|			} else {
  983|      0|				sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  984|      0|			}
  985|      0|			EVP_PKEY_free(pkey);
  986|      0|			EVP_PKEY_CTX_free(ctx);
  987|      0|			sc_evp_md_free(mgf_md);
  988|      0|			sc_evp_md_free(pss_md);
  989|      0|			free(rsa_out);
  990|      0|			sc_log(context, "Returning %lu", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  991|      0|			return rv;
  992|      4|		} else {
  993|      4|			EVP_PKEY_free(pkey);
  994|      4|		}
  995|       |
  996|      4|		if ((unsigned int) rsa_outlen == data_len && memcmp(rsa_out, data, data_len) == 0)
  ------------------
  |  Branch (996:7): [True: 3, False: 1]
  |  Branch (996:48): [True: 0, False: 3]
  ------------------
  997|      0|			rv = CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  998|      4|		else
  999|      4|			rv = CKR_SIGNATURE_INVALID;
  ------------------
  |  | 1140|      4|#define CKR_SIGNATURE_INVALID 0x000000C0UL
  ------------------
 1000|      4|		free(rsa_out);
 1001|      4|	}
 1002|       |
 1003|      4|	return rv;
 1004|     41|}
openssl.c:sc_pkcs11_openssl_md_release:
  412|    200|{
  413|    200|	if (op) {
  ------------------
  |  Branch (413:6): [True: 200, False: 0]
  ------------------
  414|    200|		EVP_MD_CTX	*md_ctx = DIGEST_CTX(op);
  ------------------
  |  |  350|    200|	(op ? (EVP_MD_CTX *) (op)->priv_data : NULL)
  |  |  ------------------
  |  |  |  Branch (350:3): [True: 200, False: 0]
  |  |  ------------------
  ------------------
  415|    200|		if (md_ctx)
  ------------------
  |  Branch (415:7): [True: 199, False: 1]
  ------------------
  416|    200|			EVP_MD_CTX_destroy(md_ctx);
  417|       |		op->priv_data = NULL;
  418|    200|	}
  419|    200|}
openssl.c:sc_pkcs11_openssl_md_init:
  353|    200|{
  354|    200|	sc_pkcs11_mechanism_type_t *mt;
  355|    200|	EVP_MD_CTX	*md_ctx;
  356|    200|	EVP_MD		*md;
  357|       |
  358|    200|	if (!op || !(mt = op->type) || !(md = (EVP_MD *) mt->mech_data))
  ------------------
  |  Branch (358:6): [True: 0, False: 200]
  |  Branch (358:13): [True: 0, False: 200]
  |  Branch (358:33): [True: 1, False: 199]
  ------------------
  359|      1|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      1|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  360|       |
  361|    199|	if (!(md_ctx = EVP_MD_CTX_create())) {
  ------------------
  |  Branch (361:6): [True: 0, False: 199]
  ------------------
  362|      0|		sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  363|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  364|      0|	}
  365|    199|	if (!EVP_DigestInit(md_ctx, md)) {
  ------------------
  |  Branch (365:6): [True: 0, False: 199]
  ------------------
  366|      0|		sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  367|      0|		EVP_MD_CTX_destroy(md_ctx);
  368|      0|		return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  369|      0|	}
  370|    199|	op->priv_data = md_ctx;
  371|    199|	return CKR_OK;
  ------------------
  |  | 1086|    199|#define CKR_OK 0x00000000UL
  ------------------
  372|    199|}
openssl.c:sc_pkcs11_openssl_md_update:
  376|    380|{
  377|    380|	EVP_MD_CTX *md_ctx = DIGEST_CTX(op);
  ------------------
  |  |  350|    380|	(op ? (EVP_MD_CTX *) (op)->priv_data : NULL)
  |  |  ------------------
  |  |  |  Branch (350:3): [True: 380, False: 0]
  |  |  ------------------
  ------------------
  378|    380|	if (!md_ctx) {
  ------------------
  |  Branch (378:6): [True: 0, False: 380]
  ------------------
  379|      0|		sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  380|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  381|      0|	}
  382|    380|	if (!EVP_DigestUpdate(md_ctx, pData, pDataLen)) {
  ------------------
  |  Branch (382:6): [True: 0, False: 380]
  ------------------
  383|      0|		sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  384|      0|		return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  385|      0|	}
  386|    380|	return CKR_OK;
  ------------------
  |  | 1086|    380|#define CKR_OK 0x00000000UL
  ------------------
  387|    380|}
openssl.c:sc_pkcs11_openssl_md_final:
  391|    166|{
  392|    166|	unsigned int tmp_len = 0;
  393|    166|	EVP_MD_CTX *md_ctx = DIGEST_CTX(op);
  ------------------
  |  |  350|    166|	(op ? (EVP_MD_CTX *) (op)->priv_data : NULL)
  |  |  ------------------
  |  |  |  Branch (350:3): [True: 166, False: 0]
  |  |  ------------------
  ------------------
  394|       |
  395|    166|	if (!md_ctx)
  ------------------
  |  Branch (395:6): [True: 0, False: 166]
  ------------------
  396|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  397|    166|	if (*pulDigestLen < (unsigned) EVP_MD_CTX_size(md_ctx)) {
  ------------------
  |  Branch (397:6): [True: 1, False: 165]
  ------------------
  398|      1|		sc_log(context, "Provided buffer too small: %lu < %d",
  ------------------
  |  |   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__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  399|      1|		       *pulDigestLen, EVP_MD_CTX_size(md_ctx));
  |  |  ------------------
  ------------------
  399|      1|		       *pulDigestLen, EVP_MD_CTX_size(md_ctx));
  400|      1|		*pulDigestLen = EVP_MD_CTX_size(md_ctx);
  401|      1|		return CKR_BUFFER_TOO_SMALL;
  ------------------
  |  | 1165|      1|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
  402|      1|	}
  403|    165|	if (!EVP_DigestFinal(md_ctx, pDigest, &tmp_len)) {
  ------------------
  |  Branch (403:6): [True: 0, False: 165]
  ------------------
  404|      0|		sc_log_openssl(context);
  ------------------
  |  |   72|      0|#define sc_log_openssl(ctx)   sc_do_log_openssl(ctx, SC_LOG_DEBUG_DEPS, FILENAME, __LINE__, __FUNCTION__)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  405|      0|		return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  406|      0|	}
  407|    165|	*pulDigestLen = (CK_ULONG)tmp_len;
  408|    165|	return CKR_OK;
  ------------------
  |  | 1086|    165|#define CKR_OK 0x00000000UL
  ------------------
  409|    165|}
openssl.c:ossl_md_free:
  250|  84.1k|{
  251|  84.1k|	sc_evp_md_free((EVP_MD *)md);
  252|  84.1k|}
openssl.c:ossl_md_copy:
  238|  42.0k|{
  239|       |#if OPENSSL_VERSION_NUMBER >= 0x30000000L
  240|       |	int ret = EVP_MD_up_ref((EVP_MD *)src);
  241|       |	if (ret != 1) {
  242|       |		return CKR_GENERAL_ERROR;
  243|       |	}
  244|       |#endif
  245|  42.0k|	*dst = (EVP_MD *)src;
  246|  42.0k|	return CKR_OK;
  ------------------
  |  | 1086|  42.0k|#define CKR_OK 0x00000000UL
  ------------------
  247|  42.0k|}
openssl.c:dup_mem:
  230|  48.1k|{
  231|  48.1k|	void *out = malloc(in_len);
  232|  48.1k|	if (out)
  ------------------
  |  Branch (232:6): [True: 48.1k, False: 0]
  ------------------
  233|  48.1k|		memcpy(out, in, in_len);
  234|  48.1k|	return out;
  235|  48.1k|}

lookup_enum_spec:
 1337|  40.8k|{
 1338|  40.8k|	CK_ULONG i;
 1339|       |
 1340|   384k|	for(i = 0; i < spec->size; i++)
  ------------------
  |  Branch (1340:13): [True: 384k, False: 0]
  ------------------
 1341|   384k|		if(spec->specs[i].type == value)
  ------------------
  |  Branch (1341:6): [True: 40.8k, False: 343k]
  ------------------
 1342|  40.8k|			return spec->specs[i].name;
 1343|      0|	return NULL;
 1344|  40.8k|}
lookup_enum:
 1349|  40.8k|{
 1350|  40.8k|	CK_ULONG i;
 1351|       |
 1352|   448k|	for(i = 0; ck_types[i].type < ( sizeof(ck_types) / sizeof(enum_spec) ) ; i++)
  ------------------
  |  Branch (1352:13): [True: 448k, False: 0]
  ------------------
 1353|   448k|		if(ck_types[i].type == type)
  ------------------
  |  Branch (1353:6): [True: 40.8k, False: 408k]
  ------------------
 1354|  40.8k|			return lookup_enum_spec(&(ck_types[i]), value);
 1355|      0|	return NULL;
 1356|  40.8k|}

module_init:
  242|      2|{
  243|       |#ifdef _WIN32
  244|       |	InitializeCriticalSection(&c_initialize_cs);
  245|       |#endif
  246|      2|	sc_notify_init();
  247|      2|	return 1;
  248|      2|}
C_Initialize:
  292|  17.0k|{
  293|  17.0k|	CK_RV rv;
  294|  17.0k|#if !defined(_WIN32)
  295|  17.0k|	pid_t current_pid;
  296|  17.0k|#endif
  297|  17.0k|	int rc;
  298|  17.0k|	sc_context_param_t ctx_opts;
  299|       |
  300|  17.0k|#if !defined(_WIN32)
  301|       |	/* Handle fork() exception */
  302|  17.0k|	C_INITIALIZE_M_LOCK
  ------------------
  |  |   71|  17.0k|#define C_INITIALIZE_M_LOCK  pthread_mutex_lock(&c_initialize_m);
  ------------------
  303|  17.0k|	current_pid = getpid();
  304|  17.0k|	if (current_pid != initialized_pid) {
  ------------------
  |  Branch (304:6): [True: 1, False: 17.0k]
  ------------------
  305|      1|		if (context && CKR_OK == sc_pkcs11_lock()) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (305:7): [True: 0, False: 1]
  |  Branch (305:18): [True: 0, False: 0]
  ------------------
  306|      0|			context->flags |= SC_CTX_FLAG_TERMINATE;
  ------------------
  |  |  856|      0|#define SC_CTX_FLAG_TERMINATE				0x00000001
  ------------------
  307|      0|			sc_pkcs11_unlock();
  308|      0|		}
  309|      1|		C_Finalize(NULL_PTR);
  ------------------
  |  |   27|      1|#define NULL_PTR ((void *)0)
  ------------------
  310|      1|	}
  311|  17.0k|	initialized_pid = current_pid;
  312|  17.0k|	in_finalize = 0;
  313|  17.0k|	C_INITIALIZE_M_UNLOCK
  ------------------
  |  |   72|  17.0k|#define C_INITIALIZE_M_UNLOCK pthread_mutex_unlock(&c_initialize_m);
  ------------------
  314|  17.0k|#endif
  315|       |
  316|       |	/* protect from nesting */
  317|  17.0k|	C_INITIALIZE_M_LOCK
  ------------------
  |  |   71|  17.0k|#define C_INITIALIZE_M_LOCK  pthread_mutex_lock(&c_initialize_m);
  ------------------
  318|  17.0k|	nesting++;
  319|  17.0k|	if (nesting > 1) {
  ------------------
  |  Branch (319:6): [True: 0, False: 17.0k]
  ------------------
  320|      0|		nesting--;
  321|      0|		C_INITIALIZE_M_UNLOCK
  ------------------
  |  |   72|      0|#define C_INITIALIZE_M_UNLOCK pthread_mutex_unlock(&c_initialize_m);
  ------------------
  322|      0|		return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  323|      0|	}
  324|  17.0k|	C_INITIALIZE_M_UNLOCK
  ------------------
  |  |   72|  17.0k|#define C_INITIALIZE_M_UNLOCK pthread_mutex_unlock(&c_initialize_m);
  ------------------
  325|       |	/* protect from nesting */
  326|       |
  327|       |	/* protect from multiple threads tryng to setup locking */
  328|  17.0k|	C_INITIALIZE_M_LOCK
  ------------------
  |  |   71|  17.0k|#define C_INITIALIZE_M_LOCK  pthread_mutex_lock(&c_initialize_m);
  ------------------
  329|       |
  330|  17.0k|	if (context != NULL) {
  ------------------
  |  Branch (330:6): [True: 0, False: 17.0k]
  ------------------
  331|      0|		if (CKR_OK == sc_pkcs11_lock()) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (331:7): [True: 0, False: 0]
  ------------------
  332|      0|			sc_log(context, "C_Initialize(): Cryptoki already initialized\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  333|      0|			sc_pkcs11_unlock();
  334|      0|		}
  335|      0|		nesting--;
  336|      0|		C_INITIALIZE_M_UNLOCK
  ------------------
  |  |   72|      0|#define C_INITIALIZE_M_UNLOCK pthread_mutex_unlock(&c_initialize_m);
  ------------------
  337|      0|		return CKR_CRYPTOKI_ALREADY_INITIALIZED;
  ------------------
  |  | 1170|      0|#define CKR_CRYPTOKI_ALREADY_INITIALIZED 0x00000191UL
  ------------------
  338|      0|	}
  339|       |
  340|  17.0k|	rv = sc_pkcs11_init_lock((CK_C_INITIALIZE_ARGS_PTR) pInitArgs);
  341|  17.0k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (341:6): [True: 0, False: 17.0k]
  ------------------
  342|      0|		goto out;
  343|       |
  344|       |	/* set context options */
  345|  17.0k|	memset(&ctx_opts, 0, sizeof(sc_context_param_t));
  346|  17.0k|	ctx_opts.ver        = 0;
  347|  17.0k|	ctx_opts.app_name   = MODULE_APP_NAME;
  ------------------
  |  |   49|  17.0k|#define MODULE_APP_NAME "opensc-pkcs11"
  ------------------
  348|  17.0k|	ctx_opts.thread_ctx = &sc_thread_ctx;
  349|       |
  350|  17.0k|	rc = sc_context_create(&context, &ctx_opts);
  351|  17.0k|	if (rc != SC_SUCCESS) {
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
  |  Branch (351:6): [True: 0, False: 17.0k]
  ------------------
  352|      0|		rv = CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  353|      0|		goto out;
  354|      0|	}
  355|       |
  356|       |	/* Load configuration */
  357|  17.0k|	load_pkcs11_parameters(&sc_pkcs11_conf, context);
  358|       |
  359|       |	/* List of sessions */
  360|  17.0k|	if (0 != list_init(&sessions)) {
  ------------------
  |  Branch (360:6): [True: 0, False: 17.0k]
  ------------------
  361|      0|		rv = CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  362|      0|		goto out;
  363|      0|	}
  364|  17.0k|	list_attributes_seeker(&sessions, session_list_seeker);
  365|       |
  366|       |	/* List of slots */
  367|  17.0k|	if (0 != list_init(&virtual_slots)) {
  ------------------
  |  Branch (367:6): [True: 0, False: 17.0k]
  ------------------
  368|      0|		rv = CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  369|      0|		goto out;
  370|      0|	}
  371|  17.0k|	list_attributes_seeker(&virtual_slots, slot_list_seeker);
  372|       |
  373|  17.0k|	card_detect_all();
  374|       |
  375|  17.0k|out:
  376|  17.0k|	if (context != NULL)
  ------------------
  |  Branch (376:6): [True: 17.0k, False: 0]
  ------------------
  377|  17.0k|		SC_LOG_RV("C_Initialize() = %s", rv);
  ------------------
  |  |  237|  17.0k|#define SC_LOG_RV(fmt, rv)\
  |  |  238|  17.0k|do {\
  |  |  239|  17.0k|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|  17.0k|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 17.0k, False: 0]
  |  |  ------------------
  |  |  241|  17.0k|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|  17.0k|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|  17.0k|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 17.0k]
  |  |  ------------------
  ------------------
  378|       |
  379|  17.0k|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (379:6): [True: 0, False: 17.0k]
  ------------------
  380|      0|		if (context != NULL) {
  ------------------
  |  Branch (380:7): [True: 0, False: 0]
  ------------------
  381|      0|			sc_release_context(context);
  382|      0|			context = NULL;
  383|      0|		}
  384|       |		/* Release and destroy the mutex */
  385|      0|		sc_pkcs11_free_lock();
  386|      0|	}
  387|       |
  388|       |	/* protect from multiple threads tryng to setup locking */
  389|  17.0k|	nesting--;
  390|  17.0k|	C_INITIALIZE_M_UNLOCK
  ------------------
  |  |   72|  17.0k|#define C_INITIALIZE_M_UNLOCK pthread_mutex_unlock(&c_initialize_m);
  ------------------
  391|       |
  392|  17.0k|	return rv;
  393|  17.0k|}
C_Finalize:
  396|  17.0k|{
  397|  17.0k|	int i;
  398|  17.0k|	void *p;
  399|  17.0k|	sc_pkcs11_slot_t *slot;
  400|  17.0k|	CK_RV rv;
  401|       |
  402|  17.0k|	if (pReserved != NULL_PTR)
  ------------------
  |  |   27|  17.0k|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (402:6): [True: 0, False: 17.0k]
  ------------------
  403|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  404|       |
  405|  17.0k|#if !defined(_WIN32)
  406|  17.0k|	sc_notify_close();
  407|  17.0k|#endif
  408|       |
  409|  17.0k|	if (context == NULL)
  ------------------
  |  Branch (409:6): [True: 1, False: 17.0k]
  ------------------
  410|      1|		return CKR_CRYPTOKI_NOT_INITIALIZED;
  ------------------
  |  | 1169|      1|#define CKR_CRYPTOKI_NOT_INITIALIZED 0x00000190UL
  ------------------
  411|       |
  412|  17.0k|	rv = sc_pkcs11_lock();
  413|  17.0k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (413:6): [True: 0, False: 17.0k]
  ------------------
  414|      0|		return rv;
  415|       |
  416|  17.0k|	sc_log(context, "C_Finalize()");
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  417|       |
  418|       |	/* cancel pending calls */
  419|  17.0k|	in_finalize = 1;
  420|  17.0k|	sc_cancel(context);
  421|       |	/* remove all cards from readers */
  422|  34.0k|	for (i=0; i < (int)sc_ctx_get_reader_count(context); i++)
  ------------------
  |  Branch (422:12): [True: 17.0k, False: 17.0k]
  ------------------
  423|  17.0k|		card_removed(sc_ctx_get_reader(context, i));
  424|       |
  425|  17.0k|	while ((p = list_fetch(&sessions)))
  ------------------
  |  Branch (425:9): [True: 0, False: 17.0k]
  ------------------
  426|      0|		free(p);
  427|  17.0k|	list_destroy(&sessions);
  428|       |
  429|  34.0k|	while ((slot = list_fetch(&virtual_slots))) {
  ------------------
  |  Branch (429:9): [True: 17.0k, False: 17.0k]
  ------------------
  430|  17.0k|		sc_wait_for_event(context, 0, NULL, NULL, 0, &slot->reader_events);
  431|  17.0k|		list_destroy(&slot->objects);
  432|  17.0k|		list_destroy(&slot->logins);
  433|  17.0k|		free(slot);
  434|  17.0k|	}
  435|  17.0k|	list_destroy(&virtual_slots);
  436|       |
  437|  17.0k|	sc_release_context(context);
  438|  17.0k|	context = NULL;
  439|       |
  440|       |	/* Release and destroy the mutex */
  441|  17.0k|	sc_pkcs11_free_lock();
  442|       |
  443|  17.0k|	return rv;
  444|  17.0k|}
C_InitToken:
  729|    261|{
  730|    261|	struct sc_pkcs11_session *session;
  731|    261|	struct sc_pkcs11_slot *slot;
  732|    261|	unsigned char *label, *cpo;
  733|    261|	CK_RV rv;
  734|    261|	unsigned int i;
  735|       |
  736|       |	/* Strip trailing whitespace and null terminate the label.
  737|       |	 * Keep the fixed-length buffer though as some other layers or drivers (SC-HSM)
  738|       |	 * might expect the length is fixed! */
  739|    261|	label = malloc(33);
  740|    261|	if (label == NULL) {
  ------------------
  |  Branch (740:6): [True: 0, False: 261]
  ------------------
  741|      0|		sc_log(context, "Failed to allocate label memory");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  742|      0|		return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  743|      0|	}
  744|    261|	memcpy(label, pLabel, 32);
  745|    261|	label[32] = 0;
  746|    261|	cpo = label + 31;
  747|  8.12k|	while ((cpo >= label) && (*cpo == ' ')) {
  ------------------
  |  Branch (747:9): [True: 8.12k, False: 1]
  |  Branch (747:27): [True: 7.86k, False: 260]
  ------------------
  748|  7.86k|		*cpo = 0;
  749|  7.86k|		cpo--;
  750|  7.86k|	}
  751|       |
  752|    261|	sc_log(context, "C_InitToken(pLabel='%s') called", label);
  ------------------
  |  |   71|    261|#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|    261|	rv = sc_pkcs11_lock();
  754|    261|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|    261|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (754:6): [True: 0, False: 261]
  ------------------
  755|      0|		free(label);
  756|      0|		return rv;
  757|      0|	}
  758|       |
  759|    261|	rv = slot_get_token(slotID, &slot);
  760|    261|	if (rv != CKR_OK)   {
  ------------------
  |  | 1086|    261|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (760:6): [True: 0, False: 261]
  ------------------
  761|      0|		sc_log(context, "C_InitToken() get token error 0x%lX", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  762|      0|		goto out;
  763|      0|	}
  764|       |
  765|    261|	if (!slot->p11card || !slot->p11card->framework
  ------------------
  |  Branch (765:6): [True: 0, False: 261]
  |  Branch (765:24): [True: 0, False: 261]
  ------------------
  766|    261|		   || !slot->p11card->framework->init_token) {
  ------------------
  |  Branch (766:9): [True: 0, False: 261]
  ------------------
  767|      0|		sc_log(context, "C_InitToken() not supported by framework");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  768|      0|		rv = CKR_FUNCTION_NOT_SUPPORTED;
  ------------------
  |  | 1111|      0|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
  769|      0|		goto out;
  770|      0|	}
  771|       |
  772|       |	/* Make sure there's no open session for this token */
  773|    261|	for (i=0; i<list_size(&sessions); i++) {
  ------------------
  |  Branch (773:12): [True: 261, False: 0]
  ------------------
  774|    261|		session = (struct sc_pkcs11_session*)list_get_at(&sessions, i);
  775|    261|		if (session->slot == slot) {
  ------------------
  |  Branch (775:7): [True: 261, False: 0]
  ------------------
  776|    261|			rv = CKR_SESSION_EXISTS;
  ------------------
  |  | 1137|    261|#define CKR_SESSION_EXISTS 0x000000B6UL
  ------------------
  777|    261|			goto out;
  778|    261|		}
  779|    261|	}
  780|       |
  781|      0|	rv = slot->p11card->framework->init_token(slot, slot->fw_data, pPin, ulPinLen, label);
  782|      0|	if (rv == CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (782:6): [True: 0, False: 0]
  ------------------
  783|       |		/* Now we should re-bind all tokens so they get the
  784|       |		 * corresponding function vector and flags */
  785|      0|	}
  786|       |
  787|    261|out:
  788|    261|	sc_pkcs11_unlock();
  789|    261|	sc_log(context, "C_InitToken(pLabel='%s') returns 0x%lX", label, rv);
  ------------------
  |  |   71|    261|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  790|    261|	free(label);
  791|    261|	return rv;
  792|      0|}
sc_pkcs11_init_lock:
  955|  17.0k|{
  956|  17.0k|	CK_RV rv = CKR_OK;
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  957|       |
  958|  17.0k|	int applock = 0;
  959|  17.0k|	int oslock = 0;
  960|  17.0k|	if (global_lock)
  ------------------
  |  Branch (960:6): [True: 0, False: 17.0k]
  ------------------
  961|      0|		return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  962|       |
  963|       |	/* No CK_C_INITIALIZE_ARGS pointer, no locking */
  964|  17.0k|	if (!args)
  ------------------
  |  Branch (964:6): [True: 17.0k, False: 0]
  ------------------
  965|  17.0k|		return CKR_OK;
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  966|       |
  967|      0|	if (args->pReserved != NULL_PTR)
  ------------------
  |  |   27|      0|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (967:6): [True: 0, False: 0]
  ------------------
  968|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  969|       |
  970|      0|	app_locking = *args;
  971|       |
  972|       |	/* If the app tells us OS locking is okay,
  973|       |	 * use that. Otherwise use the supplied functions.
  974|       |	 */
  975|      0|	global_locking = NULL;
  976|      0|	if (args->CreateMutex && args->DestroyMutex &&
  ------------------
  |  Branch (976:6): [True: 0, False: 0]
  |  Branch (976:27): [True: 0, False: 0]
  ------------------
  977|      0|		   args->LockMutex   && args->UnlockMutex) {
  ------------------
  |  Branch (977:6): [True: 0, False: 0]
  |  Branch (977:27): [True: 0, False: 0]
  ------------------
  978|      0|			applock = 1;
  979|      0|	}
  980|      0|	if ((args->flags & CKF_OS_LOCKING_OK)) {
  ------------------
  |  |  341|      0|#define CKF_OS_LOCKING_OK 0x00000002UL
  ------------------
  |  Branch (980:6): [True: 0, False: 0]
  ------------------
  981|      0|		oslock = 1;
  982|      0|	}
  983|       |
  984|       |	/* Based on PKCS#11 v2.11 11.4 */
  985|      0|	if (applock && oslock) {
  ------------------
  |  Branch (985:6): [True: 0, False: 0]
  |  Branch (985:17): [True: 0, False: 0]
  ------------------
  986|       |		/* Shall be used in threaded environment, prefer app provided locking */
  987|      0|		global_locking = &app_locking;
  988|      0|	} else if (!applock && oslock) {
  ------------------
  |  Branch (988:13): [True: 0, False: 0]
  |  Branch (988:25): [True: 0, False: 0]
  ------------------
  989|       |		/* Shall be used in threaded environment, must use operating system locking */
  990|      0|		global_locking = default_mutex_funcs;
  991|      0|	} else if (applock && !oslock) {
  ------------------
  |  Branch (991:13): [True: 0, False: 0]
  |  Branch (991:24): [True: 0, False: 0]
  ------------------
  992|       |		/* Shall be used in threaded environment, must use app provided locking */
  993|      0|		global_locking = &app_locking;
  994|      0|	} else if (!applock && !oslock) {
  ------------------
  |  Branch (994:13): [True: 0, False: 0]
  |  Branch (994:25): [True: 0, False: 0]
  ------------------
  995|       |		/* Shall not be used in threaded environment, use operating system locking */
  996|      0|		global_locking = default_mutex_funcs;
  997|      0|	}
  998|       |
  999|      0|	if (global_locking != NULL) {
  ------------------
  |  Branch (999:6): [True: 0, False: 0]
  ------------------
 1000|       |		/* create mutex */
 1001|      0|		rv = global_locking->CreateMutex(&global_lock);
 1002|      0|	}
 1003|       |
 1004|      0|	return rv;
 1005|      0|}
sc_pkcs11_lock:
 1008|  62.1k|{
 1009|  62.1k|	if (context == NULL)
  ------------------
  |  Branch (1009:6): [True: 0, False: 62.1k]
  ------------------
 1010|      0|		return CKR_CRYPTOKI_NOT_INITIALIZED;
  ------------------
  |  | 1169|      0|#define CKR_CRYPTOKI_NOT_INITIALIZED 0x00000190UL
  ------------------
 1011|       |
 1012|  62.1k|	if (!global_lock)
  ------------------
  |  Branch (1012:6): [True: 62.1k, False: 0]
  ------------------
 1013|  62.1k|		return CKR_OK;
  ------------------
  |  | 1086|  62.1k|#define CKR_OK 0x00000000UL
  ------------------
 1014|      0|	if (global_locking)  {
  ------------------
  |  Branch (1014:6): [True: 0, False: 0]
  ------------------
 1015|      0|		while (global_locking->LockMutex(global_lock) != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1015:10): [True: 0, False: 0]
  ------------------
 1016|      0|			;
 1017|      0|	}
 1018|       |
 1019|      0|	return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
 1020|  62.1k|}
sc_pkcs11_unlock:
 1034|  45.1k|{
 1035|  45.1k|	__sc_pkcs11_unlock(global_lock);
 1036|  45.1k|}
sc_pkcs11_free_lock:
 1043|  17.0k|{
 1044|  17.0k|	void	*tempLock;
 1045|       |
 1046|  17.0k|	if (!(tempLock = global_lock))
  ------------------
  |  Branch (1046:6): [True: 17.0k, False: 0]
  ------------------
 1047|  17.0k|		return;
 1048|       |
 1049|       |	/* Clear the global lock pointer - once we've
 1050|       |	 * unlocked the mutex it's as good as gone */
 1051|      0|	global_lock = NULL;
 1052|       |
 1053|       |	/* Now unlock. On SMP machines the synchronization
 1054|       |	 * primitives should take care of flushing out
 1055|       |	 * all changed data to RAM */
 1056|      0|	__sc_pkcs11_unlock(tempLock);
 1057|       |
 1058|      0|	if (global_locking)
  ------------------
  |  Branch (1058:6): [True: 0, False: 0]
  ------------------
 1059|      0|		global_locking->DestroyMutex(tempLock);
 1060|       |	global_locking = NULL;
 1061|      0|}
pkcs11-global.c:sc_create_mutex:
  175|  34.0k|{
  176|  34.0k|	if (global_locking == NULL)
  ------------------
  |  Branch (176:6): [True: 34.0k, False: 0]
  ------------------
  177|  34.0k|		return SC_SUCCESS;
  ------------------
  |  |   28|  34.0k|#define SC_SUCCESS				0
  ------------------
  178|      0|	if (global_locking->CreateMutex(m) == CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (178:6): [True: 0, False: 0]
  ------------------
  179|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  180|      0|	else
  181|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  182|      0|}
pkcs11-global.c:sc_lock_mutex:
  185|  1.46M|{
  186|  1.46M|	if (global_locking == NULL)
  ------------------
  |  Branch (186:6): [True: 1.46M, False: 0]
  ------------------
  187|  1.46M|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.46M|#define SC_SUCCESS				0
  ------------------
  188|      0|	if (global_locking->LockMutex(m) == CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (188:6): [True: 0, False: 0]
  ------------------
  189|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  190|      0|	else
  191|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  192|      0|}
pkcs11-global.c:sc_unlock_mutex:
  195|  1.46M|{
  196|  1.46M|	if (global_locking == NULL)
  ------------------
  |  Branch (196:6): [True: 1.46M, False: 0]
  ------------------
  197|  1.46M|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.46M|#define SC_SUCCESS				0
  ------------------
  198|      0|	if (global_locking->UnlockMutex(m) == CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (198:6): [True: 0, False: 0]
  ------------------
  199|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  200|      0|	else
  201|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  202|       |
  203|      0|}
pkcs11-global.c:session_list_seeker:
  221|  29.5k|static int session_list_seeker(const void *el, const void *key) {
  222|  29.5k|	const struct sc_pkcs11_session *session = (struct sc_pkcs11_session *)el;
  223|  29.5k|	if ((el == NULL) || (key == NULL))
  ------------------
  |  Branch (223:6): [True: 0, False: 29.5k]
  |  Branch (223:22): [True: 0, False: 29.5k]
  ------------------
  224|      0|		return 0;
  225|  29.5k|	if (session->handle == *(CK_SESSION_HANDLE*)key)
  ------------------
  |  Branch (225:6): [True: 29.5k, False: 0]
  ------------------
  226|  29.5k|		return 1;
  227|      0|	return 0;
  228|  29.5k|}
pkcs11-global.c:slot_list_seeker:
  229|  31.4k|static int slot_list_seeker(const void *el, const void *key) {
  230|  31.4k|	const struct sc_pkcs11_slot *slot = (struct sc_pkcs11_slot *)el;
  231|  31.4k|	if ((el == NULL) || (key == NULL))
  ------------------
  |  Branch (231:6): [True: 0, False: 31.4k]
  |  Branch (231:22): [True: 0, False: 31.4k]
  ------------------
  232|      0|		return 0;
  233|  31.4k|	if (slot->id == *(CK_SLOT_ID *)key)
  ------------------
  |  Branch (233:6): [True: 31.4k, False: 0]
  ------------------
  234|  31.4k|		return 1;
  235|      0|	return 0;
  236|  31.4k|}
pkcs11-global.c:__sc_pkcs11_unlock:
 1024|  45.1k|{
 1025|  45.1k|	if (!lock)
  ------------------
  |  Branch (1025:6): [True: 45.1k, False: 0]
  ------------------
 1026|  45.1k|		return;
 1027|      0|	if (global_locking) {
  ------------------
  |  Branch (1027:6): [True: 0, False: 0]
  ------------------
 1028|      0|		while (global_locking->UnlockMutex(lock) != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1028:10): [True: 0, False: 0]
  ------------------
 1029|      0|			;
 1030|      0|	}
 1031|      0|}

C_CreateObject:
  160|    319|{
  161|    319|	return sc_create_object_int(hSession, pTemplate, ulCount, phObject, 1);
  162|    319|}
C_FindObjectsInit:
  354|  1.53k|{
  355|  1.53k|	CK_RV rv;
  356|  1.53k|	CK_BBOOL is_private = TRUE;
  ------------------
  |  |   51|  1.53k|#define TRUE 1
  ------------------
  357|  1.53k|	CK_ATTRIBUTE private_attribute = { CKA_PRIVATE, &is_private, sizeof(is_private) };
  ------------------
  |  |  139|  1.53k|#define CKA_PRIVATE 0x00000002UL
  ------------------
  358|  1.53k|	int match, hide_private;
  359|  1.53k|	unsigned int i, j;
  360|  1.53k|	struct sc_pkcs11_session *session;
  361|  1.53k|	struct sc_pkcs11_object *object;
  362|  1.53k|	struct sc_pkcs11_find_operation *operation;
  363|  1.53k|	struct sc_pkcs11_slot *slot;
  364|  1.53k|	struct sc_pkcs11_operation *op = NULL;
  365|       |
  366|  1.53k|	if (pTemplate == NULL_PTR && ulCount > 0)
  ------------------
  |  |   27|  3.06k|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (366:6): [True: 0, False: 1.53k]
  |  Branch (366:31): [True: 0, False: 0]
  ------------------
  367|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  368|       |
  369|  1.53k|	rv = sc_pkcs11_lock();
  370|  1.53k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (370:6): [True: 0, False: 1.53k]
  ------------------
  371|      0|		return rv;
  372|       |
  373|  1.53k|	rv = get_session(hSession, &session);
  374|  1.53k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (374:6): [True: 0, False: 1.53k]
  ------------------
  375|      0|		goto out;
  376|       |
  377|  1.53k|	sc_log(context, "C_FindObjectsInit(slot = %lu)\n", session->slot->id);
  ------------------
  |  |   71|  1.53k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  378|  1.53k|	dump_template(SC_LOG_DEBUG_NORMAL, "C_FindObjectsInit()", pTemplate, ulCount);
  ------------------
  |  |  411|  1.53k|		sc_pkcs11_print_attrs(level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  412|  1.53k|				info, pTemplate, ulCount)
  ------------------
  379|       |
  380|  1.53k|	rv = session_start_operation(session, SC_PKCS11_OPERATION_FIND,
  381|  1.53k|				     &find_mechanism, &op);
  382|  1.53k|	operation = (struct sc_pkcs11_find_operation *) op;
  383|  1.53k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (383:6): [True: 0, False: 1.53k]
  ------------------
  384|      0|		goto out;
  385|       |
  386|  1.53k|	operation->current_handle = 0;
  387|  1.53k|	operation->num_handles = 0;
  388|  1.53k|	operation->allocated_handles = 0;
  389|  1.53k|	operation->handles = NULL;
  390|  1.53k|	slot = session->slot;
  391|       |
  392|       |	/* Check whether we should hide private objects */
  393|  1.53k|	hide_private = 0;
  394|  1.53k|	if ((slot->login_user == -1) && (slot->token_info.flags & CKF_LOGIN_REQUIRED))
  ------------------
  |  |  414|    819|#define CKF_LOGIN_REQUIRED 0x00000004UL
  ------------------
  |  Branch (394:6): [True: 819, False: 713]
  |  Branch (394:34): [True: 643, False: 176]
  ------------------
  395|    643|		hide_private = 1;
  396|       |
  397|       |	/* For each object in token do */
  398|  19.6k|	for (i=0; i<list_size(&slot->objects); i++) {
  ------------------
  |  Branch (398:12): [True: 18.1k, False: 1.53k]
  ------------------
  399|  18.1k|		object = (struct sc_pkcs11_object *)list_get_at(&slot->objects, i);
  400|  18.1k|		sc_log(context, "Object with handle 0x%lx", object->handle);
  ------------------
  |  |   71|  18.1k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  401|       |
  402|       |		/* User not logged in and private object? */
  403|  18.1k|		if (hide_private) {
  ------------------
  |  Branch (403:7): [True: 15.0k, False: 3.12k]
  ------------------
  404|  15.0k|			if (object->ops->get_attribute(session, object, &private_attribute) != CKR_OK)
  ------------------
  |  | 1086|  15.0k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (404:8): [True: 0, False: 15.0k]
  ------------------
  405|      0|			        continue;
  406|  15.0k|			if (is_private) {
  ------------------
  |  Branch (406:8): [True: 3.24k, False: 11.7k]
  ------------------
  407|  3.24k|				sc_log(context,
  ------------------
  |  |   71|  3.24k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  408|  3.24k|				       "Object %lu/%lu: Private object and not logged in.",
  409|  3.24k|				       slot->id, object->handle);
  410|  3.24k|				continue;
  411|  3.24k|			}
  412|  15.0k|		}
  413|       |
  414|       |		/* Try to match every attribute */
  415|  14.8k|		match = 1;
  416|  17.5k|		for (j = 0; j < ulCount; j++) {
  ------------------
  |  Branch (416:15): [True: 16.4k, False: 1.08k]
  ------------------
  417|  16.4k|			rv = object->ops->cmp_attribute(session, object, &pTemplate[j]);
  418|  16.4k|			if (rv == 0) {
  ------------------
  |  Branch (418:8): [True: 13.8k, False: 2.61k]
  ------------------
  419|  13.8k|				sc_log(context,
  ------------------
  |  |   71|  13.8k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  420|  13.8k|				       "Object %lu/%lu: Attribute 0x%lx does NOT match.",
  421|  13.8k|				       slot->id, object->handle, pTemplate[j].type);
  422|  13.8k|				match = 0;
  423|  13.8k|				break;
  424|  13.8k|			}
  425|       |
  426|  2.61k|			if (context->debug >= 4) {
  ------------------
  |  Branch (426:8): [True: 0, False: 2.61k]
  ------------------
  427|      0|				sc_log(context,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  428|      0|				       "Object %lu/%lu: Attribute 0x%lx matches.",
  429|      0|				       slot->id, object->handle, pTemplate[j].type);
  430|      0|			}
  431|  2.61k|		}
  432|       |
  433|  14.8k|		if (match) {
  ------------------
  |  Branch (433:7): [True: 1.08k, False: 13.8k]
  ------------------
  434|  1.08k|			sc_log(context, "Object %lu/%lu matches\n", slot->id,
  ------------------
  |  |   71|  1.08k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  435|  1.08k|			       object->handle);
  436|       |			/* Realloc handles - remove restriction on only 32 matching objects -dee */
  437|  1.08k|			if (operation->num_handles >= operation->allocated_handles) {
  ------------------
  |  Branch (437:8): [True: 706, False: 377]
  ------------------
  438|    706|				operation->allocated_handles += SC_PKCS11_FIND_INC_HANDLES;
  ------------------
  |  |  370|    706|#define SC_PKCS11_FIND_INC_HANDLES	32
  ------------------
  439|    706|				sc_log(context, "realloc for %d handles", operation->allocated_handles);
  ------------------
  |  |   71|    706|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  440|    706|				operation->handles = realloc(operation->handles,
  441|    706|					sizeof(CK_OBJECT_HANDLE) * operation->allocated_handles);
  442|    706|				if (operation->handles == NULL) {
  ------------------
  |  Branch (442:9): [True: 0, False: 706]
  ------------------
  443|      0|					rv = CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  444|      0|					goto out;
  445|      0|				}
  446|    706|			}
  447|  1.08k|			operation->handles[operation->num_handles++] = object->handle;
  448|  1.08k|		}
  449|  14.8k|	}
  450|  1.53k|	rv = CKR_OK;
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  451|       |
  452|  1.53k|	sc_log(context, "%d matching objects\n", operation->num_handles);
  ------------------
  |  |   71|  1.53k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  453|       |
  454|  1.53k|out:
  455|  1.53k|	sc_pkcs11_unlock();
  456|  1.53k|	return rv;
  457|  1.53k|}
C_FindObjects:
  465|  1.53k|{
  466|  1.53k|	CK_RV rv;
  467|  1.53k|	CK_ULONG to_return;
  468|  1.53k|	struct sc_pkcs11_session *session;
  469|  1.53k|	struct sc_pkcs11_find_operation *operation;
  470|  1.53k|	struct sc_pkcs11_operation *op = NULL;
  471|       |
  472|  1.53k|	if (phObject == NULL_PTR || ulMaxObjectCount == 0 || pulObjectCount == NULL_PTR)
  ------------------
  |  |   27|  3.06k|#define NULL_PTR ((void *)0)
  ------------------
              	if (phObject == NULL_PTR || ulMaxObjectCount == 0 || pulObjectCount == NULL_PTR)
  ------------------
  |  |   27|  1.53k|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (472:6): [True: 0, False: 1.53k]
  |  Branch (472:30): [True: 0, False: 1.53k]
  |  Branch (472:55): [True: 0, False: 1.53k]
  ------------------
  473|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  474|       |
  475|  1.53k|	rv = sc_pkcs11_lock();
  476|  1.53k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (476:6): [True: 0, False: 1.53k]
  ------------------
  477|      0|		return rv;
  478|       |
  479|  1.53k|	rv = get_session(hSession, &session);
  480|  1.53k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (480:6): [True: 0, False: 1.53k]
  ------------------
  481|      0|		goto out;
  482|       |
  483|  1.53k|	rv = session_get_operation(session, SC_PKCS11_OPERATION_FIND, &op);
  484|  1.53k|	operation = (struct sc_pkcs11_find_operation *) op;
  485|  1.53k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (485:6): [True: 0, False: 1.53k]
  ------------------
  486|      0|		goto out;
  487|       |
  488|  1.53k|	to_return = (CK_ULONG) operation->num_handles - operation->current_handle;
  489|  1.53k|	if (to_return > ulMaxObjectCount)
  ------------------
  |  Branch (489:6): [True: 111, False: 1.42k]
  ------------------
  490|    111|		to_return = ulMaxObjectCount;
  491|       |
  492|  1.53k|	*pulObjectCount = to_return;
  493|       |
  494|  1.53k|	memcpy(phObject, &operation->handles[operation->current_handle], to_return * sizeof(CK_OBJECT_HANDLE));
  495|       |
  496|  1.53k|	operation->current_handle += to_return;
  497|       |
  498|  1.53k|out:	sc_pkcs11_unlock();
  499|  1.53k|	return rv;
  500|  1.53k|}
C_FindObjectsFinal:
  505|  1.53k|{
  506|  1.53k|	CK_RV rv;
  507|  1.53k|	struct sc_pkcs11_session *session;
  508|       |
  509|  1.53k|	rv = sc_pkcs11_lock();
  510|  1.53k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (510:6): [True: 0, False: 1.53k]
  ------------------
  511|      0|		return rv;
  512|       |
  513|  1.53k|	rv = get_session(hSession, &session);
  514|  1.53k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (514:6): [True: 0, False: 1.53k]
  ------------------
  515|      0|		goto out;
  516|       |
  517|  1.53k|	rv = session_get_operation(session, SC_PKCS11_OPERATION_FIND, NULL);
  518|  1.53k|	if (rv == CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (518:6): [True: 1.53k, False: 0]
  ------------------
  519|  1.53k|		session_stop_operation(session, SC_PKCS11_OPERATION_FIND);
  520|       |
  521|  1.53k|out:	sc_pkcs11_unlock();
  522|  1.53k|	return rv;
  523|  1.53k|}
C_DigestInit:
  532|    310|{
  533|    310|	CK_RV rv;
  534|    310|	struct sc_pkcs11_session *session;
  535|       |
  536|    310|	if (pMechanism == NULL_PTR)
  ------------------
  |  |   27|    310|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (536:6): [True: 0, False: 310]
  ------------------
  537|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  538|       |
  539|    310|	rv = sc_pkcs11_lock();
  540|    310|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    310|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (540:6): [True: 0, False: 310]
  ------------------
  541|      0|		return rv;
  542|       |
  543|    310|	sc_log(context, "C_DigestInit(hSession=0x%lx)", hSession);
  ------------------
  |  |   71|    310|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  544|    310|	rv = get_session(hSession, &session);
  545|    310|	if (rv == CKR_OK)
  ------------------
  |  | 1086|    310|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (545:6): [True: 310, False: 0]
  ------------------
  546|    310|		rv = sc_pkcs11_md_init(session, pMechanism);
  547|       |
  548|       |	SC_LOG_RV("C_DigestInit() = %s", rv);
  ------------------
  |  |  237|    310|#define SC_LOG_RV(fmt, rv)\
  |  |  238|    310|do {\
  |  |  239|    310|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|    310|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 310, False: 0]
  |  |  ------------------
  |  |  241|    310|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|    310|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|    310|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|    310|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 310]
  |  |  ------------------
  ------------------
  549|    310|	sc_pkcs11_unlock();
  550|    310|	return rv;
  551|    310|}
C_Digest:
  560|      1|{
  561|      1|	CK_RV rv;
  562|      1|	struct sc_pkcs11_session *session;
  563|      1|	CK_ULONG  ulBuflen = 0;
  564|       |
  565|      1|	rv = sc_pkcs11_lock();
  566|      1|	if (rv != CKR_OK)
  ------------------
  |  | 1086|      1|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (566:6): [True: 0, False: 1]
  ------------------
  567|      0|		return rv;
  568|       |
  569|      1|	sc_log(context, "C_Digest(hSession=0x%lx)", hSession);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  570|      1|	rv = get_session(hSession, &session);
  571|      1|	if (rv != CKR_OK)
  ------------------
  |  | 1086|      1|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (571:6): [True: 0, False: 1]
  ------------------
  572|      0|		goto out;
  573|       |
  574|       |	/* if pDigest == NULL, buffer size request */
  575|      1|	if (pDigest) {
  ------------------
  |  Branch (575:6): [True: 1, False: 0]
  ------------------
  576|       |	    /* As per PKCS#11 2.20 we need to check if buffer too small before update */
  577|      1|	    rv = sc_pkcs11_md_final(session, NULL, &ulBuflen);
  578|      1|	    if (rv != CKR_OK)
  ------------------
  |  | 1086|      1|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (578:10): [True: 0, False: 1]
  ------------------
  579|      0|		goto out;
  580|       |
  581|      1|	    if (ulBuflen > *pulDigestLen) {
  ------------------
  |  Branch (581:10): [True: 0, False: 1]
  ------------------
  582|      0|	        *pulDigestLen = ulBuflen;
  583|      0|		rv = CKR_BUFFER_TOO_SMALL;
  ------------------
  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
  584|      0|		goto out;
  585|      0|	    }
  586|       |
  587|      1|	    rv = sc_pkcs11_md_update(session, pData, ulDataLen);
  588|      1|	}
  589|      1|	if (rv == CKR_OK)
  ------------------
  |  | 1086|      1|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (589:6): [True: 1, False: 0]
  ------------------
  590|      1|		rv = sc_pkcs11_md_final(session, pDigest, pulDigestLen);
  591|       |
  592|      1|out:
  593|       |	SC_LOG_RV("C_Digest = %s", rv);
  ------------------
  |  |  237|      1|#define SC_LOG_RV(fmt, rv)\
  |  |  238|      1|do {\
  |  |  239|      1|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|      1|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 1, False: 0]
  |  |  ------------------
  |  |  241|      1|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|      1|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|      1|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 1]
  |  |  ------------------
  ------------------
  594|      1|	sc_pkcs11_unlock();
  595|      1|	return rv;
  596|      1|}
C_DigestUpdate:
  603|    185|{
  604|    185|	CK_RV rv;
  605|    185|	struct sc_pkcs11_session *session;
  606|       |
  607|    185|	rv = sc_pkcs11_lock();
  608|    185|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    185|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (608:6): [True: 0, False: 185]
  ------------------
  609|      0|		return rv;
  610|       |
  611|    185|	rv = get_session(hSession, &session);
  612|    185|	if (rv == CKR_OK)
  ------------------
  |  | 1086|    185|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (612:6): [True: 185, False: 0]
  ------------------
  613|    185|		rv = sc_pkcs11_md_update(session, pPart, ulPartLen);
  614|       |
  615|       |	SC_LOG_RV("C_DigestUpdate() = %s", rv);
  ------------------
  |  |  237|    185|#define SC_LOG_RV(fmt, rv)\
  |  |  238|    185|do {\
  |  |  239|    185|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|    185|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 185, False: 0]
  |  |  ------------------
  |  |  241|    185|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|    185|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|    185|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|    185|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 185]
  |  |  ------------------
  ------------------
  616|    185|	sc_pkcs11_unlock();
  617|    185|	return rv;
  618|    185|}
C_DigestFinal:
  633|     10|{
  634|     10|	CK_RV rv;
  635|     10|	struct sc_pkcs11_session *session;
  636|       |
  637|     10|	rv = sc_pkcs11_lock();
  638|     10|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     10|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (638:6): [True: 0, False: 10]
  ------------------
  639|      0|		return rv;
  640|       |
  641|     10|	rv = get_session(hSession, &session);
  642|     10|	if (rv == CKR_OK)
  ------------------
  |  | 1086|     10|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (642:6): [True: 10, False: 0]
  ------------------
  643|     10|		rv = sc_pkcs11_md_final(session, pDigest, pulDigestLen);
  644|       |
  645|       |	SC_LOG_RV("C_DigestFinal() = %s", rv);
  ------------------
  |  |  237|     10|#define SC_LOG_RV(fmt, rv)\
  |  |  238|     10|do {\
  |  |  239|     10|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|     10|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 10, False: 0]
  |  |  ------------------
  |  |  241|     10|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|     10|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|     10|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|     10|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 10]
  |  |  ------------------
  ------------------
  646|     10|	sc_pkcs11_unlock();
  647|     10|	return rv;
  648|     10|}
C_SignInit:
  655|    475|{
  656|    475|	CK_BBOOL can_sign;
  657|    475|	CK_KEY_TYPE key_type;
  658|    475|	CK_ATTRIBUTE sign_attribute = { CKA_SIGN, &can_sign, sizeof(can_sign) };
  ------------------
  |  |  167|    475|#define CKA_SIGN 0x00000108UL
  ------------------
  659|    475|	CK_ATTRIBUTE key_type_attr = { CKA_KEY_TYPE, &key_type, sizeof(key_type) };
  ------------------
  |  |  159|    475|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  660|    475|	struct sc_pkcs11_session *session;
  661|    475|	struct sc_pkcs11_object *object;
  662|    475|	CK_RV rv;
  663|       |
  664|    475|	if (pMechanism == NULL_PTR)
  ------------------
  |  |   27|    475|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (664:6): [True: 0, False: 475]
  ------------------
  665|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  666|       |
  667|    475|	rv = sc_pkcs11_lock();
  668|    475|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    475|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (668:6): [True: 0, False: 475]
  ------------------
  669|      0|		return rv;
  670|       |
  671|    475|	rv = get_object_from_session(hSession, hKey, &session, &object);
  672|    475|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|    475|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (672:6): [True: 209, False: 266]
  ------------------
  673|    209|		if (rv == CKR_OBJECT_HANDLE_INVALID)
  ------------------
  |  | 1124|    209|#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL
  ------------------
  |  Branch (673:7): [True: 209, False: 0]
  ------------------
  674|    209|			rv = CKR_KEY_HANDLE_INVALID;
  ------------------
  |  | 1112|    209|#define CKR_KEY_HANDLE_INVALID 0x00000060UL
  ------------------
  675|    209|		goto out;
  676|    209|	}
  677|       |
  678|    266|	if (object->ops->sign == NULL_PTR) {
  ------------------
  |  |   27|    266|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (678:6): [True: 0, False: 266]
  ------------------
  679|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  680|      0|		goto out;
  681|      0|	}
  682|       |
  683|    266|	rv = object->ops->get_attribute(session, object, &sign_attribute);
  684|    266|	if (rv != CKR_OK || !can_sign) {
  ------------------
  |  | 1086|    532|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (684:6): [True: 0, False: 266]
  |  Branch (684:22): [True: 3, False: 263]
  ------------------
  685|      3|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      3|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  686|      3|		goto out;
  687|      3|	}
  688|    263|	rv = object->ops->get_attribute(session, object, &key_type_attr);
  689|    263|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|    263|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (689:6): [True: 0, False: 263]
  ------------------
  690|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  691|      0|		goto out;
  692|      0|	}
  693|       |
  694|    263|	rv = sc_pkcs11_sign_init(session, pMechanism, object, key_type);
  695|       |
  696|    475|out:
  697|       |	SC_LOG_RV("C_SignInit() = %s", rv);
  ------------------
  |  |  237|    475|#define SC_LOG_RV(fmt, rv)\
  |  |  238|    475|do {\
  |  |  239|    475|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|    475|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 475, False: 0]
  |  |  ------------------
  |  |  241|    475|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|    475|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|    475|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|    475|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 475]
  |  |  ------------------
  ------------------
  698|    475|	sc_pkcs11_unlock();
  699|    475|	return rv;
  700|    263|}
C_Sign:
  709|    238|{
  710|    238|	CK_RV rv;
  711|    238|	struct sc_pkcs11_session *session;
  712|    238|	CK_ULONG length;
  713|       |
  714|    238|	rv = sc_pkcs11_lock();
  715|    238|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    238|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (715:6): [True: 0, False: 238]
  ------------------
  716|      0|		return rv;
  717|       |
  718|    238|	rv = get_session(hSession, &session);
  719|    238|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    238|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (719:6): [True: 0, False: 238]
  ------------------
  720|      0|		goto out;
  721|       |
  722|       |	/* According to the pkcs11 specs, we must not do any calls that
  723|       |	 * change our crypto state if the caller is just asking for the
  724|       |	 * signature buffer size, or if the result would be
  725|       |	 * CKR_BUFFER_TOO_SMALL. Thus we cannot do the sign_update call
  726|       |	 * below. */
  727|    238|	if ((rv = sc_pkcs11_sign_size(session, &length)) != CKR_OK)
  ------------------
  |  | 1086|    238|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (727:6): [True: 0, False: 238]
  ------------------
  728|      0|		goto out;
  729|       |
  730|    238|	if (pSignature == NULL || length > *pulSignatureLen) {
  ------------------
  |  Branch (730:6): [True: 0, False: 238]
  |  Branch (730:28): [True: 0, False: 238]
  ------------------
  731|      0|		*pulSignatureLen = length;
  732|      0|		rv = pSignature ? CKR_BUFFER_TOO_SMALL : CKR_OK;
  ------------------
  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
              		rv = pSignature ? CKR_BUFFER_TOO_SMALL : CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (732:8): [True: 0, False: 0]
  ------------------
  733|      0|		goto out;
  734|      0|	}
  735|       |
  736|    238|	rv = sc_pkcs11_sign_update(session, pData, ulDataLen);
  737|    238|	if (rv == CKR_OK) {
  ------------------
  |  | 1086|    238|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (737:6): [True: 238, False: 0]
  ------------------
  738|    238|		rv = restore_login_state(session->slot);
  739|    238|		if (rv == CKR_OK)
  ------------------
  |  | 1086|    238|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (739:7): [True: 238, False: 0]
  ------------------
  740|    238|			rv = sc_pkcs11_sign_final(session, pSignature, pulSignatureLen);
  741|    238|		rv = reset_login_state(session->slot, rv);
  742|    238|	}
  743|       |
  744|    238|out:
  745|       |	SC_LOG_RV("C_Sign() = %s", rv);
  ------------------
  |  |  237|    238|#define SC_LOG_RV(fmt, rv)\
  |  |  238|    238|do {\
  |  |  239|    238|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|    238|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 238, False: 0]
  |  |  ------------------
  |  |  241|    238|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|    238|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|    238|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|    238|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 238]
  |  |  ------------------
  ------------------
  746|    238|	sc_pkcs11_unlock();
  747|    238|	return rv;
  748|    238|}
C_SignUpdate:
  755|     24|{
  756|     24|	CK_RV rv;
  757|     24|	struct sc_pkcs11_session *session;
  758|       |
  759|     24|	rv = sc_pkcs11_lock();
  760|     24|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     24|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (760:6): [True: 0, False: 24]
  ------------------
  761|      0|		return rv;
  762|       |
  763|     24|	rv = get_session(hSession, &session);
  764|     24|	if (rv == CKR_OK)
  ------------------
  |  | 1086|     24|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (764:6): [True: 24, False: 0]
  ------------------
  765|     24|		rv = sc_pkcs11_sign_update(session, pPart, ulPartLen);
  766|       |
  767|       |	SC_LOG_RV("C_SignUpdate() = %s", rv);
  ------------------
  |  |  237|     24|#define SC_LOG_RV(fmt, rv)\
  |  |  238|     24|do {\
  |  |  239|     24|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|     24|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 24, False: 0]
  |  |  ------------------
  |  |  241|     24|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|     24|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|     24|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|     24|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 24]
  |  |  ------------------
  ------------------
  768|     24|	sc_pkcs11_unlock();
  769|     24|	return rv;
  770|     24|}
C_SignFinal:
  777|      7|{
  778|      7|	struct sc_pkcs11_session *session;
  779|      7|	CK_ULONG length;
  780|      7|	CK_RV rv;
  781|       |
  782|      7|	rv = sc_pkcs11_lock();
  783|      7|	if (rv != CKR_OK)
  ------------------
  |  | 1086|      7|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (783:6): [True: 0, False: 7]
  ------------------
  784|      0|		return rv;
  785|       |
  786|      7|	rv = get_session(hSession, &session);
  787|      7|	if (rv != CKR_OK)
  ------------------
  |  | 1086|      7|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (787:6): [True: 0, False: 7]
  ------------------
  788|      0|		goto out;
  789|       |
  790|       |	/* According to the pkcs11 specs, we must not do any calls that
  791|       |	 * change our crypto state if the caller is just asking for the
  792|       |	 * signature buffer size, or if the result would be
  793|       |	 * CKR_BUFFER_TOO_SMALL.
  794|       |	 */
  795|      7|	if ((rv = sc_pkcs11_sign_size(session, &length)) != CKR_OK)
  ------------------
  |  | 1086|      7|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (795:6): [True: 0, False: 7]
  ------------------
  796|      0|		goto out;
  797|       |
  798|      7|	if (pSignature == NULL || length > *pulSignatureLen) {
  ------------------
  |  Branch (798:6): [True: 0, False: 7]
  |  Branch (798:28): [True: 0, False: 7]
  ------------------
  799|      0|		*pulSignatureLen = length;
  800|      0|		rv = pSignature ? CKR_BUFFER_TOO_SMALL : CKR_OK;
  ------------------
  |  | 1165|      0|#define CKR_BUFFER_TOO_SMALL 0x00000150UL
  ------------------
              		rv = pSignature ? CKR_BUFFER_TOO_SMALL : CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (800:8): [True: 0, False: 0]
  ------------------
  801|      7|	} else {
  802|      7|		rv = restore_login_state(session->slot);
  803|      7|		if (rv == CKR_OK)
  ------------------
  |  | 1086|      7|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (803:7): [True: 7, False: 0]
  ------------------
  804|      7|			rv = sc_pkcs11_sign_final(session, pSignature, pulSignatureLen);
  805|      7|		rv = reset_login_state(session->slot, rv);
  806|      7|	}
  807|       |
  808|      7|out:
  809|       |	SC_LOG_RV("C_SignFinal() = %s", rv);
  ------------------
  |  |  237|      7|#define SC_LOG_RV(fmt, rv)\
  |  |  238|      7|do {\
  |  |  239|      7|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|      7|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 7, False: 0]
  |  |  ------------------
  |  |  241|      7|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|      7|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|      7|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|      7|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 7]
  |  |  ------------------
  ------------------
  810|      7|	sc_pkcs11_unlock();
  811|      7|	return rv;
  812|      7|}
C_DecryptInit:
  961|    362|{				/* handle of the decryption key */
  962|    362|	CK_BBOOL can_decrypt, can_unwrap;
  963|    362|	CK_KEY_TYPE key_type;
  964|    362|	CK_ATTRIBUTE decrypt_attribute = { CKA_DECRYPT,	&can_decrypt,	sizeof(can_decrypt) };
  ------------------
  |  |  164|    362|#define CKA_DECRYPT 0x00000105UL
  ------------------
  965|    362|	CK_ATTRIBUTE key_type_attr = { CKA_KEY_TYPE,	&key_type,	sizeof(key_type) };
  ------------------
  |  |  159|    362|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
  966|    362|	CK_ATTRIBUTE unwrap_attribute = { CKA_UNWRAP,	&can_unwrap,	sizeof(can_unwrap) };
  ------------------
  |  |  166|    362|#define CKA_UNWRAP 0x00000107UL
  ------------------
  967|    362|	struct sc_pkcs11_session *session;
  968|    362|	struct sc_pkcs11_object *object;
  969|    362|	CK_RV rv;
  970|       |
  971|    362|	if (pMechanism == NULL_PTR)
  ------------------
  |  |   27|    362|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (971:6): [True: 0, False: 362]
  ------------------
  972|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  973|       |
  974|    362|	rv = sc_pkcs11_lock();
  975|    362|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    362|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (975:6): [True: 0, False: 362]
  ------------------
  976|      0|		return rv;
  977|       |
  978|    362|	rv = get_object_from_session(hSession, hKey, &session, &object);
  979|    362|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|    362|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (979:6): [True: 0, False: 362]
  ------------------
  980|      0|		if (rv == CKR_OBJECT_HANDLE_INVALID)
  ------------------
  |  | 1124|      0|#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL
  ------------------
  |  Branch (980:7): [True: 0, False: 0]
  ------------------
  981|      0|			rv = CKR_KEY_HANDLE_INVALID;
  ------------------
  |  | 1112|      0|#define CKR_KEY_HANDLE_INVALID 0x00000060UL
  ------------------
  982|      0|		goto out;
  983|      0|	}
  984|       |
  985|    362|	if (object->ops->decrypt == NULL_PTR) {
  ------------------
  |  |   27|    362|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (985:6): [True: 0, False: 362]
  ------------------
  986|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  987|      0|		goto out;
  988|      0|	}
  989|       |
  990|    362|	rv = object->ops->get_attribute(session, object, &decrypt_attribute);
  991|    362|	if (rv != CKR_OK || !can_decrypt) {
  ------------------
  |  | 1086|    724|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (991:6): [True: 0, False: 362]
  |  Branch (991:22): [True: 127, False: 235]
  ------------------
  992|       |		/* Also accept UNWRAP - apps call Decrypt when they mean Unwrap */
  993|    127|		rv = object->ops->get_attribute(session, object, &unwrap_attribute);
  994|    127|		if (rv != CKR_OK || !can_unwrap) {
  ------------------
  |  | 1086|    254|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (994:7): [True: 0, False: 127]
  |  Branch (994:23): [True: 116, False: 11]
  ------------------
  995|    116|			rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|    116|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
  996|    116|			goto out;
  997|    116|		}
  998|    127|	}
  999|    246|	rv = object->ops->get_attribute(session, object, &key_type_attr);
 1000|    246|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|    246|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1000:6): [True: 0, False: 246]
  ------------------
 1001|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
 1002|      0|		goto out;
 1003|      0|	}
 1004|       |
 1005|    246|	rv = sc_pkcs11_decr_init(session, pMechanism, object, key_type);
 1006|       |
 1007|    362|out:
 1008|       |	SC_LOG_RV("C_DecryptInit() = %s", rv);
  ------------------
  |  |  237|    362|#define SC_LOG_RV(fmt, rv)\
  |  |  238|    362|do {\
  |  |  239|    362|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|    362|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 362, False: 0]
  |  |  ------------------
  |  |  241|    362|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|    362|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|    362|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|    362|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 362]
  |  |  ------------------
  ------------------
 1009|    362|	sc_pkcs11_unlock();
 1010|    362|	return rv;
 1011|    246|}
C_Decrypt:
 1019|    204|{
 1020|    204|	CK_RV rv;
 1021|    204|	struct sc_pkcs11_session *session;
 1022|       |
 1023|    204|	rv = sc_pkcs11_lock();
 1024|    204|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    204|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1024:6): [True: 0, False: 204]
  ------------------
 1025|      0|		return rv;
 1026|       |
 1027|    204|	rv = get_session(hSession, &session);
 1028|    204|	if (rv == CKR_OK) {
  ------------------
  |  | 1086|    204|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1028:6): [True: 204, False: 0]
  ------------------
 1029|    204|		rv = restore_login_state(session->slot);
 1030|    204|		if (rv == CKR_OK) {
  ------------------
  |  | 1086|    204|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1030:7): [True: 204, False: 0]
  ------------------
 1031|    204|			rv = sc_pkcs11_decr(session, pEncryptedData,
 1032|    204|					ulEncryptedDataLen, pData, pulDataLen);
 1033|    204|		}
 1034|    204|		rv = reset_login_state(session->slot, rv);
 1035|    204|	}
 1036|       |
 1037|       |	/* do not log error code to prevent side channel attack */
 1038|    204|	SC_LOG("C_Decrypt()");
  ------------------
  |  |  254|    204|	do { \
  |  |  255|    204|		sc_log(context, (fmt)); \
  |  |  ------------------
  |  |  |  |   71|    204|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  256|    204|	} while (0)
  |  |  ------------------
  |  |  |  Branch (256:11): [Folded, False: 204]
  |  |  ------------------
  ------------------
 1039|    204|	sc_pkcs11_unlock();
 1040|    204|	return rv;
 1041|    204|}
C_GenerateKeyPair:
 1150|    251|{				/* gets priv. key handle */
 1151|    251|	CK_RV rv;
 1152|    251|	struct sc_pkcs11_session *session;
 1153|    251|	struct sc_pkcs11_slot *slot;
 1154|       |
 1155|    251|	if (pMechanism == NULL_PTR
  ------------------
  |  |   27|    502|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (1155:6): [True: 0, False: 251]
  ------------------
 1156|    251|			|| (pPublicKeyTemplate == NULL_PTR && ulPublicKeyAttributeCount > 0)
  ------------------
  |  |   27|    502|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (1156:8): [True: 0, False: 251]
  |  Branch (1156:42): [True: 0, False: 0]
  ------------------
 1157|    251|			|| (pPrivateKeyTemplate == NULL_PTR && ulPrivateKeyAttributeCount > 0))
  ------------------
  |  |   27|    502|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (1157:8): [True: 0, False: 251]
  |  Branch (1157:43): [True: 0, False: 0]
  ------------------
 1158|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
 1159|       |
 1160|    251|	rv = sc_pkcs11_lock();
 1161|    251|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    251|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1161:6): [True: 0, False: 251]
  ------------------
 1162|      0|		return rv;
 1163|       |
 1164|    251|	dump_template(SC_LOG_DEBUG_NORMAL, "C_GenerateKeyPair(), PrivKey attrs", pPrivateKeyTemplate, ulPrivateKeyAttributeCount);
  ------------------
  |  |  411|    251|		sc_pkcs11_print_attrs(level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  412|    251|				info, pTemplate, ulCount)
  ------------------
 1165|    251|	dump_template(SC_LOG_DEBUG_NORMAL, "C_GenerateKeyPair(), PubKey attrs", pPublicKeyTemplate, ulPublicKeyAttributeCount);
  ------------------
  |  |  411|    251|		sc_pkcs11_print_attrs(level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  412|    251|				info, pTemplate, ulCount)
  ------------------
 1166|       |
 1167|    251|	rv = get_session(hSession, &session);
 1168|    251|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    251|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1168:6): [True: 0, False: 251]
  ------------------
 1169|      0|		goto out;
 1170|       |
 1171|    251|	if (!(session->flags & CKF_RW_SESSION)) {
  ------------------
  |  |  402|    251|#define CKF_RW_SESSION 0x00000002UL
  ------------------
  |  Branch (1171:6): [True: 0, False: 251]
  ------------------
 1172|      0|		rv = CKR_SESSION_READ_ONLY;
  ------------------
  |  | 1136|      0|#define CKR_SESSION_READ_ONLY 0x000000B5UL
  ------------------
 1173|      0|		goto out;
 1174|      0|	}
 1175|       |
 1176|    251|	slot = session->slot;
 1177|    251|	if (slot == NULL || slot->p11card == NULL || slot->p11card->framework == NULL
  ------------------
  |  Branch (1177:6): [True: 0, False: 251]
  |  Branch (1177:22): [True: 0, False: 251]
  |  Branch (1177:47): [True: 0, False: 251]
  ------------------
 1178|    251|			|| slot->p11card->framework->gen_keypair == NULL)
  ------------------
  |  Branch (1178:7): [True: 0, False: 251]
  ------------------
 1179|      0|		rv = CKR_FUNCTION_NOT_SUPPORTED;
  ------------------
  |  | 1111|      0|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
 1180|    251|	else {
 1181|    251|		rv = restore_login_state(slot);
 1182|    251|		if (rv == CKR_OK)
  ------------------
  |  | 1086|    251|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1182:7): [True: 251, False: 0]
  ------------------
 1183|    251|			rv = slot->p11card->framework->gen_keypair(slot, pMechanism,
 1184|    251|					pPublicKeyTemplate, ulPublicKeyAttributeCount,
 1185|    251|					pPrivateKeyTemplate, ulPrivateKeyAttributeCount,
 1186|    251|					phPublicKey, phPrivateKey);
 1187|    251|		rv = reset_login_state(session->slot, rv);
 1188|    251|	}
 1189|       |
 1190|    251|out:
 1191|    251|	sc_pkcs11_unlock();
 1192|    251|	return rv;
 1193|    251|}
C_UnwrapKey:
 1278|      2|{				/* gets handle of recovered key */
 1279|      2|	CK_RV rv;
 1280|      2|	CK_BBOOL can_unwrap;
 1281|      2|	CK_KEY_TYPE key_type;
 1282|      2|	CK_ATTRIBUTE unwrap_attribute = { CKA_UNWRAP, &can_unwrap, sizeof(can_unwrap) };
  ------------------
  |  |  166|      2|#define CKA_UNWRAP 0x00000107UL
  ------------------
 1283|      2|	CK_ATTRIBUTE key_type_attr = { CKA_KEY_TYPE, &key_type, sizeof(key_type) };
  ------------------
  |  |  159|      2|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
 1284|      2|	struct sc_pkcs11_session *session;
 1285|      2|	struct sc_pkcs11_object *object;
 1286|      2|	struct sc_pkcs11_object *key_object;
 1287|       |
 1288|      2|	if (pMechanism == NULL_PTR)
  ------------------
  |  |   27|      2|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (1288:6): [True: 0, False: 2]
  ------------------
 1289|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
 1290|       |
 1291|      2|	rv = sc_pkcs11_lock();
 1292|      2|	if (rv != CKR_OK)
  ------------------
  |  | 1086|      2|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1292:6): [True: 0, False: 2]
  ------------------
 1293|      0|		return rv;
 1294|       |
 1295|      2|	rv = get_object_from_session(hSession, hUnwrappingKey, &session, &object);
 1296|      2|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|      2|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1296:6): [True: 0, False: 2]
  ------------------
 1297|      0|		if (rv == CKR_OBJECT_HANDLE_INVALID)
  ------------------
  |  | 1124|      0|#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL
  ------------------
  |  Branch (1297:7): [True: 0, False: 0]
  ------------------
 1298|      0|			rv = CKR_KEY_HANDLE_INVALID;
  ------------------
  |  | 1112|      0|#define CKR_KEY_HANDLE_INVALID 0x00000060UL
  ------------------
 1299|      0|		goto out;
 1300|      0|	}
 1301|      2|	if (object->ops->unwrap_key == NULL_PTR) {
  ------------------
  |  |   27|      2|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (1301:6): [True: 0, False: 2]
  ------------------
 1302|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
 1303|      0|		goto out;
 1304|      0|	}
 1305|       |
 1306|      2|	rv = object->ops->get_attribute(session, object, &unwrap_attribute);
 1307|      2|	if (rv != CKR_OK || !can_unwrap) {
  ------------------
  |  | 1086|      4|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1307:6): [True: 0, False: 2]
  |  Branch (1307:22): [True: 1, False: 1]
  ------------------
 1308|      1|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      1|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
 1309|      1|		goto out;
 1310|      1|	}
 1311|      1|	rv = object->ops->get_attribute(session, object, &key_type_attr);
 1312|      1|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|      1|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1312:6): [True: 0, False: 1]
  ------------------
 1313|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
 1314|      0|		goto out;
 1315|      0|	}
 1316|       |
 1317|       |	/* Create the target object in memory */
 1318|      1|	rv = sc_create_object_int(hSession, pTemplate, ulAttributeCount, phKey, 0);
 1319|       |
 1320|      1|	if (rv != CKR_OK)
  ------------------
  |  | 1086|      1|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1320:6): [True: 1, False: 0]
  ------------------
 1321|      1|	    goto out;
 1322|       |
 1323|      0|	rv = get_object_from_session(hSession, *phKey, &session, &key_object);
 1324|      0|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1324:6): [True: 0, False: 0]
  ------------------
 1325|      0|		if (rv == CKR_OBJECT_HANDLE_INVALID)
  ------------------
  |  | 1124|      0|#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL
  ------------------
  |  Branch (1325:7): [True: 0, False: 0]
  ------------------
 1326|      0|			rv = CKR_KEY_HANDLE_INVALID;
  ------------------
  |  | 1112|      0|#define CKR_KEY_HANDLE_INVALID 0x00000060UL
  ------------------
 1327|      0|		goto out;
 1328|      0|	}
 1329|       |
 1330|      0|	rv = restore_login_state(session->slot);
 1331|      0|	if (rv == CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1331:6): [True: 0, False: 0]
  ------------------
 1332|      0|		rv = sc_pkcs11_unwrap(session, pMechanism, object, key_type,
 1333|      0|				pWrappedKey, ulWrappedKeyLen, key_object);
 1334|       |	/* TODO if (rv != CK_OK) need to destroy the object */
 1335|      0|	rv = reset_login_state(session->slot, rv);
 1336|       |
 1337|      2|out:
 1338|      2|	sc_pkcs11_unlock();
 1339|      2|	return rv;
 1340|      0|}
C_DeriveKey:
 1348|      2|{
 1349|       |/* TODO: -DEE ECDH with Cofactor  on PIV is an example */
 1350|       |/* TODO: need to do a lot of checking, will only support ECDH for now.*/
 1351|      2|	CK_RV rv;
 1352|      2|	CK_BBOOL can_derive;
 1353|      2|	CK_KEY_TYPE key_type;
 1354|      2|	CK_ATTRIBUTE derive_attribute = { CKA_DERIVE, &can_derive, sizeof(can_derive) };
  ------------------
  |  |  171|      2|#define CKA_DERIVE 0x0000010CUL
  ------------------
 1355|      2|	CK_ATTRIBUTE key_type_attr = { CKA_KEY_TYPE, &key_type, sizeof(key_type) };
  ------------------
  |  |  159|      2|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
 1356|      2|	struct sc_pkcs11_session *session;
 1357|      2|	struct sc_pkcs11_object *object;
 1358|      2|	struct sc_pkcs11_object *key_object;
 1359|       |
 1360|      2|	if (pMechanism == NULL_PTR)
  ------------------
  |  |   27|      2|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (1360:6): [True: 0, False: 2]
  ------------------
 1361|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
 1362|       |
 1363|      2|	rv = sc_pkcs11_lock();
 1364|      2|	if (rv != CKR_OK)
  ------------------
  |  | 1086|      2|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1364:6): [True: 0, False: 2]
  ------------------
 1365|      0|		return rv;
 1366|       |
 1367|      2|	rv = get_object_from_session(hSession, hBaseKey, &session, &object);
 1368|      2|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|      2|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1368:6): [True: 0, False: 2]
  ------------------
 1369|      0|		if (rv == CKR_OBJECT_HANDLE_INVALID)
  ------------------
  |  | 1124|      0|#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL
  ------------------
  |  Branch (1369:7): [True: 0, False: 0]
  ------------------
 1370|      0|			rv = CKR_KEY_HANDLE_INVALID;
  ------------------
  |  | 1112|      0|#define CKR_KEY_HANDLE_INVALID 0x00000060UL
  ------------------
 1371|      0|		goto out;
 1372|      0|	}
 1373|       |
 1374|      2|	if (object->ops->derive == NULL_PTR) {
  ------------------
  |  |   27|      2|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (1374:6): [True: 0, False: 2]
  ------------------
 1375|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
 1376|      0|		goto out;
 1377|      0|	}
 1378|       |
 1379|      2|	rv = object->ops->get_attribute(session, object, &derive_attribute);
 1380|      2|	if (rv != CKR_OK || !can_derive) {
  ------------------
  |  | 1086|      4|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1380:6): [True: 0, False: 2]
  |  Branch (1380:22): [True: 1, False: 1]
  ------------------
 1381|      1|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      1|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
 1382|      1|		goto out;
 1383|      1|	}
 1384|      1|	rv = object->ops->get_attribute(session, object, &key_type_attr);
 1385|      1|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|      1|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1385:6): [True: 0, False: 1]
  ------------------
 1386|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
 1387|      0|		goto out;
 1388|      0|	}
 1389|       |	/* TODO DEE Should also check SENSITIVE, ALWAYS_SENSITIVE, EXTRACTABLE,
 1390|       |	   NEVER_EXTRACTABLE of the BaseKey against the template for the newkey.
 1391|       |	*/
 1392|       |
 1393|      1|	switch(key_type) {
 1394|      0|	    case CKK_EC:
  ------------------
  |  |  467|      0|#define CKK_EC 0x00000003UL
  ------------------
  |  Branch (1394:6): [True: 0, False: 1]
  ------------------
 1395|      0|	    case CKK_EC_MONTGOMERY:
  ------------------
  |  |  519|      0|#define CKK_EC_MONTGOMERY 0x00000041UL
  ------------------
  |  Branch (1395:6): [True: 0, False: 1]
  ------------------
 1396|       |
 1397|      0|		rv = sc_create_object_int(hSession, pTemplate, ulAttributeCount, phKey, 0);
 1398|      0|		if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1398:7): [True: 0, False: 0]
  ------------------
 1399|      0|		    goto out;
 1400|       |
 1401|      0|		rv = get_object_from_session(hSession, *phKey, &session, &key_object);
 1402|      0|		if (rv != CKR_OK) {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1402:7): [True: 0, False: 0]
  ------------------
 1403|      0|			if (rv == CKR_OBJECT_HANDLE_INVALID)
  ------------------
  |  | 1124|      0|#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL
  ------------------
  |  Branch (1403:8): [True: 0, False: 0]
  ------------------
 1404|      0|				rv = CKR_KEY_HANDLE_INVALID;
  ------------------
  |  | 1112|      0|#define CKR_KEY_HANDLE_INVALID 0x00000060UL
  ------------------
 1405|      0|			goto out;
 1406|      0|		}
 1407|       |
 1408|      0|		rv = restore_login_state(session->slot);
 1409|      0|		if (rv == CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1409:7): [True: 0, False: 0]
  ------------------
 1410|      0|			rv = sc_pkcs11_deri(session, pMechanism, object, key_type,
 1411|      0|					hSession, *phKey, key_object);
 1412|       |		/* TODO if (rv != CK_OK) need to destroy the object */
 1413|      0|		rv = reset_login_state(session->slot, rv);
 1414|       |
 1415|      0|		break;
 1416|      1|	    default:
  ------------------
  |  Branch (1416:6): [True: 1, False: 0]
  ------------------
 1417|      1|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      1|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
 1418|      1|	}
 1419|       |
 1420|      2|out:
 1421|      2|	sc_pkcs11_unlock();
 1422|      2|	return rv;
 1423|      1|}
C_GenerateRandom:
 1435|  7.86k|{				/* number of bytes to be generated */
 1436|  7.86k|	CK_RV rv;
 1437|  7.86k|	struct sc_pkcs11_session *session;
 1438|  7.86k|	struct sc_pkcs11_slot *slot;
 1439|       |
 1440|  7.86k|	rv = sc_pkcs11_lock();
 1441|  7.86k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  7.86k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1441:6): [True: 0, False: 7.86k]
  ------------------
 1442|      0|		return rv;
 1443|       |
 1444|  7.86k|	rv = get_session(hSession, &session);
 1445|  7.86k|	if (rv == CKR_OK) {
  ------------------
  |  | 1086|  7.86k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1445:6): [True: 7.86k, False: 0]
  ------------------
 1446|  7.86k|		slot = session->slot;
 1447|  7.86k|		if (slot == NULL || slot->p11card == NULL || slot->p11card->framework == NULL
  ------------------
  |  Branch (1447:7): [True: 0, False: 7.86k]
  |  Branch (1447:23): [True: 0, False: 7.86k]
  |  Branch (1447:48): [True: 0, False: 7.86k]
  ------------------
 1448|  7.86k|				|| slot->p11card->framework->get_random == NULL)
  ------------------
  |  Branch (1448:8): [True: 0, False: 7.86k]
  ------------------
 1449|      0|			rv = CKR_RANDOM_NO_RNG;
  ------------------
  |  | 1162|      0|#define CKR_RANDOM_NO_RNG 0x00000121UL
  ------------------
 1450|  7.86k|		else
 1451|  7.86k|			rv = slot->p11card->framework->get_random(slot, RandomData, ulRandomLen);
 1452|  7.86k|	}
 1453|       |
 1454|       |	SC_LOG_RV("C_GenerateRandom() = %s", rv);
  ------------------
  |  |  237|  7.86k|#define SC_LOG_RV(fmt, rv)\
  |  |  238|  7.86k|do {\
  |  |  239|  7.86k|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|  7.86k|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 7.86k, False: 0]
  |  |  ------------------
  |  |  241|  7.86k|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|  7.86k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|  7.86k|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|  7.86k|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 7.86k]
  |  |  ------------------
  ------------------
 1455|  7.86k|	sc_pkcs11_unlock();
 1456|  7.86k|	return rv;
 1457|  7.86k|}
C_VerifyInit:
 1472|     74|{				/* handle of the verification key */
 1473|       |#ifndef ENABLE_OPENSSL
 1474|       |	return CKR_FUNCTION_NOT_SUPPORTED;
 1475|       |#else
 1476|     74|	CK_KEY_TYPE key_type;
 1477|     74|	CK_ATTRIBUTE key_type_attr = { CKA_KEY_TYPE, &key_type, sizeof(key_type) };
  ------------------
  |  |  159|     74|#define CKA_KEY_TYPE 0x00000100UL
  ------------------
 1478|     74|	CK_RV rv;
 1479|     74|	struct sc_pkcs11_session *session;
 1480|     74|	struct sc_pkcs11_object *object;
 1481|       |
 1482|     74|	if (pMechanism == NULL_PTR)
  ------------------
  |  |   27|     74|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (1482:6): [True: 0, False: 74]
  ------------------
 1483|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
 1484|       |
 1485|     74|	rv = sc_pkcs11_lock();
 1486|     74|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     74|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1486:6): [True: 0, False: 74]
  ------------------
 1487|      0|		return rv;
 1488|       |
 1489|       |
 1490|     74|	rv = get_object_from_session(hSession, hKey, &session, &object);
 1491|     74|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|     74|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1491:6): [True: 0, False: 74]
  ------------------
 1492|      0|		if (rv == CKR_OBJECT_HANDLE_INVALID)
  ------------------
  |  | 1124|      0|#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL
  ------------------
  |  Branch (1492:7): [True: 0, False: 0]
  ------------------
 1493|      0|			rv = CKR_KEY_HANDLE_INVALID;
  ------------------
  |  | 1112|      0|#define CKR_KEY_HANDLE_INVALID 0x00000060UL
  ------------------
 1494|      0|		goto out;
 1495|      0|	}
 1496|     74|	rv = object->ops->get_attribute(session, object, &key_type_attr);
 1497|     74|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|     74|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1497:6): [True: 0, False: 74]
  ------------------
 1498|      0|		rv = CKR_KEY_TYPE_INCONSISTENT;
  ------------------
  |  | 1114|      0|#define CKR_KEY_TYPE_INCONSISTENT 0x00000063UL
  ------------------
 1499|      0|		goto out;
 1500|      0|	}
 1501|       |
 1502|     74|	rv = sc_pkcs11_verif_init(session, pMechanism, object, key_type);
 1503|       |
 1504|     74|out:
 1505|       |	SC_LOG_RV("C_VerifyInit() = %s", rv);
  ------------------
  |  |  237|     74|#define SC_LOG_RV(fmt, rv)\
  |  |  238|     74|do {\
  |  |  239|     74|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|     74|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 74, False: 0]
  |  |  ------------------
  |  |  241|     74|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|     74|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|     74|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|     74|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 74]
  |  |  ------------------
  ------------------
 1506|     74|	sc_pkcs11_unlock();
 1507|     74|	return rv;
 1508|     74|#endif
 1509|     74|}
C_Verify:
 1516|     49|{				/* count of bytes of signature */
 1517|       |#ifndef ENABLE_OPENSSL
 1518|       |	return CKR_FUNCTION_NOT_SUPPORTED;
 1519|       |#else
 1520|     49|	CK_RV rv;
 1521|     49|	struct sc_pkcs11_session *session;
 1522|       |
 1523|     49|	rv = sc_pkcs11_lock();
 1524|     49|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1524:6): [True: 0, False: 49]
  ------------------
 1525|      0|		return rv;
 1526|       |
 1527|     49|	rv = get_session(hSession, &session);
 1528|     49|	if (rv != CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1528:6): [True: 0, False: 49]
  ------------------
 1529|      0|		goto out;
 1530|       |
 1531|     49|	rv = sc_pkcs11_verif_update(session, pData, ulDataLen);
 1532|     49|	if (rv == CKR_OK) {
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1532:6): [True: 49, False: 0]
  ------------------
 1533|     49|		rv = restore_login_state(session->slot);
 1534|     49|		if (rv == CKR_OK)
  ------------------
  |  | 1086|     49|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1534:7): [True: 49, False: 0]
  ------------------
 1535|     49|			rv = sc_pkcs11_verif_final(session, pSignature, ulSignatureLen);
 1536|     49|		rv = reset_login_state(session->slot, rv);
 1537|     49|	}
 1538|       |
 1539|     49|out:
 1540|       |	SC_LOG_RV("C_Verify() = %s", rv);
  ------------------
  |  |  237|     49|#define SC_LOG_RV(fmt, rv)\
  |  |  238|     49|do {\
  |  |  239|     49|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|     49|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 49, False: 0]
  |  |  ------------------
  |  |  241|     49|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|     49|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|     49|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|     49|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 49]
  |  |  ------------------
  ------------------
 1541|     49|	sc_pkcs11_unlock();
 1542|     49|	return rv;
 1543|     49|#endif
 1544|     49|}
sc_pkcs11_any_cmp_attribute:
 1909|  16.4k|{
 1910|  16.4k|	CK_RV rv;
 1911|  16.4k|	struct sc_pkcs11_object *object;
 1912|  16.4k|	u8 temp1[1024];
 1913|  16.4k|	u8 *temp2 = NULL;	/* dynamic allocation for large attributes */
 1914|  16.4k|	CK_ATTRIBUTE temp_attr;
 1915|       |
 1916|  16.4k|	object = (struct sc_pkcs11_object *)ptr;
 1917|  16.4k|	temp_attr.type = attr->type;
 1918|  16.4k|	temp_attr.pValue = NULL;
 1919|  16.4k|	temp_attr.ulValueLen = 0;
 1920|       |
 1921|       |	/* Get the length of the attribute */
 1922|  16.4k|	rv = object->ops->get_attribute(session, object, &temp_attr);
 1923|  16.4k|	if (rv != CKR_OK || temp_attr.ulValueLen != attr->ulValueLen)
  ------------------
  |  | 1086|  32.8k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1923:6): [True: 0, False: 16.4k]
  |  Branch (1923:22): [True: 97, False: 16.3k]
  ------------------
 1924|     97|		return 0;
 1925|       |
 1926|  16.3k|	if (temp_attr.ulValueLen <= sizeof(temp1))
  ------------------
  |  Branch (1926:6): [True: 16.3k, False: 0]
  ------------------
 1927|  16.3k|		temp_attr.pValue = temp1;
 1928|      0|	else {
 1929|      0|		temp2 = calloc(1, temp_attr.ulValueLen);
 1930|      0|		if (temp2 == NULL)
  ------------------
  |  Branch (1930:7): [True: 0, False: 0]
  ------------------
 1931|      0|			return 0;
 1932|      0|		temp_attr.pValue = temp2;
 1933|      0|	}
 1934|       |
 1935|       |	/* Get the attribute */
 1936|  16.3k|	rv = object->ops->get_attribute(session, object, &temp_attr);
 1937|  16.3k|	if (rv != CKR_OK) {
  ------------------
  |  | 1086|  16.3k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1937:6): [True: 0, False: 16.3k]
  ------------------
 1938|      0|		rv = 0;
 1939|      0|		goto done;
 1940|      0|	}
 1941|       |#ifdef DEBUG
 1942|       |	{
 1943|       |		char foo[64];
 1944|       |
 1945|       |		snprintf(foo, sizeof(foo), "Object %p (slot 0x%lx)", object, session->slot->id);
 1946|       |		dump_template(SC_LOG_DEBUG_NORMAL, foo, &temp_attr, 1);
 1947|       |	}
 1948|       |#endif
 1949|  16.3k|	rv = temp_attr.ulValueLen == attr->ulValueLen
  ------------------
  |  Branch (1949:7): [True: 16.3k, False: 0]
  ------------------
 1950|  16.3k|	    && !memcmp(temp_attr.pValue, attr->pValue, attr->ulValueLen);
  ------------------
  |  Branch (1950:9): [True: 2.61k, False: 13.7k]
  ------------------
 1951|       |
 1952|  16.3k|      done:
 1953|  16.3k|	if (temp2 != NULL)
  ------------------
  |  Branch (1953:6): [True: 0, False: 16.3k]
  ------------------
 1954|      0|		free(temp2);
 1955|       |
 1956|  16.3k|	return rv;
 1957|  16.3k|}
pkcs11-object.c:sc_create_object_int:
  102|    320|{
  103|    320|	CK_RV rv = CKR_OK;
  ------------------
  |  | 1086|    320|#define CKR_OK 0x00000000UL
  ------------------
  104|    320|	struct sc_pkcs11_session *session;
  105|    320|	struct sc_pkcs11_card *card;
  106|    320|	CK_BBOOL is_token = FALSE;
  ------------------
  |  |   48|    320|#define FALSE 0
  ------------------
  107|       |
  108|    320|	LOG_FUNC_CALLED(context);
  ------------------
  |  |  151|    320|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    320|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    320|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    320|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 320]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  109|    320|	if (pTemplate == NULL_PTR || ulCount == 0)
  ------------------
  |  |   27|    640|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (109:6): [True: 0, False: 320]
  |  Branch (109:31): [True: 0, False: 320]
  ------------------
  110|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  111|       |
  112|    320|	if (use_lock) {
  ------------------
  |  Branch (112:6): [True: 319, False: 1]
  ------------------
  113|    319|	    rv = sc_pkcs11_lock();
  114|    319|	    if (rv != CKR_OK)
  ------------------
  |  | 1086|    319|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (114:10): [True: 0, False: 319]
  ------------------
  115|      0|		return rv;
  116|    319|	}
  117|       |
  118|    320|	dump_template(SC_LOG_DEBUG_NORMAL, "C_CreateObject()", pTemplate, ulCount);
  ------------------
  |  |  411|    320|		sc_pkcs11_print_attrs(level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  412|    320|				info, pTemplate, ulCount)
  ------------------
  119|       |
  120|    320|	session = list_seek(&sessions, &hSession);
  121|    320|	if (!session) {
  ------------------
  |  Branch (121:6): [True: 0, False: 320]
  ------------------
  122|      0|		rv = CKR_SESSION_HANDLE_INVALID;
  ------------------
  |  | 1134|      0|#define CKR_SESSION_HANDLE_INVALID 0x000000B3UL
  ------------------
  123|      0|		goto out;
  124|      0|	}
  125|       |
  126|    320|	rv = attr_find(pTemplate, ulCount, CKA_TOKEN, &is_token, NULL);
  ------------------
  |  |  138|    320|#define CKA_TOKEN 0x00000001UL
  ------------------
  127|    320|	if (rv != CKR_TEMPLATE_INCOMPLETE && rv != CKR_OK) {
  ------------------
  |  | 1142|    640|#define CKR_TEMPLATE_INCOMPLETE 0x000000D0UL
  ------------------
              	if (rv != CKR_TEMPLATE_INCOMPLETE && rv != CKR_OK) {
  ------------------
  |  | 1086|    320|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (127:6): [True: 320, False: 0]
  |  Branch (127:39): [True: 0, False: 320]
  ------------------
  128|      0|		goto out;
  129|      0|	}
  130|       |
  131|    320|	if (is_token == TRUE) {
  ------------------
  |  |   51|    320|#define TRUE 1
  ------------------
  |  Branch (131:6): [True: 266, False: 54]
  ------------------
  132|    266|		if (session->slot->token_info.flags & CKF_WRITE_PROTECTED) {
  ------------------
  |  |  413|    266|#define CKF_WRITE_PROTECTED 0x00000002UL
  ------------------
  |  Branch (132:7): [True: 1, False: 265]
  ------------------
  133|      1|			rv = CKR_TOKEN_WRITE_PROTECTED;
  ------------------
  |  | 1146|      1|#define CKR_TOKEN_WRITE_PROTECTED 0x000000E2UL
  ------------------
  134|      1|			goto out;
  135|      1|		}
  136|    265|		if (!(session->flags & CKF_RW_SESSION)) {
  ------------------
  |  |  402|    265|#define CKF_RW_SESSION 0x00000002UL
  ------------------
  |  Branch (136:7): [True: 0, False: 265]
  ------------------
  137|      0|			rv = CKR_SESSION_READ_ONLY;
  ------------------
  |  | 1136|      0|#define CKR_SESSION_READ_ONLY 0x000000B5UL
  ------------------
  138|      0|			goto out;
  139|      0|		}
  140|    265|	}
  141|       |
  142|    319|	card = session->slot->p11card;
  143|    319|	if (card->framework->create_object == NULL)
  ------------------
  |  Branch (143:6): [True: 0, False: 319]
  ------------------
  144|      0|		rv = CKR_FUNCTION_NOT_SUPPORTED;
  ------------------
  |  | 1111|      0|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
  145|    319|	else
  146|    319|		rv = card->framework->create_object(session->slot, pTemplate, ulCount, phObject);
  147|       |
  148|    320|out:
  149|    320|	if (use_lock)
  ------------------
  |  Branch (149:6): [True: 319, False: 1]
  ------------------
  150|    319|		sc_pkcs11_unlock();
  151|       |
  152|    320|	return rv;
  153|    319|}
pkcs11-object.c:get_object_from_session:
   78|    915|{
   79|    915|	struct sc_pkcs11_session *sess;
   80|    915|	CK_RV rv;
   81|       |
   82|    915|	rv = get_session(hSession, &sess);
   83|    915|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    915|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (83:6): [True: 0, False: 915]
  ------------------
   84|      0|		return rv;
   85|       |
   86|    915|	*object = list_seek(&sess->slot->objects, &hObject);
   87|    915|	if (!*object)
  ------------------
  |  Branch (87:6): [True: 209, False: 706]
  ------------------
   88|    209|		return CKR_OBJECT_HANDLE_INVALID;
  ------------------
  |  | 1124|    209|#define CKR_OBJECT_HANDLE_INVALID 0x00000082UL
  ------------------
   89|    706|	*session = sess;
   90|    706|	return CKR_OK;
  ------------------
  |  | 1086|    706|#define CKR_OK 0x00000000UL
  ------------------
   91|    915|}
pkcs11-object.c:sc_find_release:
   65|  1.53k|{
   66|  1.53k|	struct sc_pkcs11_find_operation *fop = (struct sc_pkcs11_find_operation *)operation;
   67|       |
   68|  1.53k|	if (fop->handles) {
  ------------------
  |  Branch (68:6): [True: 706, False: 826]
  ------------------
   69|    706|		free(fop->handles);
   70|       |		fop->handles = NULL;
   71|    706|	}
   72|  1.53k|}

get_session:
   31|  14.6k|{
   32|  14.6k|	*session = list_seek(&sessions, &hSession);
   33|  14.6k|	if (!*session)
  ------------------
  |  Branch (33:6): [True: 0, False: 14.6k]
  ------------------
   34|      0|		return CKR_SESSION_HANDLE_INVALID;
  ------------------
  |  | 1134|      0|#define CKR_SESSION_HANDLE_INVALID 0x000000B3UL
  ------------------
   35|  14.6k|	return CKR_OK;
  ------------------
  |  | 1086|  14.6k|#define CKR_OK 0x00000000UL
  ------------------
   36|  14.6k|}
C_OpenSession:
   43|  12.6k|{				/* receives new session handle */
   44|  12.6k|	CK_RV rv;
   45|  12.6k|	struct sc_pkcs11_slot *slot;
   46|  12.6k|	struct sc_pkcs11_session *session;
   47|       |
   48|  12.6k|	if (!(flags & CKF_SERIAL_SESSION))
  ------------------
  |  |  403|  12.6k|#define CKF_SERIAL_SESSION 0x00000004UL
  ------------------
  |  Branch (48:6): [True: 0, False: 12.6k]
  ------------------
   49|      0|		return CKR_SESSION_PARALLEL_NOT_SUPPORTED;
  ------------------
  |  | 1135|      0|#define CKR_SESSION_PARALLEL_NOT_SUPPORTED 0x000000B4UL
  ------------------
   50|       |
   51|  12.6k|	if (flags & ~(CKF_SERIAL_SESSION | CKF_RW_SESSION))
  ------------------
  |  |  403|  12.6k|#define CKF_SERIAL_SESSION 0x00000004UL
  ------------------
              	if (flags & ~(CKF_SERIAL_SESSION | CKF_RW_SESSION))
  ------------------
  |  |  402|  12.6k|#define CKF_RW_SESSION 0x00000002UL
  ------------------
  |  Branch (51:6): [True: 0, False: 12.6k]
  ------------------
   52|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
   53|       |
   54|  12.6k|	rv = sc_pkcs11_lock();
   55|  12.6k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  12.6k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (55:6): [True: 0, False: 12.6k]
  ------------------
   56|      0|		return rv;
   57|       |
   58|  12.6k|	sc_log(context, "C_OpenSession(0x%lx)", slotID);
  ------------------
  |  |   71|  12.6k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   59|       |
   60|  12.6k|	rv = slot_get_token(slotID, &slot);
   61|  12.6k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  12.6k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (61:6): [True: 1.30k, False: 11.3k]
  ------------------
   62|  1.30k|		goto out;
   63|       |
   64|       |	/* Check that no conflicting sessions exist */
   65|  11.3k|	if (!(flags & CKF_RW_SESSION) && (slot->login_user == CKU_SO)) {
  ------------------
  |  |  402|  11.3k|#define CKF_RW_SESSION 0x00000002UL
  ------------------
              	if (!(flags & CKF_RW_SESSION) && (slot->login_user == CKU_SO)) {
  ------------------
  |  | 1210|      0|#define CKU_SO 0UL
  ------------------
  |  Branch (65:6): [True: 0, False: 11.3k]
  |  Branch (65:35): [True: 0, False: 0]
  ------------------
   66|      0|		rv = CKR_SESSION_READ_WRITE_SO_EXISTS;
  ------------------
  |  | 1139|      0|#define CKR_SESSION_READ_WRITE_SO_EXISTS 0x000000B8UL
  ------------------
   67|      0|		goto out;
   68|      0|	}
   69|       |
   70|  11.3k|	session = (struct sc_pkcs11_session *)calloc(1, sizeof(struct sc_pkcs11_session));
   71|  11.3k|	if (session == NULL) {
  ------------------
  |  Branch (71:6): [True: 0, False: 11.3k]
  ------------------
   72|      0|		rv = CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
   73|      0|		goto out;
   74|      0|	}
   75|       |
   76|       |	/* make session handle from pointer and check its uniqueness */
   77|  11.3k|	session->handle = (CK_SESSION_HANDLE)(uintptr_t)session;
   78|  11.3k|	if (list_seek(&sessions, &session->handle) != NULL) {
  ------------------
  |  Branch (78:6): [True: 0, False: 11.3k]
  ------------------
   79|      0|		sc_log(context, "C_OpenSession handle 0x%lx already exists", session->handle);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   80|       |
   81|      0|		free(session);
   82|       |
   83|      0|		rv = CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
   84|      0|		goto out;
   85|      0|	}
   86|       |
   87|  11.3k|	session->slot = slot;
   88|  11.3k|	session->notify_callback = Notify;
   89|  11.3k|	session->notify_data = pApplication;
   90|  11.3k|	session->flags = flags;
   91|  11.3k|	slot->nsessions++;
   92|  11.3k|	list_append(&sessions, session);
   93|  11.3k|	*phSession = session->handle;
   94|  11.3k|	sc_log(context, "C_OpenSession handle: 0x%lx", session->handle);
  ------------------
  |  |   71|  11.3k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   95|       |
   96|  12.6k|out:
   97|       |	SC_LOG_RV("C_OpenSession() = %s", rv);
  ------------------
  |  |  237|  12.6k|#define SC_LOG_RV(fmt, rv)\
  |  |  238|  12.6k|do {\
  |  |  239|  12.6k|        const char *name = lookup_enum(RV_T, (rv));\
  |  |  240|  12.6k|        if (name)\
  |  |  ------------------
  |  |  |  Branch (240:13): [True: 12.6k, False: 0]
  |  |  ------------------
  |  |  241|  12.6k|                sc_log(context, (fmt), name);\
  |  |  ------------------
  |  |  |  |   71|  12.6k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  242|  12.6k|        else {\
  |  |  243|      0|                size_t needed = snprintf(NULL, 0, "0x%08lX", (rv)) + 1;\
  |  |  244|      0|                char *buffer = malloc(needed);\
  |  |  245|      0|                if (buffer) {\
  |  |  ------------------
  |  |  |  Branch (245:21): [True: 0, False: 0]
  |  |  ------------------
  |  |  246|      0|                        sprintf(buffer, "0x%08lX", (rv));\
  |  |  247|      0|                        sc_log(context, (fmt), buffer);\
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  248|      0|                        free(buffer);\
  |  |  249|      0|                }\
  |  |  250|      0|        }\
  |  |  251|  12.6k|} while(0)
  |  |  ------------------
  |  |  |  Branch (251:9): [Folded, False: 12.6k]
  |  |  ------------------
  ------------------
   98|  12.6k|	sc_pkcs11_unlock();
   99|  12.6k|	return rv;
  100|  11.3k|}
sc_pkcs11_close_all_sessions:
  141|  17.0k|{
  142|  17.0k|	CK_RV rv = CKR_OK, error;
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  143|  17.0k|	struct sc_pkcs11_session *session;
  144|  17.0k|	unsigned int i;
  145|  17.0k|	sc_log(context, "real C_CloseAllSessions(0x%lx) %d", slotID, list_size(&sessions));
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  146|  17.0k|	for (i = list_size(&sessions); i > 0; i--) {
  ------------------
  |  Branch (146:33): [True: 0, False: 17.0k]
  ------------------
  147|      0|		session = list_get_at(&sessions, i - 1);
  148|      0|		if (session && session->slot && session->slot->id == slotID) {
  ------------------
  |  Branch (148:7): [True: 0, False: 0]
  |  Branch (148:18): [True: 0, False: 0]
  |  Branch (148:35): [True: 0, False: 0]
  ------------------
  149|      0|			if ((error = sc_pkcs11_close_session(session->handle)) != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (149:8): [True: 0, False: 0]
  ------------------
  150|      0|				rv = error;
  151|      0|		}
  152|      0|	}
  153|  17.0k|	return rv;
  154|  17.0k|}
C_CloseSession:
  157|  11.3k|{				/* the session's handle */
  158|  11.3k|	CK_RV rv;
  159|       |
  160|  11.3k|	rv = sc_pkcs11_lock();
  161|  11.3k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  11.3k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (161:6): [True: 0, False: 11.3k]
  ------------------
  162|      0|		return rv;
  163|       |
  164|  11.3k|	sc_log(context, "C_CloseSession(0x%lx)", hSession);
  ------------------
  |  |   71|  11.3k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  165|       |
  166|  11.3k|	rv = sc_pkcs11_close_session(hSession);
  167|       |
  168|  11.3k|	sc_pkcs11_unlock();
  169|  11.3k|	return rv;
  170|  11.3k|}
C_Login:
  331|  3.33k|{				/* the length of the PIN */
  332|  3.33k|	CK_RV rv;
  333|  3.33k|	struct sc_pkcs11_session *session;
  334|  3.33k|	struct sc_pkcs11_slot *slot;
  335|       |
  336|  3.33k|	if (pPin == NULL_PTR && ulPinLen > 0)
  ------------------
  |  |   27|  6.66k|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (336:6): [True: 0, False: 3.33k]
  |  Branch (336:26): [True: 0, False: 0]
  ------------------
  337|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  338|       |
  339|  3.33k|	rv = sc_pkcs11_lock();
  340|  3.33k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  3.33k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (340:6): [True: 0, False: 3.33k]
  ------------------
  341|      0|		return rv;
  342|       |
  343|  3.33k|	if (userType != CKU_USER && userType != CKU_SO && userType != CKU_CONTEXT_SPECIFIC) {
  ------------------
  |  | 1211|  6.66k|#define CKU_USER 1UL
  ------------------
              	if (userType != CKU_USER && userType != CKU_SO && userType != CKU_CONTEXT_SPECIFIC) {
  ------------------
  |  | 1210|  6.03k|#define CKU_SO 0UL
  ------------------
              	if (userType != CKU_USER && userType != CKU_SO && userType != CKU_CONTEXT_SPECIFIC) {
  ------------------
  |  | 1212|  1.67k|#define CKU_CONTEXT_SPECIFIC 2UL
  ------------------
  |  Branch (343:6): [True: 2.70k, False: 631]
  |  Branch (343:30): [True: 1.67k, False: 1.02k]
  |  Branch (343:52): [True: 1.17k, False: 496]
  ------------------
  344|  1.17k|		rv = CKR_USER_TYPE_INVALID;
  ------------------
  |  | 1153|  1.17k|#define CKR_USER_TYPE_INVALID 0x00000103UL
  ------------------
  345|  1.17k|		goto out;
  346|  1.17k|	}
  347|  2.15k|	session = list_seek(&sessions, &hSession);
  348|  2.15k|	if (!session) {
  ------------------
  |  Branch (348:6): [True: 0, False: 2.15k]
  ------------------
  349|      0|		rv = CKR_SESSION_HANDLE_INVALID;
  ------------------
  |  | 1134|      0|#define CKR_SESSION_HANDLE_INVALID 0x000000B3UL
  ------------------
  350|      0|		goto out;
  351|      0|	}
  352|       |
  353|  2.15k|	sc_log(context, "C_Login(0x%lx, %lu)", hSession, userType);
  ------------------
  |  |   71|  2.15k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  354|       |
  355|  2.15k|	slot = session->slot;
  356|       |
  357|  2.15k|	if (!(slot->token_info.flags & CKF_USER_PIN_INITIALIZED) && userType == CKU_USER) {
  ------------------
  |  |  415|  2.15k|#define CKF_USER_PIN_INITIALIZED 0x00000008UL
  ------------------
              	if (!(slot->token_info.flags & CKF_USER_PIN_INITIALIZED) && userType == CKU_USER) {
  ------------------
  |  | 1211|    571|#define CKU_USER 1UL
  ------------------
  |  Branch (357:6): [True: 571, False: 1.58k]
  |  Branch (357:62): [True: 315, False: 256]
  ------------------
  358|    315|		rv = CKR_USER_PIN_NOT_INITIALIZED;
  ------------------
  |  | 1152|    315|#define CKR_USER_PIN_NOT_INITIALIZED 0x00000102UL
  ------------------
  359|    315|		goto out;
  360|    315|	}
  361|       |
  362|       |	/* TODO: check if context specific is valid */
  363|  1.83k|	if (userType == CKU_CONTEXT_SPECIFIC) {
  ------------------
  |  | 1212|  1.83k|#define CKU_CONTEXT_SPECIFIC 2UL
  ------------------
  |  Branch (363:6): [True: 496, False: 1.34k]
  ------------------
  364|    496|		if (slot->login_user == -1) {
  ------------------
  |  Branch (364:7): [True: 64, False: 432]
  ------------------
  365|     64|			rv = CKR_OPERATION_NOT_INITIALIZED;
  ------------------
  |  | 1126|     64|#define CKR_OPERATION_NOT_INITIALIZED 0x00000091UL
  ------------------
  366|     64|		}
  367|    432|		else   {
  368|    432|			rv = restore_login_state(slot);
  369|    432|			if (rv == CKR_OK && slot->p11card && slot->p11card->framework)
  ------------------
  |  | 1086|    864|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (369:8): [True: 432, False: 0]
  |  Branch (369:24): [True: 432, False: 0]
  |  Branch (369:41): [True: 432, False: 0]
  ------------------
  370|    432|				rv = slot->p11card->framework->login(slot, userType, pPin, ulPinLen);
  371|    432|			rv = reset_login_state(slot, rv);
  372|    432|		}
  373|    496|	}
  374|  1.34k|	else {
  375|  1.34k|		sc_log(context, "C_Login() slot->login_user %i", slot->login_user);
  ------------------
  |  |   71|  1.34k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  376|  1.34k|		if (slot->login_user >= 0) {
  ------------------
  |  Branch (376:7): [True: 0, False: 1.34k]
  ------------------
  377|      0|			if ((CK_USER_TYPE) slot->login_user == userType)
  ------------------
  |  Branch (377:8): [True: 0, False: 0]
  ------------------
  378|      0|				rv = CKR_USER_ALREADY_LOGGED_IN;
  ------------------
  |  | 1150|      0|#define CKR_USER_ALREADY_LOGGED_IN 0x00000100UL
  ------------------
  379|      0|			else
  380|      0|				rv = CKR_USER_ANOTHER_ALREADY_LOGGED_IN;
  ------------------
  |  | 1154|      0|#define CKR_USER_ANOTHER_ALREADY_LOGGED_IN 0x00000104UL
  ------------------
  381|      0|			goto out;
  382|      0|		}
  383|       |
  384|  1.34k|		rv = restore_login_state(slot);
  385|  1.34k|		if (rv == CKR_OK) {
  ------------------
  |  | 1086|  1.34k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (385:7): [True: 1.34k, False: 0]
  ------------------
  386|  1.34k|			sc_log(context, "C_Login() userType %li", userType);
  ------------------
  |  |   71|  1.34k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  387|  1.34k|			if (slot->p11card == NULL)
  ------------------
  |  Branch (387:8): [True: 0, False: 1.34k]
  ------------------
  388|      0|				return CKR_TOKEN_NOT_RECOGNIZED;
  ------------------
  |  | 1145|      0|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
  389|  1.34k|			rv = slot->p11card->framework->login(slot, userType, pPin, ulPinLen);
  390|  1.34k|			sc_log(context, "fLogin() rv %li", rv);
  ------------------
  |  |   71|  1.34k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  391|  1.34k|		}
  392|  1.34k|		if (rv == CKR_OK)
  ------------------
  |  | 1086|  1.34k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (392:7): [True: 908, False: 435]
  ------------------
  393|    908|			rv = push_login_state(slot, userType, pPin, ulPinLen);
  394|  1.34k|		if (rv == CKR_OK) {
  ------------------
  |  | 1086|  1.34k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (394:7): [True: 908, False: 435]
  ------------------
  395|    908|			slot->login_user = (int) userType;
  396|    908|		}
  397|  1.34k|		rv = reset_login_state(slot, rv);
  398|  1.34k|	}
  399|       |
  400|  3.33k|out:
  401|  3.33k|	sc_pkcs11_unlock();
  402|  3.33k|	return rv;
  403|  1.83k|}
C_InitPIN:
  454|    319|{
  455|    319|	CK_RV rv;
  456|    319|	struct sc_pkcs11_session *session;
  457|    319|	struct sc_pkcs11_slot *slot;
  458|       |
  459|    319|	sc_log(context, "C_InitPIN() called, pin '%s'", pPin ? (char *) pPin : "<null>");
  ------------------
  |  |   71|    638|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 319, False: 0]
  |  |  ------------------
  ------------------
  460|    319|	if (pPin == NULL_PTR && ulPinLen > 0)
  ------------------
  |  |   27|    638|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (460:6): [True: 0, False: 319]
  |  Branch (460:26): [True: 0, False: 0]
  ------------------
  461|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  462|       |
  463|    319|	rv = sc_pkcs11_lock();
  464|    319|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    319|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (464:6): [True: 0, False: 319]
  ------------------
  465|      0|		return rv;
  466|       |
  467|    319|	session = list_seek(&sessions, &hSession);
  468|    319|	if (!session) {
  ------------------
  |  Branch (468:6): [True: 0, False: 319]
  ------------------
  469|      0|		rv = CKR_SESSION_HANDLE_INVALID;
  ------------------
  |  | 1134|      0|#define CKR_SESSION_HANDLE_INVALID 0x000000B3UL
  ------------------
  470|      0|		goto out;
  471|      0|	}
  472|       |
  473|    319|	if (!(session->flags & CKF_RW_SESSION)) {
  ------------------
  |  |  402|    319|#define CKF_RW_SESSION 0x00000002UL
  ------------------
  |  Branch (473:6): [True: 0, False: 319]
  ------------------
  474|      0|		rv = CKR_SESSION_READ_ONLY;
  ------------------
  |  | 1136|      0|#define CKR_SESSION_READ_ONLY 0x000000B5UL
  ------------------
  475|      0|		goto out;
  476|      0|	}
  477|       |
  478|    319|	slot = session->slot;
  479|    319|	if (slot->login_user != CKU_SO) {
  ------------------
  |  | 1210|    319|#define CKU_SO 0UL
  ------------------
  |  Branch (479:6): [True: 159, False: 160]
  ------------------
  480|    159|		rv = CKR_USER_NOT_LOGGED_IN;
  ------------------
  |  | 1151|    159|#define CKR_USER_NOT_LOGGED_IN 0x00000101UL
  ------------------
  481|    160|	} else if (slot->p11card == NULL || slot->p11card->framework->init_pin == NULL) {
  ------------------
  |  Branch (481:13): [True: 0, False: 160]
  |  Branch (481:38): [True: 0, False: 160]
  ------------------
  482|      0|		rv = CKR_FUNCTION_NOT_SUPPORTED;
  ------------------
  |  | 1111|      0|#define CKR_FUNCTION_NOT_SUPPORTED 0x00000054UL
  ------------------
  483|    160|	} else {
  484|    160|		rv = restore_login_state(slot);
  485|    160|		if (rv == CKR_OK) {
  ------------------
  |  | 1086|    160|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (485:7): [True: 160, False: 0]
  ------------------
  486|    160|			rv = slot->p11card->framework->init_pin(slot, pPin, ulPinLen);
  487|    160|			sc_log(context, "C_InitPIN() init-pin result %li", rv);
  ------------------
  |  |   71|    160|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  488|    160|		}
  489|    160|		rv = reset_login_state(slot, rv);
  490|    160|	}
  491|       |
  492|    319|out:
  493|    319|	sc_pkcs11_unlock();
  494|    319|	return rv;
  495|    319|}
C_SetPIN:
  499|    764|{
  500|    764|	CK_RV rv;
  501|    764|	struct sc_pkcs11_session *session;
  502|    764|	struct sc_pkcs11_slot *slot;
  503|       |
  504|    764|	if ((pOldPin == NULL_PTR && ulOldLen > 0) || (pNewPin == NULL_PTR && ulNewLen > 0))
  ------------------
  |  |   27|  1.52k|#define NULL_PTR ((void *)0)
  ------------------
              	if ((pOldPin == NULL_PTR && ulOldLen > 0) || (pNewPin == NULL_PTR && ulNewLen > 0))
  ------------------
  |  |   27|  1.52k|#define NULL_PTR ((void *)0)
  ------------------
  |  Branch (504:7): [True: 0, False: 764]
  |  Branch (504:30): [True: 0, False: 0]
  |  Branch (504:48): [True: 0, False: 764]
  |  Branch (504:71): [True: 0, False: 0]
  ------------------
  505|      0|		return CKR_ARGUMENTS_BAD;
  ------------------
  |  | 1092|      0|#define CKR_ARGUMENTS_BAD 0x00000007UL
  ------------------
  506|       |
  507|    764|	rv = sc_pkcs11_lock();
  508|    764|	if (rv != CKR_OK)
  ------------------
  |  | 1086|    764|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (508:6): [True: 0, False: 764]
  ------------------
  509|      0|		return rv;
  510|       |
  511|    764|	session = list_seek(&sessions, &hSession);
  512|    764|	if (!session) {
  ------------------
  |  Branch (512:6): [True: 0, False: 764]
  ------------------
  513|      0|		rv = CKR_SESSION_HANDLE_INVALID;
  ------------------
  |  | 1134|      0|#define CKR_SESSION_HANDLE_INVALID 0x000000B3UL
  ------------------
  514|      0|		goto out;
  515|      0|	}
  516|       |
  517|    764|	slot = session->slot;
  518|    764|	sc_log(context, "Changing PIN (session 0x%lx; login user %d)", hSession, slot->login_user);
  ------------------
  |  |   71|    764|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  519|       |
  520|    764|	if (!(session->flags & CKF_RW_SESSION)) {
  ------------------
  |  |  402|    764|#define CKF_RW_SESSION 0x00000002UL
  ------------------
  |  Branch (520:6): [True: 0, False: 764]
  ------------------
  521|      0|		rv = CKR_SESSION_READ_ONLY;
  ------------------
  |  | 1136|      0|#define CKR_SESSION_READ_ONLY 0x000000B5UL
  ------------------
  522|      0|		goto out;
  523|      0|	}
  524|       |
  525|    764|	rv = restore_login_state(slot);
  526|    764|	if (rv == CKR_OK) {
  ------------------
  |  | 1086|    764|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (526:6): [True: 764, False: 0]
  ------------------
  527|    764|		if (slot->p11card == NULL)
  ------------------
  |  Branch (527:7): [True: 0, False: 764]
  ------------------
  528|      0|			return CKR_TOKEN_NOT_RECOGNIZED;
  ------------------
  |  | 1145|      0|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
  529|    764|		rv = slot->p11card->framework->change_pin(slot, pOldPin, ulOldLen, pNewPin, ulNewLen);
  530|    764|	}
  531|    764|	rv = reset_login_state(slot, rv);
  532|       |
  533|    764|out:
  534|    764|	sc_pkcs11_unlock();
  535|    764|	return rv;
  536|    764|}
pkcs11-session.c:sc_pkcs11_close_session:
  105|  11.3k|{
  106|  11.3k|	struct sc_pkcs11_slot *slot;
  107|  11.3k|	struct sc_pkcs11_session *session;
  108|       |
  109|  11.3k|	sc_log(context, "real C_CloseSession(0x%lx)", hSession);
  ------------------
  |  |   71|  11.3k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  110|       |
  111|  11.3k|	session = list_seek(&sessions, &hSession);
  112|  11.3k|	if (!session)
  ------------------
  |  Branch (112:6): [True: 0, False: 11.3k]
  ------------------
  113|      0|		return CKR_SESSION_HANDLE_INVALID;
  ------------------
  |  | 1134|      0|#define CKR_SESSION_HANDLE_INVALID 0x000000B3UL
  ------------------
  114|       |
  115|       |	/* If we're the last session using this slot, make sure
  116|       |	 * we log out */
  117|  11.3k|	slot = session->slot;
  118|  11.3k|	slot->nsessions--;
  119|  11.3k|	if (slot->nsessions == 0 && slot->login_user >= 0) {
  ------------------
  |  Branch (119:6): [True: 11.3k, False: 0]
  |  Branch (119:30): [True: 898, False: 10.4k]
  ------------------
  120|    898|		slot->login_user = -1;
  121|    898|		if (sc_pkcs11_conf.atomic)
  ------------------
  |  Branch (121:7): [True: 0, False: 898]
  ------------------
  122|      0|			pop_all_login_states(slot);
  123|    898|		else {
  124|    898|			if (slot->p11card == NULL)
  ------------------
  |  Branch (124:8): [True: 0, False: 898]
  ------------------
  125|      0|				return CKR_TOKEN_NOT_RECOGNIZED;
  ------------------
  |  | 1145|      0|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
  126|    898|			slot->p11card->framework->logout(slot);
  127|    898|		}
  128|    898|	}
  129|   113k|	for (size_t i = 0; i < SC_PKCS11_OPERATION_MAX; i++)
  ------------------
  |  Branch (129:21): [True: 101k, False: 11.3k]
  ------------------
  130|   101k|		sc_pkcs11_release_operation(&session->operation[i]);
  131|       |
  132|  11.3k|	if (list_delete(&sessions, session) != 0)
  ------------------
  |  Branch (132:6): [True: 0, False: 11.3k]
  ------------------
  133|      0|		sc_log(context, "Could not delete session from list!");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  134|  11.3k|	free(session);
  135|  11.3k|	return CKR_OK;
  ------------------
  |  | 1086|  11.3k|#define CKR_OK 0x00000000UL
  ------------------
  136|  11.3k|}

_debug_virtual_slots:
   32|  17.0k|{
   33|  17.0k|	int i, vs_size;
   34|  17.0k|	sc_pkcs11_slot_t * slot;
   35|       |
   36|  17.0k|	vs_size = list_size(&virtual_slots);
   37|  17.0k|	_sc_debug(context, 10,
   38|  17.0k|			"VSS size:%d", vs_size);
   39|  17.0k|	_sc_debug(context, 10,
   40|  17.0k|			"VSS  [i] id   flags LU events nsessions slot_info.flags reader p11card description");
   41|  34.0k|	for (i = 0; i < vs_size; i++) {
  ------------------
  |  Branch (41:14): [True: 17.0k, False: 17.0k]
  ------------------
   42|  17.0k|		slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
   43|  17.0k|		if (slot) {
  ------------------
  |  Branch (43:7): [True: 17.0k, False: 0]
  ------------------
   44|  17.0k|			_sc_debug(context, 10,
   45|  17.0k|				"VSS %s[%d] 0x%2.2lx 0x%4.4x %d  %d  %d %4.4lx  %p %p %.64s",
   46|  17.0k|				((slot == p) ? "*" : " "),
  ------------------
  |  Branch (46:6): [True: 17.0k, False: 0]
  ------------------
   47|  17.0k|				i, slot->id, slot->flags, slot->login_user, slot->events, slot->nsessions,
   48|  17.0k|				slot->slot_info.flags,
   49|  17.0k|				slot->reader, slot->p11card,
   50|  17.0k|				slot->slot_info.slotDescription);
   51|  17.0k|		}
   52|  17.0k|	}
   53|  17.0k|	_sc_debug(context, 10, "VSS END");
   54|  17.0k|}
init_slot_info:
   92|  30.9k|{
   93|  30.9k|	if (reader) {
  ------------------
  |  Branch (93:6): [True: 30.9k, False: 0]
  ------------------
   94|  30.9k|		strcpy_bp(pInfo->slotDescription, reader->name, 64);
   95|  30.9k|		strcpy_bp(pInfo->manufacturerID, reader->vendor, 32);
   96|  30.9k|		pInfo->hardwareVersion.major = reader->version_major;
   97|  30.9k|		pInfo->hardwareVersion.minor = reader->version_minor;
   98|  30.9k|	} else {
   99|      0|		strcpy_bp(pInfo->slotDescription, "Virtual hotplug slot", 64);
  100|      0|		strcpy_bp(pInfo->manufacturerID, OPENSC_VS_FF_COMPANY_NAME, 32);
  ------------------
  |  |  244|      0|#define OPENSC_VS_FF_COMPANY_NAME "OpenSC Project"
  ------------------
  101|      0|		pInfo->hardwareVersion.major = OPENSC_VERSION_MAJOR;
  ------------------
  |  |  232|      0|#define OPENSC_VERSION_MAJOR 0
  ------------------
  102|      0|		pInfo->hardwareVersion.minor = OPENSC_VERSION_MINOR;
  ------------------
  |  |  235|      0|#define OPENSC_VERSION_MINOR 27
  ------------------
  103|      0|	}
  104|  30.9k|	pInfo->flags = CKF_REMOVABLE_DEVICE | CKF_HW_SLOT;
  ------------------
  |  |  408|  30.9k|#define CKF_REMOVABLE_DEVICE 0x00000002UL
  ------------------
              	pInfo->flags = CKF_REMOVABLE_DEVICE | CKF_HW_SLOT;
  ------------------
  |  |  409|  30.9k|#define CKF_HW_SLOT 0x00000004UL
  ------------------
  105|  30.9k|	pInfo->firmwareVersion.major = 0;
  106|  30.9k|	pInfo->firmwareVersion.minor = 0;
  107|  30.9k|}
create_slot:
  122|  17.0k|{
  123|  17.0k|	unsigned int events;
  124|  17.0k|	sc_reader_t *found;
  125|       |	/* find unused slots previously allocated for the same reader */
  126|  17.0k|	struct sc_pkcs11_slot *slot = reader_reclaim_slot(reader);
  127|       |
  128|       |	/* create a new slot if no empty slot is available */
  129|  17.0k|	if (!slot) {
  ------------------
  |  Branch (129:6): [True: 17.0k, False: 0]
  ------------------
  130|  17.0k|		sc_log(context, "Creating new slot");
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  131|  17.0k|		if (list_size(&virtual_slots) >= sc_pkcs11_conf.max_virtual_slots)
  ------------------
  |  Branch (131:7): [True: 0, False: 17.0k]
  ------------------
  132|      0|			return CKR_FUNCTION_FAILED;
  ------------------
  |  | 1091|      0|#define CKR_FUNCTION_FAILED 0x00000006UL
  ------------------
  133|       |
  134|  17.0k|		slot = (struct sc_pkcs11_slot *)calloc(1, sizeof(struct sc_pkcs11_slot));
  135|  17.0k|		if (!slot)
  ------------------
  |  Branch (135:7): [True: 0, False: 17.0k]
  ------------------
  136|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  137|       |
  138|  17.0k|		list_append(&virtual_slots, slot);
  139|  17.0k|		if (0 != list_init(&slot->objects)) {
  ------------------
  |  Branch (139:7): [True: 0, False: 17.0k]
  ------------------
  140|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  141|      0|		}
  142|  17.0k|		list_attributes_seeker(&slot->objects, object_list_seeker);
  143|       |
  144|  17.0k|		if (0 != list_init(&slot->logins)) {
  ------------------
  |  Branch (144:7): [True: 0, False: 17.0k]
  ------------------
  145|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  146|      0|		}
  147|  17.0k|	} else {
  148|      0|		DEBUG_VSS(slot, "Reusing this old slot");
  ------------------
  |  |  260|      0|#define DEBUG_VSS(S, ...) do { sc_log(context,"VSS " __VA_ARGS__); _debug_virtual_slots(S); } while (0)
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (260:102): [Folded, False: 0]
  |  |  ------------------
  ------------------
  149|       |
  150|       |		/* reuse the old list of logins/objects since they should be empty */
  151|      0|		list_t logins = slot->logins;
  152|      0|		list_t objects = slot->objects;
  153|       |
  154|      0|		memset(slot, 0, sizeof *slot);
  155|       |
  156|      0|		slot->logins = logins;
  157|      0|		slot->objects = objects;
  158|      0|	}
  159|       |
  160|  17.0k|	slot->login_user = -1;
  161|  17.0k|	slot->id = (CK_SLOT_ID) list_locate(&virtual_slots, slot);
  162|  17.0k|	init_slot_info(&slot->slot_info, reader);
  163|  17.0k|	slot->reader = reader;
  164|  17.0k|	sc_wait_for_event(context, SC_EVENT_CARD_EVENTS | SC_EVENT_READER_EVENTS, &found, &events, 0, &slot->reader_events);
  ------------------
  |  |  215|  17.0k|#define SC_EVENT_CARD_EVENTS		(SC_EVENT_CARD_INSERTED|SC_EVENT_CARD_REMOVED)
  |  |  ------------------
  |  |  |  |  213|  17.0k|#define SC_EVENT_CARD_INSERTED		0x0001
  |  |  ------------------
  |  |               #define SC_EVENT_CARD_EVENTS		(SC_EVENT_CARD_INSERTED|SC_EVENT_CARD_REMOVED)
  |  |  ------------------
  |  |  |  |  214|  17.0k|#define SC_EVENT_CARD_REMOVED		0x0002
  |  |  ------------------
  ------------------
              	sc_wait_for_event(context, SC_EVENT_CARD_EVENTS | SC_EVENT_READER_EVENTS, &found, &events, 0, &slot->reader_events);
  ------------------
  |  |  218|  17.0k|#define SC_EVENT_READER_EVENTS		(SC_EVENT_READER_ATTACHED|SC_EVENT_READER_DETACHED)
  |  |  ------------------
  |  |  |  |  216|  17.0k|#define SC_EVENT_READER_ATTACHED	0x0004
  |  |  ------------------
  |  |               #define SC_EVENT_READER_EVENTS		(SC_EVENT_READER_ATTACHED|SC_EVENT_READER_DETACHED)
  |  |  ------------------
  |  |  |  |  217|  17.0k|#define SC_EVENT_READER_DETACHED	0x0008
  |  |  ------------------
  ------------------
  165|       |
  166|  17.0k|	DEBUG_VSS(slot, "Finished initializing this slot");
  ------------------
  |  |  260|  17.0k|#define DEBUG_VSS(S, ...) do { sc_log(context,"VSS " __VA_ARGS__); _debug_virtual_slots(S); } while (0)
  |  |  ------------------
  |  |  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  |  Branch (260:102): [Folded, False: 17.0k]
  |  |  ------------------
  ------------------
  167|       |
  168|  17.0k|	return CKR_OK;
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  169|  17.0k|}
sc_pkcs11_card_free:
  172|  22.7k|{
  173|  22.7k|	if (p11card) {
  ------------------
  |  Branch (173:6): [True: 17.0k, False: 5.71k]
  ------------------
  174|  17.0k|		size_t i;
  175|  17.0k|		if (p11card->framework && p11card->framework->unbind)
  ------------------
  |  Branch (175:7): [True: 13.8k, False: 3.15k]
  |  Branch (175:29): [True: 13.8k, False: 0]
  ------------------
  176|  13.8k|			p11card->framework->unbind(p11card);
  177|  17.0k|		sc_disconnect_card(p11card->card);
  178|   160k|		for (i=0; i < p11card->nmechanisms; ++i) {
  ------------------
  |  Branch (178:13): [True: 143k, False: 17.0k]
  ------------------
  179|   143k|			if (p11card->mechanisms[i]->free_mech_data) {
  ------------------
  |  Branch (179:8): [True: 108k, False: 34.8k]
  ------------------
  180|   108k|				p11card->mechanisms[i]->free_mech_data(p11card->mechanisms[i]->mech_data);
  181|   108k|			}
  182|   143k|			free(p11card->mechanisms[i]);
  183|   143k|		}
  184|  17.0k|		free(p11card->mechanisms);
  185|  17.0k|		free(p11card);
  186|  17.0k|	}
  187|  22.7k|}
card_removed:
  190|  17.0k|{
  191|  17.0k|	unsigned int i;
  192|  17.0k|	struct sc_pkcs11_card *p11card = NULL;
  193|       |	/* Mark all slots as "token not present" */
  194|  17.0k|	sc_log(context, "%s: card removed", reader->name);
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  195|       |
  196|       |
  197|  34.0k|	for (i=0; i < list_size(&virtual_slots); i++) {
  ------------------
  |  Branch (197:12): [True: 17.0k, False: 17.0k]
  ------------------
  198|  17.0k|		sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
  199|  17.0k|		if (slot->reader == reader) {
  ------------------
  |  Branch (199:7): [True: 17.0k, False: 0]
  ------------------
  200|       |			/* Save the "card" object */
  201|  17.0k|			if (slot->p11card)
  ------------------
  |  Branch (201:8): [True: 11.3k, False: 5.71k]
  ------------------
  202|  11.3k|				p11card = slot->p11card;
  203|  17.0k|			slot_token_removed(slot->id);
  204|  17.0k|		}
  205|  17.0k|	}
  206|       |
  207|  17.0k|	sc_pkcs11_card_free(p11card);
  208|       |
  209|  17.0k|	return CKR_OK;
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  210|  17.0k|}
card_detect:
  214|  1.30k|{
  215|  1.30k|	struct sc_pkcs11_card *p11card = NULL;
  216|  1.30k|	int free_p11card = 0;
  217|  1.30k|	int rc;
  218|  1.30k|	int no_change = 0;
  219|  1.30k|	CK_RV rv;
  220|  1.30k|	unsigned int i;
  221|  1.30k|	int j;
  222|  1.30k|	static int retry = 3;
  223|       |
  224|  1.30k|	sc_log(context, "%s: Detecting smart card", reader->name);
  ------------------
  |  |   71|  1.30k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  225|       |	/* Check if someone inserted a card */
  226|       |
  227|  1.30k|	if (reader_states != NULL) {
  ------------------
  |  Branch (227:6): [True: 1.30k, False: 0]
  ------------------
  228|       |		/* check if any event has occurred since last invocation of `card_detect()` */
  229|  1.30k|		unsigned int mask, events;
  230|  1.30k|		sc_reader_t *event_reader;
  231|       |		/* Detect card and reader events */
  232|  1.30k|		mask = SC_EVENT_CARD_EVENTS | SC_EVENT_READER_EVENTS;
  ------------------
  |  |  215|  1.30k|#define SC_EVENT_CARD_EVENTS		(SC_EVENT_CARD_INSERTED|SC_EVENT_CARD_REMOVED)
  |  |  ------------------
  |  |  |  |  213|  1.30k|#define SC_EVENT_CARD_INSERTED		0x0001
  |  |  ------------------
  |  |               #define SC_EVENT_CARD_EVENTS		(SC_EVENT_CARD_INSERTED|SC_EVENT_CARD_REMOVED)
  |  |  ------------------
  |  |  |  |  214|  1.30k|#define SC_EVENT_CARD_REMOVED		0x0002
  |  |  ------------------
  ------------------
              		mask = SC_EVENT_CARD_EVENTS | SC_EVENT_READER_EVENTS;
  ------------------
  |  |  218|  1.30k|#define SC_EVENT_READER_EVENTS		(SC_EVENT_READER_ATTACHED|SC_EVENT_READER_DETACHED)
  |  |  ------------------
  |  |  |  |  216|  1.30k|#define SC_EVENT_READER_ATTACHED	0x0004
  |  |  ------------------
  |  |               #define SC_EVENT_READER_EVENTS		(SC_EVENT_READER_ATTACHED|SC_EVENT_READER_DETACHED)
  |  |  ------------------
  |  |  |  |  217|  1.30k|#define SC_EVENT_READER_DETACHED	0x0008
  |  |  ------------------
  ------------------
  233|  1.30k|		int r = sc_wait_for_event(context, mask, &event_reader, &events, 0, reader_states);
  234|  1.30k|		if (r == SC_ERROR_EVENT_TIMEOUT || reader != event_reader)
  ------------------
  |  |   43|  2.61k|#define SC_ERROR_EVENT_TIMEOUT			-1112
  ------------------
  |  Branch (234:7): [True: 0, False: 1.30k]
  |  Branch (234:38): [True: 1.30k, False: 0]
  ------------------
  235|       |			/* no change happened */
  236|  1.30k|			no_change = 1;
  237|      0|		else
  238|       |			/* if some error occurred or there actually was a change, continue with detection routine */
  239|      0|			no_change = 0;
  240|  1.30k|	}
  241|       |
  242|  1.30k|again:
  243|  1.30k|	rc = sc_detect_card_presence(reader);
  244|  1.30k|	if (rc < 0) {
  ------------------
  |  Branch (244:6): [True: 1.30k, False: 0]
  ------------------
  245|  1.30k|		sc_log(context, "%s: failed, %s", reader->name, sc_strerror(rc));
  ------------------
  |  |   71|  1.30k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  246|  1.30k|		return sc_to_cryptoki_error(rc, NULL);
  247|  1.30k|	}
  248|      0|	if (rc == 0) {
  ------------------
  |  Branch (248:6): [True: 0, False: 0]
  ------------------
  249|      0|		sc_log(context, "%s: card absent", reader->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__
  |  |  ------------------
  ------------------
  250|      0|		card_removed(reader);	/* Release all resources */
  251|      0|		return CKR_TOKEN_NOT_PRESENT;
  ------------------
  |  | 1144|      0|#define CKR_TOKEN_NOT_PRESENT 0x000000E0UL
  ------------------
  252|      0|	}
  253|       |
  254|      0|	if (no_change == 1) {
  ------------------
  |  Branch (254:6): [True: 0, False: 0]
  ------------------
  255|      0|		sc_log(context, "%s: card present, no change detected", reader->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__
  |  |  ------------------
  ------------------
  256|      0|		return CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  257|      0|	}
  258|       |
  259|       |	/* If the card was changed, disconnect the current one */
  260|      0|	if (rc & SC_READER_CARD_CHANGED) {
  ------------------
  |  |  367|      0|#define SC_READER_CARD_CHANGED		0x00000002
  ------------------
  |  Branch (260:6): [True: 0, False: 0]
  ------------------
  261|      0|		sc_log(context, "%s: Card changed", reader->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__
  |  |  ------------------
  ------------------
  262|       |		/* The following should never happen - but if it
  263|       |		 * does we'll be stuck in an endless loop.
  264|       |		 * So better be fussy.*/
  265|      0|		card_removed(reader);
  266|      0|		if (!retry--) {
  ------------------
  |  Branch (266:7): [True: 0, False: 0]
  ------------------
  267|      0|			retry = 3;
  268|      0|			return CKR_TOKEN_NOT_PRESENT;
  ------------------
  |  | 1144|      0|#define CKR_TOKEN_NOT_PRESENT 0x000000E0UL
  ------------------
  269|      0|		}
  270|      0|		goto again;
  271|      0|	}
  272|       |
  273|       |	/* Locate a slot related to the reader */
  274|      0|	for (i=0; i<list_size(&virtual_slots); i++) {
  ------------------
  |  Branch (274:12): [True: 0, False: 0]
  ------------------
  275|      0|		sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
  276|      0|		if (slot->reader == reader) {
  ------------------
  |  Branch (276:7): [True: 0, False: 0]
  ------------------
  277|      0|			p11card = slot->p11card;
  278|      0|			break;
  279|      0|		}
  280|      0|	}
  281|       |
  282|       |	/* Detect the card if it's not known already */
  283|      0|	if (p11card == NULL) {
  ------------------
  |  Branch (283:6): [True: 0, False: 0]
  ------------------
  284|      0|		sc_log(context, "%s: First seen the card ", reader->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__
  |  |  ------------------
  ------------------
  285|      0|		p11card = (struct sc_pkcs11_card *)calloc(1, sizeof(struct sc_pkcs11_card));
  286|      0|		if (!p11card)
  ------------------
  |  Branch (286:7): [True: 0, False: 0]
  ------------------
  287|      0|			return CKR_HOST_MEMORY;
  ------------------
  |  | 1088|      0|#define CKR_HOST_MEMORY 0x00000002UL
  ------------------
  288|      0|		free_p11card = 1;
  289|      0|		p11card->reader = reader;
  290|      0|	}
  291|       |
  292|      0|	if (p11card->card == NULL) {
  ------------------
  |  Branch (292:6): [True: 0, False: 0]
  ------------------
  293|      0|		sc_log(context, "%s: Connecting ... ", reader->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__
  |  |  ------------------
  ------------------
  294|      0|		rc = sc_connect_card(reader, &p11card->card);
  295|      0|		if (rc != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (295:7): [True: 0, False: 0]
  ------------------
  296|      0|			sc_log(context, "%s: SC connect card error %i", reader->name, rc);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  297|      0|			rv = sc_to_cryptoki_error(rc, NULL);
  298|      0|			goto fail;
  299|      0|		}
  300|       |
  301|       |		/* escape commands are only guaranteed to be working with a card
  302|       |		 * inserted. That's why by now, after sc_connect_card() the reader's
  303|       |		 * metadata may have changed. We re-initialize the metadata for every
  304|       |		 * slot of this reader here. */
  305|      0|		if (reader->flags & SC_READER_ENABLE_ESCAPE) {
  ------------------
  |  |  372|      0|#define SC_READER_ENABLE_ESCAPE		0x00000040
  ------------------
  |  Branch (305:7): [True: 0, False: 0]
  ------------------
  306|      0|			for (i = 0; i<list_size(&virtual_slots); i++) {
  ------------------
  |  Branch (306:16): [True: 0, False: 0]
  ------------------
  307|      0|				sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
  308|      0|				if (slot->reader == reader)
  ------------------
  |  Branch (308:9): [True: 0, False: 0]
  ------------------
  309|      0|					init_slot_info(&slot->slot_info, reader);
  310|      0|			}
  311|      0|		}
  312|       |
  313|      0|		sc_log(context, "%s: Connected SC card %p", reader->name, p11card->card);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  314|      0|	}
  315|       |
  316|       |	/* Detect the framework */
  317|      0|	if (p11card->framework == NULL) {
  ------------------
  |  Branch (317:6): [True: 0, False: 0]
  ------------------
  318|      0|		struct sc_app_info *app_generic = sc_pkcs15_get_application_by_type(p11card->card, "generic");
  319|       |
  320|      0|		sc_log(context, "%s: Detecting Framework. %i on-card applications", reader->name, p11card->card->app_count);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  321|      0|		sc_log(context, "%s: generic application %s", reader->name, app_generic ? app_generic->label : "<none>");
  ------------------
  |  |   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__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  322|       |
  323|      0|		for (i = 0; frameworks[i]; i++)
  ------------------
  |  Branch (323:15): [True: 0, False: 0]
  ------------------
  324|      0|			if (frameworks[i]->bind != NULL)
  ------------------
  |  Branch (324:8): [True: 0, False: 0]
  ------------------
  325|      0|				break;
  326|       |		/*TODO: only first framework is used: pkcs15init framework is not reachable here */
  327|      0|		if (frameworks[i] == NULL) {
  ------------------
  |  Branch (327:7): [True: 0, False: 0]
  ------------------
  328|      0|			rv = CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|      0|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  329|      0|			goto fail;
  330|      0|		}
  331|       |
  332|      0|		p11card->framework = frameworks[i];
  333|       |
  334|       |		/* Initialize framework */
  335|      0|		sc_log(context, "%s: Detected framework %d. Creating tokens.", reader->name, i);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  336|       |		/* Bind 'generic' application or (emulated?) card without applications */
  337|      0|		if (app_generic || !p11card->card->app_count)   {
  ------------------
  |  Branch (337:7): [True: 0, False: 0]
  |  Branch (337:22): [True: 0, False: 0]
  ------------------
  338|      0|			scconf_block *conf_block = NULL;
  339|      0|			int enable_InitToken = 0;
  340|       |
  341|      0|			conf_block = sc_match_atr_block(p11card->card->ctx, NULL,
  342|      0|				&p11card->reader->atr);
  343|      0|			if (!conf_block) /* check default block */
  ------------------
  |  Branch (343:8): [True: 0, False: 0]
  ------------------
  344|      0|				conf_block = sc_get_conf_block(context,
  345|      0|					"framework", "pkcs15", 1);
  346|       |
  347|      0|			enable_InitToken = scconf_get_bool(conf_block,
  348|      0|				"pkcs11_enable_InitToken", 0);
  349|       |
  350|      0|			sc_log(context, "%s: Try to bind 'generic' token.", reader->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__
  |  |  ------------------
  ------------------
  351|      0|			rv = frameworks[i]->bind(p11card, app_generic);
  352|      0|			if (rv == CKR_TOKEN_NOT_RECOGNIZED && enable_InitToken)   {
  ------------------
  |  | 1145|      0|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
  |  Branch (352:8): [True: 0, False: 0]
  |  Branch (352:42): [True: 0, False: 0]
  ------------------
  353|      0|				sc_log(context, "%s: 'InitToken' enabled -- accept non-binded card", reader->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__
  |  |  ------------------
  ------------------
  354|      0|				rv = CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  355|      0|			}
  356|      0|			if (rv != CKR_OK)   {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (356:8): [True: 0, False: 0]
  ------------------
  357|      0|				sc_log(context,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  358|      0|				       "%s: cannot bind 'generic' token: rv 0x%lX",
  359|      0|				       reader->name, rv);
  360|      0|				goto fail;
  361|      0|			}
  362|       |
  363|      0|			sc_log(context, "%s: Creating 'generic' token.", reader->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__
  |  |  ------------------
  ------------------
  364|      0|			rv = frameworks[i]->create_tokens(p11card, app_generic);
  365|      0|			if (rv != CKR_OK)   {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (365:8): [True: 0, False: 0]
  ------------------
  366|      0|				sc_log(context,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  367|      0|				       "%s: create 'generic' token error 0x%lX",
  368|      0|				       reader->name, rv);
  369|      0|				goto fail;
  370|      0|			}
  371|       |			/* p11card is now bound to some slot */
  372|      0|			free_p11card = 0;
  373|      0|		}
  374|       |
  375|       |		/* Now bind the rest of applications that are not 'generic' */
  376|      0|		for (j = 0; j < p11card->card->app_count; j++)   {
  ------------------
  |  Branch (376:15): [True: 0, False: 0]
  ------------------
  377|      0|			struct sc_app_info *app_info = p11card->card->app[j];
  378|      0|			char *app_name = app_info ? app_info->label : "<anonymous>";
  ------------------
  |  Branch (378:21): [True: 0, False: 0]
  ------------------
  379|       |
  380|      0|			if (app_generic && app_generic == p11card->card->app[j])
  ------------------
  |  Branch (380:8): [True: 0, False: 0]
  |  Branch (380:23): [True: 0, False: 0]
  ------------------
  381|      0|				continue;
  382|       |
  383|      0|			sc_log(context, "%s: Binding %s token.", reader->name, app_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__
  |  |  ------------------
  ------------------
  384|      0|			rv = frameworks[i]->bind(p11card, app_info);
  385|      0|			if (rv != CKR_OK)   {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (385:8): [True: 0, False: 0]
  ------------------
  386|      0|				sc_log(context, "%s: bind %s token error Ox%lX",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  387|      0|				       reader->name, app_name, rv);
  388|      0|				continue;
  389|      0|			}
  390|       |
  391|      0|			sc_log(context, "%s: Creating %s token.", reader->name, app_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__
  |  |  ------------------
  ------------------
  392|      0|			rv = frameworks[i]->create_tokens(p11card, app_info);
  393|      0|			if (rv != CKR_OK)   {
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (393:8): [True: 0, False: 0]
  ------------------
  394|      0|				sc_log(context,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  395|      0|				       "%s: create %s token error 0x%lX",
  396|      0|				       reader->name, app_name, rv);
  397|      0|				goto fail;
  398|      0|			}
  399|       |			/* p11card is now bound to some slot */
  400|      0|			free_p11card = 0;
  401|      0|		}
  402|      0|	}
  403|       |
  404|      0|	sc_log(context, "%s: Detection ended", reader->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__
  |  |  ------------------
  ------------------
  405|      0|	rv = CKR_OK;
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  406|       |
  407|      0|fail:
  408|      0|	if (free_p11card) {
  ------------------
  |  Branch (408:6): [True: 0, False: 0]
  ------------------
  409|      0|		sc_pkcs11_card_free(p11card);
  410|      0|	}
  411|       |
  412|      0|	return rv;
  413|      0|}
card_detect_all:
  418|  17.0k|{
  419|  17.0k|	unsigned int i, j;
  420|       |
  421|  17.0k|	sc_log(context, "Detect all cards");
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  422|       |	/* Detect cards in all initialized readers */
  423|  17.0k|	for (i=0; i< sc_ctx_get_reader_count(context); i++) {
  ------------------
  |  Branch (423:12): [True: 0, False: 17.0k]
  ------------------
  424|      0|		sc_reader_t *reader = sc_ctx_get_reader(context, i);
  425|       |
  426|      0|		if (reader->flags & SC_READER_REMOVED) {
  ------------------
  |  |  371|      0|#define SC_READER_REMOVED			0x00000020
  ------------------
  |  Branch (426:7): [True: 0, False: 0]
  ------------------
  427|      0|			card_removed(reader);
  428|       |			/* do not remove slots related to this reader which would be
  429|       |			 * possible according to PKCS#11 2.20 and later, because NSS can't
  430|       |			 * handle a shrinking slot list
  431|       |			 * https://bugzilla.mozilla.org/show_bug.cgi?id=1613632 */
  432|       |
  433|       |			/* Instead, remove the relation between reader and slot */
  434|      0|			for (j = 0; j<list_size(&virtual_slots); j++) {
  ------------------
  |  Branch (434:16): [True: 0, False: 0]
  ------------------
  435|      0|				sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, j);
  436|      0|				if (slot->reader == reader) {
  ------------------
  |  Branch (436:9): [True: 0, False: 0]
  ------------------
  437|      0|					slot->reader = NULL;
  438|      0|					sc_wait_for_event(context, 0, NULL, NULL, 0, &slot->reader_events);
  439|      0|				}
  440|      0|			}
  441|      0|		} else {
  442|       |			/* Locate a slot related to the reader */
  443|      0|			int found = 0;
  444|      0|			for (j = 0; j<list_size(&virtual_slots); j++) {
  ------------------
  |  Branch (444:16): [True: 0, False: 0]
  ------------------
  445|      0|				sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, j);
  446|      0|				if (slot->reader == reader) {
  ------------------
  |  Branch (446:9): [True: 0, False: 0]
  ------------------
  447|      0|					found = 1;
  448|      0|					card_detect(slot->reader, &slot->reader_events);
  449|      0|					break;
  450|      0|				}
  451|      0|			}
  452|      0|			if (!found) {
  ------------------
  |  Branch (452:8): [True: 0, False: 0]
  ------------------
  453|      0|				for (j = 0; j < sc_pkcs11_conf.slots_per_card; j++) {
  ------------------
  |  Branch (453:17): [True: 0, False: 0]
  ------------------
  454|      0|					CK_RV rv = create_slot(reader);
  455|      0|					if (rv != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (455:10): [True: 0, False: 0]
  ------------------
  456|      0|						return rv;
  457|      0|				}
  458|      0|				card_detect(reader, NULL);
  459|      0|			}
  460|      0|		}
  461|      0|	}
  462|  17.0k|	sc_log(context, "All cards detected");
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  463|  17.0k|	return CKR_OK;
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  464|  17.0k|}
slot_allocate:
  468|  11.8k|{
  469|  11.8k|	unsigned int i;
  470|  11.8k|	struct sc_pkcs11_slot *tmp_slot = NULL;
  471|       |
  472|       |	/* Locate a free slot for this reader */
  473|  12.3k|	for (i=0; i< list_size(&virtual_slots); i++) {
  ------------------
  |  Branch (473:12): [True: 11.8k, False: 524]
  ------------------
  474|  11.8k|		tmp_slot = (struct sc_pkcs11_slot *)list_get_at(&virtual_slots, i);
  475|  11.8k|		if (tmp_slot->reader == p11card->reader && tmp_slot->p11card == NULL)
  ------------------
  |  Branch (475:7): [True: 11.8k, False: 0]
  |  Branch (475:46): [True: 11.3k, False: 524]
  ------------------
  476|  11.3k|			break;
  477|  11.8k|	}
  478|  11.8k|	if (!tmp_slot || (i == list_size(&virtual_slots)))
  ------------------
  |  Branch (478:6): [True: 0, False: 11.8k]
  |  Branch (478:19): [True: 524, False: 11.3k]
  ------------------
  479|    524|		return CKR_FUNCTION_FAILED;
  ------------------
  |  | 1091|    524|#define CKR_FUNCTION_FAILED 0x00000006UL
  ------------------
  480|  11.3k|	sc_log(context, "Allocated slot 0x%lx for card in reader %s", tmp_slot->id, p11card->reader->name);
  ------------------
  |  |   71|  11.3k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  481|  11.3k|	tmp_slot->p11card = p11card;
  482|  11.3k|	tmp_slot->events = SC_EVENT_CARD_INSERTED;
  ------------------
  |  |  213|  11.3k|#define SC_EVENT_CARD_INSERTED		0x0001
  ------------------
  483|  11.3k|	*slot = tmp_slot;
  484|  11.3k|	return CKR_OK;
  ------------------
  |  | 1086|  11.3k|#define CKR_OK 0x00000000UL
  ------------------
  485|  11.8k|}
slot_get_slot:
  488|  31.4k|{
  489|  31.4k|	if (context == NULL)
  ------------------
  |  Branch (489:6): [True: 0, False: 31.4k]
  ------------------
  490|      0|		return CKR_CRYPTOKI_NOT_INITIALIZED;
  ------------------
  |  | 1169|      0|#define CKR_CRYPTOKI_NOT_INITIALIZED 0x00000190UL
  ------------------
  491|       |
  492|  31.4k|	*slot = list_seek(&virtual_slots, &id);	/* FIXME: check for null? */
  493|  31.4k|	if (!*slot)
  ------------------
  |  Branch (493:6): [True: 0, False: 31.4k]
  ------------------
  494|      0|		return CKR_SLOT_ID_INVALID;
  ------------------
  |  | 1089|      0|#define CKR_SLOT_ID_INVALID 0x00000003UL
  ------------------
  495|  31.4k|	return CKR_OK;
  ------------------
  |  | 1086|  31.4k|#define CKR_OK 0x00000000UL
  ------------------
  496|  31.4k|}
slot_get_token:
  499|  14.4k|{
  500|  14.4k|	CK_RV rv;
  501|       |
  502|  14.4k|	sc_log(context, "Slot(id=0x%lX): get token", id);
  ------------------
  |  |   71|  14.4k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  503|  14.4k|	rv = slot_get_slot(id, slot);
  504|  14.4k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  14.4k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (504:6): [True: 0, False: 14.4k]
  ------------------
  505|      0|		return rv;
  506|       |
  507|  14.4k|	if (!((*slot)->slot_info.flags & CKF_TOKEN_PRESENT)) {
  ------------------
  |  |  407|  14.4k|#define CKF_TOKEN_PRESENT 0x00000001UL
  ------------------
  |  Branch (507:6): [True: 1.30k, False: 13.1k]
  ------------------
  508|  1.30k|		if ((*slot)->reader == NULL)
  ------------------
  |  Branch (508:7): [True: 0, False: 1.30k]
  ------------------
  509|      0|			return CKR_TOKEN_NOT_PRESENT;
  ------------------
  |  | 1144|      0|#define CKR_TOKEN_NOT_PRESENT 0x000000E0UL
  ------------------
  510|  1.30k|		sc_log(context, "Slot(id=0x%lX): get token: now detect card", id);
  ------------------
  |  |   71|  1.30k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  511|  1.30k|		rv = card_detect((*slot)->reader, &(*slot)->reader_events);
  512|  1.30k|		if (rv != CKR_OK)
  ------------------
  |  | 1086|  1.30k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (512:7): [True: 1.30k, False: 0]
  ------------------
  513|  1.30k|			return rv;
  514|  1.30k|	}
  515|       |
  516|  13.1k|	if (!((*slot)->slot_info.flags & CKF_TOKEN_PRESENT)) {
  ------------------
  |  |  407|  13.1k|#define CKF_TOKEN_PRESENT 0x00000001UL
  ------------------
  |  Branch (516:6): [True: 0, False: 13.1k]
  ------------------
  517|      0|		sc_log(context, "card detected, but slot not presenting token");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  518|      0|		return CKR_TOKEN_NOT_PRESENT;
  ------------------
  |  | 1144|      0|#define CKR_TOKEN_NOT_PRESENT 0x000000E0UL
  ------------------
  519|      0|	}
  520|  13.1k|	sc_log(context, "Slot-get-token returns OK");
  ------------------
  |  |   71|  13.1k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  521|  13.1k|	return CKR_OK;
  ------------------
  |  | 1086|  13.1k|#define CKR_OK 0x00000000UL
  ------------------
  522|  13.1k|}
slot_token_removed:
  525|  17.0k|{
  526|  17.0k|	CK_RV rv;
  527|  17.0k|	int token_was_present;
  528|  17.0k|	struct sc_pkcs11_slot *slot;
  529|  17.0k|	struct sc_pkcs11_object *object;
  530|       |
  531|  17.0k|	sc_log(context, "slot_token_removed(0x%lx)", id);
  ------------------
  |  |   71|  17.0k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  532|  17.0k|	rv = slot_get_slot(id, &slot);
  533|  17.0k|	if (rv != CKR_OK)
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (533:6): [True: 0, False: 17.0k]
  ------------------
  534|      0|		return rv;
  535|       |
  536|  17.0k|	token_was_present = (slot->slot_info.flags & CKF_TOKEN_PRESENT);
  ------------------
  |  |  407|  17.0k|#define CKF_TOKEN_PRESENT 0x00000001UL
  ------------------
  537|       |
  538|       |	/* Terminate active sessions */
  539|  17.0k|	sc_pkcs11_close_all_sessions(id);
  540|       |
  541|  47.9k|	while ((object = list_fetch(&slot->objects))) {
  ------------------
  |  Branch (541:9): [True: 30.8k, False: 17.0k]
  ------------------
  542|  30.8k|		if (object->ops->release)
  ------------------
  |  Branch (542:7): [True: 30.8k, False: 0]
  ------------------
  543|  30.8k|			object->ops->release(object);
  544|  30.8k|	}
  545|       |
  546|       |	/* Release framework stuff */
  547|  17.0k|	if (slot->p11card != NULL) {
  ------------------
  |  Branch (547:6): [True: 11.3k, False: 5.71k]
  ------------------
  548|  11.3k|		if (slot->fw_data != NULL && slot->p11card->framework != NULL
  ------------------
  |  Branch (548:7): [True: 5.97k, False: 5.34k]
  |  Branch (548:32): [True: 5.97k, False: 0]
  ------------------
  549|  5.97k|				&& slot->p11card->framework->release_token != NULL) {
  ------------------
  |  Branch (549:8): [True: 5.97k, False: 0]
  ------------------
  550|  5.97k|			slot->p11card->framework->release_token(slot->p11card, slot->fw_data);
  551|  5.97k|			slot->fw_data = NULL;
  552|  5.97k|		}
  553|  11.3k|		slot->p11card = NULL;
  554|  11.3k|	}
  555|       |
  556|       |	/* Reset relevant slot properties */
  557|  17.0k|	slot->slot_info.flags &= ~CKF_TOKEN_PRESENT;
  ------------------
  |  |  407|  17.0k|#define CKF_TOKEN_PRESENT 0x00000001UL
  ------------------
  558|  17.0k|	slot->login_user = -1;
  559|  17.0k|	slot->profile = NULL;
  560|  17.0k|	pop_all_login_states(slot);
  561|       |
  562|  17.0k|	if (token_was_present)
  ------------------
  |  Branch (562:6): [True: 11.3k, False: 5.71k]
  ------------------
  563|  11.3k|		slot->events = SC_EVENT_CARD_REMOVED;
  ------------------
  |  |  214|  11.3k|#define SC_EVENT_CARD_REMOVED		0x0002
  ------------------
  564|       |
  565|  17.0k|	memset(&slot->token_info, 0, sizeof slot->token_info);
  566|       |
  567|  17.0k|	return CKR_OK;
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  568|  17.0k|}
slot.c:reader_reclaim_slot:
   67|  17.0k|{
   68|  17.0k|	unsigned int i;
   69|  17.0k|	CK_UTF8CHAR slotDescription[64];
   70|  17.0k|	CK_UTF8CHAR manufacturerID[32];
   71|       |
   72|  17.0k|	if (reader == NULL)
  ------------------
  |  Branch (72:6): [True: 0, False: 17.0k]
  ------------------
   73|      0|		return NULL;
   74|  17.0k|	strcpy_bp(slotDescription, reader->name, 64);
   75|  17.0k|	strcpy_bp(manufacturerID, reader->vendor, 32);
   76|       |
   77|       |	/* Locate a slot related to the reader */
   78|  17.0k|	for (i = 0; i<list_size(&virtual_slots); i++) {
  ------------------
  |  Branch (78:14): [True: 0, False: 17.0k]
  ------------------
   79|      0|		sc_pkcs11_slot_t *slot = (sc_pkcs11_slot_t *) list_get_at(&virtual_slots, i);
   80|      0|		if (slot->reader == NULL
  ------------------
  |  Branch (80:7): [True: 0, False: 0]
  ------------------
   81|      0|				&& 0 == memcmp(slot->slot_info.slotDescription, slotDescription, 64)
  ------------------
  |  Branch (81:8): [True: 0, False: 0]
  ------------------
   82|      0|				&& 0 == memcmp(slot->slot_info.manufacturerID, manufacturerID, 32)
  ------------------
  |  Branch (82:8): [True: 0, False: 0]
  ------------------
   83|      0|				&& slot->slot_info.hardwareVersion.major == reader->version_major
  ------------------
  |  Branch (83:8): [True: 0, False: 0]
  ------------------
   84|      0|				&& slot->slot_info.hardwareVersion.minor == reader->version_minor) {
  ------------------
  |  Branch (84:8): [True: 0, False: 0]
  ------------------
   85|      0|			return slot;
   86|      0|		}
   87|      0|	}
   88|  17.0k|	return NULL;
   89|  17.0k|}
slot.c:object_list_seeker:
  111|  1.95k|{
  112|  1.95k|	const struct sc_pkcs11_object *object = (struct sc_pkcs11_object *)el;
  113|       |
  114|  1.95k|	if ((el == NULL) || (key == NULL))
  ------------------
  |  Branch (114:6): [True: 0, False: 1.95k]
  |  Branch (114:22): [True: 0, False: 1.95k]
  ------------------
  115|      0|		return 0;
  116|  1.95k|	if (object->handle == *(CK_OBJECT_HANDLE*)key)
  ------------------
  |  Branch (116:6): [True: 706, False: 1.24k]
  ------------------
  117|    706|		return 1;
  118|  1.24k|	return 0;
  119|  1.95k|}

sc_pkcs15init_get_authentic_ops:
  925|     14|{
  926|     14|	return &sc_pkcs15init_authentic_operations;
  927|     14|}

sc_pkcs15init_get_cardos_ops:
  942|      5|{
  943|      5|	return &sc_pkcs15init_cardos_operations;
  944|      5|}

sc_pkcs15init_get_cryptoflex_ops:
  953|      2|{
  954|      2|	return &sc_pkcs15init_cryptoflex_operations;
  955|      2|}
sc_pkcs15init_get_cyberflex_ops:
  959|      2|{
  960|      2|	return &sc_pkcs15init_cyberflex_operations;
  961|      2|}

sc_pkcs15init_get_entersafe_ops:
  531|      3|{
  532|      3|	return &sc_pkcs15init_entersafe_operations;
  533|      3|}

sc_pkcs15init_get_epass2003_ops:
  780|      5|{
  781|      5|	return &sc_pkcs15init_epass2003_operations;
  782|      5|}

sc_pkcs15init_get_gids_ops:
  189|      5|{
  190|      5|	return &sc_pkcs15init_gids_operations;
  191|      5|}

sc_pkcs15init_get_iasecc_ops:
 1896|      3|{
 1897|      3|	return &sc_pkcs15init_iasecc_operations;
 1898|      3|}

sc_pkcs15init_get_isoApplet_ops:
  803|      2|{
  804|      2|	return &sc_pkcs15init_isoApplet_operations;
  805|      2|}

sc_pkcs15init_bind:
  306|    268|{
  307|    268|	struct sc_context *ctx = card->ctx;
  308|    268|	struct sc_profile *profile;
  309|    268|	struct sc_pkcs15init_operations * (* func)(void) = NULL;
  310|    268|	const char	*driver = card->driver->short_name;
  311|    268|	char		card_profile[PATH_MAX];
  312|    268|	int		r, i;
  313|       |
  314|    268|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    268|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    268|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    268|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    268|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 268]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|       |	/* Put the card into administrative mode */
  316|    268|	r = sc_pkcs15init_set_lifecycle(card, SC_CARDCTRL_LIFECYCLE_ADMIN);
  317|    268|	if (r < 0 && r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|    265|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (317:6): [True: 265, False: 3]
  |  Branch (317:15): [True: 11, False: 254]
  ------------------
  318|    268|		LOG_TEST_RET(ctx, r, "Set lifecycle error");
  ------------------
  |  |  174|     11|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     11|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     11|	int _ret = (r); \
  |  |  |  |  168|     11|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 11, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     11|		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|     11|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     11|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     11|		return _ret; \
  |  |  |  |  172|     11|	} \
  |  |  |  |  173|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  319|       |
  320|    257|	profile = sc_profile_new();
  321|    257|	profile->card = card;
  322|       |
  323|  3.36k|	for (i = 0; profile_operations[i].name; i++) {
  ------------------
  |  Branch (323:14): [True: 3.29k, False: 67]
  ------------------
  324|  3.29k|		if (!strcasecmp(driver, profile_operations[i].name)) {
  ------------------
  |  Branch (324:7): [True: 190, False: 3.10k]
  ------------------
  325|    190|			func = (struct sc_pkcs15init_operations *(*)(void)) profile_operations[i].func;
  326|    190|			break;
  327|    190|		}
  328|  3.29k|	}
  329|    257|	if (!func) {
  ------------------
  |  Branch (329:6): [True: 67, False: 190]
  ------------------
  330|       |		/* no builtin support for this driver => look if there's a
  331|       |		 * dynamic module for this card */
  332|     67|		func = (struct sc_pkcs15init_operations *(*)(void)) load_dynamic_driver(card->ctx, &profile->dll, driver);
  333|     67|	}
  334|    257|	if (func) {
  ------------------
  |  Branch (334:6): [True: 190, False: 67]
  ------------------
  335|    190|		profile->ops = func();
  336|    190|	}
  337|     67|	else {
  338|     67|		sc_log(ctx, "Unsupported card driver %s", driver);
  ------------------
  |  |   71|     67|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  339|     67|		sc_profile_free(profile);
  340|     67|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported card driver");
  ------------------
  |  |  174|     67|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     67|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     67|	int _ret = (r); \
  |  |  |  |  168|     67|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 67, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     67|		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|     67|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     67|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     67|		return _ret; \
  |  |  |  |  172|     67|	} \
  |  |  |  |  173|     67|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|     67|	}
  342|       |
  343|       |	/* Massage the main profile name to see if there are
  344|       |	 * any options in there
  345|       |	 */
  346|    190|	profile->name = strdup(name);
  347|    190|	if (strchr(profile->name, '+') != NULL) {
  ------------------
  |  Branch (347:6): [True: 0, False: 190]
  ------------------
  348|      0|		char	*s;
  349|       |
  350|      0|		i = 0;
  351|      0|		(void) strtok(profile->name, "+");
  352|      0|		while ((s = strtok(NULL, "+")) != NULL) {
  ------------------
  |  Branch (352:10): [True: 0, False: 0]
  ------------------
  353|      0|			if (i < SC_PKCS15INIT_MAX_OPTIONS-1)
  ------------------
  |  |   95|      0|#define SC_PKCS15INIT_MAX_OPTIONS 16
  ------------------
  |  Branch (353:8): [True: 0, False: 0]
  ------------------
  354|      0|				profile->options[i++] = strdup(s);
  355|      0|		}
  356|      0|	}
  357|       |
  358|    190|	r = sc_pkcs15init_read_info(card, profile);
  359|    190|	if (r < 0) {
  ------------------
  |  Branch (359:6): [True: 29, False: 161]
  ------------------
  360|     29|		sc_profile_free(profile);
  361|     29|		LOG_TEST_RET(ctx, r, "Read info error");
  ------------------
  |  |  174|     29|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     29|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     29|	int _ret = (r); \
  |  |  |  |  168|     29|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 29, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     29|		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|     29|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     29|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     29|		return _ret; \
  |  |  |  |  172|     29|	} \
  |  |  |  |  173|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  362|     29|	}
  363|       |
  364|       |	/* Check the config file for a profile name.
  365|       |	 * If none is defined, use the default profile name.
  366|       |	 */
  367|    161|	if (!get_profile_from_config(card, card_profile, sizeof(card_profile)))
  ------------------
  |  Branch (367:6): [True: 161, False: 0]
  ------------------
  368|    161|		strlcpy(card_profile, driver, sizeof card_profile);
  ------------------
  |  |   43|    161|#define strlcpy _strlcpy
  ------------------
  369|    161|	if (profile_option != NULL)
  ------------------
  |  Branch (369:6): [True: 0, False: 161]
  ------------------
  370|      0|		strlcpy(card_profile, profile_option, sizeof(card_profile));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  371|       |
  372|    161|	do   {
  373|    161|		r = sc_profile_load(profile, profile->name);
  374|    161|		if (r < 0)   {
  ------------------
  |  Branch (374:7): [True: 161, False: 0]
  ------------------
  375|    161|			sc_log(ctx, "Failed to load profile '%s': %s", profile->name, sc_strerror(r));
  ------------------
  |  |   71|    161|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  376|    161|			break;
  377|    161|		}
  378|       |
  379|      0|		r = sc_profile_load(profile, card_profile);
  380|      0|		if (r < 0)   {
  ------------------
  |  Branch (380:7): [True: 0, False: 0]
  ------------------
  381|      0|			sc_log(ctx, "Failed to load profile '%s': %s", card_profile, sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  382|      0|			break;
  383|      0|		}
  384|       |
  385|      0|		r = sc_profile_finish(profile, app_info);
  386|      0|		if (r < 0)
  ------------------
  |  Branch (386:7): [True: 0, False: 0]
  ------------------
  387|      0|			sc_log(ctx, "Failed to finalize profile: %s", sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  388|      0|	}  while (0);
  ------------------
  |  Branch (388:12): [Folded, False: 0]
  ------------------
  389|       |
  390|    161|	if (r < 0) {
  ------------------
  |  Branch (390:6): [True: 161, False: 0]
  ------------------
  391|    161|		sc_profile_free(profile);
  392|    161|		LOG_TEST_RET(ctx, r, "Load profile error");
  ------------------
  |  |  174|    161|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    161|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    161|	int _ret = (r); \
  |  |  |  |  168|    161|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 161, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    161|		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|    161|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    161|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    161|		return _ret; \
  |  |  |  |  172|    161|	} \
  |  |  |  |  173|    161|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  393|    161|	}
  394|       |
  395|      0|	if (app_info && app_info->aid.len)   {
  ------------------
  |  Branch (395:6): [True: 0, False: 0]
  |  Branch (395:18): [True: 0, False: 0]
  ------------------
  396|      0|		struct sc_path path;
  397|       |
  398|      0|		if (card->ef_atr && card->ef_atr->aid.len)   {
  ------------------
  |  Branch (398:7): [True: 0, False: 0]
  |  Branch (398:23): [True: 0, False: 0]
  ------------------
  399|      0|			sc_log(ctx, "sc_pkcs15init_bind() select MF using EF.ATR data");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  400|      0|			memset(&path, 0, sizeof(struct sc_path));
  401|      0|			path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  402|      0|			path.aid = card->ef_atr->aid;
  403|      0|			r = sc_select_file(card, &path, NULL);
  404|      0|			if (r)
  ------------------
  |  Branch (404:8): [True: 0, False: 0]
  ------------------
  405|      0|				return r;
  406|      0|		}
  407|       |
  408|      0|		if (app_info->path.len)   {
  ------------------
  |  Branch (408:7): [True: 0, False: 0]
  ------------------
  409|      0|			path = app_info->path;
  410|      0|		}
  411|      0|		else   {
  412|      0|			memset(&path, 0, sizeof(struct sc_path));
  413|      0|			path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  414|      0|			path.aid = app_info->aid;
  415|      0|		}
  416|      0|		sc_log(ctx, "sc_pkcs15init_bind() select application path(type:%X) '%s'", path.type, sc_print_path(&path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  417|      0|		r = sc_select_file(card, &path, NULL);
  418|      0|	}
  419|       |
  420|      0|	*result = profile;
  421|      0|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  422|      0|}
sc_pkcs15init_set_lifecycle:
  491|    268|{
  492|    268|	return sc_card_ctl(card, SC_CARDCTL_LIFECYCLE_SET, &lcycle);
  493|    268|}
sc_pkcs15init_store_certificate:
 2161|      3|{
 2162|      3|	struct sc_context *ctx = p15card->card->ctx;
 2163|      3|	struct sc_pkcs15_cert_info *cert_info = NULL;
 2164|      3|	struct sc_pkcs15_object *object = NULL;
 2165|      3|	struct sc_pkcs15_object *key_object = NULL;
 2166|      3|	struct sc_path existing_path;
 2167|      3|	const char *label = NULL;
 2168|      3|	int		r;
 2169|       |
 2170|      3|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|      3|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      3|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      3|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      3|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2171|       |
 2172|      3|	memset(&existing_path, 0, sizeof(struct sc_path));
 2173|       |
 2174|      3|	label = args->label;
 2175|      3|	if (!label)
  ------------------
  |  Branch (2175:6): [True: 3, False: 0]
  ------------------
 2176|      3|		label = "Certificate";
 2177|       |
 2178|      3|	r = sc_pkcs15init_select_intrinsic_id(p15card, profile, SC_PKCS15_TYPE_CERT_X509,
  ------------------
  |  |  439|      3|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
 2179|      3|			&args->id, &args->der_encoded);
 2180|      3|	LOG_TEST_RET(ctx, r, "Get certificate 'intrinsic ID' error");
  ------------------
  |  |  174|      3|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|      3|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|      3|	int _ret = (r); \
  |  |  |  |  168|      3|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|      3|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|      3|		return _ret; \
  |  |  |  |  172|      3|	} \
  |  |  |  |  173|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2181|      0|	sc_log(ctx, "Cert(ID:%s) rv %i", sc_pkcs15_print_id(&args->id), r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2182|       |
 2183|       |	/* Select an ID if the user didn't specify one, otherwise make sure it's unique */
 2184|      0|	r = select_id(p15card, SC_PKCS15_TYPE_CERT, &args->id);
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
 2185|      0|	if (r == SC_ERROR_NON_UNIQUE_ID && args->update)   {
  ------------------
  |  |  107|      0|#define SC_ERROR_NON_UNIQUE_ID			-1505
  ------------------
  |  Branch (2185:6): [True: 0, False: 0]
  |  Branch (2185:37): [True: 0, False: 0]
  ------------------
 2186|      0|		struct sc_pkcs15_object *existing_obj = NULL;
 2187|       |
 2188|      0|		r = sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_CERT, &args->id, &existing_obj);
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
 2189|      0|		if (!r)   {
  ------------------
  |  Branch (2189:7): [True: 0, False: 0]
  ------------------
 2190|      0|			sc_log(ctx, "Found cert(ID:%s)", sc_pkcs15_print_id(&args->id));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2191|      0|			existing_path = ((struct sc_pkcs15_cert_info *)existing_obj->data)->path;
 2192|       |
 2193|      0|			sc_pkcs15_remove_object(p15card, existing_obj);
 2194|      0|			sc_pkcs15_free_object(existing_obj);
 2195|      0|		}
 2196|       |
 2197|      0|		r = select_id(p15card, SC_PKCS15_TYPE_CERT, &args->id);
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
 2198|      0|	}
 2199|      0|	sc_log(ctx, "Select ID Cert(ID:%s) rv %i", sc_pkcs15_print_id(&args->id), r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2200|      0|	LOG_TEST_RET(ctx, r, "Select certificate ID error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2201|       |
 2202|      0|	object = sc_pkcs15init_new_object(SC_PKCS15_TYPE_CERT_X509, label, NULL, NULL);
  ------------------
  |  |  439|      0|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
 2203|      0|	if (object == NULL)
  ------------------
  |  Branch (2203:6): [True: 0, False: 0]
  ------------------
 2204|      0|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Failed to allocate certificate object");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2205|      0|	cert_info = (struct sc_pkcs15_cert_info *) object->data;
 2206|      0|	cert_info->id = args->id;
 2207|      0|	cert_info->authority = args->authority;
 2208|      0|	sc_der_copy(&object->content, &args->der_encoded);
 2209|      0|	sc_der_copy(&cert_info->value, &args->der_encoded);
 2210|       |
 2211|      0|	if (existing_path.len)   {
  ------------------
  |  Branch (2211:6): [True: 0, False: 0]
  ------------------
 2212|      0|		sc_log(ctx, "Using existing path %s", sc_print_path(&existing_path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2213|      0|		cert_info->path = existing_path;
 2214|      0|	}
 2215|       |
 2216|      0|	sc_log(ctx, "Store cert(%.*s,ID:%s,der(%p,%zu))", (int)sizeof(object->label), object->label,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2217|      0|			sc_pkcs15_print_id(&cert_info->id), args->der_encoded.value, args->der_encoded.len);
 2218|       |
 2219|      0|	if (!profile->pkcs15.direct_certificates)
  ------------------
  |  Branch (2219:6): [True: 0, False: 0]
  ------------------
 2220|      0|		r = sc_pkcs15init_store_data(p15card, profile, object, &args->der_encoded, &cert_info->path);
 2221|       |
 2222|       |	/* Now update the CDF */
 2223|      0|	if (r >= 0)   {
  ------------------
  |  Branch (2223:6): [True: 0, False: 0]
  ------------------
 2224|      0|		r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_CDF, object);
  ------------------
  |  |  492|      0|#define SC_PKCS15_CDF			4
  ------------------
 2225|       |		/* TODO: update private key PKCS#15 object with the certificate's attributes */
 2226|      0|	}
 2227|       |
 2228|      0|	if (r >= 0)   {
  ------------------
  |  Branch (2228:6): [True: 0, False: 0]
  ------------------
 2229|      0|		r = sc_pkcs15_prkey_attrs_from_cert(p15card, object, &key_object);
 2230|      0|		if (r)   {
  ------------------
  |  Branch (2230:7): [True: 0, False: 0]
  ------------------
 2231|      0|			r = 0;
 2232|      0|		}
 2233|      0|		else if (key_object) {
  ------------------
  |  Branch (2233:12): [True: 0, False: 0]
  ------------------
 2234|      0|			if (profile->ops->emu_update_any_df) {
  ------------------
  |  Branch (2234:8): [True: 0, False: 0]
  ------------------
 2235|      0|				r = profile->ops->emu_update_any_df(profile, p15card, SC_AC_OP_UPDATE, key_object);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
 2236|      0|				if (r == SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (2236:9): [True: 0, False: 0]
  ------------------
 2237|      0|					r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2238|      0|			}
 2239|      0|			else {
 2240|      0|				r = sc_pkcs15init_update_any_df(p15card, profile, key_object->df, 0);
 2241|      0|				sc_log(ctx, "update_any_df returned %i", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2242|      0|			}
 2243|      0|		}
 2244|      0|	}
 2245|       |
 2246|      0|	if (r < 0)   {
  ------------------
  |  Branch (2246:6): [True: 0, False: 0]
  ------------------
 2247|      0|		sc_pkcs15_remove_object(p15card, object);
 2248|      0|		sc_pkcs15_free_object(object);
 2249|      0|	}
 2250|      0|	else if (res_obj)   {
  ------------------
  |  Branch (2250:11): [True: 0, False: 0]
  ------------------
 2251|      0|		*res_obj = object;
 2252|      0|	}
 2253|       |
 2254|      0|	profile->dirty = 1;
 2255|       |
 2256|      0|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2257|      0|}
sc_pkcs15init_store_data_object:
 2268|     21|{
 2269|     21|	struct sc_context *ctx = p15card->card->ctx;
 2270|     21|	struct sc_pkcs15_data_info *data_object_info;
 2271|     21|	struct sc_pkcs15_object *object;
 2272|     21|	struct sc_pkcs15_object *objs[32];
 2273|     21|	const char	*label;
 2274|     21|	int		r, i;
 2275|     21|	unsigned int    tid = 0x01;
 2276|       |
 2277|     21|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     21|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     21|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     21|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     21|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2278|     21|	if (!profile)
  ------------------
  |  Branch (2278:6): [True: 21, False: 0]
  ------------------
 2279|     21|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Missing profile");
  ------------------
  |  |  174|     21|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     21|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     21|	int _ret = (r); \
  |  |  |  |  168|     21|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 21, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     21|		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|     21|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     21|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     21|		return _ret; \
  |  |  |  |  172|     21|	} \
  |  |  |  |  173|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2280|      0|	label = args->label;
 2281|       |
 2282|      0|	if (!args->id.len) {
  ------------------
  |  Branch (2282:6): [True: 0, False: 0]
  ------------------
 2283|       |		/* Select an ID if the user didn't specify one, otherwise
 2284|       |		 * make sure it's unique (even though data objects doesn't
 2285|       |		 * have a pkcs15 id we need one here to create a unique
 2286|       |		 * file id from the data file template */
 2287|      0|		r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_DATA_OBJECT, objs, 32);
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
 2288|      0|		LOG_TEST_RET(ctx, r, "Get 'DATA' objects error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2289|       |
 2290|      0|		for (i = 0; i < r; i++) {
  ------------------
  |  Branch (2290:15): [True: 0, False: 0]
  ------------------
 2291|      0|			unsigned char cid;
 2292|      0|			struct sc_pkcs15_data_info *cinfo = (struct sc_pkcs15_data_info *) objs[i]->data;
 2293|      0|			if (!cinfo->path.len)
  ------------------
  |  Branch (2293:8): [True: 0, False: 0]
  ------------------
 2294|      0|				continue;
 2295|      0|			cid = cinfo->path.value[cinfo->path.len - 1];
 2296|      0|			if (cid >= tid)
  ------------------
  |  Branch (2296:8): [True: 0, False: 0]
  ------------------
 2297|      0|				tid = cid + 1;
 2298|      0|		}
 2299|      0|		if (tid > 0xff)
  ------------------
  |  Branch (2299:7): [True: 0, False: 0]
  ------------------
 2300|       |			/* too many data objects ... */
 2301|      0|			return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
 2302|      0|		args->id.len = 1;
 2303|      0|		args->id.value[0] = tid;
 2304|      0|	}
 2305|      0|	else   {
 2306|       |		/* in case the user specifies an id it should be at most
 2307|       |		 * one byte long */
 2308|      0|		if (args->id.len > 1)
  ------------------
  |  Branch (2308:7): [True: 0, False: 0]
  ------------------
 2309|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2310|      0|	}
 2311|       |
 2312|      0|	object = sc_pkcs15init_new_object(SC_PKCS15_TYPE_DATA_OBJECT, label, &args->auth_id, NULL);
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
 2313|      0|	if (object == NULL)
  ------------------
  |  Branch (2313:6): [True: 0, False: 0]
  ------------------
 2314|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2315|       |
 2316|      0|	data_object_info = (struct sc_pkcs15_data_info *) object->data;
 2317|      0|	if (args->app_label != NULL)
  ------------------
  |  Branch (2317:6): [True: 0, False: 0]
  ------------------
 2318|      0|		strlcpy(data_object_info->app_label, args->app_label, sizeof(data_object_info->app_label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 2319|      0|	else if (label != NULL)
  ------------------
  |  Branch (2319:11): [True: 0, False: 0]
  ------------------
 2320|      0|		strlcpy(data_object_info->app_label, label, sizeof(data_object_info->app_label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 2321|       |
 2322|      0|	data_object_info->app_oid = args->app_oid;
 2323|      0|	sc_der_copy(&data_object_info->data, &args->der_encoded);
 2324|       |
 2325|      0|	r = sc_pkcs15init_store_data(p15card, profile, object, &args->der_encoded, &data_object_info->path);
 2326|      0|	LOG_TEST_GOTO_ERR(ctx, r, "Store 'DATA' object error");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2327|       |
 2328|       |	/* Now update the DDF */
 2329|      0|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_DODF, object);
  ------------------
  |  |  495|      0|#define SC_PKCS15_DODF			7
  ------------------
 2330|      0|	LOG_TEST_GOTO_ERR(ctx, r, "'DODF' update error");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2331|       |
 2332|      0|	if (r >= 0 && res_obj)
  ------------------
  |  Branch (2332:6): [True: 0, False: 0]
  |  Branch (2332:16): [True: 0, False: 0]
  ------------------
 2333|      0|		*res_obj = object;
 2334|      0|	object = NULL;
 2335|       |
 2336|      0|	profile->dirty = 1;
 2337|       |
 2338|      0|err:
 2339|      0|	sc_pkcs15_free_object(object);
 2340|      0|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2341|      0|}
sc_pkcs15init_select_intrinsic_id:
 2840|      3|{
 2841|       |#ifndef ENABLE_OPENSSL
 2842|       |	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
 2843|       |#else
 2844|      3|	struct sc_context *ctx = p15card->card->ctx;
 2845|      3|	struct sc_pkcs15_pubkey *pubkey = NULL;
 2846|      3|	unsigned id_style;
 2847|      3|	struct sc_pkcs15_id id;
 2848|      3|	unsigned char *id_data = NULL;
 2849|      3|	size_t id_data_len = 0;
 2850|      3|	int rv, allocated = 0;
 2851|       |
 2852|      3|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|      3|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      3|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      3|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      3|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2853|       |
 2854|      3|	if (!id_out || !profile)
  ------------------
  |  Branch (2854:6): [True: 0, False: 3]
  |  Branch (2854:17): [True: 3, False: 0]
  ------------------
 2855|      3|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|      3|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      3|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      3|	int _ret = r; \
  |  |  |  |  155|      3|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      3|		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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      3|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      3|	} 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|      3|	return _ret; \
  |  |  |  |  163|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2856|       |
 2857|      0|	id_style = profile->id_style;
 2858|       |
 2859|       |	/* ID already exists */
 2860|      0|	if (id_out->len)
  ------------------
  |  Branch (2860:6): [True: 0, False: 0]
  ------------------
 2861|      0|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2862|       |
 2863|       |	/* Native ID style is not intrinsic one */
 2864|      0|	if (id_style == SC_PKCS15INIT_ID_STYLE_NATIVE)
  ------------------
  |  |  165|      0|#define SC_PKCS15INIT_ID_STYLE_NATIVE		0
  ------------------
  |  Branch (2864:6): [True: 0, False: 0]
  ------------------
 2865|      0|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2866|       |
 2867|      0|	memset(&id, 0, sizeof(id));
 2868|       |	/* Get PKCS15 public key */
 2869|      0|	switch(type)   {
 2870|      0|	case SC_PKCS15_TYPE_CERT_X509:
  ------------------
  |  |  439|      0|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  |  Branch (2870:2): [True: 0, False: 0]
  ------------------
 2871|      0|		rv = sc_pkcs15_pubkey_from_cert(ctx, (struct sc_pkcs15_der *)data, &pubkey);
 2872|      0|		LOG_TEST_RET(ctx, rv, "X509 parse error");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2873|      0|		allocated = 1;
 2874|      0|		break;
 2875|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2875:2): [True: 0, False: 0]
  ------------------
 2876|      0|		rv = sc_pkcs15_pubkey_from_prvkey(ctx, (struct sc_pkcs15_prkey *)data, &pubkey);
 2877|      0|		LOG_TEST_RET(ctx, rv, "Cannot get public key");
  ------------------
  |  |  174|      0|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2878|      0|		allocated = 1;
 2879|      0|		break;
 2880|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (2880:2): [True: 0, False: 0]
  ------------------
 2881|      0|		pubkey = (struct sc_pkcs15_pubkey *)data;
 2882|      0|		allocated = 0;
 2883|      0|		break;
 2884|      0|	default:
  ------------------
  |  Branch (2884:2): [True: 0, False: 0]
  ------------------
 2885|      0|		sc_log(ctx, "Intrinsic ID is not implemented for the object type 0x%X", type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2886|      0|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2887|      0|	}
 2888|       |
 2889|       |	/* Skip silently if key is not initialized. */
 2890|      0|	if (pubkey->algorithm == SC_ALGORITHM_RSA && !pubkey->u.rsa.modulus.len)
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2890:6): [True: 0, False: 0]
  |  Branch (2890:47): [True: 0, False: 0]
  ------------------
 2891|      0|		goto done;
 2892|      0|	else if (pubkey->algorithm == SC_ALGORITHM_GOSTR3410 &&
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (2892:11): [True: 0, False: 0]
  ------------------
 2893|      0|			!pubkey->u.gostr3410.xy.data)
  ------------------
  |  Branch (2893:4): [True: 0, False: 0]
  ------------------
 2894|      0|		goto done;
 2895|      0|	else if (pubkey->algorithm == SC_ALGORITHM_EC && !pubkey->u.ec.ecpointQ.value)
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2895:11): [True: 0, False: 0]
  |  Branch (2895:51): [True: 0, False: 0]
  ------------------
 2896|      0|		goto done;
 2897|       |
 2898|       |	/* In Mozilla 'GOST R 34.10' is not yet supported.
 2899|       |	 * So, switch to the ID recommended by RFC2459 */
 2900|      0|	if (pubkey->algorithm == SC_ALGORITHM_GOSTR3410 && id_style == SC_PKCS15INIT_ID_STYLE_MOZILLA)
  ------------------
  |  |   71|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
              	if (pubkey->algorithm == SC_ALGORITHM_GOSTR3410 && id_style == SC_PKCS15INIT_ID_STYLE_MOZILLA)
  ------------------
  |  |  166|      0|#define SC_PKCS15INIT_ID_STYLE_MOZILLA		1
  ------------------
  |  Branch (2900:6): [True: 0, False: 0]
  |  Branch (2900:53): [True: 0, False: 0]
  ------------------
 2901|      0|		id_style = SC_PKCS15INIT_ID_STYLE_RFC2459;
  ------------------
  |  |  167|      0|#define SC_PKCS15INIT_ID_STYLE_RFC2459		2
  ------------------
 2902|       |
 2903|      0|	switch (id_style)  {
 2904|      0|	case SC_PKCS15INIT_ID_STYLE_MOZILLA:
  ------------------
  |  |  166|      0|#define SC_PKCS15INIT_ID_STYLE_MOZILLA		1
  ------------------
  |  Branch (2904:2): [True: 0, False: 0]
  ------------------
 2905|      0|		if (pubkey->algorithm == SC_ALGORITHM_RSA)
  ------------------
  |  |   69|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2905:7): [True: 0, False: 0]
  ------------------
 2906|      0|			SHA1(pubkey->u.rsa.modulus.data, pubkey->u.rsa.modulus.len, id.value);
 2907|      0|		else if (pubkey->algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   70|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2907:12): [True: 0, False: 0]
  ------------------
 2908|       |			/* ID should be SHA1 of the X coordinate according to PKCS#15 v1.1 */
 2909|       |			/* skip the 04 tag and get the X component */
 2910|      0|			SHA1(pubkey->u.ec.ecpointQ.value+1, (pubkey->u.ec.ecpointQ.len - 1) / 2, id.value);
 2911|      0|		else
 2912|      0|			goto done;
 2913|       |
 2914|      0|		id.len = SHA_DIGEST_LENGTH;
 2915|      0|		break;
 2916|      0|	case SC_PKCS15INIT_ID_STYLE_RFC2459:
  ------------------
  |  |  167|      0|#define SC_PKCS15INIT_ID_STYLE_RFC2459		2
  ------------------
  |  Branch (2916:2): [True: 0, False: 0]
  ------------------
 2917|      0|		rv = sc_pkcs15_encode_pubkey(ctx, pubkey, &id_data, &id_data_len);
 2918|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Encoding public key error");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2919|       |
 2920|      0|		if (!id_data || !id_data_len) {
  ------------------
  |  Branch (2920:7): [True: 0, False: 0]
  |  Branch (2920:19): [True: 0, False: 0]
  ------------------
 2921|      0|			rv = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2922|      0|			LOG_TEST_GOTO_ERR(ctx, rv, "Encoding public key error");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2923|      0|		}
 2924|       |
 2925|      0|		SHA1(id_data, id_data_len, id.value);
 2926|      0|		id.len = SHA_DIGEST_LENGTH;
 2927|       |
 2928|      0|		break;
 2929|      0|	default:
  ------------------
  |  Branch (2929:2): [True: 0, False: 0]
  ------------------
 2930|      0|		sc_log(ctx, "Unsupported ID style: %i", id_style);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2931|      0|		rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2932|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Non supported ID style");
  ------------------
  |  |  184|      0|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      0|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      0|	int _ret = (r); \
  |  |  |  |  178|      0|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      0|		goto err; \
  |  |  |  |  182|      0|	} \
  |  |  |  |  183|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2933|      0|	}
 2934|       |
 2935|      0|done:
 2936|      0|	memcpy(id_out, &id, sizeof(*id_out));
 2937|      0|	rv = (int)id_out->len;
 2938|       |
 2939|      0|err:
 2940|      0|	if (id_data)
  ------------------
  |  Branch (2940:6): [True: 0, False: 0]
  ------------------
 2941|      0|		free(id_data);
 2942|      0|	if (allocated)
  ------------------
  |  Branch (2942:6): [True: 0, False: 0]
  ------------------
 2943|      0|		sc_pkcs15_free_pubkey(pubkey);
 2944|       |
 2945|      0|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2946|      0|#endif
 2947|      0|}
pkcs15-lib.c:load_dynamic_driver:
  263|     67|{
  264|     67|	const char *version, *libname;
  265|     67|	void *handle;
  266|     67|	void *(*modinit)(const char *)  = NULL;
  267|     67|	const char *(*modversion)(void) = NULL;
  268|       |
  269|     67|	libname = find_library(ctx, name);
  270|     67|	if (!libname)
  ------------------
  |  Branch (270:6): [True: 67, False: 0]
  ------------------
  271|     67|		return NULL;
  272|      0|	handle = sc_dlopen(libname);
  273|      0|	if (handle == NULL) {
  ------------------
  |  Branch (273:6): [True: 0, False: 0]
  ------------------
  274|      0|		sc_log(ctx, "Module %s: cannot load '%s' library: %s", name, libname, sc_dlerror());
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  275|      0|		return NULL;
  276|      0|	}
  277|       |
  278|       |	/* verify correctness of module */
  279|      0|	modinit    = (void *(*)(const char *)) sc_dlsym(handle, "sc_module_init");
  280|      0|	modversion = (const char *(*)(void)) sc_dlsym(handle, "sc_driver_version");
  281|      0|	if (modinit == NULL || modversion == NULL) {
  ------------------
  |  Branch (281:6): [True: 0, False: 0]
  |  Branch (281:25): [True: 0, False: 0]
  ------------------
  282|      0|		sc_log(ctx, "dynamic library '%s' is not a OpenSC module",libname);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  283|      0|		sc_dlclose(handle);
  284|      0|		return NULL;
  285|      0|	}
  286|       |	/* verify module version */
  287|      0|	version = modversion();
  288|      0|	if (version == NULL || strncmp(version, "0.9.", strlen("0.9.")) > 0) {
  ------------------
  |  Branch (288:6): [True: 0, False: 0]
  |  Branch (288:25): [True: 0, False: 0]
  ------------------
  289|      0|		sc_log(ctx,"dynamic library '%s': invalid module version",libname);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  290|      0|		sc_dlclose(handle);
  291|      0|		return NULL;
  292|      0|	}
  293|      0|	*dll = handle;
  294|      0|	sc_log(ctx, "successfully loaded pkcs15init driver '%s'", 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__
  |  |  ------------------
  ------------------
  295|       |
  296|      0|	return modinit(name);
  297|      0|}
pkcs15-lib.c:find_library:
  230|     67|{
  231|     67|	int          i;
  232|     67|	const char   *libname = NULL;
  233|     67|	scconf_block *blk, **blocks;
  234|       |
  235|    134|	for (i = 0; ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (235:14): [True: 67, False: 67]
  ------------------
  236|     67|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i], "framework", "pkcs15");
  237|     67|		if (!blocks)
  ------------------
  |  Branch (237:7): [True: 0, False: 67]
  ------------------
  238|      0|			continue;
  239|     67|		blk = blocks[0];
  240|     67|		free(blocks);
  241|     67|		if (blk == NULL)
  ------------------
  |  Branch (241:7): [True: 67, False: 0]
  ------------------
  242|     67|			continue;
  243|      0|		blocks = scconf_find_blocks(ctx->conf, blk, "pkcs15init", name);
  244|      0|		if (!blocks)
  ------------------
  |  Branch (244:7): [True: 0, False: 0]
  ------------------
  245|      0|			continue;
  246|      0|		blk = blocks[0];
  247|      0|		free(blocks);
  248|      0|		if (blk == NULL)
  ------------------
  |  Branch (248:7): [True: 0, False: 0]
  ------------------
  249|      0|			continue;
  250|      0|		libname = scconf_get_str(blk, "module", NULL);
  251|      0|		break;
  252|      0|	}
  253|     67|	if (!libname) {
  ------------------
  |  Branch (253:6): [True: 67, False: 0]
  ------------------
  254|     67|		sc_log(ctx, "unable to locate pkcs15init driver for '%s'", name);
  ------------------
  |  |   71|     67|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  255|     67|	}
  256|     67|	return libname;
  257|     67|}
pkcs15-lib.c:get_profile_from_config:
  200|    161|{
  201|    161|	struct sc_context *ctx = card->ctx;
  202|    161|	const char *tmp;
  203|    161|	scconf_block **blocks, *blk;
  204|    161|	int i;
  205|       |
  206|    322|	for (i = 0; ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (206:14): [True: 161, False: 161]
  ------------------
  207|    161|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i],
  208|    161|					"card_driver",
  209|    161|					card->driver->short_name);
  210|    161|		if (!blocks)
  ------------------
  |  Branch (210:7): [True: 0, False: 161]
  ------------------
  211|      0|			continue;
  212|    161|		blk = blocks[0];
  213|    161|		free(blocks);
  214|    161|		if (blk == NULL)
  ------------------
  |  Branch (214:7): [True: 161, False: 0]
  ------------------
  215|    161|			continue;
  216|       |
  217|      0|		tmp = scconf_get_str(blk, "profile", NULL);
  218|      0|		if (tmp != NULL) {
  ------------------
  |  Branch (218:7): [True: 0, False: 0]
  ------------------
  219|      0|			strlcpy(buffer, tmp, size);
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  220|      0|			return 1;
  221|      0|		}
  222|      0|	}
  223|       |
  224|    161|	return 0;
  225|    161|}
pkcs15-lib.c:sc_pkcs15init_read_info:
 4518|    190|{
 4519|    190|	struct sc_path	path;
 4520|    190|	struct sc_file	*file = NULL;
 4521|    190|	unsigned char	*mem = NULL;
 4522|    190|	size_t		len = 0;
 4523|    190|	int		r;
 4524|       |
 4525|    190|	sc_format_path(OPENSC_INFO_FILEPATH, &path);
  ------------------
  |  |   70|    190|#define OPENSC_INFO_FILEPATH		"3F0050154946"
  ------------------
 4526|    190|	r = sc_select_file(card, &path, &file);
 4527|    190|	if (r >= 0) {
  ------------------
  |  Branch (4527:6): [True: 71, False: 119]
  ------------------
 4528|     71|		len = file->size;
 4529|     71|		sc_file_free(file);
 4530|     71|		if (len > MAX_FILE_SIZE)
  ------------------
  |  |  220|     71|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (4530:7): [True: 0, False: 71]
  ------------------
 4531|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4532|     71|		mem = malloc(len);
 4533|     71|		if (mem != NULL)
  ------------------
  |  Branch (4533:7): [True: 71, False: 0]
  ------------------
 4534|     71|			r = sc_read_binary(card, 0, mem, len, 0);
 4535|      0|		else
 4536|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 4537|     71|	}
 4538|    119|	else   {
 4539|    119|		r = 0;
 4540|    119|		sc_file_free(file);
 4541|    119|	}
 4542|       |
 4543|    190|	if (r >= 0)
  ------------------
  |  Branch (4543:6): [True: 177, False: 13]
  ------------------
 4544|    177|		r = sc_pkcs15init_parse_info(card, mem, r, profile);
 4545|       |
 4546|    190|	if (mem)
  ------------------
  |  Branch (4546:6): [True: 71, False: 119]
  ------------------
 4547|     71|		free(mem);
 4548|    190|	return r;
 4549|    190|}
pkcs15-lib.c:sc_pkcs15init_parse_info:
 4579|    177|{
 4580|    177|	unsigned char	tag;
 4581|    177|	const unsigned char *end;
 4582|    177|	unsigned int	nopts = 0;
 4583|    177|	size_t		n;
 4584|    177|	int	r = 0;
 4585|       |
 4586|    177|	if ((p == NULL) || (len == 0))
  ------------------
  |  Branch (4586:6): [True: 119, False: 58]
  |  Branch (4586:21): [True: 9, False: 49]
  ------------------
 4587|    128|		return 0;
 4588|       |
 4589|     49|	end = p + (len - 1);
 4590|    620|	while (p < end) {	/* more bytes to look at */
  ------------------
  |  Branch (4590:9): [True: 615, False: 5]
  ------------------
 4591|    615|		r = 0;
 4592|       |
 4593|    615|		tag = *p; p++;
 4594|    615|		if ((tag == 0) || (tag == 0xff) || (p >= end))
  ------------------
  |  Branch (4594:7): [True: 12, False: 603]
  |  Branch (4594:21): [True: 6, False: 597]
  |  Branch (4594:38): [True: 10, False: 587]
  ------------------
 4595|     28|			break;
 4596|       |
 4597|    587|		n = *p;
 4598|    587|		p++;
 4599|       |
 4600|    587|		if (p >= end || p + n > end) { /* invalid length byte n */
  ------------------
  |  Branch (4600:7): [True: 10, False: 577]
  |  Branch (4600:19): [True: 5, False: 572]
  ------------------
 4601|     15|			r = SC_ERROR_PKCS15INIT;
  ------------------
  |  |  102|     15|#define SC_ERROR_PKCS15INIT			-1500
  ------------------
 4602|     15|			goto error;
 4603|     15|		}
 4604|       |
 4605|    572|		switch (tag) {
 4606|    198|		case OPENSC_INFO_TAG_PROFILE:
  ------------------
  |  |   72|    198|#define OPENSC_INFO_TAG_PROFILE		0x01
  ------------------
  |  Branch (4606:3): [True: 198, False: 374]
  ------------------
 4607|    198|			r = set_info_string(&profile->name, p, n);
 4608|    198|			if (r < 0)
  ------------------
  |  Branch (4608:8): [True: 0, False: 198]
  ------------------
 4609|      0|				goto error;
 4610|    198|			break;
 4611|    198|		case OPENSC_INFO_TAG_OPTION:
  ------------------
  |  |   73|     83|#define OPENSC_INFO_TAG_OPTION		0x02
  ------------------
  |  Branch (4611:3): [True: 83, False: 489]
  ------------------
 4612|     83|			if (nopts >= SC_PKCS15INIT_MAX_OPTIONS - 1) {
  ------------------
  |  |   95|     83|#define SC_PKCS15INIT_MAX_OPTIONS 16
  ------------------
  |  Branch (4612:8): [True: 1, False: 82]
  ------------------
 4613|      1|				sc_log(card->ctx, "Too many options in OpenSC Info file");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4614|      1|				r = SC_ERROR_PKCS15INIT;
  ------------------
  |  |  102|      1|#define SC_ERROR_PKCS15INIT			-1500
  ------------------
 4615|      1|				goto error;
 4616|      1|			}
 4617|     82|			r = set_info_string(&profile->options[nopts], p, n);
 4618|     82|			if (r < 0)
  ------------------
  |  Branch (4618:8): [True: 0, False: 82]
  ------------------
 4619|      0|				goto error;
 4620|     82|			profile->options[++nopts] = NULL;
 4621|     82|			break;
 4622|    291|		default:
  ------------------
  |  Branch (4622:3): [True: 291, False: 281]
  ------------------
 4623|    291|			/* Unknown options ignored */ ;
 4624|    572|		}
 4625|    571|		p += n;
 4626|    571|	}
 4627|     33|	return 0;
 4628|       |
 4629|     16|error:
 4630|     16|	sc_log(card->ctx, "OpenSC info file corrupted");
  ------------------
  |  |   71|     16|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4631|     16|	if (profile->name) {
  ------------------
  |  Branch (4631:6): [True: 16, False: 0]
  ------------------
 4632|     16|		free(profile->name);
 4633|     16|		profile->name = NULL;
 4634|     16|	}
 4635|     65|	for (size_t i = 0; i < nopts; i++) {
  ------------------
  |  Branch (4635:21): [True: 49, False: 16]
  ------------------
 4636|     49|		if (profile->options[i])
  ------------------
  |  Branch (4636:7): [True: 49, False: 0]
  ------------------
 4637|     49|			free(profile->options[i]);
 4638|       |		profile->options[i] = NULL;
 4639|     49|	}
 4640|     16|	return r;
 4641|     49|}
pkcs15-lib.c:set_info_string:
 4554|    280|{
 4555|    280|	char	*s;
 4556|       |
 4557|    280|	if (!(s = malloc(len+1)))
  ------------------
  |  Branch (4557:6): [True: 0, False: 280]
  ------------------
 4558|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 4559|    280|	memcpy(s, p, len);
 4560|    280|	s[len] = '\0';
 4561|    280|	if (*strp)
  ------------------
  |  Branch (4561:6): [True: 198, False: 82]
  ------------------
 4562|    198|		free(*strp);
 4563|    280|	*strp = s;
 4564|    280|	return SC_SUCCESS;
  ------------------
  |  |   28|    280|#define SC_SUCCESS				0
  ------------------
 4565|    280|}

sc_pkcs15init_get_muscle_ops:
  321|      2|{
  322|      2|	return &sc_pkcs15init_muscle_operations;
  323|      2|}

sc_pkcs15init_get_myeid_ops:
  995|      4|struct sc_pkcs15init_operations *sc_pkcs15init_get_myeid_ops(void) {
  996|      4|	return &sc_pkcs15init_myeid_operations;
  997|      4|}

sc_pkcs15init_get_oberthur_ops:
  936|      1|{
  937|      1|	return &sc_pkcs15init_oberthur_operations;
  938|      1|}

sc_pkcs15init_get_openpgp_ops:
  620|     13|{
  621|     13|	return &sc_pkcs15init_openpgp_operations;
  622|     13|}

sc_pkcs15init_get_rtecp_ops:
  714|      4|{
  715|      4|	return &sc_pkcs15init_rtecp_operations;
  716|      4|}

sc_pkcs15init_get_rutoken_ops:
  324|      6|{
  325|      6|	return &sc_pkcs15init_rutoken_operations;
  326|      6|}

sc_pkcs15init_get_sc_hsm_ops:
  693|      8|{
  694|      8|	return &sc_pkcs15init_sc_hsm_operations;
  695|      8|}

sc_pkcs15init_get_setcos_ops:
  633|     76|{
  634|     76|	return &sc_pkcs15init_setcos_operations;
  635|     76|}

sc_pkcs15init_get_starcos_ops:
  963|     35|{
  964|     35|	return &sc_pkcs15init_starcos_operations;
  965|     35|}

sc_profile_new:
  290|    257|{
  291|    257|	struct sc_pkcs15_card *p15card;
  292|    257|	struct sc_profile *pro;
  293|       |
  294|    257|	pro = calloc(1, sizeof(*pro));
  295|    257|	if (pro == NULL)
  ------------------
  |  Branch (295:6): [True: 0, False: 257]
  ------------------
  296|      0|		return NULL;
  297|    257|	pro->p15_spec = p15card = sc_pkcs15_card_new();
  298|       |
  299|    257|	pro->pkcs15.do_last_update = 1;
  300|       |
  301|    257|	if (p15card) {
  ------------------
  |  Branch (301:6): [True: 257, False: 0]
  ------------------
  302|    257|		p15card->tokeninfo->label = strdup("OpenSC Card");
  303|    257|		p15card->tokeninfo->manufacturer_id = strdup("OpenSC Project");
  304|    257|		p15card->tokeninfo->serial_number = strdup("0000");
  305|    257|		p15card->tokeninfo->flags = SC_PKCS15_TOKEN_EID_COMPLIANT;
  ------------------
  |  |  598|    257|#define SC_PKCS15_TOKEN_EID_COMPLIANT			0x08
  ------------------
  306|    257|		p15card->tokeninfo->version = 0;
  307|       |
  308|       |		/* Set up EF(TokenInfo) and EF(ODF) */
  309|    257|		p15card->file_tokeninfo = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|    257|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  310|    257|		p15card->file_odf = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|    257|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  311|    257|		p15card->file_unusedspace = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|    257|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  312|    257|	}
  313|       |
  314|       |	/* Assume card does RSA natively */
  315|    257|	pro->rsa_access_flags = DEF_PRKEY_RSA_ACCESS;
  ------------------
  |  |   52|    257|#define DEF_PRKEY_RSA_ACCESS	0x1D
  ------------------
  316|    257|	pro->pin_encoding = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|    257|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  317|    257|	pro->pin_minlen = 4;
  318|    257|	pro->pin_maxlen = 8;
  319|    257|	pro->id_style = SC_PKCS15INIT_ID_STYLE_NATIVE;
  ------------------
  |  |  165|    257|#define SC_PKCS15INIT_ID_STYLE_NATIVE		0
  ------------------
  320|       |
  321|    257|	return pro;
  322|    257|}
sc_profile_load:
  326|    161|{
  327|    161|	struct sc_context *ctx = profile->card->ctx;
  328|    161|	scconf_context	*conf;
  329|    161|	const char *profile_dir = NULL;
  330|    161|	char path[PATH_MAX];
  331|    161|	int res = 0, i;
  332|       |#ifdef _WIN32
  333|       |	char temp_path[PATH_MAX];
  334|       |	size_t temp_len;
  335|       |#endif
  336|       |
  337|    161|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    161|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    161|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    161|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    161|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 161]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  338|    322|	for (i = 0; ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (338:14): [True: 161, False: 161]
  ------------------
  339|    161|		profile_dir = scconf_get_str(ctx->conf_blocks[i], "profile_dir", NULL);
  340|    161|		if (profile_dir)
  ------------------
  |  Branch (340:7): [True: 0, False: 161]
  ------------------
  341|      0|			break;
  342|    161|	}
  343|       |
  344|    161|	if (!profile_dir) {
  ------------------
  |  Branch (344:6): [True: 161, False: 0]
  ------------------
  345|       |#ifdef _WIN32
  346|       |		temp_len = PATH_MAX - 1;
  347|       |		res = sc_ctx_win32_get_config_value(NULL, "ProfileDir", "Software\\" OPENSC_VS_FF_COMPANY_NAME "\\OpenSC" OPENSC_ARCH_SUFFIX,
  348|       |				temp_path, &temp_len);
  349|       |		if (res)
  350|       |			LOG_FUNC_RETURN(ctx, res);
  351|       |		temp_path[temp_len] = '\0';
  352|       |		profile_dir = temp_path;
  353|       |#else
  354|    161|		profile_dir = SC_PKCS15_PROFILE_DIRECTORY;
  355|    161|#endif
  356|    161|	}
  357|    161|	sc_log(ctx, "Using profile directory '%s'.", profile_dir);
  ------------------
  |  |   71|    161|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  358|       |
  359|       |#ifdef _WIN32
  360|       |	snprintf(path, sizeof(path), "%s\\%s.%s", profile_dir, filename, SC_PKCS15_PROFILE_SUFFIX);
  361|       |#else /* _WIN32 */
  362|    161|	snprintf(path, sizeof(path), "%s/%s.%s", profile_dir, filename, SC_PKCS15_PROFILE_SUFFIX);
  ------------------
  |  |   31|    161|#define SC_PKCS15_PROFILE_SUFFIX	"profile"
  ------------------
  363|    161|#endif /* _WIN32 */
  364|       |
  365|    161|	sc_log(ctx, "Trying profile file %s", path);
  ------------------
  |  |   71|    161|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  366|       |
  367|    161|	conf = scconf_new(path);
  368|    161|	res = scconf_parse(conf);
  369|       |
  370|    161|	sc_log(ctx, "profile %s loaded ok", path);
  ------------------
  |  |   71|    161|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  371|       |
  372|    161|	if (res < 0) {
  ------------------
  |  Branch (372:6): [True: 161, False: 0]
  ------------------
  373|    161|		scconf_free(conf);
  374|    161|		LOG_FUNC_RETURN(ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|    161|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    161|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    161|	int _ret = r; \
  |  |  |  |  155|    161|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 161, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    161|		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|    161|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 161, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    161|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    161|	} 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|    161|	return _ret; \
  |  |  |  |  163|    161|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  375|    161|	}
  376|       |
  377|      0|	if (res == 0) {
  ------------------
  |  Branch (377:6): [True: 0, False: 0]
  ------------------
  378|      0|		scconf_free(conf);
  379|      0|		LOG_FUNC_RETURN(ctx, SC_ERROR_SYNTAX_ERROR);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  380|      0|	}
  381|       |
  382|      0|	res = process_conf(profile, conf);
  383|      0|	scconf_free(conf);
  384|      0|	LOG_FUNC_RETURN(ctx, res);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  385|      0|}
sc_profile_free:
  448|    257|{
  449|    257|	struct auth_info *ai;
  450|    257|	struct pin_info *pi;
  451|    257|	sc_macro_t	*mi;
  452|    257|	sc_template_t	*ti;
  453|       |
  454|    257|	if (profile->name)
  ------------------
  |  Branch (454:6): [True: 174, False: 83]
  ------------------
  455|    174|		free(profile->name);
  456|    257|	if (profile->driver)
  ------------------
  |  Branch (456:6): [True: 0, False: 257]
  ------------------
  457|      0|		free(profile->driver);
  458|       |
  459|    257|	free_file_list(&profile->ef_list);
  460|       |
  461|    257|	while ((ai = profile->auth_list) != NULL) {
  ------------------
  |  Branch (461:9): [True: 0, False: 257]
  ------------------
  462|      0|		profile->auth_list = ai->next;
  463|      0|		free(ai);
  464|      0|	}
  465|       |
  466|    257|	while ((ti = profile->template_list) != NULL) {
  ------------------
  |  Branch (466:9): [True: 0, False: 257]
  ------------------
  467|      0|		profile->template_list = ti->next;
  468|      0|		if (ti->data)
  ------------------
  |  Branch (468:7): [True: 0, False: 0]
  ------------------
  469|      0|			sc_profile_free(ti->data);
  470|      0|		if (ti->name)
  ------------------
  |  Branch (470:7): [True: 0, False: 0]
  ------------------
  471|      0|			free(ti->name);
  472|      0|		free(ti);
  473|      0|	}
  474|       |
  475|    257|	while ((mi = profile->macro_list) != NULL) {
  ------------------
  |  Branch (475:9): [True: 0, False: 257]
  ------------------
  476|      0|		profile->macro_list = mi->next;
  477|      0|		if (mi->name)
  ------------------
  |  Branch (477:7): [True: 0, False: 0]
  ------------------
  478|      0|			free(mi->name);
  479|      0|		free(mi);
  480|      0|	}
  481|       |
  482|    257|	while ((pi = profile->pin_list) != NULL) {
  ------------------
  |  Branch (482:9): [True: 0, False: 257]
  ------------------
  483|      0|		profile->pin_list = pi->next;
  484|      0|		if (pi->file_name)
  ------------------
  |  Branch (484:7): [True: 0, False: 0]
  ------------------
  485|      0|			free(pi->file_name);
  486|      0|		free(pi);
  487|      0|	}
  488|       |
  489|    290|	for (int i = 0; profile->options[i]; i++) {
  ------------------
  |  Branch (489:18): [True: 33, False: 257]
  ------------------
  490|     33|		free(profile->options[i]);
  491|     33|	}
  492|       |
  493|    257|	if (profile->p15_spec)
  ------------------
  |  Branch (493:6): [True: 257, False: 0]
  ------------------
  494|    257|		sc_pkcs15_card_free(profile->p15_spec);
  495|       |
  496|    257|	if (profile->dll)
  ------------------
  |  Branch (496:6): [True: 0, False: 257]
  ------------------
  497|      0|		sc_dlclose(profile->dll);
  498|       |
  499|    257|	free(profile);
  500|    257|}
profile.c:init_file:
  270|    771|{
  271|    771|	struct sc_file	*file;
  272|    771|	unsigned int	op;
  273|       |
  274|    771|	file = sc_file_new();
  275|  24.6k|	for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|  24.6k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (275:15): [True: 23.9k, False: 771]
  ------------------
  276|  23.9k|		sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|  23.9k|#define SC_AC_NONE			0x00000000
  ------------------
  277|  23.9k|	}
  278|    771|	file->type = type;
  279|    771|	file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|    771|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  280|    771|	if (file->type != SC_FILE_TYPE_DF && file->type != SC_FILE_TYPE_BSO)
  ------------------
  |  |  214|  1.54k|#define SC_FILE_TYPE_DF			0x04
  ------------------
              	if (file->type != SC_FILE_TYPE_DF && file->type != SC_FILE_TYPE_BSO)
  ------------------
  |  |  217|    771|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (280:6): [True: 771, False: 0]
  |  Branch (280:39): [True: 771, False: 0]
  ------------------
  281|    771|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|    771|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  282|    771|	return file;
  283|    771|}
profile.c:free_file_list:
 1212|    257|{
 1213|    257|	struct file_info	*fi;
 1214|       |
 1215|    257|	while ((fi = *list) != NULL) {
  ------------------
  |  Branch (1215:9): [True: 0, False: 257]
  ------------------
 1216|      0|		*list = fi->next;
 1217|       |
 1218|      0|		if (fi->dont_free == 0)
  ------------------
  |  Branch (1218:7): [True: 0, False: 0]
  ------------------
 1219|      0|			sc_file_free(fi->file);
 1220|      0|		free(fi->profile_extension);
 1221|      0|		free(fi->ident);
 1222|      0|		free(fi);
 1223|      0|	}
 1224|    257|}

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

scconf_new:
   37|  17.1k|{
   38|  17.1k|	scconf_context *config;
   39|       |
   40|  17.1k|	config = calloc(1, sizeof(scconf_context));
   41|  17.1k|	if (!config) {
  ------------------
  |  Branch (41:6): [True: 0, False: 17.1k]
  ------------------
   42|      0|		return NULL;
   43|      0|	}
   44|  17.1k|	config->filename = filename ? strdup(filename) : NULL;
  ------------------
  |  Branch (44:21): [True: 17.1k, False: 0]
  ------------------
   45|  17.1k|	config->root = calloc(1, sizeof(scconf_block));
   46|  17.1k|	if (!config->root) {
  ------------------
  |  Branch (46:6): [True: 0, False: 17.1k]
  ------------------
   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|  17.1k|	return config;
   54|  17.1k|}
scconf_free:
   57|  17.1k|{
   58|  17.1k|	if (config) {
  ------------------
  |  Branch (58:6): [True: 17.1k, False: 0]
  ------------------
   59|  17.1k|		scconf_block_destroy(config->root);
   60|  17.1k|		if (config->filename) {
  ------------------
  |  Branch (60:7): [True: 17.1k, False: 0]
  ------------------
   61|  17.1k|			free(config->filename);
   62|  17.1k|		}
   63|  17.1k|		free(config);
   64|  17.1k|	}
   65|  17.1k|}
scconf_find_blocks:
   87|   951k|{
   88|   951k|	scconf_block **blocks = NULL, **tmp;
   89|   951k|	int alloc_size, size;
   90|   951k|	scconf_item *item;
   91|       |
   92|   951k|	if (!block) {
  ------------------
  |  Branch (92:6): [True: 51.0k, False: 900k]
  ------------------
   93|  51.0k|		block = config->root;
   94|  51.0k|	}
   95|   951k|	if (!item_name) {
  ------------------
  |  Branch (95:6): [True: 0, False: 951k]
  ------------------
   96|      0|		return NULL;
   97|      0|	}
   98|   951k|	size = 0;
   99|   951k|	alloc_size = 10;
  100|   951k|	tmp = (scconf_block **) realloc(blocks, sizeof(scconf_block *) * alloc_size);
  101|   951k|	if (!tmp) {
  ------------------
  |  Branch (101:6): [True: 0, False: 951k]
  ------------------
  102|      0|		free(blocks);
  103|      0|		return NULL;
  104|      0|	}
  105|   951k|	blocks = tmp;
  106|       |
  107|  1.90M|	for (item = block->items; item; item = item->next) {
  ------------------
  |  Branch (107:28): [True: 951k, False: 951k]
  ------------------
  108|   951k|		if (item->type == SCCONF_ITEM_TYPE_BLOCK &&
  ------------------
  |  |   43|  1.90M|#define SCCONF_ITEM_TYPE_BLOCK		1	/* key = key, block */
  ------------------
  |  Branch (108:7): [True: 51.0k, False: 900k]
  ------------------
  109|  51.0k|		    strcasecmp(item_name, item->key) == 0) {
  ------------------
  |  Branch (109:7): [True: 51.0k, False: 0]
  ------------------
  110|  51.0k|			if (!item->value.block)
  ------------------
  |  Branch (110:8): [True: 0, False: 51.0k]
  ------------------
  111|      0|				continue;
  112|  51.0k|			if (key && strcasecmp(key, item->value.block->name->data)) {
  ------------------
  |  Branch (112:8): [True: 51.0k, False: 0]
  |  Branch (112:15): [True: 34.0k, False: 17.0k]
  ------------------
  113|  34.0k|				continue;
  114|  34.0k|			}
  115|  17.0k|			if (size + 1 >= alloc_size) {
  ------------------
  |  Branch (115:8): [True: 0, False: 17.0k]
  ------------------
  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|  17.0k|			blocks[size++] = item->value.block;
  125|  17.0k|		}
  126|   951k|	}
  127|   951k|	blocks[size] = NULL;
  128|   951k|	return blocks;
  129|   951k|}
scconf_find_list:
  132|   152k|{
  133|   152k|	scconf_item *item;
  134|       |
  135|   152k|	if (!block)
  ------------------
  |  Branch (135:6): [True: 32.8k, False: 119k]
  ------------------
  136|  32.8k|		return NULL;
  137|       |
  138|   221k|	for (item = block->items; item; item = item->next)
  ------------------
  |  Branch (138:28): [True: 119k, False: 102k]
  ------------------
  139|   119k|		if (item->type == SCCONF_ITEM_TYPE_VALUE && strcasecmp(option, item->key) == 0)
  ------------------
  |  |   44|   238k|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (139:7): [True: 119k, False: 0]
  |  Branch (139:47): [True: 17.0k, False: 102k]
  ------------------
  140|  17.0k|			return item->value.list;
  141|   102k|	return NULL;
  142|   119k|}
scconf_get_str:
  145|  34.2k|{
  146|  34.2k|	const scconf_list *list;
  147|       |
  148|  34.2k|	list = scconf_find_list(block, option);
  149|  34.2k|	if (!list)
  ------------------
  |  Branch (149:6): [True: 34.2k, False: 0]
  ------------------
  150|  34.2k|		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|  17.0k|{
  161|  17.0k|	const scconf_list *list;
  162|  17.0k|	long res;
  163|       |
  164|  17.0k|	list = scconf_find_list(block, option);
  165|  17.0k|	if (!list) {
  ------------------
  |  Branch (165:6): [True: 17.0k, False: 0]
  ------------------
  166|  17.0k|		return def;
  167|  17.0k|	}
  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|  83.8k|{
  177|  83.8k|	const scconf_list *list;
  178|       |
  179|  83.8k|	list = scconf_find_list(block, option);
  180|  83.8k|	if (!list) {
  ------------------
  |  Branch (180:6): [True: 83.8k, False: 0]
  ------------------
  181|  83.8k|		return def;
  182|  83.8k|	}
  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|  83.8k|}
scconf_item_destroy:
  257|  34.2k|{
  258|  34.2k|	scconf_item *next;
  259|       |
  260|  68.2k|	while (item) {
  ------------------
  |  Branch (260:9): [True: 34.0k, False: 34.2k]
  ------------------
  261|  34.0k|		next = item->next;
  262|       |
  263|  34.0k|		switch (item->type) {
  ------------------
  |  Branch (263:11): [True: 34.0k, False: 0]
  ------------------
  264|      0|		case SCCONF_ITEM_TYPE_COMMENT:
  ------------------
  |  |   42|      0|#define SCCONF_ITEM_TYPE_COMMENT	0	/* key = NULL, comment */
  ------------------
  |  Branch (264:3): [True: 0, False: 34.0k]
  ------------------
  265|      0|			if (item->value.comment) {
  ------------------
  |  Branch (265:8): [True: 0, False: 0]
  ------------------
  266|      0|				free(item->value.comment);
  267|      0|			}
  268|      0|			item->value.comment = NULL;
  269|      0|			break;
  270|  17.0k|		case SCCONF_ITEM_TYPE_BLOCK:
  ------------------
  |  |   43|  17.0k|#define SCCONF_ITEM_TYPE_BLOCK		1	/* key = key, block */
  ------------------
  |  Branch (270:3): [True: 17.0k, False: 17.0k]
  ------------------
  271|  17.0k|			scconf_block_destroy(item->value.block);
  272|  17.0k|			break;
  273|  17.0k|		case SCCONF_ITEM_TYPE_VALUE:
  ------------------
  |  |   44|  17.0k|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (273:3): [True: 17.0k, False: 17.0k]
  ------------------
  274|  17.0k|			scconf_list_destroy(item->value.list);
  275|  17.0k|			break;
  276|  34.0k|		}
  277|       |
  278|  34.0k|		if (item->key) {
  ------------------
  |  Branch (278:7): [True: 34.0k, False: 0]
  ------------------
  279|  34.0k|			free(item->key);
  280|  34.0k|		}
  281|       |		item->key = NULL;
  282|  34.0k|		free(item);
  283|  34.0k|		item = next;
  284|  34.0k|	}
  285|  34.2k|}
scconf_block_destroy:
  310|  34.2k|{
  311|  34.2k|	if (block) {
  ------------------
  |  Branch (311:6): [True: 34.2k, False: 0]
  ------------------
  312|  34.2k|		scconf_list_destroy(block->name);
  313|  34.2k|		scconf_item_destroy(block->items);
  314|  34.2k|		free(block);
  315|  34.2k|	}
  316|  34.2k|}
scconf_list_add:
  319|  51.0k|{
  320|  51.0k|	scconf_list *rec, **tmp;
  321|       |
  322|  51.0k|	rec = calloc(1, sizeof(scconf_list));
  323|  51.0k|	if (!rec) {
  ------------------
  |  Branch (323:6): [True: 0, False: 51.0k]
  ------------------
  324|      0|		return NULL;
  325|      0|	}
  326|  51.0k|	rec->data = value ? strdup(value) : NULL;
  ------------------
  |  Branch (326:14): [True: 51.0k, False: 0]
  ------------------
  327|       |
  328|  51.0k|	if (!*list) {
  ------------------
  |  Branch (328:6): [True: 34.0k, False: 17.0k]
  ------------------
  329|  34.0k|		*list = rec;
  330|  34.0k|	} else {
  331|  34.0k|		for (tmp = list; *tmp; tmp = &(*tmp)->next);
  ------------------
  |  Branch (331:20): [True: 17.0k, False: 17.0k]
  ------------------
  332|  17.0k|		*tmp = rec;
  333|  17.0k|	}
  334|  51.0k|	return rec;
  335|  51.0k|}
scconf_list_destroy:
  350|   102k|{
  351|   102k|	scconf_list *next;
  352|       |
  353|   153k|	while (list) {
  ------------------
  |  Branch (353:9): [True: 51.0k, False: 102k]
  ------------------
  354|  51.0k|		next = list->next;
  355|  51.0k|		if (list->data) {
  ------------------
  |  Branch (355:7): [True: 51.0k, False: 0]
  ------------------
  356|  51.0k|			free(list->data);
  357|  51.0k|		}
  358|  51.0k|		free(list);
  359|  51.0k|		list = next;
  360|  51.0k|	}
  361|   102k|}

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

test_digest:
  332|    105|{
  333|    105|	CK_SESSION_HANDLE session;
  334|    105|	const uint8_t    *ptr = NULL;
  335|    105|	unsigned char    *dig_data = NULL;
  336|    105|	size_t            dig_size = 0;
  337|    105|	CK_MECHANISM      mech = {0, NULL_PTR, 0};
  ------------------
  |  |   27|    105|#define NULL_PTR ((void *)0)
  ------------------
  338|    105|	unsigned char     buffer[64] = {0};
  339|    105|	CK_ULONG          hash_len = sizeof(buffer);
  340|       |
  341|    105|	if (set_mechanism(&data, &size, &mech))
  ------------------
  |  Branch (341:6): [True: 0, False: 105]
  ------------------
  342|      0|		return;
  343|       |
  344|       |	/* Copy data for hashing*/
  345|    105|	ptr = data;
  346|    105|	if ((dig_size = get_buffer(&ptr, size, &data, &size, 6000)) == 0)
  ------------------
  |  Branch (346:6): [True: 2, False: 103]
  ------------------
  347|      2|		return;
  348|    103|	if (!(dig_data = malloc(dig_size)))
  ------------------
  |  Branch (348:6): [True: 0, False: 103]
  ------------------
  349|      0|		return;
  350|    103|	memcpy(dig_data, ptr, dig_size);
  351|       |
  352|    103|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    103|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (352:6): [True: 34, False: 69]
  ------------------
  353|     34|		goto end;
  354|       |
  355|     69|	if (p11->C_DigestInit(session, &mech) == CKR_OK)
  ------------------
  |  | 1086|     69|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (355:6): [True: 1, False: 68]
  ------------------
  356|      1|		p11->C_Digest(session, dig_data, dig_size, buffer, &hash_len);
  357|       |
  358|     69|	p11->C_CloseSession(session);
  359|     69|	p11->C_Finalize(NULL);
  360|    103|end:
  361|    103|	free(dig_data);
  362|    103|}
fill_bool_attr:
  638|  3.20k|{
  639|  3.20k|	if (value) {
  ------------------
  |  Branch (639:6): [True: 2.25k, False: 946]
  ------------------
  640|  2.25k|		FILL_ATTR((*keyTemplate)[*n_attr], type, &_true, sizeof(_true));
  ------------------
  |  |  631|  2.25k|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|  2.25k|	(attr).type=(typ); \
  |  |  633|  2.25k|	(attr).pValue=(val); \
  |  |  634|  2.25k|	(attr).ulValueLen=len; \
  |  |  635|  2.25k|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 2.25k]
  |  |  ------------------
  ------------------
  641|  2.25k|	}
  642|    946|	else {
  643|    946|		FILL_ATTR((*keyTemplate)[*n_attr], type, &_false, sizeof(_false));
  ------------------
  |  |  631|    946|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|    946|	(attr).type=(typ); \
  |  |  633|    946|	(attr).pValue=(val); \
  |  |  634|    946|	(attr).ulValueLen=len; \
  |  |  635|    946|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 946]
  |  |  ------------------
  ------------------
  644|    946|	}
  645|       |	
  646|  3.20k|	++(*n_attr);
  647|  3.20k|}
fill_key_template:
  650|    905|{
  651|    905|	const unsigned char *ptr = NULL;
  652|    905|	size_t               ecparams_size = 0;
  653|    905|	size_t               opt_object_label_size = 0;
  654|    905|	size_t               opt_object_id_len = 0;
  655|    905|	size_t               opt_allowed_mechanisms_len = 0;
  656|    905|	int bool_types[] = {CKA_MODULUS_BITS, CKA_PUBLIC_EXPONENT, CKA_VERIFY, CKA_SENSITIVE,
  ------------------
  |  |  175|    905|#define CKA_MODULUS_BITS 0x00000121UL
  ------------------
              	int bool_types[] = {CKA_MODULUS_BITS, CKA_PUBLIC_EXPONENT, CKA_VERIFY, CKA_SENSITIVE,
  ------------------
  |  |  176|    905|#define CKA_PUBLIC_EXPONENT 0x00000122UL
  ------------------
              	int bool_types[] = {CKA_MODULUS_BITS, CKA_PUBLIC_EXPONENT, CKA_VERIFY, CKA_SENSITIVE,
  ------------------
  |  |  169|    905|#define CKA_VERIFY 0x0000010AUL
  ------------------
              	int bool_types[] = {CKA_MODULUS_BITS, CKA_PUBLIC_EXPONENT, CKA_VERIFY, CKA_SENSITIVE,
  ------------------
  |  |  162|    905|#define CKA_SENSITIVE 0x00000103UL
  ------------------
  657|    905|						CKA_SIGN, CKA_ENCRYPT, CKA_DECRYPT, CKA_WRAP, CKA_UNWRAP,
  ------------------
  |  |  167|    905|#define CKA_SIGN 0x00000108UL
  ------------------
              						CKA_SIGN, CKA_ENCRYPT, CKA_DECRYPT, CKA_WRAP, CKA_UNWRAP,
  ------------------
  |  |  163|    905|#define CKA_ENCRYPT 0x00000104UL
  ------------------
              						CKA_SIGN, CKA_ENCRYPT, CKA_DECRYPT, CKA_WRAP, CKA_UNWRAP,
  ------------------
  |  |  164|    905|#define CKA_DECRYPT 0x00000105UL
  ------------------
              						CKA_SIGN, CKA_ENCRYPT, CKA_DECRYPT, CKA_WRAP, CKA_UNWRAP,
  ------------------
  |  |  165|    905|#define CKA_WRAP 0x00000106UL
  ------------------
              						CKA_SIGN, CKA_ENCRYPT, CKA_DECRYPT, CKA_WRAP, CKA_UNWRAP,
  ------------------
  |  |  166|    905|#define CKA_UNWRAP 0x00000107UL
  ------------------
  658|    905|						CKA_DERIVE, CKA_PRIVATE, CKA_ALWAYS_AUTHENTICATE, CKA_EXTRACTABLE};
  ------------------
  |  |  171|    905|#define CKA_DERIVE 0x0000010CUL
  ------------------
              						CKA_DERIVE, CKA_PRIVATE, CKA_ALWAYS_AUTHENTICATE, CKA_EXTRACTABLE};
  ------------------
  |  |  139|    905|#define CKA_PRIVATE 0x00000002UL
  ------------------
              						CKA_DERIVE, CKA_PRIVATE, CKA_ALWAYS_AUTHENTICATE, CKA_EXTRACTABLE};
  ------------------
  |  |  202|    905|#define CKA_ALWAYS_AUTHENTICATE 0x00000202UL
  ------------------
              						CKA_DERIVE, CKA_PRIVATE, CKA_ALWAYS_AUTHENTICATE, CKA_EXTRACTABLE};
  ------------------
  |  |  192|    905|#define CKA_EXTRACTABLE 0x00000162UL
  ------------------
  659|       |
  660|    905|	if (!(*keyTemplate = malloc(20 * sizeof(CK_ATTRIBUTE))))
  ------------------
  |  Branch (660:6): [True: 0, False: 905]
  ------------------
  661|      0|		return 1;
  662|    905|	memset(*keyTemplate, 0, 20 * sizeof(CK_ATTRIBUTE));
  663|    905|	FILL_ATTR((*keyTemplate)[0], CKA_CLASS, class, sizeof(CKA_CLASS));
  ------------------
  |  |  631|    905|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|    905|	(attr).type=(typ); \
  |  |  633|    905|	(attr).pValue=(val); \
  |  |  634|    905|	(attr).ulValueLen=len; \
  |  |  635|    905|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 905]
  |  |  ------------------
  ------------------
  664|    905|	*n_attr = 1;
  665|    905|	fill_bool_attr(keyTemplate, n_attr, CKA_TOKEN, token);
  ------------------
  |  |  138|    905|#define CKA_TOKEN 0x00000001UL
  ------------------
  666|       |
  667|  12.3k|	for (int i = 0; i < 13; i++) {
  ------------------
  |  Branch (667:18): [True: 11.4k, False: 874]
  ------------------
  668|       |		/* ... | present -> 0/1 | value | ...*/
  669|  11.4k|		if (*size < 3)
  ------------------
  |  Branch (669:7): [True: 31, False: 11.4k]
  ------------------
  670|     31|			return 1;
  671|  11.4k|		if ((*data)[0] % 2) {
  ------------------
  |  Branch (671:7): [True: 1.81k, False: 9.65k]
  ------------------
  672|  1.81k|			fill_bool_attr(keyTemplate, n_attr, bool_types[i], (*data)[1] % 2);
  673|  1.81k|			(*data)++; (*size)--;
  674|  1.81k|		}
  675|  11.4k|		(*data)++; (*size)--;
  676|  11.4k|	}
  677|       |
  678|    874|	if (*size > 2 && (*data)[0] % 2 && *n_attr < 20){
  ------------------
  |  Branch (678:6): [True: 868, False: 6]
  |  Branch (678:19): [True: 150, False: 718]
  |  Branch (678:37): [True: 150, False: 0]
  ------------------
  679|       |		/* ... | present -> 0/1 | value | ...*/
  680|    150|		key_type = (CK_ULONG) (*data)[1];
  681|    150|		FILL_ATTR((*keyTemplate)[*n_attr], CKA_KEY_TYPE, &key_type, sizeof(key_type));
  ------------------
  |  |  631|    150|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|    150|	(attr).type=(typ); \
  |  |  633|    150|	(attr).pValue=(val); \
  |  |  634|    150|	(attr).ulValueLen=len; \
  |  |  635|    150|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 150]
  |  |  ------------------
  ------------------
  682|    150|		++(*n_attr);
  683|    150|		(*data) += 2;
  684|    150|		(*size) -= 2;
  685|    150|	}
  686|       |
  687|    874|	if (*size > 3 && (*data)[0] % 2 && *n_attr < 20){
  ------------------
  |  Branch (687:6): [True: 850, False: 24]
  |  Branch (687:19): [True: 81, False: 769]
  |  Branch (687:37): [True: 81, False: 0]
  ------------------
  688|       |		/* ... | present -> 0/1 | len | len | data | ... */
  689|     81|		(*data)++; (*size)--;
  690|     81|		ptr = *data;
  691|     81|		if ((ecparams_size = get_buffer(&ptr, *size, data, size, 256)) == 0)
  ------------------
  |  Branch (691:7): [True: 1, False: 80]
  ------------------
  692|      1|			return 1;
  693|     80|		memcpy(ecparams, ptr, ecparams_size);
  694|     80|		FILL_ATTR((*keyTemplate)[*n_attr], CKA_EC_PARAMS, ecparams, ecparams_size);
  ------------------
  |  |  631|     80|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|     80|	(attr).type=(typ); \
  |  |  633|     80|	(attr).pValue=(val); \
  |  |  634|     80|	(attr).ulValueLen=len; \
  |  |  635|     80|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 80]
  |  |  ------------------
  ------------------
  695|     80|		++(*n_attr);
  696|     80|	}
  697|       |
  698|    873|	if (*size > 3 && (*data)[0] % 2 && *n_attr < 20){
  ------------------
  |  Branch (698:6): [True: 842, False: 31]
  |  Branch (698:19): [True: 65, False: 777]
  |  Branch (698:37): [True: 65, False: 0]
  ------------------
  699|       |		/* ... | present -> 0/1 | len | len | data | ... */
  700|     65|		(*data)++; (*size)--;
  701|     65|		ptr = *data;
  702|     65|		if ((opt_object_label_size = get_buffer(&ptr, *size, data, size, 128)) == 0)
  ------------------
  |  Branch (702:7): [True: 6, False: 59]
  ------------------
  703|      6|			return 1;
  704|     59|		memcpy(opt_object_label, ptr, opt_object_label_size);
  705|     59|		FILL_ATTR((*keyTemplate)[*n_attr], CKA_LABEL, opt_object_label, opt_object_label_size);
  ------------------
  |  |  631|     59|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|     59|	(attr).type=(typ); \
  |  |  633|     59|	(attr).pValue=(val); \
  |  |  634|     59|	(attr).ulValueLen=len; \
  |  |  635|     59|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 59]
  |  |  ------------------
  ------------------
  706|     59|		++(*n_attr);
  707|     59|	}
  708|       |
  709|    867|	if (*size > 3 && (*data)[0] % 2 && *n_attr < 20){
  ------------------
  |  Branch (709:6): [True: 834, False: 33]
  |  Branch (709:19): [True: 47, False: 787]
  |  Branch (709:37): [True: 47, False: 0]
  ------------------
  710|       |		/* ... | present -> 0/1 | len | len | data | ... */
  711|     47|		(*data)++; (*size)--;
  712|     47|		ptr = *data;
  713|     47|		if ((opt_object_id_len = get_buffer(&ptr, *size, data, size, 100)) == 0)
  ------------------
  |  Branch (713:7): [True: 2, False: 45]
  ------------------
  714|      2|			return 1;
  715|     45|		memcpy(opt_object_id, ptr, opt_object_id_len);
  716|     45|		FILL_ATTR((*keyTemplate)[*n_attr], CKA_ID, opt_object_id, opt_object_id_len);
  ------------------
  |  |  631|     45|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|     45|	(attr).type=(typ); \
  |  |  633|     45|	(attr).pValue=(val); \
  |  |  634|     45|	(attr).ulValueLen=len; \
  |  |  635|     45|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 45]
  |  |  ------------------
  ------------------
  717|     45|		++(*n_attr);
  718|     45|	}
  719|    865|	if (*size > 4 && (*data)[0]  % 2 && *n_attr < 20){
  ------------------
  |  Branch (719:6): [True: 826, False: 39]
  |  Branch (719:19): [True: 37, False: 789]
  |  Branch (719:38): [True: 37, False: 0]
  ------------------
  720|       |		/* ... | present -> 0/1 | len | mech1 | mech2 | ... | mechn | ... */
  721|     37|		opt_allowed_mechanisms_len = (*data)[1] > 20 ? 20 : (*data)[1];
  ------------------
  |  Branch (721:32): [True: 18, False: 19]
  ------------------
  722|     37|		(*data) += 2;
  723|     37|		(*size) -= 2;
  724|    245|		for (size_t i = 0; i < opt_allowed_mechanisms_len; i++) {
  ------------------
  |  Branch (724:22): [True: 224, False: 21]
  ------------------
  725|    224|			if (*size <= sizeof(unsigned int))
  ------------------
  |  Branch (725:8): [True: 16, False: 208]
  ------------------
  726|     16|				return 1;
  727|    208|			opt_allowed_mechanisms[i] = *((unsigned int *)data);
  728|    208|			(*data) += sizeof(unsigned int);
  729|    208|			(*size) -= sizeof(unsigned int);
  730|    208|		}
  731|     21|		FILL_ATTR((*keyTemplate)[*n_attr], CKA_ALLOWED_MECHANISMS, opt_allowed_mechanisms, opt_allowed_mechanisms_len);
  ------------------
  |  |  631|     21|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|     21|	(attr).type=(typ); \
  |  |  633|     21|	(attr).pValue=(val); \
  |  |  634|     21|	(attr).ulValueLen=len; \
  |  |  635|     21|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 21]
  |  |  ------------------
  ------------------
  732|     21|		++(*n_attr);
  733|     21|	}
  734|    849|	if (*size == 0)
  ------------------
  |  Branch (734:6): [True: 0, False: 849]
  ------------------
  735|      0|		return 1;
  736|    849|	return 0;
  737|    849|}
LLVMFuzzerTestOneInput:
 1056|  17.2k|{
 1057|  17.2k|	uint8_t operation = 0;
 1058|  17.2k|	void (*func_ptr[])(const uint8_t*, size_t) = {
 1059|  17.2k|		test_change_pin,
 1060|  17.2k|		test_init_pin,
 1061|  17.2k|		test_init_token,
 1062|  17.2k|		test_random,
 1063|  17.2k|		test_digest_update,
 1064|  17.2k|		test_digest,
 1065|  17.2k|		test_sign,
 1066|  17.2k|		test_verify,
 1067|  17.2k|		test_decrypt,
 1068|  17.2k|		test_wrap,
 1069|  17.2k|		test_unwrap,
 1070|  17.2k|		test_derive,
 1071|  17.2k|		test_genkeypair,
 1072|  17.2k|		test_store_data,
 1073|  17.2k|		test_store_cert,
 1074|  17.2k|		test_store_key
 1075|  17.2k|	};
 1076|       |
 1077|  17.2k|	if (size < 10)
  ------------------
  |  Branch (1077:6): [True: 6, False: 17.2k]
  ------------------
 1078|      6|		return 0;
 1079|       |
 1080|  17.2k|	operation = *data % 16;
 1081|  17.2k|	data++;
 1082|  17.2k|	size--;
 1083|       |
 1084|  17.2k|	func_ptr[operation](data, size);
 1085|       |
 1086|  17.2k|	return 0;
 1087|  17.2k|}
fuzz_pkcs11.c:set_mechanism:
  176|  2.06k|{
  177|  2.06k|	if (*size < sizeof(unsigned long int))
  ------------------
  |  Branch (177:6): [True: 0, False: 2.06k]
  ------------------
  178|      0|		return 1;
  179|       |
  180|  2.06k|	memset(mech, 0, sizeof(*mech));
  181|  2.06k|	(*mech).mechanism = *((unsigned long int *)*data);
  182|  2.06k|	*data += sizeof(unsigned long int);
  183|  2.06k|	*size -= sizeof(unsigned long int);
  184|  2.06k|	return 0;
  185|  2.06k|}
fuzz_pkcs11.c:fuzz_pkcs11_initialize:
  152|  17.0k|{
  153|  17.0k|	p11 = &pkcs11_function_list_3_0;
  154|       |
  155|  17.0k|	context = NULL;
  156|  17.0k|	memset(&sc_pkcs11_conf, 0, sizeof(struct sc_pkcs11_config));
  157|       |
  158|  17.0k|	p11->C_Initialize(NULL);
  159|       |
  160|  17.0k|	#if FUZZING
  161|       |	/* fuzz target can connect to real card via C_Initialize */
  162|  17.0k|	if (fuzz_card_connect(data, size, slot_out) != CKR_OK) {
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (162:6): [True: 4.40k, False: 12.6k]
  ------------------
  163|  4.40k|		p11->C_Finalize(NULL);
  164|  4.40k|		return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|  4.40k|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  165|  4.40k|	}
  166|  12.6k|	#endif
  167|       |
  168|  12.6k|	if (p11->C_OpenSession(0, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL, NULL, session) != CKR_OK) {
  ------------------
  |  |  403|  12.6k|#define CKF_SERIAL_SESSION 0x00000004UL
  ------------------
              	if (p11->C_OpenSession(0, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL, NULL, session) != CKR_OK) {
  ------------------
  |  |  402|  12.6k|#define CKF_RW_SESSION 0x00000002UL
  ------------------
              	if (p11->C_OpenSession(0, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL, NULL, session) != CKR_OK) {
  ------------------
  |  | 1086|  12.6k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (168:6): [True: 1.30k, False: 11.3k]
  ------------------
  169|  1.30k|		p11->C_Finalize(NULL);
  170|  1.30k|		return CKR_GENERAL_ERROR;
  ------------------
  |  | 1090|  1.30k|#define CKR_GENERAL_ERROR 0x00000005UL
  ------------------
  171|  1.30k|	}
  172|  11.3k|	return CKR_OK;
  ------------------
  |  | 1086|  11.3k|#define CKR_OK 0x00000000UL
  ------------------
  173|  12.6k|}
fuzz_pkcs11.c:fuzz_card_connect:
   53|  17.0k|{
   54|       |	/* Works in the same manner as card_detect() for only one slot and card with virtual reader */
   55|  17.0k|	struct sc_pkcs11_card *p11card = NULL;
   56|  17.0k|	struct sc_reader *reader = NULL;
   57|  17.0k|	struct sc_app_info *app_generic = NULL;
   58|  17.0k|	sc_pkcs11_slot_t *slot = NULL;
   59|  17.0k|	CK_RV rv = CKR_OK;
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
   60|  17.0k|	int free_p11card = 0;
   61|       |
   62|       |	/* Erase possible virtual slots*/
   63|  17.0k|	list_clear(&virtual_slots);
   64|       |
   65|       |	/* Erase possible readers from context */
   66|  17.0k|	while (list_size(&context->readers)) {
  ------------------
  |  Branch (66:9): [True: 0, False: 17.0k]
  ------------------
   67|      0|		sc_reader_t *rdr = (sc_reader_t *) list_get_at(&context->readers, 0);
   68|      0|		_sc_delete_reader(context, rdr);
   69|      0|	}
   70|  17.0k|	if (context->reader_driver->ops->finish != NULL)
  ------------------
  |  Branch (70:6): [True: 17.0k, False: 0]
  ------------------
   71|  17.0k|		context->reader_driver->ops->finish(context);
   72|       |
   73|       |	/* Create virtual reader */
   74|  17.0k|	context->reader_driver = sc_get_fuzz_driver();
   75|  17.0k|	fuzz_add_reader(context, data, size);
   76|  17.0k|	reader = sc_ctx_get_reader(context, 0);
   77|       |
   78|       |	/* Add slot for reader */
   79|  17.0k|	if (create_slot(reader) != CKR_OK) {
  ------------------
  |  | 1086|  17.0k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (79:6): [True: 0, False: 17.0k]
  ------------------
   80|      0|		goto fail;
   81|      0|	}
   82|       |
   83|       |	/* Locate a slot related to the reader */
   84|  17.0k|	for (size_t i = 0; i < list_size(&virtual_slots); i++) {
  ------------------
  |  Branch (84:21): [True: 17.0k, False: 0]
  ------------------
   85|  17.0k|		slot = (sc_pkcs11_slot_t *)list_get_at(&virtual_slots, (int)i);
   86|  17.0k|		if (slot->reader == reader) {
  ------------------
  |  Branch (86:7): [True: 17.0k, False: 0]
  ------------------
   87|  17.0k|			p11card = slot->p11card;
   88|  17.0k|			break;
   89|  17.0k|		}
   90|  17.0k|	}
   91|       |
   92|       |	/* Create p11card */
   93|  17.0k|	p11card = (struct sc_pkcs11_card *)calloc(1, sizeof(struct sc_pkcs11_card));
   94|  17.0k|	p11card->reader = reader;
   95|  17.0k|	free_p11card = 1;
   96|       |
   97|       |	/* Connect card to reader */
   98|  17.0k|	if ((rv = sc_connect_card(reader, &p11card->card)) != SC_SUCCESS) {
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
  |  Branch (98:6): [True: 3.15k, False: 13.8k]
  ------------------
   99|  3.15k|		goto fail;
  100|  3.15k|	}
  101|  13.8k|	init_slot_info(&slot->slot_info, reader);
  102|       |
  103|       |	/* Instead of detecting framework*/
  104|  13.8k|	p11card->framework = &framework_pkcs15;
  105|       |
  106|       |	/* Bind 'generic' application or (emulated?) card without applications */
  107|  13.8k|	app_generic = sc_pkcs15_get_application_by_type(p11card->card, "generic");
  108|  13.8k|	if (app_generic || !p11card->card->app_count) {
  ------------------
  |  Branch (108:6): [True: 0, False: 13.8k]
  |  Branch (108:21): [True: 12.2k, False: 1.66k]
  ------------------
  109|  12.2k|		scconf_block *conf_block = NULL;
  110|       |
  111|  12.2k|		conf_block = sc_match_atr_block(p11card->card->ctx, NULL, &p11card->reader->atr);
  112|  12.2k|		if (!conf_block) /* check default block */
  ------------------
  |  Branch (112:7): [True: 12.2k, False: 0]
  ------------------
  113|  12.2k|			conf_block = sc_get_conf_block(context, "framework", "pkcs15", 1);
  114|       |
  115|  12.2k|		rv = p11card->framework->bind(p11card, app_generic);
  116|  12.2k|		if (rv != CKR_TOKEN_NOT_RECOGNIZED && rv != CKR_OK)
  ------------------
  |  | 1145|  24.4k|#define CKR_TOKEN_NOT_RECOGNIZED 0x000000E1UL
  ------------------
              		if (rv != CKR_TOKEN_NOT_RECOGNIZED && rv != CKR_OK)
  ------------------
  |  | 1086|  6.91k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (116:7): [True: 6.91k, False: 5.30k]
  |  Branch (116:41): [True: 1.25k, False: 5.65k]
  ------------------
  117|  1.25k|			goto fail;
  118|       |
  119|  10.9k|		rv = p11card->framework->create_tokens(p11card, app_generic);
  120|  10.9k|		if (rv != CKR_OK)
  ------------------
  |  | 1086|  10.9k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (120:7): [True: 0, False: 10.9k]
  ------------------
  121|      0|			goto fail;
  122|  10.9k|		free_p11card = 0;
  123|  10.9k|	}
  124|       |	
  125|       |	/* Bind rest of application*/
  126|  16.9k|	for (int j = 0; j < p11card->card->app_count; j++)   {
  ------------------
  |  Branch (126:18): [True: 4.33k, False: 12.6k]
  ------------------
  127|  4.33k|		struct sc_app_info *app_info = p11card->card->app[j];
  128|       |
  129|  4.33k|		if (app_generic && app_generic == p11card->card->app[j])
  ------------------
  |  Branch (129:7): [True: 0, False: 4.33k]
  |  Branch (129:22): [True: 0, False: 0]
  ------------------
  130|      0|			continue;
  131|       |
  132|  4.33k|		if (p11card->framework->bind(p11card, app_info) != CKR_OK) {
  ------------------
  |  | 1086|  4.33k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (132:7): [True: 3.52k, False: 814]
  ------------------
  133|  3.52k|			continue;
  134|  3.52k|		}
  135|    814|		rv = p11card->framework->create_tokens(p11card, app_info);
  136|    814|		if (rv != CKR_OK) {
  ------------------
  |  | 1086|    814|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (136:7): [True: 0, False: 814]
  ------------------
  137|      0|			goto fail;
  138|      0|		}
  139|    814|		free_p11card = 0;
  140|    814|	}
  141|  12.6k|	if (slot_out)
  ------------------
  |  Branch (141:6): [True: 262, False: 12.3k]
  ------------------
  142|    262|		*slot_out = slot;
  143|  17.0k|fail:
  144|  17.0k|	if (free_p11card) {
  ------------------
  |  Branch (144:6): [True: 5.71k, False: 11.3k]
  ------------------
  145|  5.71k|		sc_pkcs11_card_free(p11card);
  146|  5.71k|	}
  147|  17.0k|	return (int)rv;
  148|  12.6k|}
fuzz_pkcs11.c:test_change_pin:
  188|    901|{
  189|    901|	CK_SESSION_HANDLE session;
  190|    901|	CK_TOKEN_INFO     info;
  191|    901|	char             *pin = NULL;
  192|    901|	char             *new_pin = NULL;
  193|    901|	int               login_type = data[0];
  194|    901|	data++; size--;
  195|       |
  196|    901|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (196:6): [True: 1, False: 900]
  ------------------
  197|      1|		goto end;
  198|    900|	if (!(new_pin = extract_word(&data, &size)))
  ------------------
  |  Branch (198:6): [True: 3, False: 897]
  ------------------
  199|      3|		goto end;
  200|       |
  201|    897|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    897|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (201:6): [True: 133, False: 764]
  ------------------
  202|    133|		goto end;
  203|    764|	p11->C_GetTokenInfo(0, &info);
  204|    764|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, pin == NULL ? 0 : strlen(pin));
  ------------------
  |  Branch (204:57): [True: 0, False: 764]
  ------------------
  205|    764|	p11->C_SetPIN(session,
  206|    764|		(CK_UTF8CHAR *) pin, pin == NULL ? 0 : strlen(pin),
  ------------------
  |  Branch (206:24): [True: 0, False: 764]
  ------------------
  207|    764|		(CK_UTF8CHAR *) new_pin, new_pin == NULL ? 0 : strlen(new_pin));
  ------------------
  |  Branch (207:28): [True: 0, False: 764]
  ------------------
  208|       |
  209|    764|	p11->C_CloseSession(session);
  210|    764|	p11->C_Finalize(NULL);
  211|    901|end:
  212|    901|	free(new_pin);
  213|    901|	free(pin);
  214|    901|}
fuzz_pkcs11.c:test_init_pin:
  217|    473|{
  218|    473|	CK_SESSION_HANDLE session;
  219|    473|	CK_TOKEN_INFO     info;
  220|    473|	char             *pin = NULL;
  221|    473|	char             *so_pin = NULL;
  222|    473|	int               login_type = data[0];
  223|    473|	data++; size--;
  224|       |
  225|    473|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (225:6): [True: 1, False: 472]
  ------------------
  226|      1|		goto end;
  227|    472|	if (!(so_pin = extract_word(&data, &size)))
  ------------------
  |  Branch (227:6): [True: 1, False: 471]
  ------------------
  228|      1|		goto end;
  229|       |
  230|    471|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    471|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (230:6): [True: 152, False: 319]
  ------------------
  231|    152|		goto end;
  232|    319|	p11->C_GetTokenInfo(0, &info);
  233|    319|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) so_pin, so_pin == NULL ? 0 : strlen(so_pin));
  ------------------
  |  Branch (233:60): [True: 0, False: 319]
  ------------------
  234|    319|	p11->C_InitPIN(session, (CK_UTF8CHAR *) pin, pin == NULL ? 0 : strlen(pin));
  ------------------
  |  Branch (234:47): [True: 0, False: 319]
  ------------------
  235|       |
  236|    319|	p11->C_CloseSession(session);
  237|    319|	p11->C_Finalize(NULL);
  238|    473|end:
  239|    473|	free(pin);
  240|    473|	free(so_pin);
  241|    473|}
fuzz_pkcs11.c:test_init_token:
  244|    439|{
  245|    439|	CK_SESSION_HANDLE session;
  246|    439|	char             *pin = NULL;
  247|    439|	unsigned char    *label = NULL;
  248|    439|	size_t            label_len = 0;
  249|    439|	unsigned char     token_label[33];
  250|    439|	sc_pkcs11_slot_t *slot = NULL;
  251|       |	/* token label must be padded with blank characters, and which must not be null-terminated*/
  252|    439|	memset(token_label, ' ', sizeof(token_label));
  253|       |
  254|    439|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (254:6): [True: 1, False: 438]
  ------------------
  255|      1|		goto end;
  256|    438|	if (!(label = (unsigned char *) extract_word(&data, &size)))
  ------------------
  |  Branch (256:6): [True: 2, False: 436]
  ------------------
  257|      2|		goto end;
  258|    436|	label_len = strlen((char *) label);
  259|    436|	memcpy(token_label, label, label_len < 33 ? label_len : 32);
  ------------------
  |  Branch (259:29): [True: 433, False: 3]
  ------------------
  260|       |
  261|    436|	if (fuzz_pkcs11_initialize(data, size, &slot, &session) != CKR_OK)
  ------------------
  |  | 1086|    436|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (261:6): [True: 175, False: 261]
  ------------------
  262|    175|		goto end;
  263|    261|	p11->C_InitToken(slot->id, (CK_UTF8CHAR *) pin, pin == NULL ? 0 : strlen(pin), token_label);
  ------------------
  |  Branch (263:50): [True: 0, False: 261]
  ------------------
  264|       |
  265|    261|	p11->C_CloseSession(session);
  266|    261|	p11->C_Finalize(NULL);
  267|    439|end:
  268|    439|	free(pin);
  269|    439|	free(label);
  270|    439|}
fuzz_pkcs11.c:test_random:
  273|  12.8k|{
  274|  12.8k|	CK_SESSION_HANDLE session;
  275|  12.8k|	size_t            random_len = data[0];
  276|  12.8k|	CK_BYTE           buf[256];
  277|  12.8k|	data++; size--;
  278|       |
  279|  12.8k|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|  12.8k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (279:6): [True: 4.94k, False: 7.86k]
  ------------------
  280|  4.94k|		return;
  281|       |
  282|  7.86k|	p11->C_GenerateRandom(session, buf, random_len);
  283|       |
  284|  7.86k|	p11->C_CloseSession(session);
  285|       |	p11->C_Finalize(NULL);
  286|  7.86k|}
fuzz_pkcs11.c:test_digest_update:
  289|    268|{
  290|    268|	CK_SESSION_HANDLE session;
  291|    268|	const uint8_t    *dig_data = NULL;
  292|    268|	size_t            dig_size = 0;
  293|    268|	CK_MECHANISM      mech = {0, NULL_PTR, 0};
  ------------------
  |  |   27|    268|#define NULL_PTR ((void *)0)
  ------------------
  294|    268|	unsigned char     buffer[64] = {0};
  295|    268|	CK_ULONG          hash_len = sizeof(buffer);
  296|    268|	size_t to_process = 0;
  297|    268|	CK_RV rv = 0;
  298|       |
  299|    268|	if (set_mechanism(&data, &size, &mech))
  ------------------
  |  Branch (299:6): [True: 0, False: 268]
  ------------------
  300|      0|		return;
  301|       |
  302|       |	/* Copy data for hashing*/
  303|    268|	dig_data = data;
  304|    268|	if ((dig_size = get_buffer(&dig_data, size, &data, &size, 6000)) == 0)
  ------------------
  |  Branch (304:6): [True: 2, False: 266]
  ------------------
  305|      2|		return;
  306|       |
  307|    266|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    266|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (307:6): [True: 25, False: 241]
  ------------------
  308|     25|		return;
  309|       |
  310|    241|	if (p11->C_DigestInit(session, &mech) != CKR_OK)
  ------------------
  |  | 1086|    241|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (310:6): [True: 231, False: 10]
  ------------------
  311|    231|		goto end;
  312|       |
  313|    195|	while (dig_size > 0) {
  ------------------
  |  Branch (313:9): [True: 185, False: 10]
  ------------------
  314|    185|		to_process = dig_size > sizeof(buffer) ? sizeof(buffer) : dig_size;
  ------------------
  |  Branch (314:16): [True: 175, False: 10]
  ------------------
  315|    185|		dig_size -= to_process;
  316|    185|		memcpy(buffer, dig_data, to_process);
  317|    185|		dig_data += to_process;
  318|       |
  319|    185|		rv = p11->C_DigestUpdate(session, buffer, to_process);
  320|    185|		if (rv != CKR_OK)
  ------------------
  |  | 1086|    185|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (320:7): [True: 0, False: 185]
  ------------------
  321|      0|			goto end;
  322|    185|	}
  323|     10|	hash_len = sizeof(buffer);
  324|     10|	p11->C_DigestFinal(session, buffer, &hash_len);
  325|       |
  326|    241|end:
  327|    241|	p11->C_CloseSession(session);
  328|       |	p11->C_Finalize(NULL);
  329|    241|}
fuzz_pkcs11.c:test_sign:
  396|    511|{
  397|    511|	CK_SESSION_HANDLE    session;
  398|    511|	uint8_t              login_type = CKU_USER;
  ------------------
  |  | 1211|    511|#define CKU_USER 1UL
  ------------------
  399|    511|	char                *pin = NULL;
  400|    511|	const unsigned char *opt_id;
  401|    511|	size_t               opt_id_len = 0;
  402|    511|	const uint8_t       *sign_data = NULL;
  403|    511|	size_t               sign_data_size = 0;
  404|    511|	CK_OBJECT_HANDLE     key = CK_INVALID_HANDLE;
  ------------------
  |  |   33|    511|#define CK_INVALID_HANDLE 0UL
  ------------------
  405|    511|	unsigned char        in_buffer[1025], sig_buffer[512];
  406|    511|	CK_MECHANISM         mech = {0, NULL_PTR, 0};
  ------------------
  |  |   27|    511|#define NULL_PTR ((void *)0)
  ------------------
  407|    511|	CK_ULONG             sig_len = sizeof(sig_buffer);
  408|    511|	size_t               to_process = 0;
  409|    511|	CK_TOKEN_INFO        info;
  410|       |
  411|       |	/* Process options*/
  412|    511|	if (set_mechanism(&data, &size, &mech) || size < 3)
  ------------------
  |  Branch (412:6): [True: 0, False: 511]
  |  Branch (412:44): [True: 1, False: 510]
  ------------------
  413|      1|		return;
  414|    510|	login_type = data[0];
  415|    510|	data++; size--;
  416|    510|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (416:6): [True: 2, False: 508]
  ------------------
  417|      2|		return;
  418|    508|	opt_id = data;
  419|    508|	opt_id_len = get_buffer(&opt_id, size, &data, &size, 256);
  420|       |
  421|       |	/* Prepare buffer for signing */
  422|    508|	sign_data = data;
  423|    508|	if ((sign_data_size = get_buffer(&sign_data, size, &data, &size, 6000)) == 0)
  ------------------
  |  Branch (423:6): [True: 2, False: 506]
  ------------------
  424|      2|		goto end;
  425|       |
  426|       |	/* Initialize */
  427|    506|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    506|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (427:6): [True: 31, False: 475]
  ------------------
  428|     31|		goto end;
  429|    475|	p11->C_GetTokenInfo(0, &info);
  430|    475|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
  431|    475|	fuzz_find_object(session, CKO_PRIVATE_KEY, &key, opt_id_len ? opt_id : NULL, opt_id_len);
  ------------------
  |  | 1030|    475|#define CKO_PRIVATE_KEY 0x00000003UL
  ------------------
  |  Branch (431:51): [True: 6, False: 469]
  ------------------
  432|       |
  433|    475|	if (p11->C_SignInit(session, &mech, key) != CKR_OK)
  ------------------
  |  | 1086|    475|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (433:6): [True: 230, False: 245]
  ------------------
  434|    230|		goto fin;
  435|    245|	p11->C_Login(session, CKU_CONTEXT_SPECIFIC, (CK_UTF8CHAR *) pin, strlen(pin));
  ------------------
  |  | 1212|    245|#define CKU_CONTEXT_SPECIFIC 2UL
  ------------------
  436|       |
  437|    245|	if (sign_data_size <= sizeof(in_buffer)) {
  ------------------
  |  Branch (437:6): [True: 238, False: 7]
  ------------------
  438|    238|		memcpy(in_buffer, sign_data, sign_data_size);
  439|    238|		p11->C_Sign(session, in_buffer, sign_data_size, sig_buffer, &sig_len);
  440|    238|	} else {
  441|     31|		while (sign_data_size > 0) {
  ------------------
  |  Branch (441:10): [True: 24, False: 7]
  ------------------
  442|     24|			to_process = sign_data_size < sizeof(in_buffer) ? sign_data_size : sizeof(in_buffer);
  ------------------
  |  Branch (442:17): [True: 7, False: 17]
  ------------------
  443|     24|			sign_data_size -= to_process;
  444|     24|			memcpy(in_buffer, sign_data, to_process);
  445|     24|			sign_data += to_process;
  446|       |
  447|     24|			if (p11->C_SignUpdate(session, in_buffer, to_process) != CKR_OK)
  ------------------
  |  | 1086|     24|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (447:8): [True: 0, False: 24]
  ------------------
  448|      0|				goto fin;
  449|     24|		}
  450|       |
  451|      7|		sig_len = sizeof(sig_buffer);
  452|      7|		p11->C_SignFinal(session, sig_buffer, &sig_len);
  453|      7|	}
  454|       |
  455|    475|fin:
  456|    475|	p11->C_CloseSession(session);
  457|    475|	p11->C_Finalize(NULL);
  458|    508|end:
  459|    508|	free(pin);
  460|    508|}
fuzz_pkcs11.c:fuzz_find_object:
  366|  1.53k|{
  367|       |	/* taken from tools/pkcs11-tool.c */
  368|  1.53k|	CK_ATTRIBUTE attrs[2];
  369|  1.53k|	unsigned int nattrs = 0;
  370|  1.53k|	CK_ULONG     count = 0;
  371|       |
  372|  1.53k|	attrs[0].type = CKA_CLASS;
  ------------------
  |  |  137|  1.53k|#define CKA_CLASS 0x00000000UL
  ------------------
  373|  1.53k|	attrs[0].pValue = &cls;
  374|  1.53k|	attrs[0].ulValueLen = sizeof(cls);
  375|  1.53k|	nattrs++;
  376|  1.53k|	if (id) {
  ------------------
  |  Branch (376:6): [True: 335, False: 1.19k]
  ------------------
  377|    335|		attrs[nattrs].type = CKA_ID;
  ------------------
  |  |  161|    335|#define CKA_ID 0x00000102UL
  ------------------
  378|    335|		attrs[nattrs].pValue = (void *) id;
  379|    335|		attrs[nattrs].ulValueLen = id_len;
  380|    335|		nattrs++;
  381|    335|	}
  382|       |
  383|  1.53k|	if (p11->C_FindObjectsInit(sess, attrs, nattrs) != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (383:6): [True: 0, False: 1.53k]
  ------------------
  384|      0|		return -1;
  385|       |
  386|  1.53k|	if (p11->C_FindObjects(sess, ret, 1, &count) != CKR_OK)
  ------------------
  |  | 1086|  1.53k|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (386:6): [True: 0, False: 1.53k]
  ------------------
  387|      0|		return -1;
  388|       |
  389|  1.53k|	if (count == 0)
  ------------------
  |  Branch (389:6): [True: 826, False: 706]
  ------------------
  390|    826|		*ret = CK_INVALID_HANDLE;
  ------------------
  |  |   33|    826|#define CK_INVALID_HANDLE 0UL
  ------------------
  391|  1.53k|	p11->C_FindObjectsFinal(sess);
  392|  1.53k|	return (int)count;
  393|  1.53k|}
fuzz_pkcs11.c:test_verify:
  463|    271|{
  464|    271|	CK_SESSION_HANDLE    session;
  465|    271|	CK_MECHANISM         mech = {0, NULL_PTR, 0};
  ------------------
  |  |   27|    271|#define NULL_PTR ((void *)0)
  ------------------
  466|    271|	uint8_t              login_type = CKU_USER;
  ------------------
  |  | 1211|    271|#define CKU_USER 1UL
  ------------------
  467|    271|	char                *pin = NULL;
  468|    271|	const unsigned char *opt_id = NULL;
  469|    271|	size_t               opt_id_len = 0;
  470|    271|	const uint8_t       *verify_data = NULL, *sig_data = NULL;
  471|    271|	size_t               verify_data_size = 0;
  472|    271|	CK_OBJECT_HANDLE     key = CK_INVALID_HANDLE;
  ------------------
  |  |   33|    271|#define CK_INVALID_HANDLE 0UL
  ------------------
  473|    271|	unsigned char        in_buffer[1025], sig_buffer[512];
  474|    271|	CK_ULONG             sig_len = sizeof(sig_buffer);
  475|    271|	size_t               to_process = 0;
  476|       |
  477|       |	/* Process options*/
  478|    271|	if (set_mechanism(&data, &size, &mech) || size < 3)
  ------------------
  |  Branch (478:6): [True: 0, False: 271]
  |  Branch (478:44): [True: 1, False: 270]
  ------------------
  479|      1|		return;
  480|    270|	login_type = data[0];
  481|    270|	data++; size--;
  482|    270|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (482:6): [True: 3, False: 267]
  ------------------
  483|      3|		return;
  484|    267|	opt_id = data;
  485|    267|	opt_id_len = get_buffer(&opt_id, size, &data, &size, 256);
  486|       |
  487|       |	/* Prepare buffer with data */
  488|    267|	verify_data = data;
  489|    267|	if ((verify_data_size = get_buffer(&verify_data, size, &data, &size, 6000)) == 0)
  ------------------
  |  Branch (489:6): [True: 2, False: 265]
  ------------------
  490|      2|		goto end;
  491|       |	/* Get buffer with signature */
  492|    265|	sig_data = data;
  493|    265|	if ((sig_len = get_buffer(&sig_data, size, &data, &size, 512)) == 0)
  ------------------
  |  Branch (493:6): [True: 4, False: 261]
  ------------------
  494|      4|		goto end;
  495|    261|	memcpy(sig_buffer, sig_data, sig_len);
  496|       |
  497|       |	/* Initialize */
  498|    261|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    261|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (498:6): [True: 3, False: 258]
  ------------------
  499|      3|		goto end;
  500|       |
  501|    258|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
  502|       |
  503|    258|	if (!fuzz_find_object(session, CKO_PUBLIC_KEY, &key, opt_id_len ? opt_id : NULL, opt_id_len)
  ------------------
  |  | 1029|    258|#define CKO_PUBLIC_KEY 0x00000002UL
  ------------------
  |  Branch (503:6): [True: 184, False: 74]
  |  Branch (503:55): [True: 128, False: 130]
  ------------------
  504|    184|		&& !fuzz_find_object(session, CKO_CERTIFICATE, &key, opt_id_len ? opt_id : NULL, opt_id_len))
  ------------------
  |  | 1028|    184|#define CKO_CERTIFICATE 0x00000001UL
  ------------------
  |  Branch (504:6): [True: 184, False: 0]
  |  Branch (504:56): [True: 126, False: 58]
  ------------------
  505|    184|		goto fin;
  506|       |
  507|     74|	if (p11->C_VerifyInit(session, &mech, key) != CKR_OK)
  ------------------
  |  | 1086|     74|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (507:6): [True: 25, False: 49]
  ------------------
  508|     25|		goto fin;
  509|       |
  510|     49|	if (verify_data_size <= sizeof(in_buffer)) {
  ------------------
  |  Branch (510:6): [True: 49, False: 0]
  ------------------
  511|     49|		memcpy(in_buffer, verify_data, verify_data_size);
  512|     49|		p11->C_Verify(session, in_buffer, verify_data_size, sig_buffer, sig_len);
  513|     49|	} else {
  514|      0|		while (verify_data_size > 0) {
  ------------------
  |  Branch (514:10): [True: 0, False: 0]
  ------------------
  515|      0|			to_process = verify_data_size < sizeof(in_buffer) ? verify_data_size : sizeof(in_buffer);
  ------------------
  |  Branch (515:17): [True: 0, False: 0]
  ------------------
  516|      0|			verify_data_size -= to_process;
  517|      0|			memcpy(in_buffer, verify_data, to_process);
  518|      0|			verify_data += to_process;
  519|       |
  520|      0|			if (p11->C_VerifyUpdate(session, in_buffer, to_process) != CKR_OK)
  ------------------
  |  | 1086|      0|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (520:8): [True: 0, False: 0]
  ------------------
  521|      0|				goto fin;
  522|      0|		}
  523|       |
  524|      0|		p11->C_VerifyFinal(session, sig_buffer, sig_len);
  525|      0|	}
  526|    258|fin:
  527|    258|	p11->C_CloseSession(session);
  528|    258|	p11->C_Finalize(NULL);
  529|    267|end:
  530|    267|	free(pin);
  531|    267|}
fuzz_pkcs11.c:test_decrypt:
  534|    535|{
  535|    535|	CK_SESSION_HANDLE    session;
  536|    535|	uint8_t              login_type = CKU_USER;
  ------------------
  |  | 1211|    535|#define CKU_USER 1UL
  ------------------
  537|    535|	char                *pin = NULL;
  538|    535|	const unsigned char *opt_id;
  539|    535|	size_t               opt_id_len = 0;
  540|    535|	const uint8_t       *dec_data = NULL;
  541|    535|	size_t               dec_data_size = 0;
  542|    535|	CK_OBJECT_HANDLE     key = CK_INVALID_HANDLE;
  ------------------
  |  |   33|    535|#define CK_INVALID_HANDLE 0UL
  ------------------
  543|    535|	unsigned char        in_buffer[1024], out_buffer[1024];
  544|    535|	CK_MECHANISM         mech = {0, NULL_PTR, 0};
  ------------------
  |  |   27|    535|#define NULL_PTR ((void *)0)
  ------------------
  545|    535|	size_t               out_len = 0;
  546|       |
  547|       |	/* Process options*/
  548|    535|	if (set_mechanism(&data, &size, &mech) || size < 3)
  ------------------
  |  Branch (548:6): [True: 0, False: 535]
  |  Branch (548:44): [True: 1, False: 534]
  ------------------
  549|      1|		return;
  550|    534|	login_type = data[0];
  551|    534|	data++; size--;
  552|    534|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (552:6): [True: 2, False: 532]
  ------------------
  553|      2|		return;
  554|    532|	opt_id = data;
  555|    532|	opt_id_len = get_buffer(&opt_id, size, &data, &size, 256);
  556|       |
  557|       |	/* Prepare buffer for signing */
  558|    532|	dec_data = data;
  559|    532|	if ((dec_data_size = get_buffer(&dec_data, size, &data, &size, 1024)) == 0)
  ------------------
  |  Branch (559:6): [True: 5, False: 527]
  ------------------
  560|      5|		goto end;
  561|       |
  562|       |	/* Initialize */
  563|    527|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    527|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (563:6): [True: 50, False: 477]
  ------------------
  564|     50|		goto end;
  565|       |
  566|    477|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
  567|    477|	if (!fuzz_find_object(session, CKO_PRIVATE_KEY, &key, opt_id_len ? opt_id : NULL, opt_id_len)
  ------------------
  |  | 1030|    477|#define CKO_PRIVATE_KEY 0x00000003UL
  ------------------
  |  Branch (567:6): [True: 115, False: 362]
  |  Branch (567:56): [True: 34, False: 443]
  ------------------
  568|    115|		&& !fuzz_find_object(session, CKO_SECRET_KEY, &key, opt_id_len ? opt_id : NULL, opt_id_len))
  ------------------
  |  | 1031|    115|#define CKO_SECRET_KEY 0x00000004UL
  ------------------
  |  Branch (568:6): [True: 115, False: 0]
  |  Branch (568:55): [True: 31, False: 84]
  ------------------
  569|    115|		goto fin;
  570|       |
  571|    362|	if (p11->C_DecryptInit(session, &mech, key) != CKR_OK)
  ------------------
  |  | 1086|    362|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (571:6): [True: 158, False: 204]
  ------------------
  572|    158|		goto fin;
  573|       |
  574|    204|	p11->C_Login(session, CKU_CONTEXT_SPECIFIC, (CK_UTF8CHAR *) pin, strlen(pin));
  ------------------
  |  | 1212|    204|#define CKU_CONTEXT_SPECIFIC 2UL
  ------------------
  575|    204|	out_len = sizeof(out_buffer);
  576|       |
  577|    204|	memcpy(in_buffer, dec_data, dec_data_size);
  578|    204|	p11->C_Decrypt(session, in_buffer, dec_data_size, out_buffer, &out_len);
  579|    477|fin:
  580|    477|	p11->C_CloseSession(session);
  581|    477|	p11->C_Finalize(NULL);
  582|    532|end:
  583|    532|	free(pin);
  584|    532|}
fuzz_pkcs11.c:test_wrap:
  587|     17|{
  588|     17|	CK_SESSION_HANDLE    session;
  589|     17|	uint8_t              login_type = CKU_USER;
  ------------------
  |  | 1211|     17|#define CKU_USER 1UL
  ------------------
  590|     17|	char                *pin = NULL;
  591|     17|	CK_BYTE              pWrappedKey[4096];
  592|     17|	CK_ULONG             pulWrappedKeyLen = sizeof(pWrappedKey);
  593|     17|	CK_MECHANISM         mech = {0, NULL_PTR, 0};
  ------------------
  |  |   27|     17|#define NULL_PTR ((void *)0)
  ------------------
  594|     17|	CK_OBJECT_HANDLE     hWrappingKey;
  595|     17|	CK_OBJECT_HANDLE     hkey;
  596|     17|	const unsigned char *hkey_id;
  597|     17|	const unsigned char *opt_id;
  598|     17|	size_t               opt_id_len = 0, hkey_id_len = 0;
  599|       |
  600|       |	/* Set options */
  601|     17|	if (set_mechanism(&data, &size, &mech) || size < 3)
  ------------------
  |  Branch (601:6): [True: 0, False: 17]
  |  Branch (601:44): [True: 1, False: 16]
  ------------------
  602|      1|		return;
  603|     16|	login_type = data[0];
  604|     16|	data++; size--;
  605|     16|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (605:6): [True: 1, False: 15]
  ------------------
  606|      1|		return;
  607|     15|	opt_id = data;
  608|     15|	opt_id_len = get_buffer(&opt_id, size, &data, &size, 256);
  609|     15|	hkey_id = data;
  610|     15|	hkey_id_len = get_buffer(&hkey_id, size, &data, &size, 256);
  611|       |
  612|       |	/* Initialize */
  613|     15|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|     15|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (613:6): [True: 3, False: 12]
  ------------------
  614|      3|		goto end;
  615|       |
  616|     12|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
  617|     12|	if (!fuzz_find_object(session, CKO_SECRET_KEY, &hkey, hkey_id_len ? hkey_id : NULL, hkey_id_len))
  ------------------
  |  | 1031|     12|#define CKO_SECRET_KEY 0x00000004UL
  ------------------
  |  Branch (617:6): [True: 12, False: 0]
  |  Branch (617:56): [True: 7, False: 5]
  ------------------
  618|     12|		goto fin;
  619|      0|	if (!fuzz_find_object(session, CKO_PUBLIC_KEY, &hWrappingKey, opt_id_len ? opt_id : NULL, opt_id_len))
  ------------------
  |  | 1029|      0|#define CKO_PUBLIC_KEY 0x00000002UL
  ------------------
  |  Branch (619:6): [True: 0, False: 0]
  |  Branch (619:64): [True: 0, False: 0]
  ------------------
  620|      0|		if (!fuzz_find_object(session, CKO_SECRET_KEY, &hWrappingKey, opt_id_len ? opt_id : NULL, opt_id_len))
  ------------------
  |  | 1031|      0|#define CKO_SECRET_KEY 0x00000004UL
  ------------------
  |  Branch (620:7): [True: 0, False: 0]
  |  Branch (620:65): [True: 0, False: 0]
  ------------------
  621|      0|			goto fin;
  622|      0|	p11->C_WrapKey(session, &mech, hWrappingKey, hkey, pWrappedKey, &pulWrappedKeyLen);
  623|       |
  624|     12|fin:
  625|     12|	p11->C_CloseSession(session);
  626|     12|	p11->C_Finalize(NULL);
  627|     15|end:
  628|     15|	free(pin);
  629|     15|}
fuzz_pkcs11.c:test_unwrap:
  740|     23|{
  741|     23|	CK_SESSION_HANDLE    session;
  742|     23|	CK_MECHANISM         mech = {0, NULL_PTR, 0};
  ------------------
  |  |   27|     23|#define NULL_PTR ((void *)0)
  ------------------
  743|     23|	uint8_t              login_type = CKU_USER;
  ------------------
  |  | 1211|     23|#define CKU_USER 1UL
  ------------------
  744|     23|	char                *pin = NULL;
  745|     23|	const unsigned char *opt_id, *wrapped_key;
  746|     23|	size_t               opt_id_len;
  747|     23|	CK_OBJECT_HANDLE     hUnwrappingKey;
  748|     23|	CK_ULONG             wrapped_key_length;
  749|     23|	CK_BYTE_PTR          pWrappedKey;
  750|     23|	unsigned char        in_buffer[1024];
  751|     23|	CK_OBJECT_CLASS      secret_key_class = CKO_SECRET_KEY;
  ------------------
  |  | 1031|     23|#define CKO_SECRET_KEY 0x00000004UL
  ------------------
  752|     23|	CK_ATTRIBUTE        *keyTemplate = NULL;
  753|     23|	int                  n_attr = 2;
  754|     23|	CK_OBJECT_HANDLE     hSecretKey;
  755|       |
  756|       |	/* Set options */
  757|     23|	if (set_mechanism(&data, &size, &mech) || size < 3)
  ------------------
  |  Branch (757:6): [True: 0, False: 23]
  |  Branch (757:44): [True: 2, False: 21]
  ------------------
  758|      2|		goto end;
  759|     21|	login_type = data[0];
  760|     21|	data++; size--;
  761|     21|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (761:6): [True: 2, False: 19]
  ------------------
  762|      2|		goto end;
  763|     19|	opt_id = data;
  764|     19|	opt_id_len = get_buffer(&opt_id, size, &data, &size, 256);
  765|     19|	wrapped_key = data;
  766|     19|	if ((wrapped_key_length = get_buffer(&wrapped_key, size, &data, &size, 1024)) == 0)
  ------------------
  |  Branch (766:6): [True: 2, False: 17]
  ------------------
  767|      2|		goto end;
  768|     17|	memcpy(in_buffer, wrapped_key, wrapped_key_length);
  769|     17|	pWrappedKey = in_buffer;
  770|       |
  771|     17|	if (fill_key_template((CK_ATTRIBUTE **) &keyTemplate, &n_attr, &data, &size, &secret_key_class, true))
  ------------------
  |  Branch (771:6): [True: 7, False: 10]
  ------------------
  772|      7|		goto end;
  773|       |
  774|       |	/* Initialize */
  775|     10|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|     10|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (775:6): [True: 6, False: 4]
  ------------------
  776|      6|		goto end;
  777|       |
  778|      4|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
  779|       |	/* Find keys*/
  780|      4|	if (!fuzz_find_object(session, CKO_PRIVATE_KEY, &hUnwrappingKey, opt_id_len ? opt_id : NULL, opt_id_len))
  ------------------
  |  | 1030|      4|#define CKO_PRIVATE_KEY 0x00000003UL
  ------------------
  |  Branch (780:6): [True: 2, False: 2]
  |  Branch (780:67): [True: 1, False: 3]
  ------------------
  781|      2|		if (!fuzz_find_object(session, CKO_SECRET_KEY, &hUnwrappingKey, opt_id_len ? opt_id : NULL, opt_id_len))
  ------------------
  |  | 1031|      2|#define CKO_SECRET_KEY 0x00000004UL
  ------------------
  |  Branch (781:7): [True: 2, False: 0]
  |  Branch (781:67): [True: 1, False: 1]
  ------------------
  782|      2|			goto fin;
  783|      2|	p11->C_UnwrapKey(session, &mech, hUnwrappingKey, pWrappedKey, wrapped_key_length, keyTemplate, n_attr, &hSecretKey);
  784|       |
  785|      4|fin:
  786|      4|	p11->C_CloseSession(session);
  787|      4|	p11->C_Finalize(NULL);
  788|     23|end:
  789|     23|	free(pin);
  790|     23|	free(keyTemplate);
  791|     23|}
fuzz_pkcs11.c:test_derive:
  794|     19|{
  795|     19|	CK_SESSION_HANDLE    session;
  796|     19|	CK_OBJECT_HANDLE     key;
  797|     19|	CK_MECHANISM         mech = {0, NULL_PTR, 0};
  ------------------
  |  |   27|     19|#define NULL_PTR ((void *)0)
  ------------------
  798|     19|	uint8_t              login_type = CKU_USER;
  ------------------
  |  | 1211|     19|#define CKU_USER 1UL
  ------------------
  799|     19|	char                *pin = NULL;
  800|     19|	const unsigned char *opt_id = NULL;
  801|     19|	size_t               opt_id_len;
  802|     19|	CK_OBJECT_HANDLE     newkey = 0;
  803|     19|	CK_OBJECT_CLASS      newkey_class = CKO_SECRET_KEY;
  ------------------
  |  | 1031|     19|#define CKO_SECRET_KEY 0x00000004UL
  ------------------
  804|     19|	CK_ATTRIBUTE        *keyTemplate = NULL;
  805|     19|	int                  n_attrs = 2;
  806|       |
  807|       |	/* Set options */
  808|     19|	if (set_mechanism(&data, &size, &mech) || size < 3)
  ------------------
  |  Branch (808:6): [True: 0, False: 19]
  |  Branch (808:44): [True: 1, False: 18]
  ------------------
  809|      1|		goto end;
  810|     18|	login_type = data[0];
  811|     18|	data++; size--;
  812|     18|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (812:6): [True: 1, False: 17]
  ------------------
  813|      1|		goto end;
  814|     17|	opt_id = data;
  815|     17|	opt_id_len = get_buffer(&opt_id, size, &data, &size, 256);
  816|     17|	if (fill_key_template((CK_ATTRIBUTE **) &keyTemplate, &n_attrs, &data, &size, &newkey_class, false))
  ------------------
  |  Branch (816:6): [True: 1, False: 16]
  ------------------
  817|      1|		goto end;
  818|       |
  819|       |	/* Initialize */
  820|     16|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|     16|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (820:6): [True: 11, False: 5]
  ------------------
  821|     11|		goto end;
  822|       |
  823|      5|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
  824|      5|	if (fuzz_find_object(session, CKO_PRIVATE_KEY, &key, opt_id_len ? opt_id : NULL, opt_id_len))
  ------------------
  |  | 1030|      5|#define CKO_PRIVATE_KEY 0x00000003UL
  ------------------
  |  Branch (824:6): [True: 2, False: 3]
  |  Branch (824:55): [True: 1, False: 4]
  ------------------
  825|      2|		p11->C_DeriveKey(session, &mech, key, keyTemplate, n_attrs, &newkey);
  826|       |
  827|      5|	p11->C_CloseSession(session);
  828|      5|	p11->C_Finalize(NULL);
  829|     19|end:
  830|     19|	free(pin);
  831|     19|	free(keyTemplate);
  832|     19|}
fuzz_pkcs11.c:test_genkeypair:
  835|    314|{
  836|    314|	CK_SESSION_HANDLE session;
  837|    314|	CK_OBJECT_HANDLE  hPublicKey;
  838|    314|	CK_OBJECT_HANDLE  hPrivateKey;
  839|    314|	CK_MECHANISM      mech = {0, NULL_PTR, 0};
  ------------------
  |  |   27|    314|#define NULL_PTR ((void *)0)
  ------------------
  840|    314|	uint8_t           login_type = CKU_USER;
  ------------------
  |  | 1211|    314|#define CKU_USER 1UL
  ------------------
  841|    314|	char             *pin = NULL;
  842|    314|	CK_OBJECT_CLASS   pubkey_class = CKO_PUBLIC_KEY;
  ------------------
  |  | 1029|    314|#define CKO_PUBLIC_KEY 0x00000002UL
  ------------------
  843|    314|	CK_OBJECT_CLASS   privkey_class = CKO_PRIVATE_KEY;
  ------------------
  |  | 1030|    314|#define CKO_PRIVATE_KEY 0x00000003UL
  ------------------
  844|    314|	int               n_pubkey_attr = 2;
  845|    314|	int               n_privkey_attr = 2;
  846|    314|	CK_ATTRIBUTE     *publicKeyTemplate = NULL;
  847|    314|	CK_ATTRIBUTE     *privateKeyTemplate = NULL;
  848|       |
  849|       |	/* Process options*/
  850|    314|	if (set_mechanism(&data, &size, &mech) || size < 3)
  ------------------
  |  Branch (850:6): [True: 0, False: 314]
  |  Branch (850:44): [True: 2, False: 312]
  ------------------
  851|      2|		goto end;
  852|    312|	login_type = data[0];
  853|    312|	data++; size--;
  854|    312|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (854:6): [True: 3, False: 309]
  ------------------
  855|      3|		goto end;
  856|       |
  857|    309|	if (fill_key_template(&publicKeyTemplate, &n_pubkey_attr, &data, &size, &pubkey_class, true) != 0
  ------------------
  |  Branch (857:6): [True: 4, False: 305]
  ------------------
  858|    305|		|| fill_key_template(&privateKeyTemplate, &n_privkey_attr, &data, &size, &privkey_class, true) != 0)
  ------------------
  |  Branch (858:6): [True: 7, False: 298]
  ------------------
  859|     11|		goto end;
  860|       |
  861|       |	/* Initialize */
  862|    298|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    298|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (862:6): [True: 47, False: 251]
  ------------------
  863|     47|		goto end;
  864|       |
  865|    251|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
  866|    251|	p11->C_GenerateKeyPair(session, &mech, publicKeyTemplate, n_pubkey_attr,
  867|    251|						   privateKeyTemplate, n_privkey_attr,
  868|    251|						   &hPublicKey, &hPrivateKey);
  869|    251|	p11->C_CloseSession(session);
  870|    251|	p11->C_Finalize(NULL);
  871|       |
  872|    314|end:
  873|    314|	free(pin);
  874|    314|	free(privateKeyTemplate);
  875|    314|	free(publicKeyTemplate);
  876|    314|}
fuzz_pkcs11.c:test_store_data:
  879|     96|{
  880|     96|	CK_SESSION_HANDLE session;
  881|     96|	CK_OBJECT_HANDLE  data_obj;
  882|     96|	CK_OBJECT_CLASS   class = CKO_DATA;
  ------------------
  |  | 1027|     96|#define CKO_DATA 0x00000000UL
  ------------------
  883|     96|	uint8_t           login_type = CKU_USER;
  ------------------
  |  | 1211|     96|#define CKU_USER 1UL
  ------------------
  884|     96|	unsigned char     contents[5001];
  885|     96|	int               contents_len = 0;
  886|     96|	const uint8_t    *ptr = NULL;
  887|     96|	CK_ATTRIBUTE     *data_templ = NULL;
  888|     96|	int               n_data_attr = 0;
  889|     96|	char             *pin = NULL;
  890|     96|	unsigned char     app_id[256];
  891|     96|	int               app_id_len = 0;
  892|       |
  893|       |	/* Create data template */
  894|     96|	if (!(data_templ = malloc(20 * sizeof(CK_ATTRIBUTE))))
  ------------------
  |  Branch (894:6): [True: 0, False: 96]
  ------------------
  895|      0|		return;
  896|     96|	memset(data_templ, 0, 20 * sizeof(CK_ATTRIBUTE));
  897|       |
  898|       |	/* Get PIN */
  899|     96|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (899:6): [True: 1, False: 95]
  ------------------
  900|      1|		goto end;
  901|       |
  902|       |	/* Extract content from fuzzing input*/
  903|     95|	memset(contents, 0, sizeof(contents));
  904|     95|	ptr = data;
  905|     95|	if ((contents_len = get_buffer(&ptr, size, &data, &size, 5000)) == 0)	
  ------------------
  |  Branch (905:6): [True: 6, False: 89]
  ------------------
  906|      6|		goto end;
  907|     89|	memcpy(contents, ptr, contents_len);
  908|     89|	contents[contents_len] = '\0';
  909|       |
  910|       |	/* Fill attributes to data template */
  911|     89|	if (size < 4)
  ------------------
  |  Branch (911:6): [True: 8, False: 81]
  ------------------
  912|      8|		goto end;
  913|     81|	FILL_ATTR(data_templ[n_data_attr], CKA_CLASS, &class, sizeof(class));
  ------------------
  |  |  631|     81|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|     81|	(attr).type=(typ); \
  |  |  633|     81|	(attr).pValue=(val); \
  |  |  634|     81|	(attr).ulValueLen=len; \
  |  |  635|     81|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 81]
  |  |  ------------------
  ------------------
  914|     81|	n_data_attr++;
  915|     81|	FILL_ATTR(data_templ[n_data_attr], CKA_VALUE, &contents, contents_len);
  ------------------
  |  |  631|     81|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|     81|	(attr).type=(typ); \
  |  |  633|     81|	(attr).pValue=(val); \
  |  |  634|     81|	(attr).ulValueLen=len; \
  |  |  635|     81|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 81]
  |  |  ------------------
  ------------------
  916|     81|	n_data_attr++;
  917|     81|	fill_bool_attr(&data_templ, &n_data_attr, CKA_TOKEN, *data % 2);
  ------------------
  |  |  138|     81|#define CKA_TOKEN 0x00000001UL
  ------------------
  918|     81|	data++; size--;
  919|     81|	fill_bool_attr(&data_templ, &n_data_attr, CKA_PRIVATE, *data % 2);
  ------------------
  |  |  139|     81|#define CKA_PRIVATE 0x00000002UL
  ------------------
  920|     81|	data++; size--;
  921|       |
  922|       |	/* Get application id*/
  923|     81|	if (data[0] % 2){
  ------------------
  |  Branch (923:6): [True: 34, False: 47]
  ------------------
  924|     34|		data++; size--;
  925|     34|		ptr = data;
  926|     34|		if ((app_id_len = get_buffer(&ptr, size, &data, &size, 256)) == 0)
  ------------------
  |  Branch (926:7): [True: 9, False: 25]
  ------------------
  927|      9|			goto end;
  928|     25|		memcpy(app_id, ptr, app_id_len);
  929|     25|		FILL_ATTR(data_templ[n_data_attr], CKA_OBJECT_ID, app_id, app_id_len);
  ------------------
  |  |  631|     25|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|     25|	(attr).type=(typ); \
  |  |  633|     25|	(attr).pValue=(val); \
  |  |  634|     25|	(attr).ulValueLen=len; \
  |  |  635|     25|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 25]
  |  |  ------------------
  ------------------
  930|     25|		n_data_attr++;
  931|     25|	}
  932|       |
  933|       |	/* Initialize */
  934|     72|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|     72|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (934:6): [True: 5, False: 67]
  ------------------
  935|      5|		goto end;
  936|       |
  937|     67|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
  938|     67|	p11->C_CreateObject(session, data_templ, n_data_attr, &data_obj);
  939|     67|	p11->C_CloseSession(session);
  940|     67|	p11->C_Finalize(NULL);
  941|     96|end:
  942|     96|	free(data_templ);
  943|     96|	free(pin);
  944|     96|}
fuzz_pkcs11.c:test_store_cert:
  947|    172|{
  948|    172|	CK_SESSION_HANDLE   session;
  949|    172|	CK_OBJECT_CLASS     class = CKO_CERTIFICATE;
  ------------------
  |  | 1028|    172|#define CKO_CERTIFICATE 0x00000001UL
  ------------------
  950|    172|	uint8_t             login_type = CKU_USER;
  ------------------
  |  | 1211|    172|#define CKU_USER 1UL
  ------------------
  951|    172|	unsigned char       contents[5000];
  952|    172|	int                 contents_len = 0;
  953|    172|	const uint8_t      *ptr = NULL;
  954|    172|	CK_ATTRIBUTE       *cert_templ = NULL;
  955|    172|	int                 n_cert_attr = 0;
  956|    172|	char               *pin = NULL;
  957|    172|	CK_OBJECT_HANDLE    cert_obj;
  958|    172|	CK_CERTIFICATE_TYPE cert_type = CKC_X_509;
  ------------------
  |  |  303|    172|#define CKC_X_509 0x00000000UL
  ------------------
  959|       |
  960|       |	/* Create certificate template */
  961|    172|	if (!(cert_templ = malloc(20 * sizeof(CK_ATTRIBUTE))))
  ------------------
  |  Branch (961:6): [True: 0, False: 172]
  ------------------
  962|      0|		return;
  963|    172|	memset(cert_templ, 0, 20 * sizeof(CK_ATTRIBUTE));
  964|       |
  965|       |	/* Get PIN */
  966|    172|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (966:6): [True: 1, False: 171]
  ------------------
  967|      1|		goto end;
  968|       |
  969|       |	/* Extract content from fuzzing input */
  970|    171|	memset(contents, 0, sizeof(contents));
  971|    171|	ptr = data;
  972|    171|	if ((contents_len = get_buffer(&ptr, size, &data, &size, 5000)) == 0)	
  ------------------
  |  Branch (972:6): [True: 5, False: 166]
  ------------------
  973|      5|		goto end;
  974|    166|	memcpy(contents, ptr, contents_len);
  975|    166|	contents[contents_len] = '\0';
  976|       |
  977|       |	/* Fill attributes to certificate template */
  978|    166|	if (size < 4)
  ------------------
  |  Branch (978:6): [True: 4, False: 162]
  ------------------
  979|      4|		goto end;
  980|    162|	FILL_ATTR(cert_templ[n_cert_attr], CKA_CLASS, &class, sizeof(class));
  ------------------
  |  |  631|    162|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|    162|	(attr).type=(typ); \
  |  |  633|    162|	(attr).pValue=(val); \
  |  |  634|    162|	(attr).ulValueLen=len; \
  |  |  635|    162|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 162]
  |  |  ------------------
  ------------------
  981|    162|	n_cert_attr++;
  982|    162|	FILL_ATTR(cert_templ[n_cert_attr], CKA_VALUE, contents, contents_len);
  ------------------
  |  |  631|    162|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|    162|	(attr).type=(typ); \
  |  |  633|    162|	(attr).pValue=(val); \
  |  |  634|    162|	(attr).ulValueLen=len; \
  |  |  635|    162|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 162]
  |  |  ------------------
  ------------------
  983|    162|	n_cert_attr++;
  984|    162|	FILL_ATTR(cert_templ[n_cert_attr], CKA_CERTIFICATE_TYPE, &cert_type, sizeof(cert_type));
  ------------------
  |  |  631|    162|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|    162|	(attr).type=(typ); \
  |  |  633|    162|	(attr).pValue=(val); \
  |  |  634|    162|	(attr).ulValueLen=len; \
  |  |  635|    162|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 162]
  |  |  ------------------
  ------------------
  985|    162|	n_cert_attr++;
  986|    162|	fill_bool_attr(&cert_templ, &n_cert_attr, CKA_TOKEN, *data % 2);
  ------------------
  |  |  138|    162|#define CKA_TOKEN 0x00000001UL
  ------------------
  987|    162|	data++; size--;
  988|    162|	fill_bool_attr(&cert_templ, &n_cert_attr, CKA_PRIVATE, *data % 2);
  ------------------
  |  |  139|    162|#define CKA_PRIVATE 0x00000002UL
  ------------------
  989|    162|	data++; size--;
  990|       |
  991|       |	/* Initialize */
  992|    162|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    162|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (992:6): [True: 55, False: 107]
  ------------------
  993|     55|		goto end;
  994|       |
  995|    107|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
  996|    107|	p11->C_CreateObject(session, cert_templ, n_cert_attr, &cert_obj);
  997|    107|	p11->C_CloseSession(session);
  998|    107|	p11->C_Finalize(NULL);
  999|    172|end:
 1000|    172|	free(pin);
 1001|    172|	free(cert_templ);
 1002|    172|}
fuzz_pkcs11.c:test_store_key:
 1005|    260|{
 1006|    260|	CK_SESSION_HANDLE session;
 1007|    260|	CK_OBJECT_CLASS   class = CKO_SECRET_KEY;
  ------------------
  |  | 1031|    260|#define CKO_SECRET_KEY 0x00000004UL
  ------------------
 1008|    260|	uint8_t           login_type = CKU_USER;
  ------------------
  |  | 1211|    260|#define CKU_USER 1UL
  ------------------
 1009|    260|	unsigned char     contents[5000];
 1010|    260|	int               contents_len = 0;
 1011|    260|	const uint8_t    *ptr = NULL;
 1012|    260|	CK_ATTRIBUTE     *key_template = NULL;
 1013|    260|	int               n_key_attr = 0;
 1014|    260|	char             *pin = NULL;
 1015|    260|	CK_OBJECT_HANDLE  key_obj;
 1016|       |
 1017|    260|	memset(contents, 0, sizeof(contents));
 1018|    260|	if (size < 3)
  ------------------
  |  Branch (1018:6): [True: 0, False: 260]
  ------------------
 1019|      0|		return;
 1020|    260|	class = *data;
 1021|    260|	data++; size--;
 1022|       |
 1023|       |	/* Get PIN */
 1024|    260|	if (!(pin = extract_word(&data, &size)))
  ------------------
  |  Branch (1024:6): [True: 3, False: 257]
  ------------------
 1025|      3|		goto end;
 1026|       |
 1027|    257|	if (fill_key_template(&key_template, &n_key_attr, &data, &size, &class, true) != 0)
  ------------------
  |  Branch (1027:6): [True: 37, False: 220]
  ------------------
 1028|     37|		goto end;
 1029|       |
 1030|    220|	if (size < 3)
  ------------------
  |  Branch (1030:6): [True: 14, False: 206]
  ------------------
 1031|     14|		goto end;
 1032|    206|	if (data[0] && n_key_attr < 20) {
  ------------------
  |  Branch (1032:6): [True: 50, False: 156]
  |  Branch (1032:17): [True: 48, False: 2]
  ------------------
 1033|     48|		data++; size--;
 1034|     48|		ptr = data;
 1035|     48|		if ((contents_len = get_buffer(&ptr, size, &data, &size, 5000)) == 0)	
  ------------------
  |  Branch (1035:7): [True: 19, False: 29]
  ------------------
 1036|     19|			goto end;
 1037|     29|		memcpy(contents, ptr, contents_len);
 1038|     29|		FILL_ATTR(key_template[n_key_attr], CKA_VALUE, contents, contents_len);
  ------------------
  |  |  631|     29|#define FILL_ATTR(attr, typ, val, len) do { \
  |  |  632|     29|	(attr).type=(typ); \
  |  |  633|     29|	(attr).pValue=(val); \
  |  |  634|     29|	(attr).ulValueLen=len; \
  |  |  635|     29|} while(0)
  |  |  ------------------
  |  |  |  Branch (635:9): [Folded, False: 29]
  |  |  ------------------
  ------------------
 1039|     29|		n_key_attr++;
 1040|     29|	}
 1041|       |
 1042|       |	/* Initialize */
 1043|    187|	if (fuzz_pkcs11_initialize(data, size, NULL, &session) != CKR_OK)
  ------------------
  |  | 1086|    187|#define CKR_OK 0x00000000UL
  ------------------
  |  Branch (1043:6): [True: 42, False: 145]
  ------------------
 1044|     42|		goto end;
 1045|       |
 1046|    145|	p11->C_Login(session, login_type, (CK_UTF8CHAR *) pin, strlen(pin));
 1047|    145|	p11->C_CreateObject(session, key_template, n_key_attr, &key_obj);
 1048|    145|	p11->C_CloseSession(session);
 1049|    145|	p11->C_Finalize(NULL);
 1050|    260|end:
 1051|    260|	free(pin);
 1052|    260|	free(key_template);
 1053|    260|}

fuzz_get_chunk:
   36|   620k|{
   37|   620k|    struct driver_data *data;
   38|   620k|    uint16_t c_size;
   39|   620k|    const uint8_t *c;
   40|       |
   41|   620k|    if (chunk)
  ------------------
  |  Branch (41:9): [True: 620k, False: 0]
  ------------------
   42|   620k|        *chunk = NULL;
   43|   620k|    if (chunk_size)
  ------------------
  |  Branch (43:9): [True: 620k, False: 0]
  ------------------
   44|   620k|        *chunk_size = 0;
   45|       |
   46|   620k|    if (!chunk || !chunk_size || !reader) {
  ------------------
  |  Branch (46:9): [True: 0, False: 620k]
  |  Branch (46:19): [True: 0, False: 620k]
  |  Branch (46:34): [True: 0, False: 620k]
  ------------------
   47|      0|        if (reader)
  ------------------
  |  Branch (47:13): [True: 0, False: 0]
  ------------------
   48|      0|            sc_debug(reader->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, "Invalid Arguments");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   49|      0|        return;
   50|      0|    }
   51|   620k|    data = reader->drv_data;
   52|   620k|    if (!data || !data->Data || data->Size < sizeof c_size) {
  ------------------
  |  Branch (52:9): [True: 0, False: 620k]
  |  Branch (52:18): [True: 0, False: 620k]
  |  Branch (52:33): [True: 177k, False: 443k]
  ------------------
   53|   177k|        sc_debug(reader->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, "Invalid Arguments");
  ------------------
  |  |   70|   177k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   54|   177k|        return;
   55|   177k|    }
   56|       |    /* parse the length of the returned data on two bytes */
   57|   443k|    c_size = *((uint16_t *) data->Data);
   58|       |    /* consume two bytes from the fuzzing data */
   59|   443k|    data->Size -= sizeof c_size;
   60|   443k|    data->Data += sizeof c_size;
   61|       |
   62|   443k|    if (data->Size < c_size) {
  ------------------
  |  Branch (62:9): [True: 13.7k, False: 429k]
  ------------------
   63|  13.7k|        c_size = data->Size;
   64|  13.7k|    }
   65|       |
   66|       |    /* consume the bytes from the fuzzing data */
   67|   443k|    c = data->Data;
   68|   443k|    data->Size -= c_size;
   69|   443k|    data->Data += c_size;
   70|       |
   71|   443k|    sc_debug_hex(reader->ctx, SC_LOG_DEBUG_VERBOSE_TOOL,
  ------------------
  |  |  127|   443k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   72|   443k|        "Returning fuzzing chunk", c, c_size);
   73|       |
   74|   443k|    *chunk = c;
   75|   443k|    *chunk_size = c_size;
   76|   443k|}
sc_get_fuzz_driver:
  150|  17.0k|{
  151|  17.0k|    fuzz_ops.release = fuzz_reader_release;
  152|  17.0k|    fuzz_ops.connect = fuzz_reader_connect;
  153|  17.0k|    fuzz_ops.disconnect = fuzz_reader_disconnect;
  154|  17.0k|    fuzz_ops.transmit = fuzz_reader_transmit;
  155|  17.0k|    fuzz_ops.lock = fuzz_reader_lock;
  156|  17.0k|    fuzz_ops.unlock = fuzz_reader_unlock;
  157|  17.0k|    return &fuzz_drv;
  158|  17.0k|}
fuzz_add_reader:
  161|  17.0k|{
  162|  17.0k|    sc_reader_t	*reader;
  163|  17.0k|    struct driver_data *data;
  164|  17.0k|    char name[64] = {0};
  165|       |
  166|  17.0k|    if (!(reader = calloc(1, sizeof(*reader)))
  ------------------
  |  Branch (166:9): [True: 0, False: 17.0k]
  ------------------
  167|  17.0k|            || !(data = (calloc(1, sizeof(*data))))) {
  ------------------
  |  Branch (167:16): [True: 0, False: 17.0k]
  ------------------
  168|      0|        free(reader);
  169|      0|        return;
  170|      0|    }
  171|       |
  172|  17.0k|    data->Data = Data;
  173|  17.0k|    data->Size = Size;
  174|       |
  175|  17.0k|    reader->driver = &fuzz_drv;
  176|  17.0k|    reader->ops = &fuzz_ops;
  177|  17.0k|    reader->drv_data = data;
  178|  17.0k|    snprintf(name, sizeof name - 1, "%zu random byte%s reader (%p)",
  179|  17.0k|            Size, Size == 1 ? "" : "s", Data);
  ------------------
  |  Branch (179:19): [True: 36, False: 16.9k]
  ------------------
  180|  17.0k|    reader->name = strdup(name);
  181|       |
  182|  17.0k|    reader->ctx = ctx;
  183|  17.0k|    list_append(&ctx->readers, reader);
  184|  17.0k|}
fuzzer_reader.c:fuzz_reader_release:
   79|  17.0k|{
   80|  17.0k|    if (reader) {
  ------------------
  |  Branch (80:9): [True: 17.0k, False: 0]
  ------------------
   81|  17.0k|        free(reader->drv_data);
   82|  17.0k|        reader->drv_data = NULL;
   83|  17.0k|    }
   84|       |
   85|  17.0k|    return SC_SUCCESS;
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
   86|  17.0k|}
fuzzer_reader.c:fuzz_reader_connect:
   89|  17.0k|{
   90|  17.0k|    uint16_t chunk_size;
   91|  17.0k|    const uint8_t *chunk;
   92|       |
   93|  17.0k|    fuzz_get_chunk(reader, &chunk, &chunk_size);
   94|       |
   95|  17.0k|    if (chunk_size > SC_MAX_ATR_SIZE)
  ------------------
  |  |   41|  17.0k|#define SC_MAX_ATR_SIZE			33
  ------------------
  |  Branch (95:9): [True: 66, False: 16.9k]
  ------------------
   96|     66|        chunk_size = SC_MAX_ATR_SIZE;
  ------------------
  |  |   41|     66|#define SC_MAX_ATR_SIZE			33
  ------------------
   97|  16.9k|    else
   98|  16.9k|        reader->atr.len = chunk_size;
   99|       |
  100|  17.0k|    if (chunk_size > 0)
  ------------------
  |  Branch (100:9): [True: 12.1k, False: 4.90k]
  ------------------
  101|  12.1k|        memcpy(reader->atr.value, chunk, chunk_size);
  102|       |
  103|  17.0k|    return SC_SUCCESS;
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
  104|  17.0k|}
fuzzer_reader.c:fuzz_reader_disconnect:
  107|  17.0k|{
  108|  17.0k|    return SC_SUCCESS;
  ------------------
  |  |   28|  17.0k|#define SC_SUCCESS				0
  ------------------
  109|  17.0k|}
fuzzer_reader.c:fuzz_reader_transmit:
  112|   603k|{
  113|   603k|    const uint8_t *chunk;
  114|   603k|    uint16_t chunk_size;
  115|       |
  116|   603k|    fuzz_get_chunk(reader, &chunk, &chunk_size);
  117|       |
  118|   603k|    if (chunk_size >= 2) {
  ------------------
  |  Branch (118:9): [True: 339k, False: 264k]
  ------------------
  119|       |        /* set the SW1 and SW2 status bytes (the last two bytes of
  120|       |         * the response */
  121|   339k|        apdu->sw1 = (unsigned int)chunk[chunk_size - 2];
  122|   339k|        apdu->sw2 = (unsigned int)chunk[chunk_size - 1];
  123|   339k|        chunk_size -= 2;
  124|       |        /* set output length and copy the returned data if necessary */
  125|   339k|        if (chunk_size <= apdu->resplen)
  ------------------
  |  Branch (125:13): [True: 283k, False: 55.9k]
  ------------------
  126|   283k|            apdu->resplen = chunk_size;
  127|       |
  128|   339k|        if (apdu->resplen != 0)
  ------------------
  |  Branch (128:13): [True: 247k, False: 92.2k]
  ------------------
  129|   247k|            memcpy(apdu->resp, chunk, apdu->resplen);
  130|   339k|    } else {
  131|   264k|        apdu->sw1 = 0x6D;
  132|   264k|        apdu->sw2 = 0x00;
  133|   264k|        apdu->resplen = 0;
  134|   264k|    }
  135|       |
  136|   603k|    return SC_SUCCESS;
  ------------------
  |  |   28|   603k|#define SC_SUCCESS				0
  ------------------
  137|   603k|}
fuzzer_reader.c:fuzz_reader_lock:
  140|   315k|{
  141|   315k|    return 0;
  142|   315k|}
fuzzer_reader.c:fuzz_reader_unlock:
  145|   315k|{
  146|   315k|    return 0;
  147|   315k|}

get_word:
   26|  5.82k|{
   27|       |	/* Words are separated by one zero byte,
   28|       |	   return pointer to the next word if there is one */
   29|  5.82k|	const uint8_t *ptr = data;
   30|  5.82k|	if (!data || size == 0 || *data == 0)
  ------------------
  |  Branch (30:6): [True: 0, False: 5.82k]
  |  Branch (30:15): [True: 0, False: 5.82k]
  |  Branch (30:28): [True: 14, False: 5.81k]
  ------------------
   31|     14|		return NULL;
   32|       |	
   33|  5.81k|	ptr = memchr(data, 0, size - 1);
   34|  5.81k|	return ptr ? ++ptr : NULL;
  ------------------
  |  Branch (34:9): [True: 5.80k, False: 11]
  ------------------
   35|  5.82k|}
extract_word:
   38|  5.83k|{
   39|       |	/* Find word and return its copy (needs to be freed) */
   40|  5.83k|	char *result = NULL;
   41|  5.83k|	const uint8_t *ptr = NULL;
   42|       |
   43|  5.83k|	if (*size < 2)
  ------------------
  |  Branch (43:6): [True: 3, False: 5.82k]
  ------------------
   44|      3|		return NULL;
   45|       |
   46|  5.82k|	ptr = get_word(*data, *size);
   47|  5.82k|	if (!ptr)
  ------------------
  |  Branch (47:6): [True: 25, False: 5.80k]
  ------------------
   48|     25|		return NULL;
   49|  5.80k|	result = strdup((const char *)*data);
   50|  5.80k|	*size -=(ptr - *data);
   51|  5.80k|	*data = ptr;
   52|       |
   53|  5.80k|	return result;
   54|  5.82k|}
get_buffer:
   98|  3.87k|{
   99|       |	/* Split buf into two parts according to length stored in first two bytes */
  100|  3.87k|	uint16_t len = 0;
  101|       |
  102|  3.87k|	if (!buf || !(*buf) || buf_len < sizeof(uint16_t))
  ------------------
  |  Branch (102:6): [True: 0, False: 3.87k]
  |  Branch (102:14): [True: 0, False: 3.87k]
  |  Branch (102:25): [True: 25, False: 3.85k]
  ------------------
  103|     25|		return 0;
  104|       |
  105|       |	/* Get length of the result buffer*/
  106|  3.85k|	len = *((uint16_t *) *buf) % max_size;
  107|  3.85k|	(*buf) += 2;
  108|  3.85k|	buf_len -= 2;
  109|  3.85k|	if (buf_len <= len) {
  ------------------
  |  Branch (109:6): [True: 78, False: 3.77k]
  ------------------
  110|     78|		*out = *buf;
  111|     78|		*out_len = buf_len;
  112|     78|		return 0;
  113|     78|	}
  114|       |
  115|       |	/* Set out buffer to new reader data*/
  116|  3.77k|	*out = *buf + len;
  117|  3.77k|	*out_len = buf_len - len;
  118|  3.77k|	return len;
  119|  3.85k|}

sc_notify_init:
  532|      2|void sc_notify_init(void) {}
sc_notify_close:
  533|  17.0k|void sc_notify_close(void) {}
sc_notify:
  534|      2|void sc_notify(const char *title, const char *text) {}
sc_notify_id:
  536|    466|		struct sc_pkcs15_card *p15card, enum ui_str id) {}

